petit changement

master
Jolys Enzo 3 years ago
parent 0cc45226c8
commit 784a3d7b7b

File diff suppressed because one or more lines are too long

@ -1,2 +0,0 @@
<h3>MusiqueAction</h3>

@ -1,11 +0,0 @@
using ProjetBlazor.Modeles;
namespace ProjetBlazor.Components
{
public partial class MusiqueAction
{
public string Action { get; set; }
public int Index { get; set; }
public Musique musique { get; set; }
}
}

@ -1,51 +0,0 @@
<CascadingValue Value="@this">
<div class="container">
<div class="row">
<div class="col-6">
<div>Available items:</div>
<div>
<div class="css-grid">
@foreach (var item in Items)
{
<CraftingItem Item="item" NoDrop="true"/>
}
</div>
</div>
</div>
<div class="col-6">
<div>Recipe</div>
<div>
<div class="css-recipe">
<CraftingItem Index="0"/>
<CraftingItem Index="1"/>
<CraftingItem Index="2"/>
<CraftingItem Index="3"/>
<CraftingItem Index="4"/>
<CraftingItem Index="5"/>
<CraftingItem Index="6"/>
<CraftingItem Index="7"/>
<CraftingItem Index="8"/>
</div>
</div>
<div>Result</div>
<div>
<CraftingItem Item="RecipeResult"/>
</div>
</div>
<div class="col-12">
<div>Actions</div>
<div class="actions" id="actions">
</div>
</div>
</div>
</div>
</CascadingValue>

@ -1,74 +0,0 @@
namespace ProjetBlazor.Components
{
public partial class Crafting
{
private Item _recipeResult;
public Crafting()
{
Actions = new ObservableCollection<CraftingAction>();
Actions.CollectionChanged += OnActionsCollectionChanged;
this.RecipeItems = new List<Item> { null, null, null, null, null, null, null, null, null };
}
public ObservableCollection<CraftingAction> Actions { get; set; }
public Item CurrentDragItem { get; set; }
[Parameter]
public List<Item> Items { get; set; }
public List<Item> RecipeItems { get; set; }
public Item RecipeResult
{
get => this._recipeResult;
set
{
if (this._recipeResult == value)
{
return;
}
this._recipeResult = value;
this.StateHasChanged();
}
}
[Parameter]
public List<CraftingRecipe> Recipes { get; set; }
/// <summary>
/// Gets or sets the java script runtime.
/// </summary>
[Inject]
internal IJSRuntime JavaScriptRuntime { get; set; }
public void CheckRecipe()
{
RecipeResult = null;
// Get the current model
var currentModel = string.Join("|", this.RecipeItems.Select(s => s != null ? s.Name : string.Empty));
this.Actions.Add(new CraftingAction { Action = $"Items : {currentModel}" });
foreach (var craftingRecipe in Recipes)
{
// Get the recipe model
var recipeModel = string.Join("|", craftingRecipe.Have.SelectMany(s => s));
this.Actions.Add(new CraftingAction { Action = $"Recipe model : {recipeModel}" });
if (currentModel == recipeModel)
{
RecipeResult = craftingRecipe.Give;
}
}
}
private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
JavaScriptRuntime.InvokeVoidAsync("Crafting.AddActions", e.NewItems);
}
}
}

@ -1,19 +0,0 @@
.css-grid {
grid-template-columns: repeat(4,minmax(0,1fr));
gap: 10px;
display: grid;
width: 286px;
}
.css-recipe {
grid-template-columns: repeat(3,minmax(0,1fr));
gap: 10px;
display: grid;
width: 212px;
}
.actions {
border: 1px solid black;
height: 250px;
overflow: scroll;
}

@ -1,16 +0,0 @@
window.Crafting =
{
AddActions: function (data) {
data.forEach(element => {
var div = document.createElement('div');
div.innerHTML = 'Action: ' + element.action + ' - Index: ' + element.index;
if (element.item) {
div.innerHTML += ' - Item Name: ' + element.item.name;
}
document.getElementById('actions').appendChild(div);
});
}
}

@ -1,10 +0,0 @@
using ProjetBlazor.Modeles;
namespace ProjetBlazor.Components
{
public partial class MusiqueContainerEcoute
{
public Musique musiqueEnEcoute { get; set; }
}
}

@ -1,18 +0,0 @@

<h3>MusiquesContainer</h3>
<div class="item"
ondragover="event.preventDefault();"
draggable="true"
@ondragstart="@OnDragStart"
@ondrop="@OnDrop"
@ondragenter="@OnDragEnter"
@ondragleave="@OnDragLeave">
@if (musique != null)
{
@musique.titre
}
</div>

@ -1,64 +0,0 @@
using Blazorise;
using Microsoft.AspNetCore.Components;
using ProjetBlazor.Modeles;
namespace ProjetBlazor.Components
{
public partial class MusiquesContainer
{
[Parameter]
public int Index { get; set; }
[Parameter]
public Musique musique { get; set; }
[Parameter]
public bool NoDrop { get; set; }
[CascadingParameter]
public Crafting Parent { get; set; }
internal void OnDragEnter()
{
if (NoDrop)
{
return;
}
Parent.Actions.Add(new MusiqueAction { Action = "Drag Enter", musique = this.musique, Index = this.Index });
}
internal void OnDragLeave()
{
if (NoDrop)
{
return;
}
Parent.Actions.Add(new MusiqueAction { Action = "Drag Leave", musique = this.musique, Index = this.Index });
}
internal void OnDrop()
{
if (NoDrop)
{
return;
}
this.musique = Parent.CurrentDragItem;
Parent.RecipeItems[this.Index] = this.musique;
Parent.Actions.Add(new MusiqueAction { Action = "Drop", musique = this.musique, Index = this.Index });
// Check recipe
Parent.CheckRecipe();
}
private void OnDragStart()
{
Parent.CurrentDragItem = this.musique;
Parent.Actions.Add(new MusiqueAction { Action = "Drag Start", musique = this.musique, Index = this.Index });
}
}
}

@ -1,6 +0,0 @@
.item {
width: 64px;
height: 64px;
border: 1px solid;
overflow: hidden;
}

@ -60,7 +60,7 @@ namespace ProjetBlazor.Pages
await DataService.Delete(id);
// Reload the page
NavigationManager.NavigateTo("list", true);
NavigationManager.NavigateTo("MusiquesListe", true);
}
}

@ -2,9 +2,3 @@
color: brown;
font-family: Tahoma, Geneva, Verdana, sans-serif;
}
.galleryimages{
width: 20px;
height : 100px;
}

@ -18,11 +18,8 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Components\" />
<Folder Include="wwwroot\song\" />
</ItemGroup>
<ItemGroup>
<None Include="Components\MusiqueComponent.razor.cs" />
</ItemGroup>
</Project>

@ -1,6 +1,6 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">ProjetBlazor</a>
<a class="navbar-brand" href="">SpotiBlazor</a>
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>

Loading…
Cancel
Save