diff --git a/Valblaze.sln b/CraftTraining.sln similarity index 100% rename from Valblaze.sln rename to CraftTraining.sln diff --git a/ValblazeProject/Components/Card.razor b/ValblazeProject/Components/Card.razor deleted file mode 100644 index 874f2bc..0000000 --- a/ValblazeProject/Components/Card.razor +++ /dev/null @@ -1,7 +0,0 @@ -

Card

-@typeparam TItem -
- @CardHeader(Item) - @CardBody(Item) - @CardFooter -
\ No newline at end of file diff --git a/ValblazeProject/Components/Card.razor.cs b/ValblazeProject/Components/Card.razor.cs deleted file mode 100644 index f444b0c..0000000 --- a/ValblazeProject/Components/Card.razor.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace ValblazeProject.Components -{ - public partial class Card - { - [Parameter] - public RenderFragment CardBody { get; set; } - - [Parameter] - public RenderFragment CardFooter { get; set; } - - [Parameter] - public RenderFragment CardHeader { get; set; } - - [Parameter] - public TItem Item { get; set; } - } -} diff --git a/ValblazeProject/Components/CraftingItem.razor.cs b/ValblazeProject/Components/CraftingItem.razor.cs index 23f6b0a..04c20b3 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,15 +48,15 @@ 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() + internal void OnDragStart() { Parent.CurrentDragItem = this.Item; diff --git a/ValblazeProject/Components/CraftingItem.razor.css b/ValblazeProject/Components/CraftingItem.razor.css index b2d4521..4e20b01 100644 --- a/ValblazeProject/Components/CraftingItem.razor.css +++ b/ValblazeProject/Components/CraftingItem.razor.css @@ -1,4 +1,6 @@ .item { + display: flex; + justify-content: center; width: 64px; height: 64px; border: 1px solid; 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/Models/Cake.cs b/ValblazeProject/Models/Cake.cs deleted file mode 100644 index 77812fd..0000000 --- a/ValblazeProject/Models/Cake.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace ValblazeProject.Models -{ - public class Cake - { - public int Id { get; set; } - public string Name { get; set; } - public decimal Cost { get; set; } - } -} diff --git a/ValblazeProject/Pages/ExampleTabSet.razor b/ValblazeProject/Pages/ExampleTabSet.razor deleted file mode 100644 index 2a70582..0000000 --- a/ValblazeProject/Pages/ExampleTabSet.razor +++ /dev/null @@ -1,28 +0,0 @@ -@page "/example-tab-set" - - - -

Greetings from the first tab!

- - -
- - -

Hello from the second tab!

-
- - @if (showThirdTab) - { - -

Welcome to the disappearing third tab!

-

Toggle this tab from the first tab.

-
- } -
- -@code { - private bool showThirdTab; -} \ No newline at end of file diff --git a/ValblazeProject/Pages/Index.razor b/ValblazeProject/Pages/Index.razor index e4cef82..21c67a8 100644 --- a/ValblazeProject/Pages/Index.razor +++ b/ValblazeProject/Pages/Index.razor @@ -15,20 +15,3 @@ Welcome to your new app.

- - - -
-
- Cake Token Id - @CakeContext.Id -
-
-
@CakeContext.Name
-

Price $@CakeContext.Cost

-
- -
-
-
diff --git a/ValblazeProject/Pages/Index.razor.cs b/ValblazeProject/Pages/Index.razor.cs index 8d208d7..5b3d830 100644 --- a/ValblazeProject/Pages/Index.razor.cs +++ b/ValblazeProject/Pages/Index.razor.cs @@ -7,8 +7,6 @@ namespace ValblazeProject.Pages { public partial class Index { - public List Cakes { get; set; } - [Inject] public IDataService DataService { get; set; } diff --git a/ValblazeProject/Pages/Inventaire.razor b/ValblazeProject/Pages/Inventaire.razor index 2daa38c..aa5160d 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,41 +8,59 @@
-

Inventaire

+

@Localizer["Inventaire"]

@for(int i=0; i<10; i++){ }
+ +
- -
- + +
+ + - + @if (!string.IsNullOrWhiteSpace(context.ImageBase64)) { - @context.DisplayName +
+ + @if (context != null) + { + //@Item.DisplayName + @context.DisplayName + } +
+ //@context.DisplayName + // } else { @@ -50,7 +68,7 @@ }
- +
\ No newline at end of file diff --git a/ValblazeProject/Pages/Inventaire.razor.cs b/ValblazeProject/Pages/Inventaire.razor.cs index cee7a00..7eee9dc 100644 --- a/ValblazeProject/Pages/Inventaire.razor.cs +++ b/ValblazeProject/Pages/Inventaire.razor.cs @@ -12,6 +12,9 @@ using System.Collections.ObjectModel; using System.ComponentModel; using Microsoft.AspNetCore.Components.Forms; using System.Linq; +using Microsoft.JSInterop; +using System.Collections.Specialized; +using Microsoft.AspNetCore.Components.Web; namespace ValblazeProject.Pages { @@ -32,8 +35,12 @@ namespace ValblazeProject.Pages [Inject] public NavigationManager NavigationManager { get; set; } - - private List Recipes { get; set; } = new List(); + + /// + /// Gets or sets the java script runtime. + /// + [Inject] + internal IJSRuntime JavaScriptRuntime { get; set; } [CascadingParameter] public IModalService Modal { get; set; } @@ -42,7 +49,44 @@ namespace ValblazeProject.Pages private string _searchText; private int totalSizeByPage = 10; private bool _trie = false; + + + // Autre + 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); + } + + // Drag + private CraftingItem Drag; + public void OnDragEnter() + { + Drag.OnDragEnter(); + } + public void OnDragStart() + { + Drag.OnDragStart(); + } + public void OnDrop() + { + Drag.OnDrop(); + } + public void OnDragLeave() + { + Drag.OnDragLeave(); + } + /******************* Attribut modifier *******************/ private string search @@ -115,12 +159,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 +170,6 @@ namespace ValblazeProject.Pages if (_trie) { items = items.OrderBy(i => i.DisplayName).ToList(); - //await SortByName(); } // Gestion pagination @@ -139,7 +180,7 @@ namespace ValblazeProject.Pages } } - private async void OnDelete(int id) + /* private async void OnDelete(int id) { var parameters = new ModalParameters(); parameters.Add(nameof(Item.Id), id); @@ -156,6 +197,6 @@ namespace ValblazeProject.Pages // Reload the page NavigationManager.NavigateTo("list", true); - } + }*/ } } diff --git a/ValblazeProject/Pages/Inventaire.razor.css b/ValblazeProject/Pages/Inventaire.razor.css index 0796369..b9540ef 100644 --- a/ValblazeProject/Pages/Inventaire.razor.css +++ b/ValblazeProject/Pages/Inventaire.razor.css @@ -28,4 +28,20 @@ .filtre { width: 42px; height: 32px; -} \ No newline at end of file +} + +.actions { + border: 1px solid black; + height: 250px; + overflow: scroll; + margin-right: 20px; +} + +.item { + display: flex; + justify-content: center; + width: 64px; + height: 64px; + border: 1px solid; + overflow: hidden; +} 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 @@