|
|
@ -24,15 +24,30 @@ namespace BlazorApp.Components
|
|
|
|
|
|
|
|
|
|
|
|
public List<Item> InventoryItems { get; set; }
|
|
|
|
public List<Item> InventoryItems { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<CraftingAction> Actions { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
|
|
|
internal IJSRuntime JavaScriptRuntime { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
private int totalItem;
|
|
|
|
private int totalItem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int PageSize { get; set; }
|
|
|
|
|
|
|
|
private int CurrentPage { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private bool IsSorted { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public InventoryComp()
|
|
|
|
public InventoryComp()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.InventoryItems = new List<Item> { };
|
|
|
|
Actions = new ObservableCollection<CraftingAction>();
|
|
|
|
for (int i = 0; i < 18; i++)
|
|
|
|
Actions.CollectionChanged += OnActionsCollectionChanged;
|
|
|
|
{
|
|
|
|
|
|
|
|
this.InventoryItems.Append(null);
|
|
|
|
this.InventoryItems = new List<Item>(new Item[18]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
JavaScriptRuntime.InvokeVoidAsync("Crafting.AddActions", e.NewItems);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
|
|
|
|
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
|
|
|
@ -42,16 +57,28 @@ namespace BlazorApp.Components
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested)
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested && !IsSorted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Items = await DataService.List(e.Page, e.PageSize);
|
|
|
|
Items = await DataService.List(e.Page, e.PageSize);
|
|
|
|
totalItem = await DataService.Count();
|
|
|
|
totalItem = await DataService.Count();
|
|
|
|
|
|
|
|
CurrentPage = e.Page;
|
|
|
|
|
|
|
|
PageSize = e.PageSize;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CurrentPage = e.Page;
|
|
|
|
|
|
|
|
PageSize = e.PageSize;
|
|
|
|
|
|
|
|
Items = await DataService.SortedList(CurrentPage, PageSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async Task SortByName()
|
|
|
|
private async Task SortByName()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Items = await DataService.SortedList();
|
|
|
|
if (!IsSorted)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IsSorted = true;
|
|
|
|
|
|
|
|
Items = await DataService.SortedList(CurrentPage, PageSize);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void refresh()
|
|
|
|
void refresh()
|
|
|
|