diff --git a/ValblazeProject/Components/CraftingItem.razor.cs b/ValblazeProject/Components/CraftingItem.razor.cs index 23f6b0a..484898d 100644 --- a/ValblazeProject/Components/CraftingItem.razor.cs +++ b/ValblazeProject/Components/CraftingItem.razor.cs @@ -1,6 +1,7 @@ using Blazorise; using Microsoft.AspNetCore.Components; using ValblazeProject.Models; +using ValblazeProject.Pages; namespace ValblazeProject.Components { @@ -16,7 +17,8 @@ namespace ValblazeProject.Components public bool NoDrop { get; set; } [CascadingParameter] - public Crafting Parent { get; set; } + public Inventaire Parent { get; set; } + //public Crafting Parent { get; set; } internal void OnDragEnter() { @@ -46,12 +48,12 @@ namespace ValblazeProject.Components } this.Item = Parent.CurrentDragItem; - Parent.RecipeItems[this.Index] = this.Item; + //Parent.RecipeItems[this.Index] = this.Item; Parent.Actions.Add(new CraftingAction { Action = "Drop", Item = this.Item, Index = this.Index }); // Check recipe - Parent.CheckRecipe(); + //Parent.CheckRecipe(); } private void OnDragStart() diff --git a/ValblazeProject/Components/InventaireAction.cs b/ValblazeProject/Components/InventaireAction.cs deleted file mode 100644 index f4cf787..0000000 --- a/ValblazeProject/Components/InventaireAction.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace ValblazeProject.Components -{ - public class InventaireAction - { - } -} diff --git a/ValblazeProject/Data/WeatherForecast.cs b/ValblazeProject/Data/WeatherForecast.cs deleted file mode 100644 index 63404d5..0000000 --- a/ValblazeProject/Data/WeatherForecast.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace ValblazeProject.Data -{ - public class WeatherForecast - { - public DateTime Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string? Summary { get; set; } - } -} \ No newline at end of file diff --git a/ValblazeProject/Data/WeatherForecastService.cs b/ValblazeProject/Data/WeatherForecastService.cs deleted file mode 100644 index 6697258..0000000 --- a/ValblazeProject/Data/WeatherForecastService.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace ValblazeProject.Data -{ - public class WeatherForecastService - { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - public Task GetForecastAsync(DateTime startDate) - { - return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = startDate.AddDays(index), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = Summaries[Random.Shared.Next(Summaries.Length)] - }).ToArray()); - } - } -} \ No newline at end of file diff --git a/ValblazeProject/Pages/Inventaire.razor b/ValblazeProject/Pages/Inventaire.razor index 2daa38c..d90d93c 100644 --- a/ValblazeProject/Pages/Inventaire.razor +++ b/ValblazeProject/Pages/Inventaire.razor @@ -1,4 +1,4 @@ -@page "/invetaire" +@page "/Inventaire" @using System.Globalization @using ValblazeProject.Components @using ValblazeProject.Models @@ -8,23 +8,24 @@
-

Inventaire

+

@Localizer["Inventaire"]

@for(int i=0; i<10; i++){ }
+ +
- -
- + +
@@ -34,7 +35,6 @@ ReadData="@OnReadData" TotalItems="@totalItem" PageSize="@totalSizeByPage" - @ref="dataGrid" ShowPager Responsive> @@ -43,6 +43,7 @@ @if (!string.IsNullOrWhiteSpace(context.ImageBase64)) { @context.DisplayName + // } else { diff --git a/ValblazeProject/Pages/Inventaire.razor.cs b/ValblazeProject/Pages/Inventaire.razor.cs index cee7a00..2e4258d 100644 --- a/ValblazeProject/Pages/Inventaire.razor.cs +++ b/ValblazeProject/Pages/Inventaire.razor.cs @@ -12,6 +12,8 @@ using System.Collections.ObjectModel; using System.ComponentModel; using Microsoft.AspNetCore.Components.Forms; using System.Linq; +using Microsoft.JSInterop; +using System.Collections.Specialized; namespace ValblazeProject.Pages { @@ -32,6 +34,13 @@ namespace ValblazeProject.Pages [Inject] public NavigationManager NavigationManager { get; set; } + + /// + /// Gets or sets the java script runtime. + /// + [Inject] + internal IJSRuntime JavaScriptRuntime { get; set; } + private List Recipes { get; set; } = new List(); @@ -42,7 +51,21 @@ namespace ValblazeProject.Pages private string _searchText; private int totalSizeByPage = 10; private bool _trie = false; - + + public ObservableCollection Actions { get; set; } + + public Item CurrentDragItem { get; set; } + + public Inventaire() + { + Actions = new ObservableCollection(); + Actions.CollectionChanged += OnActionsCollectionChanged; + } + + private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) + { + JavaScriptRuntime.InvokeVoidAsync("Inventaire.AddActions", e.NewItems); + } /******************* Attribut modifier *******************/ private string search @@ -115,12 +138,10 @@ namespace ValblazeProject.Pages */ items = await DataService.List(); - //totalItem = items.Count(); // Search if (!string.IsNullOrEmpty(_searchText)) { - //await OnSearch(); items = items.Where(i => i.DisplayName.Contains(_searchText)).ToList(); } @@ -128,7 +149,6 @@ namespace ValblazeProject.Pages if (_trie) { items = items.OrderBy(i => i.DisplayName).ToList(); - //await SortByName(); } // Gestion pagination diff --git a/ValblazeProject/Pages/Inventaire.razor.css b/ValblazeProject/Pages/Inventaire.razor.css index 0796369..a6e5344 100644 --- a/ValblazeProject/Pages/Inventaire.razor.css +++ b/ValblazeProject/Pages/Inventaire.razor.css @@ -28,4 +28,11 @@ .filtre { width: 42px; height: 32px; +} + +.actions { + border: 1px solid black; + height: 250px; + overflow: scroll; + margin-right: 20px; } \ No newline at end of file diff --git a/ValblazeProject/Pages/Inventaire.razor.js b/ValblazeProject/Pages/Inventaire.razor.js new file mode 100644 index 0000000..8fdb58e --- /dev/null +++ b/ValblazeProject/Pages/Inventaire.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); + }); + } +} \ No newline at end of file diff --git a/ValblazeProject/Pages/List.razor b/ValblazeProject/Pages/List.razor index 07a86f3..5979cd6 100644 --- a/ValblazeProject/Pages/List.razor +++ b/ValblazeProject/Pages/List.razor @@ -2,7 +2,6 @@ @using System.Globalization @using ValblazeProject.Components @using ValblazeProject.Models -@using ValblazeProject.Models

@Localizer["Title"]

diff --git a/ValblazeProject/Program.cs b/ValblazeProject/Program.cs index a88adbd..e6db751 100644 --- a/ValblazeProject/Program.cs +++ b/ValblazeProject/Program.cs @@ -4,7 +4,6 @@ using Blazorise.Bootstrap; using Blazorise.Icons.FontAwesome; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; -using ValblazeProject.Data; using ValblazeProject.Services; using Blazored.Modal; using Microsoft.AspNetCore.Localization; @@ -20,9 +19,7 @@ builder.Services.AddScoped(); // API ici builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); builder.Services.AddHttpClient(); builder.Services diff --git a/ValblazeProject/Resources/Pages.Inventaire.fr-FR.resx b/ValblazeProject/Resources/Pages.Inventaire.fr-FR.resx new file mode 100644 index 0000000..89641aa --- /dev/null +++ b/ValblazeProject/Resources/Pages.Inventaire.fr-FR.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Inventaire + + + Recherche + + + Trie + + \ No newline at end of file diff --git a/ValblazeProject/Resources/Pages.Inventaire.resx b/ValblazeProject/Resources/Pages.Inventaire.resx new file mode 100644 index 0000000..6fcb8b8 --- /dev/null +++ b/ValblazeProject/Resources/Pages.Inventaire.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Inventory + + + Search: + + + Sort: + + \ No newline at end of file diff --git a/ValblazeProject/Shared/NavMenu.razor b/ValblazeProject/Shared/NavMenu.razor index 9e46983..f0a8fbf 100644 --- a/ValblazeProject/Shared/NavMenu.razor +++ b/ValblazeProject/Shared/NavMenu.razor @@ -23,7 +23,7 @@