From 4f10a6acdb5ef658669b868e380d1dfe50bc4092 Mon Sep 17 00:00:00 2001 From: aujault Date: Fri, 9 Dec 2022 09:34:57 +0100 Subject: [PATCH] display img and default one --- Blazor/Blazor/Components/Inventory.razor | 11 +---------- Blazor/Blazor/Components/Inventory.razor.cs | 15 ++++++++++++++- Blazor/Blazor/Components/InventoryAction.cs | 11 +++++++++++ Blazor/Blazor/Components/ItemInventory.razor | 18 +++++++++++++++++- .../Blazor/Components/ItemInventory.razor.cs | 3 +++ .../Blazor/Components/ItemInventory.razor.css | 6 ------ 6 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 Blazor/Blazor/Components/InventoryAction.cs delete mode 100644 Blazor/Blazor/Components/ItemInventory.razor.css diff --git a/Blazor/Blazor/Components/Inventory.razor b/Blazor/Blazor/Components/Inventory.razor index c02d63c..e711bf1 100644 --- a/Blazor/Blazor/Components/Inventory.razor +++ b/Blazor/Blazor/Components/Inventory.razor @@ -5,15 +5,6 @@
@for(int i = 0; i - } - else - { -
- -
- } + }
\ No newline at end of file diff --git a/Blazor/Blazor/Components/Inventory.razor.cs b/Blazor/Blazor/Components/Inventory.razor.cs index cb45dde..5ecc191 100644 --- a/Blazor/Blazor/Components/Inventory.razor.cs +++ b/Blazor/Blazor/Components/Inventory.razor.cs @@ -1,15 +1,24 @@ using Blazor.Models; using Blazor.Pages; using Microsoft.AspNetCore.Components; +using System.Collections.ObjectModel; + namespace Blazor.Components { partial class Inventory { + + public Inventory() + { + Actions = new ObservableCollection(); + } + public ObservableCollection Actions { get; set; } [Parameter] public InventoryList inventory { get; set; } - public void Add(Item item) + /*peut être useless*/ { + if (item == null) return; foreach(InventoryItem element in inventory.inventoryItems) { if(item.Id == element.item.Id) @@ -17,11 +26,13 @@ namespace Blazor.Components if(element.Stack == element.item.StackSize) { addEnd(item); + this.StateHasChanged(); return; } else { element.Stack += 1; + this.StateHasChanged(); return; } } @@ -29,6 +40,7 @@ namespace Blazor.Components { element.item = item; element.Stack = 1; + this.StateHasChanged(); return; } } @@ -36,6 +48,7 @@ namespace Blazor.Components } public void addEnd(Item item) + /*peut être useless*/ { int i = 0; while (inventory.inventoryItems[i]!=null) diff --git a/Blazor/Blazor/Components/InventoryAction.cs b/Blazor/Blazor/Components/InventoryAction.cs new file mode 100644 index 0000000..746e0f2 --- /dev/null +++ b/Blazor/Blazor/Components/InventoryAction.cs @@ -0,0 +1,11 @@ +using Blazor.Models; + +namespace Blazor.Components +{ + public class InventoryAction + { + public string Action { get; set; } + public int Index { get; set; } + public Item Item { get; set; } + } +} diff --git a/Blazor/Blazor/Components/ItemInventory.razor b/Blazor/Blazor/Components/ItemInventory.razor index 9053490..56d5c4a 100644 --- a/Blazor/Blazor/Components/ItemInventory.razor +++ b/Blazor/Blazor/Components/ItemInventory.razor @@ -1,3 +1,19 @@ 
- @items.item + @if(items != null) + { + @if(!string.IsNullOrWhiteSpace(items.item.ImageBase64)) + { + @items.item.DisplayName + } + else + { + @items.item.DisplayName + } + } + else + { +
+ +
+ }
\ No newline at end of file diff --git a/Blazor/Blazor/Components/ItemInventory.razor.cs b/Blazor/Blazor/Components/ItemInventory.razor.cs index 92b0953..c1ad38e 100644 --- a/Blazor/Blazor/Components/ItemInventory.razor.cs +++ b/Blazor/Blazor/Components/ItemInventory.razor.cs @@ -7,5 +7,8 @@ namespace Blazor.Components { [Parameter] public InventoryItem items { get; set; } + + [Parameter] + public int index { get; set; } } } diff --git a/Blazor/Blazor/Components/ItemInventory.razor.css b/Blazor/Blazor/Components/ItemInventory.razor.css deleted file mode 100644 index b2d4521..0000000 --- a/Blazor/Blazor/Components/ItemInventory.razor.css +++ /dev/null @@ -1,6 +0,0 @@ -.item { - width: 64px; - height: 64px; - border: 1px solid; - overflow: hidden; -}