Update docs v2

master
Louis DUFOUR 3 years ago
parent b24979ab63
commit 944e3c0c50

@ -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 *******************/
/// <summary>
/// appel de la méthode lorsqu'un item entre dans un emplacement et envoie une action
/// </summary>
@ -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 });
}
/// <summary>
@ -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);
}
}

@ -48,23 +48,6 @@ namespace ValblazeProject.Factories
};
}
/// <summary>
///
/// </summary>
/// <param name="item"></param>
/// <param name="model"></param>
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);
}
/// <summary>
///
/// </summary>
@ -92,7 +75,7 @@ namespace ValblazeProject.Factories
/// </summary>
/// <param name="item"></param>
/// <param name="model"></param>
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);
}
/// <summary>
/// Ajoute le numéro a un item

@ -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]
[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]

@ -11,8 +11,8 @@
<div class="inventaire">
<h3>@Localizer["key1"]</h3>
<div class="caseInvent">
@for(int i=0; i<10; i++){
<InventoryItem Index="i" Item=@this.Jitems[i] />
@for(int i=1; i<10; i++){
<InventoryItem Index="i" Item=@this.InventoryItems[i] />
}
</div>
<div class="mt-2">Actions</div>

@ -40,7 +40,7 @@ namespace ValblazeProject.Pages
/// <summary>
/// List inventaire sauvegarder
/// </summary>
public List<Item> Jitems;
public List<Item> InventoryItems;
/// <summary>
/// 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<List<Item>>(jsonString)!;
}
/// <summary>
/// method that call the javascript
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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<List<Item>>(jsonString)!;
}
/// <summary>
@ -124,7 +113,6 @@ namespace ValblazeProject.Pages
StateHasChanged();
}
/// <summary>
/// Méthode de recherche
/// </summary>
@ -172,5 +160,16 @@ namespace ValblazeProject.Pages
StateHasChanged();
}
}
/// <summary>
/// method that call the javascript
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
}
}

Loading…
Cancel
Save