Compare commits

..

No commits in common. '0c9b033c3dee9edc5df4edee4dd553fc59a62019' and '4b280d7ce8737f9a58594fd2ce21e693899e5f0c' have entirely different histories.

@ -1,33 +1,23 @@
[ [
{ {
"itemName": "Sand", "itemName": "null",
"position": 1, "position": 1
"number": 2,
"stackSize": 64
}, },
{ {
"itemName": "Grass Block", "itemName": "null",
"position": 2, "position": 2
"number": 3,
"stackSize": 64
}, },
{ {
"itemName": "Cobblestone", "itemName": "null",
"position": 3, "position": 3
"number": 3,
"stackSize": 64
}, },
{ {
"itemName": "Sapling", "itemName": "null",
"position": 4, "position": 4
"number": 1,
"stackSize": 64
}, },
{ {
"itemName": "Dirt", "itemName": "null",
"position": 5, "position": 5
"number": 2,
"stackSize": 64
}, },
{ {
"itemName": "null", "itemName": "null",

@ -7,19 +7,6 @@
@ondragend="@OnDragEnd" @ondragend="@OnDragEnd"
@ondragenter="@OnDragEnter" @ondragenter="@OnDragEnter"
@ondragleave="@OnDragLeave"> @ondragleave="@OnDragLeave">
@if (NoDrop == true)
{
@if (!string.IsNullOrWhiteSpace(@Image))
{
<img src="data:image/png;base64, @(Image)" class="img-thumbnail" title="@Item" alt="@Item" style="width: 64px" />
}
else
{
<img src="images/default.png" class="img-thumbnail" title="@Item" alt="@Item" style="max-width: 150px" />
}
}
else
{
@if (Item != "null") @if (Item != "null")
{ {
<label id="name">@Item</label> <label id="name">@Item</label>
@ -30,7 +17,5 @@
{ {
<p id="vide">@Localizer["emptyElement"]</p> <p id="vide">@Localizer["emptyElement"]</p>
} }
}
</div> </div>

@ -24,9 +24,6 @@ public partial class InventoryItem
[Parameter] [Parameter]
public bool NoDrop { get; set; } public bool NoDrop { get; set; }
[Parameter]
public string Image { get; set; }
[Inject] [Inject]
public IStringLocalizer<InventoryItem> Localizer { get; set; } public IStringLocalizer<InventoryItem> Localizer { get; set; }
@ -53,16 +50,13 @@ public partial class InventoryItem
internal void OnDrop() internal void OnDrop()
{ {
if (Parent.CurrentDragItem != "null") if (NoDrop)
{
if(Parent.CurrentDragIndex == 0)
{ {
this.Number = this.Number + Parent.CurrentDragNumber; return;
this.Item = Parent.CurrentDragItem;
this.StackSize = Parent.CurrentDragStackSize;
Parent.ItemsInventory[this.Index - 1] = new InventoryListItem(this.Item, this.Index, this.Number, this.StackSize);
} }
else if (this.Item == Parent.CurrentDragItem) if (Parent.CurrentDragItem != "null")
{
if(this.Item == Parent.CurrentDragItem)
{ {
this.Number = this.Number + Parent.CurrentDragNumber; this.Number = this.Number + Parent.CurrentDragNumber;
Parent.CurrentInventoryItem.Number = 0; Parent.CurrentInventoryItem.Number = 0;
@ -87,7 +81,6 @@ public partial class InventoryItem
} }
Parent.Actions.Add(new InventoryAction { Action = "Drop", ItemName = this.Item, Index = this.Index, Number = this.Number, StackSize = this.StackSize }); Parent.Actions.Add(new InventoryAction { Action = "Drop", ItemName = this.Item, Index = this.Index, Number = this.Number, StackSize = this.StackSize });
} }
internal void OnDragEnd() internal void OnDragEnd()

@ -1,8 +1,7 @@
@using myBlazorApp.Models @using myBlazorApp.Models
@using myBlazorApp.Components
<CascadingValue Value="@this"> <CascadingValue Value="@this">
<h3>@Localizer["Inventory"]</h3> <h3>@Localizer["Title"]</h3>
<div class="body"> <div class="body">
<div class="inventory"> <div class="inventory">
<div class="inventory-items"> <div class="inventory-items">
@ -14,13 +13,13 @@
</div> </div>
<div id="ItemList" class="align-end"> <div id="ItemList" class="align-end">
<h3>@Localizer["List"]</h3> <h3>List of Items</h3>
<input type="text" @bind-value="@SearchText" <input type="text" @bind-value="@SearchText"
@bind-value:event="oninput" placeholder="Search by Name" @bind-value:event="oninput" placeholder="Search by Name"
@onchange="@inputValue" /> @onchange="@inputValue" />
<button type="button" @onclick="@OnPress">@Localizer["Sort"]</button> <button type="button" @onclick="@OnPress">Sort</button>
<DataGrid TItem="Item" <DataGrid TItem="Item"
@ -33,14 +32,20 @@
<DataGridColumn Field="@nameof(Item.Id)"> <DataGridColumn Field="@nameof(Item.Id)">
<DisplayTemplate> <DisplayTemplate>
<InventoryItem Item="@context.DisplayName" NoDrop="true" Number=1 StackSize="@context.StackSize" Image="@context.ImageBase64"/> @if (!string.IsNullOrWhiteSpace(context.ImageBase64))
{
<img src="data:image/png;base64, @(context.ImageBase64)" class="img-thumbnail" title="@context.DisplayName" alt="@context.DisplayName" style="width: 50px" />
}
else
{
<img src="images/default.png" class="img-thumbnail" title="@context.DisplayName" alt="@context.DisplayName" style="max-width: 150px" />
}
</DisplayTemplate> </DisplayTemplate>
</DataGridColumn> </DataGridColumn>
<DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" /> <DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" />
</DataGrid> </DataGrid>
</div> </div>
</div> </div>
</CascadingValue> </CascadingValue>

@ -16,7 +16,7 @@ namespace myBlazorApp.Components
public partial class MyInventory public partial class MyInventory
{ {
[Parameter] [Parameter]
public List<InventoryListItem> ItemsInventory { get; set; } = new List<InventoryListItem>(); public List<InventoryListItem> ItemsInventory { get; set; }
public int index { get; set; } = 0; public int index { get; set; } = 0;
@ -97,7 +97,6 @@ namespace myBlazorApp.Components
totalItem = await DataService.Count(); totalItem = await DataService.Count();
items = await DataService.List(e.Page, e.PageSize); items = await DataService.List(e.Page, e.PageSize);
full = await DataService.List(e.Page, totalItem); full = await DataService.List(e.Page, totalItem);
ItemsInventory = await DataService.GetInventoryItems();
currentPage = e.Page; currentPage = e.Page;
pageSize = e.PageSize; pageSize = e.PageSize;
if (isSorted == false) if (isSorted == false)

@ -5,5 +5,5 @@
@using Syncfusion.Blazor.Grids; @using Syncfusion.Blazor.Grids;
<div class="inventory"> <div class="inventory">
<MyInventory/> <MyInventory ItemsInventory="@itemsInv"/>
</div> </div>

@ -60,27 +60,9 @@ namespace myBlazorApp.Resources {
/// <summary> /// <summary>
/// Looks up a localized string similar to My inventory. /// Looks up a localized string similar to My inventory.
/// </summary> /// </summary>
internal static string Inventory { internal static string Title {
get { get {
return ResourceManager.GetString("Inventory", resourceCulture); return ResourceManager.GetString("Title", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Available items.
/// </summary>
internal static string List {
get {
return ResourceManager.GetString("List", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to SORT.
/// </summary>
internal static string Sort {
get {
return ResourceManager.GetString("Sort", resourceCulture);
} }
} }
} }

@ -117,16 +117,8 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="Inventory" xml:space="preserve"> <data name="Title" xml:space="preserve">
<value>Mon inventaire</value> <value>Mon inventaire</value>
<comment/> <comment/>
</data> </data>
<data name="List" xml:space="preserve">
<value>Objets Disponibles</value>
<comment/>
</data>
<data name="Sort" xml:space="preserve">
<value>TRIER</value>
<comment/>
</data>
</root> </root>

@ -117,16 +117,8 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="Inventory" xml:space="preserve"> <data name="Title" xml:space="preserve">
<value>My inventory</value> <value>My inventory</value>
<comment/> <comment/>
</data> </data>
<data name="List" xml:space="preserve">
<value>Available items</value>
<comment/>
</data>
<data name="Sort" xml:space="preserve">
<value>SORT</value>
<comment/>
</data>
</root> </root>
Loading…
Cancel
Save