diff --git a/Sources/BlazorApp/.vs/BlazorApp/DesignTimeBuild/.dtbcache.v2 b/Sources/BlazorApp/.vs/BlazorApp/DesignTimeBuild/.dtbcache.v2 index 7c560b8..22e1a0a 100644 Binary files a/Sources/BlazorApp/.vs/BlazorApp/DesignTimeBuild/.dtbcache.v2 and b/Sources/BlazorApp/.vs/BlazorApp/DesignTimeBuild/.dtbcache.v2 differ diff --git a/Sources/BlazorApp/.vs/BlazorApp/v17/.suo b/Sources/BlazorApp/.vs/BlazorApp/v17/.suo index 7e97e23..dbe4541 100644 Binary files a/Sources/BlazorApp/.vs/BlazorApp/v17/.suo and b/Sources/BlazorApp/.vs/BlazorApp/v17/.suo differ diff --git a/Sources/BlazorApp/BlazorApp/Components/InventoryComponent.razor.cs b/Sources/BlazorApp/BlazorApp/Components/InventoryComponent.razor.cs index 438ff6a..03cdac2 100644 --- a/Sources/BlazorApp/BlazorApp/Components/InventoryComponent.razor.cs +++ b/Sources/BlazorApp/BlazorApp/Components/InventoryComponent.razor.cs @@ -16,26 +16,22 @@ namespace BlazorApp.Components [Inject] public IDataService DataService { get; set; } - - private int totalItem; public Item CurrentDragItem { get; set; } - public int CurrentDragItemIndex { get; set; } - - [CascadingParameter] - public InventoryComponent Parent { get; set; } - private bool choiceSort = false; public List RecipeItems { get; set; } + [Parameter] public List Items { get; set; } = new List(); public ObservableCollection Actions { get; set; } [Inject] internal IJSRuntime JavaScriptRuntime { get; set; } - + /// + /// Constructor + /// public InventoryComponent() { Actions = new ObservableCollection(); @@ -43,37 +39,19 @@ namespace BlazorApp.Components this.RecipeItems = new List { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; } - private async Task OnReadData(DataGridReadDataEventArgs e) - { - if (e.CancellationToken.IsCancellationRequested) - { - return; - } - - if (!e.CancellationToken.IsCancellationRequested) - { - Items = await DataService.List(e.Page, e.PageSize); - totalItem = await DataService.Count(); - } - } + /// + /// method that call the javascript + /// + /// + /// private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) { JavaScriptRuntime.InvokeVoidAsync("Crafting.AddActions", e.NewItems); } - protected override async Task OnAfterRenderAsync(bool firstRender) - { - base.OnAfterRenderAsync(firstRender); - - if (!firstRender) - { - return; - } - - - StateHasChanged(); - } - + /// + /// method to sort by name or id simultaneoustly + /// private void SortByame() { if (choiceSort) diff --git a/Sources/BlazorApp/BlazorApp/Components/InventoryItem.razor.cs b/Sources/BlazorApp/BlazorApp/Components/InventoryItem.razor.cs index 2eac849..034d055 100644 --- a/Sources/BlazorApp/BlazorApp/Components/InventoryItem.razor.cs +++ b/Sources/BlazorApp/BlazorApp/Components/InventoryItem.razor.cs @@ -23,6 +23,10 @@ namespace BlazorApp.Components [CascadingParameter] public InventoryComponent Parent { get; set; } + + /// + /// method call when a drag enter a slot and send an action + /// internal void OnDragEnter() { if (NoDrop) @@ -32,7 +36,9 @@ namespace BlazorApp.Components Parent.Actions.Add(new InventoryAction { Action = "Drag Enter", Item = this.Item, Index = this.Index }); } - + /// + /// method call when a drag leave a slot and send an action + /// internal void OnDragLeave() { if (NoDrop) @@ -42,7 +48,9 @@ namespace BlazorApp.Components Parent.Actions.Add(new InventoryAction { Action = "Drag Leave", Item = this.Item, Index = this.Index }); } - + /// + /// method that manage a drop and send an action + /// internal void OnDrop() { @@ -65,16 +73,20 @@ namespace BlazorApp.Components Parent.Actions.Add(new InventoryAction { Action = "Drop", Item = this.Item, Index = this.Index }); } + /// + /// method call when darg start and send an action + /// private void OnDragStart() { Parent.CurrentDragItem = this.Item; - Parent.CurrentDragItemIndex = this.Index; Parent.Actions.Add(new InventoryAction { Action = "Drag Start", Item = this.Item, Index = this.Index }); } - + /// + /// method call when drag end and send an action specialy when outside the inventory + /// private void OnDragEnd() { if (Parent.Actions.Last().Action == "Drag Leave") diff --git a/Sources/BlazorApp/BlazorApp/Components/ItemInInventory.cs b/Sources/BlazorApp/BlazorApp/Components/ItemInInventory.cs deleted file mode 100644 index d13437b..0000000 --- a/Sources/BlazorApp/BlazorApp/Components/ItemInInventory.cs +++ /dev/null @@ -1,11 +0,0 @@ -using BlazorApp.Models; - -namespace BlazorApp.Components -{ - public class ItemInInventory - { - public int Index { get; set; } - public Item? Item { get; set; } - - } -} \ No newline at end of file diff --git a/Sources/BlazorApp/BlazorApp/Pages/Inventory.razor.cs b/Sources/BlazorApp/BlazorApp/Pages/Inventory.razor.cs index 6b87ead..0c55700 100644 --- a/Sources/BlazorApp/BlazorApp/Pages/Inventory.razor.cs +++ b/Sources/BlazorApp/BlazorApp/Pages/Inventory.razor.cs @@ -17,9 +17,14 @@ namespace BlazorApp.Pages; [Inject] public IStringLocalizer Localizer { get; set; } - private string? title; - public List Items { get; set; } = new List(); - + private string? title; + public List Items { get; set; } = new List(); + + /// + /// first render initializ the item list + /// + /// + /// protected override async Task OnAfterRenderAsync(bool firstRender) { base.OnAfterRenderAsync(firstRender); @@ -32,18 +37,5 @@ namespace BlazorApp.Pages; StateHasChanged(); } - private async Task OnReadData(DataGridReadDataEventArgs e) - { - if (e.CancellationToken.IsCancellationRequested) - { - return; - } - - if (!e.CancellationToken.IsCancellationRequested) - { - Items = await DataService.List(e.Page, e.PageSize); - totalItem = await DataService.Count(); - } - } } diff --git a/Sources/BlazorApp/BlazorApp/bin/Debug/net6.0/BlazorApp.dll b/Sources/BlazorApp/BlazorApp/bin/Debug/net6.0/BlazorApp.dll index e4fdcee..45ca1a0 100644 Binary files a/Sources/BlazorApp/BlazorApp/bin/Debug/net6.0/BlazorApp.dll and b/Sources/BlazorApp/BlazorApp/bin/Debug/net6.0/BlazorApp.dll differ diff --git a/Sources/BlazorApp/BlazorApp/bin/Debug/net6.0/BlazorApp.pdb b/Sources/BlazorApp/BlazorApp/bin/Debug/net6.0/BlazorApp.pdb index eb237bf..aae8a09 100644 Binary files a/Sources/BlazorApp/BlazorApp/bin/Debug/net6.0/BlazorApp.pdb and b/Sources/BlazorApp/BlazorApp/bin/Debug/net6.0/BlazorApp.pdb differ diff --git a/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.csproj.CoreCompileInputs.cache b/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.csproj.CoreCompileInputs.cache index bd2b43d..965ba93 100644 --- a/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.csproj.CoreCompileInputs.cache +++ b/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -c48aeeb310f8a48dba7b738a3d0a441c5edcf556 +c50094d2a440f52dc51fdefcd65864fc3b6f0a7f diff --git a/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.dll b/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.dll index e4fdcee..45ca1a0 100644 Binary files a/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.dll and b/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.dll differ diff --git a/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.pdb b/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.pdb index eb237bf..aae8a09 100644 Binary files a/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.pdb and b/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/BlazorApp.pdb differ diff --git a/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/ref/BlazorApp.dll b/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/ref/BlazorApp.dll index 3a9276a..9d0905d 100644 Binary files a/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/ref/BlazorApp.dll and b/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/ref/BlazorApp.dll differ diff --git a/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/refint/BlazorApp.dll b/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/refint/BlazorApp.dll index 3a9276a..9d0905d 100644 Binary files a/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/refint/BlazorApp.dll and b/Sources/BlazorApp/BlazorApp/obj/Debug/net6.0/refint/BlazorApp.dll differ diff --git a/Sources/BlazorApp/BlazorApp/obj/staticwebassets.pack.sentinel b/Sources/BlazorApp/BlazorApp/obj/staticwebassets.pack.sentinel index 6bcd699..96f900f 100644 --- a/Sources/BlazorApp/BlazorApp/obj/staticwebassets.pack.sentinel +++ b/Sources/BlazorApp/BlazorApp/obj/staticwebassets.pack.sentinel @@ -209,3 +209,8 @@ 2.0 2.0 2.0 +2.0 +2.0 +2.0 +2.0 +2.0