continuation invetaire

master
Baptiste BAVEREL 2 years ago
parent d32ad07fe4
commit 72fbe8aadb

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -2,30 +2,29 @@
<div class="container">
<div class="row">
<div class="col-6">
<div>Available items:</div>
<div>Inventory</div>
<div>
<div class="css-grid">
<div class="css-gridInv">
@foreach (var item in Items)
@for(int i = 0; i<40; i++)
{
<ListItem Item="item" NoDrop="true"/>
<InventoryItem Item="null" NoDrop="false"/>
}
</div>
</div>
</div>
<div class="col-6">
<div>Inventory</div>
<div>Available items:</div>
<div>
<div class="css-gridInv">
<div class="css-grid">
@for(int i = 0; i<40; i++)
@foreach (var item in Items)
{
<InventoryItem Item="null" NoDrop="true"/>
<ListItem Item="item" NoDrop="true"/>
}
</div>
</div>
</div>
</div>
</div>

@ -11,5 +11,7 @@ namespace BlazorApp1.Components
public List<Item> Items { get; set; }
public Item CurrentDragItem { get; set; }
public ItemDisplay CurrentEllement { get; set; }
}
}

@ -2,7 +2,7 @@
namespace BlazorApp1.Components
{
public partial class InventoryItem
public partial class InventoryItem : ItemDisplay
{
[Parameter]
public int Index { get; set; }
@ -13,9 +13,31 @@ namespace BlazorApp1.Components
[Parameter]
public bool NoDrop { get; set; }
public int nbElem { get; set; }
[CascadingParameter]
public Inventory Parent { get; set; }
public void changeState()
{
StateHasChanged();
}
public Item getItem()
{
return Item;
}
public int getNbElement()
{
return nbElem;
}
public String getTypeID()
{
return "InventoryItem";
}
internal void OnDragEnter()
{
if (NoDrop)
@ -40,12 +62,41 @@ namespace BlazorApp1.Components
return;
}
if (this.Item is not null)
{
if (this.Item.Equals(Parent.CurrentDragItem) && this.nbElem < 64)
this.nbElem++;
}
else
{
Item tmp = this.Item;
int tmpNb = this.nbElem;
this.Item = Parent.CurrentDragItem;
this.nbElem = Parent.CurrentEllement.getNbElement();
if (Parent.CurrentEllement.getTypeID() == "InventoryItem")
{
InventoryItem invItem = (InventoryItem)Parent.CurrentEllement;
invItem.Item = tmp;
invItem.nbElem = tmpNb;
Parent.CurrentEllement = invItem;
}
else if (Parent.CurrentEllement.getTypeID() == "ListItem")
{
}
}
Parent.CurrentEllement.changeState();
StateHasChanged();
}
private void OnDragStart()
{
Parent.CurrentDragItem = this.Item;
Parent.CurrentEllement = this;
}
}
}

@ -0,0 +1,13 @@
namespace BlazorApp1.Components
{
public interface ItemDisplay
{
String getTypeID();
Item getItem();
int getNbElement();
void changeState();
}
}

@ -2,7 +2,7 @@
namespace BlazorApp1.Components
{
public partial class ListItem
public partial class ListItem :ItemDisplay
{
[Parameter]
public int Index { get; set; }
@ -16,6 +16,26 @@ namespace BlazorApp1.Components
[CascadingParameter]
public Inventory Parent { get; set; }
public void changeState()
{
StateHasChanged();
}
public Item getItem()
{
return Item;
}
public int getNbElement()
{
return 1;
}
public String getTypeID()
{
return "ListItem";
}
internal void OnDragEnter()
{
if (NoDrop)
@ -40,12 +60,13 @@ namespace BlazorApp1.Components
return;
}
//this.Item = Parent.CurrentDragItem;
this.Item = Parent.CurrentDragItem;
}
private void OnDragStart()
{
Parent.CurrentDragItem = this.Item;
Parent.CurrentEllement = this;
}
}
}

@ -13,9 +13,7 @@
Data="@items"
ReadData="@OnReadData"
TotalItems="@totalItem"
PageSize="10"
ShowPager
Responsive>
>
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)" Caption="#" />
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)" Caption="Image">
<DisplayTemplate>

@ -1 +1 @@
0705d4c8fcd885ba34f75dd5c88fb4f2c119e8f3
a3548e4cb925cba10bee1ef2bf3db8455d660966

@ -110,3 +110,4 @@ C:\Users\babaverel\Source\Repos\Blazor2\BlazorApp1\obj\Debug\net6.0\BlazorApp1.g
C:\Users\babaverel\Source\Repos\Blazor2\BlazorApp1\obj\Debug\net6.0\ref\BlazorApp1.dll
C:\Users\babaverel\source\repos\Blazor\BlazorApp1\obj\Debug\net6.0\scopedcss\Components\InventoryItem.razor.rz.scp.css
C:\Users\babaverel\source\repos\Blazor\BlazorApp1\obj\Debug\net6.0\scopedcss\Components\Inventory.razor.rz.scp.css
C:\Users\babaverel\Source\Repos\Blazor\BlazorApp1\obj\Debug\net6.0\scopedcss\Components\ListItem.razor.rz.scp.css

File diff suppressed because one or more lines are too long

@ -0,0 +1,6 @@
.item[b-ru82o536pj] {
width: 64px;
height: 64px;
border: 1px solid;
overflow: hidden;
}

@ -48,6 +48,13 @@
border: 1px solid;
overflow: hidden;
}
/* _content/BlazorApp1/Components/ListItem.razor.rz.scp.css */
.item[b-ru82o536pj] {
width: 64px;
height: 64px;
border: 1px solid;
overflow: hidden;
}
/* _content/BlazorApp1/Shared/MainLayout.razor.rz.scp.css */
.page[b-45rkf8v3vv] {
position: relative;

@ -46,6 +46,13 @@
border: 1px solid;
overflow: hidden;
}
/* _content/BlazorApp1/Components/ListItem.razor.rz.scp.css */
.item[b-ru82o536pj] {
width: 64px;
height: 64px;
border: 1px solid;
overflow: hidden;
}
/* _content/BlazorApp1/Shared/MainLayout.razor.rz.scp.css */
.page[b-45rkf8v3vv] {
position: relative;

@ -121,3 +121,16 @@
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0

@ -1 +1 @@
e35172263aad90d495784aab2a7d87c636b58058
5c8455510f8981a8236fa4ed734ad1db8aa8035c

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save