diff --git a/Blazor/Blazor/Components/Inventory.razor b/Blazor/Blazor/Components/Inventory.razor index 588b774..3914e05 100644 --- a/Blazor/Blazor/Components/Inventory.razor +++ b/Blazor/Blazor/Components/Inventory.razor @@ -3,7 +3,7 @@

Inventory

- @for(int i = 0; i Actions { get; set; } public Inventory() @@ -20,8 +21,6 @@ namespace Blazor.Components return; } - [Parameter] - public InventoryList inventory { get; set; } } } diff --git a/Blazor/Blazor/Components/InventoryAction.cs b/Blazor/Blazor/Components/InventoryAction.cs index 50ddc5e..4023b3d 100644 --- a/Blazor/Blazor/Components/InventoryAction.cs +++ b/Blazor/Blazor/Components/InventoryAction.cs @@ -4,13 +4,13 @@ namespace Blazor.Components { public class InventoryAction { - public InventoryAction(String ac, int num,ItemInventory objet) { + public InventoryAction(String ac, int num,Item objet) { Action = ac; Index = num; Item = objet; } public string Action { get; set; } public int Index { get; set; } - public ItemInventory Item { get; set; } + public Item Item { get; set; } } } diff --git a/Blazor/Blazor/Components/InventoryList.razor b/Blazor/Blazor/Components/InventoryList.razor index bcf2bcd..402f84b 100644 --- a/Blazor/Blazor/Components/InventoryList.razor +++ b/Blazor/Blazor/Components/InventoryList.razor @@ -10,7 +10,7 @@ Responsive> - + @if (!string.IsNullOrWhiteSpace(context.ImageBase64)) { @context.DisplayName diff --git a/Blazor/Blazor/Components/InventoryList.razor.cs b/Blazor/Blazor/Components/InventoryList.razor.cs index f893b86..af2548c 100644 --- a/Blazor/Blazor/Components/InventoryList.razor.cs +++ b/Blazor/Blazor/Components/InventoryList.razor.cs @@ -29,12 +29,34 @@ namespace Blazor.Components [Inject] public IStringLocalizer Localizer { get; set; } - protected override async Task OnInitializedAsync() - { + [CascadingParameter] + public Inventory Parent { get; set; } + + + public void OnDragStart() + { + + } + - items = await DataService.getAll(); - totalItem = await DataService.Count(); - await base.OnInitializedAsync(); + public void OnDrop() + { + Parent.CurrentDragItem = null; + return; + } + internal void OnDragEnter() + { + Parent.Actions.Add(new InventoryAction("Drag Enter", this.items[0].Id, items[0])); + } + + internal void OnDragLeave() + { + Parent.Actions.Add(new InventoryAction("Drag Leave", this.items[0].Id, items[0])); + } + + protected override async Task OnInitializedAsync() + { + } } } \ No newline at end of file diff --git a/Blazor/Blazor/Components/ItemInventory.razor.cs b/Blazor/Blazor/Components/ItemInventory.razor.cs index 95df861..956c258 100644 --- a/Blazor/Blazor/Components/ItemInventory.razor.cs +++ b/Blazor/Blazor/Components/ItemInventory.razor.cs @@ -28,7 +28,7 @@ namespace Blazor.Components Parent.CurrentDragItem = this.Items; Parent.inventory.inventoryItems[this.Index] = null; this.NoDrop = false; - Parent.Actions.Add(new InventoryAction("On drag start",this.Index,this)); + Parent.Actions.Add(new InventoryAction("On drag start",this.Index,Items.item)); Parent.update(); } @@ -40,7 +40,7 @@ namespace Blazor.Components this.Items = Parent.CurrentDragItem; NoDrop = true; Parent.CurrentDragItem = null; - Parent.Actions.Add(new InventoryAction("On Drop",this.Index,this)); + Parent.Actions.Add(new InventoryAction("On Drop",this.Index,Items.item)); return; } if(Parent.CurrentDragItem == null) @@ -52,7 +52,7 @@ namespace Blazor.Components this.Items = Parent.CurrentDragItem; this.NoDrop= true; Parent.CurrentDragItem = null; - Parent.Actions.Add(new InventoryAction("On drag start",this.Index,this)); + Parent.Actions.Add(new InventoryAction("On drag start",this.Index,Items.item)); return; } else @@ -61,7 +61,7 @@ namespace Blazor.Components if (total >this.Items.item.StackSize) { this.Items.Stack = this.Items.item.StackSize; - Parent.Actions.Add(new InventoryAction("On drag start",this.Index,this)); + Parent.Actions.Add(new InventoryAction("On drag start",this.Index,Items.item)); return; } else @@ -73,12 +73,12 @@ namespace Blazor.Components } internal void OnDragEnter() { - Parent.Actions.Add(new InventoryAction("Drag Enter",this.Index,this)); + Parent.Actions.Add(new InventoryAction("Drag Enter",this.Index,Items.item)); } internal void OnDragLeave() { - Parent.Actions.Add(new InventoryAction("Drag Leave",this.Index,this)); + Parent.Actions.Add(new InventoryAction("Drag Leave",this.Index,Items.item)); } } } diff --git a/Blazor/Blazor/Pages/Index.razor b/Blazor/Blazor/Pages/Index.razor index b919667..b099662 100644 --- a/Blazor/Blazor/Pages/Index.razor +++ b/Blazor/Blazor/Pages/Index.razor @@ -1,5 +1,5 @@ @page "/" @using Blazor.Components;
- +
diff --git a/Blazor/Blazor/Pages/Index.razor.cs b/Blazor/Blazor/Pages/Index.razor.cs index 1f3179b..0a77a38 100644 --- a/Blazor/Blazor/Pages/Index.razor.cs +++ b/Blazor/Blazor/Pages/Index.razor.cs @@ -7,12 +7,6 @@ namespace Blazor.Pages { public partial class Index { - /* TEST */ - - InventoryList inventory = new InventoryList(); - - - [Inject] public IDataService DataService { get; set; } diff --git a/Blazor/Blazor/Pages/Inventory.razor b/Blazor/Blazor/Pages/Inventory.razor index b4f1aa5..4270bee 100644 --- a/Blazor/Blazor/Pages/Inventory.razor +++ b/Blazor/Blazor/Pages/Inventory.razor @@ -8,7 +8,9 @@
- Ici c'est l'inventaire + + +