diff --git a/myBlazorApp/myBlazorApp/Components/InventoryAction.cs b/myBlazorApp/myBlazorApp/Components/InventoryAction.cs
new file mode 100644
index 0000000..6fb225c
--- /dev/null
+++ b/myBlazorApp/myBlazorApp/Components/InventoryAction.cs
@@ -0,0 +1,12 @@
+using System;
+using myBlazorApp.Models;
+namespace myBlazorApp.Components
+{
+ public class InventoryAction
+ {
+ public string Action { get; set; }
+ public int Index { get; set; }
+ public Item Item { get; set; }
+ }
+}
+
diff --git a/myBlazorApp/myBlazorApp/Components/InventoryItem.razor.cs b/myBlazorApp/myBlazorApp/Components/InventoryItem.razor.cs
index 32bacb7..1fafa8d 100644
--- a/myBlazorApp/myBlazorApp/Components/InventoryItem.razor.cs
+++ b/myBlazorApp/myBlazorApp/Components/InventoryItem.razor.cs
@@ -1,5 +1,7 @@
using System;
namespace myBlazorApp.Components;
+
+using Blazorise;
using Microsoft.AspNetCore.Components;
using myBlazorApp.Models;
@@ -9,6 +11,34 @@ public partial class InventoryItem
public Item Item { get; set; }
[Parameter]
public int Index { get; set; }
+ [CascadingParameter]
+ public MyInventory Parent { get; set; }
+
+ internal void OnDragEnter()
+ {
+
+ Parent.Actions.Add(new InventoryAction { Action = "Drag Enter", Item = this.Item, Index = this.Index });
+ }
+
+ internal void OnDragLeave()
+ {
+
+ Parent.Actions.Add(new InventoryAction { Action = "Drag Leave", Item = this.Item, Index = this.Index });
+ }
+
+ internal void OnDrop()
+ {
+ this.Item = Parent.CurrentDragItem;
+
+ Parent.Actions.Add(new InventoryAction { Action = "Drop", Item = this.Item, Index = this.Index });
+
+ }
+
+ private void OnDragStart()
+ {
+ Parent.CurrentDragItem = this.Item;
+ Parent.Actions.Add(new InventoryAction { Action = "Drag Start", Item = this.Item, Index = this.Index });
+ }
}
diff --git a/myBlazorApp/myBlazorApp/Components/MyInventory.razor b/myBlazorApp/myBlazorApp/Components/MyInventory.razor
index 908d22f..2c10786 100644
--- a/myBlazorApp/myBlazorApp/Components/MyInventory.razor
+++ b/myBlazorApp/myBlazorApp/Components/MyInventory.razor
@@ -1,23 +1,14 @@
My Inventory
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ @foreach (var item in ItemsInventory)
+ {
+
+ index++;
+ }
+ @for (int i = @index; i<18; i++)
+ {
+
+ }
diff --git a/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs b/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs
index 5e3223a..0d94bf8 100644
--- a/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs
+++ b/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs
@@ -1,12 +1,26 @@
using System;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
using Microsoft.AspNetCore.Components;
+using Microsoft.JSInterop;
using myBlazorApp.Models;
using myBlazorApp.Services;
namespace myBlazorApp.Components
{
public partial class MyInventory
{
- private List- itemsInventory = new List
- ();
+ [Parameter]
+ public List
- ItemsInventory { get; set; } = new List
- ();
+ public ObservableCollection Actions { get; set; }
+ public Item CurrentDragItem { get; set; }
+ [Parameter]
+ public int index { get; set; } = 0;
+
+ public MyInventory()
+ {
+ Actions = new ObservableCollection();
+ Actions.CollectionChanged += OnActionsCollectionChanged;
+ }
[Inject]
public IDataService DataService { get; set; }
@@ -16,6 +30,10 @@ namespace myBlazorApp.Components
[Inject]
public NavigationManager NavigationManager { get; set; }
+
+ [Inject]
+ internal IJSRuntime JavaScriptRuntime { get; set; }
+
/*
protected override async Task OnAfterRenderAsync(bool firstRender)
{
@@ -29,6 +47,11 @@ namespace myBlazorApp.Components
StateHasChanged();
}
*/
+
+ private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
+ {
+ JavaScriptRuntime.InvokeVoidAsync("MyInventory.AddActions", e.NewItems);
+ }
}
}
diff --git a/myBlazorApp/myBlazorApp/Components/MyInventory.razor.js b/myBlazorApp/myBlazorApp/Components/MyInventory.razor.js
new file mode 100644
index 0000000..33ea326
--- /dev/null
+++ b/myBlazorApp/myBlazorApp/Components/MyInventory.razor.js
@@ -0,0 +1,16 @@
+window.Crafting =
+{
+ AddActions: function (data) {
+
+ data.forEach(element => {
+ var div = document.createElement('div');
+ div.innerHTML = 'Action: ' + element.action + ' - Index: ' + element.index;
+
+ if (element.item) {
+ div.innerHTML += ' - Item Name: ' + element.item.name;
+ }
+
+ document.getElementById('actions').appendChild(div);
+ });
+ }
+}
diff --git a/myBlazorApp/myBlazorApp/Pages/Inventory.razor b/myBlazorApp/myBlazorApp/Pages/Inventory.razor
index 8a84ed5..38a76f0 100644
--- a/myBlazorApp/myBlazorApp/Pages/Inventory.razor
+++ b/myBlazorApp/myBlazorApp/Pages/Inventory.razor
@@ -3,9 +3,8 @@
@using System.Globalization
@using myBlazorApp.Models;
-
-
+
diff --git a/myBlazorApp/myBlazorApp/Pages/Inventory.razor.cs b/myBlazorApp/myBlazorApp/Pages/Inventory.razor.cs
index e9dae9e..1ab3ee8 100644
--- a/myBlazorApp/myBlazorApp/Pages/Inventory.razor.cs
+++ b/myBlazorApp/myBlazorApp/Pages/Inventory.razor.cs
@@ -12,6 +12,7 @@ namespace myBlazorApp.Pages
{
public partial class Inventory
{
+ public List- itemsInv = new List
- ();
private List
- items = new List
- ();
@@ -39,6 +40,7 @@ namespace myBlazorApp.Pages
if (!e.CancellationToken.IsCancellationRequested)
{
items = await DataService.List(e.Page, e.PageSize);
+ itemsInv = await DataService.List(e.Page, e.PageSize);
totalItem = await DataService.Count();
}
}