From 944e3c0c508515b1474773a39a1a55f6b906fb95 Mon Sep 17 00:00:00 2001 From: Louis DUFOUR Date: Fri, 30 Dec 2022 23:09:40 +0100 Subject: [PATCH] Update docs v2 --- .../Components/InventoryItem.razor.cs | 14 ++++----- ValblazeProject/Factories/ItemFactory.cs | 24 ++-------------- ValblazeProject/Inventory.json | 2 +- ValblazeProject/Pages/Inventaire.razor | 4 +-- ValblazeProject/Pages/Inventaire.razor.cs | 27 +++++++++--------- .../Debug/net6.0/ValblazeProject.assets.cache | Bin 13304 -> 13304 bytes 6 files changed, 26 insertions(+), 45 deletions(-) diff --git a/ValblazeProject/Components/InventoryItem.razor.cs b/ValblazeProject/Components/InventoryItem.razor.cs index a20f81b..b235a1b 100644 --- a/ValblazeProject/Components/InventoryItem.razor.cs +++ b/ValblazeProject/Components/InventoryItem.razor.cs @@ -8,6 +8,7 @@ namespace ValblazeProject.Components { public partial class InventoryItem { + /******************* Initialisation des attributs *******************/ [Parameter] public int Index { get; set; } @@ -20,6 +21,7 @@ namespace ValblazeProject.Components [CascadingParameter] public Inventaire Parent { get; set; } + /******************* Méthodes *******************/ /// /// appel de la méthode lorsqu'un item entre dans un emplacement et envoie une action /// @@ -42,7 +44,7 @@ namespace ValblazeProject.Components { return; } - + Parent.Actions.Add(new InventoryAction { Action = "Drag Leave", Item = this.Item, Index = this.Index }); } @@ -69,15 +71,13 @@ namespace ValblazeProject.Components } - Parent.Jitems[this.Index] = this.Item; + Parent.InventoryItems[this.Index] = this.Item; string fileName = "Inventory.json"; - string jsonString = JsonSerializer.Serialize(Parent.Jitems); + string jsonString = JsonSerializer.Serialize(Parent.InventoryItems); File.WriteAllText(fileName, jsonString); Parent.Actions.Add(new InventoryAction { Action = "Drop", Item = this.Item, Index = this.Index }); - - } /// @@ -103,9 +103,9 @@ namespace ValblazeProject.Components } Parent.Actions.Add(new InventoryAction { Action = "Delete", Item = this.Item, Index = this.Index }); - Parent.Jitems[this.Index] = null; + Parent.InventoryItems[this.Index] = null; string fileName = "Inventory.json"; - string jsonString = JsonSerializer.Serialize(Parent.Jitems); + string jsonString = JsonSerializer.Serialize(Parent.InventoryItems); File.WriteAllText(fileName, jsonString); } } diff --git a/ValblazeProject/Factories/ItemFactory.cs b/ValblazeProject/Factories/ItemFactory.cs index 256f9f5..e0caaad 100644 --- a/ValblazeProject/Factories/ItemFactory.cs +++ b/ValblazeProject/Factories/ItemFactory.cs @@ -48,23 +48,6 @@ namespace ValblazeProject.Factories }; } - /// - /// - /// - /// - /// - public static void Update(Item item, ItemModel model) - { - item.DisplayName = model.DisplayName; - item.Name = model.Name; - item.RepairWith = model.RepairWith; - item.EnchantCategories = model.EnchantCategories; - item.MaxDurability = model.MaxDurability; - item.StackSize = model.StackSize; - item.UpdatedDate = DateTime.Now; - item.ImageBase64 = Convert.ToBase64String(model.ImageContent); - } - /// /// /// @@ -92,7 +75,7 @@ namespace ValblazeProject.Factories /// /// /// - public static void Update(Item item, Item model) + public static void Update(Item item, ItemModel model) { item.DisplayName = model.DisplayName; item.Name = model.Name; @@ -101,9 +84,8 @@ namespace ValblazeProject.Factories item.MaxDurability = model.MaxDurability; item.StackSize = model.StackSize; item.UpdatedDate = DateTime.Now; - item.ImageBase64 = model.ImageBase64; - item.Num = model.Num; - } + item.ImageBase64 = Convert.ToBase64String(model.ImageContent); + } /// /// Ajoute le numéro a un item diff --git a/ValblazeProject/Inventory.json b/ValblazeProject/Inventory.json index d8d5030..8d28c3e 100644 --- a/ValblazeProject/Inventory.json +++ b/ValblazeProject/Inventory.json @@ -1 +1 @@ -[null,null,null,{"Id":1,"DisplayName":"Stone","Name":"stone","StackSize":64,"MaxDurability":0,"EnchantCategories":[],"RepairWith":[],"CreatedDate":"2022-12-30T20:30:15.8656978+01:00","UpdatedDate":null,"ImageBase64":"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAnklEQVQ4y4VTQRIAMQTzXA9w7xM8uXti0jS6B8OYEiK1zNxoa60dETsiOnb3I4dmFWABPypz925Wbw1REImRp8Y9Aa5QnvM4bZlhZ0YrzzxhjTGiMl6pfGaeEzAKxuMVsDsjvNbrBqwBReC0Yp9R8aCKlejM3S8h8UossOOMarTX2LyuKYLUn2Apl7fpE03MY\u002B6a4CWmiUj7U5/iBME\u002BeeR3wyunqoUAAAAASUVORK5CYII=","Num":1},null,null,{"Id":1,"DisplayName":"Stone","Name":"stone","StackSize":64,"MaxDurability":0,"EnchantCategories":[],"RepairWith":[],"CreatedDate":"2022-12-30T20:29:53.3896405+01:00","UpdatedDate":null,"ImageBase64":"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAnklEQVQ4y4VTQRIAMQTzXA9w7xM8uXti0jS6B8OYEiK1zNxoa60dETsiOnb3I4dmFWABPypz925Wbw1REImRp8Y9Aa5QnvM4bZlhZ0YrzzxhjTGiMl6pfGaeEzAKxuMVsDsjvNbrBqwBReC0Yp9R8aCKlejM3S8h8UossOOMarTX2LyuKYLUn2Apl7fpE03MY\u002B6a4CWmiUj7U5/iBME\u002BeeR3wyunqoUAAAAASUVORK5CYII=","Num":1},null,null,null,null,null,null,null,null,null,null,null] \ No newline at end of file +[null,{"Id":3,"DisplayName":"Dirt","Name":"dirt","StackSize":64,"MaxDurability":0,"EnchantCategories":[],"RepairWith":[],"CreatedDate":"2022-12-30T22:43:14.03027+01:00","UpdatedDate":null,"ImageBase64":"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA0UlEQVR42nWSsQ1CMQxEvQ4rINFR0SOBxAgpaRgA/Q3YhelAF\u002Bmi9\u002B/nF1YS2zn7zq7v\u002B/H7tEu31/XYbea7nw6ruM/SRYlM0HtZluEzIO\u002BKycporsI3qzGHeSW01tpwsJukkl0MAAcV0GdyJ6AKpa/cVlZyq9SG9yFicpR4TKDipOmzMjnH525m/g6QTp5uOT8zNt2D5J68SaVyPORsYPtJxVrVjBcraHSkwDH3TUxnguyZu1pRkD1v541wpjHb0MokKkz\u002BWWgDkDtgkfbm7wJ/9oUoq3qXqFkAAAAASUVORK5CYII=","Num":2},{"Id":1,"DisplayName":"Stone","Name":"stone","StackSize":64,"MaxDurability":0,"EnchantCategories":[],"RepairWith":[],"CreatedDate":"2022-12-30T23:07:15.7968257+01:00","UpdatedDate":null,"ImageBase64":"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAnklEQVQ4y4VTQRIAMQTzXA9w7xM8uXti0jS6B8OYEiK1zNxoa60dETsiOnb3I4dmFWABPypz925Wbw1REImRp8Y9Aa5QnvM4bZlhZ0YrzzxhjTGiMl6pfGaeEzAKxuMVsDsjvNbrBqwBReC0Yp9R8aCKlejM3S8h8UossOOMarTX2LyuKYLUn2Apl7fpE03MY\u002B6a4CWmiUj7U5/iBME\u002BeeR3wyunqoUAAAAASUVORK5CYII=","Num":1},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null] \ No newline at end of file diff --git a/ValblazeProject/Pages/Inventaire.razor b/ValblazeProject/Pages/Inventaire.razor index cf76a60..9bd6a19 100644 --- a/ValblazeProject/Pages/Inventaire.razor +++ b/ValblazeProject/Pages/Inventaire.razor @@ -11,8 +11,8 @@

@Localizer["key1"]

- @for(int i=0; i<10; i++){ - + @for(int i=1; i<10; i++){ + }
Actions
diff --git a/ValblazeProject/Pages/Inventaire.razor.cs b/ValblazeProject/Pages/Inventaire.razor.cs index 1f97460..57d170b 100644 --- a/ValblazeProject/Pages/Inventaire.razor.cs +++ b/ValblazeProject/Pages/Inventaire.razor.cs @@ -40,7 +40,7 @@ namespace ValblazeProject.Pages /// /// List inventaire sauvegarder /// - public List Jitems; + public List InventoryItems; /// /// Donnée de la Grid Blazorise @@ -100,18 +100,7 @@ namespace ValblazeProject.Pages string fileName = "Inventory.json"; string jsonString = File.ReadAllText(fileName); - this.Jitems = JsonSerializer.Deserialize>(jsonString)!; - } - - /// - /// method that call the javascript - /// - /// - /// - private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) - { - // je fais appel au fichier js de crafting, car je n'ai pas su résoudre le problème avec celui Inventaire.razor.js - JavaScriptRuntime.InvokeVoidAsync("Crafting.AddActions", e.NewItems); + this.InventoryItems = JsonSerializer.Deserialize>(jsonString)!; } /// @@ -124,7 +113,6 @@ namespace ValblazeProject.Pages StateHasChanged(); } - /// /// Méthode de recherche /// @@ -172,5 +160,16 @@ namespace ValblazeProject.Pages StateHasChanged(); } } + + /// + /// method that call the javascript + /// + /// + /// + private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) + { + // je fais appel au fichier js de crafting, car je n'ai pas su résoudre le problème avec celui Inventaire.razor.js + JavaScriptRuntime.InvokeVoidAsync("Crafting.AddActions", e.NewItems); + } } } diff --git a/ValblazeProject/obj/Debug/net6.0/ValblazeProject.assets.cache b/ValblazeProject/obj/Debug/net6.0/ValblazeProject.assets.cache index 2921b87fb3824dbb0c574147a2dbc800a762c92c..303f5d439899b855c97dd9e79efcdd224c4e6f50 100644 GIT binary patch delta 49 zcmV-10M7sTXZU9*P)kQa3jhEB+jQIO6m3PGQFIw{Z!)F{@G~d`1IZ5BfH#|;9YeKT Hu_(|p