From 63c8142a54e8d108573d0439f04f7ba595935195 Mon Sep 17 00:00:00 2001 From: Dominique Alexandre Date: Wed, 25 Dec 2024 19:02:13 -0500 Subject: [PATCH 01/11] Add mention that poeprices.info is only for PoE1 --- .../Settings/SettingsResources.fr.resx | 6 +----- .../Settings/SettingsResources.ko.resx | 2 +- src/Sidekick.Common.Blazor/Settings/SettingsResources.resx | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Sidekick.Common.Blazor/Settings/SettingsResources.fr.resx b/src/Sidekick.Common.Blazor/Settings/SettingsResources.fr.resx index 7b2199d1..6afaa2dc 100644 --- a/src/Sidekick.Common.Blazor/Settings/SettingsResources.fr.resx +++ b/src/Sidekick.Common.Blazor/Settings/SettingsResources.fr.resx @@ -232,7 +232,7 @@ Vérifier les prix - Afficher les prédictions de poeprices.info + Afficher les prédictions de poeprices.info (PoE1 seulement) Réinitialiser la cache @@ -324,10 +324,6 @@ Site officiel - - - - Ouvrir le répertoire des configurations diff --git a/src/Sidekick.Common.Blazor/Settings/SettingsResources.ko.resx b/src/Sidekick.Common.Blazor/Settings/SettingsResources.ko.resx index 510bd5b5..7bceb43e 100644 --- a/src/Sidekick.Common.Blazor/Settings/SettingsResources.ko.resx +++ b/src/Sidekick.Common.Blazor/Settings/SettingsResources.ko.resx @@ -232,7 +232,7 @@ 가격 검색 - poeprices.info에서 가져온 가격 예측 보여주기 + poeprices.info에서 가져온 가격 예측 보여주기 (PoE1) 캐시 초기화 diff --git a/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx b/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx index 489a77c5..7ec5e3b7 100644 --- a/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx +++ b/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx @@ -232,7 +232,7 @@ Check Prices - Show price prediction from poeprices.info + Show price prediction from poeprices.info (PoE1 only) Reset Cache @@ -342,4 +342,4 @@ poedb.tw / poe2db.tw - \ No newline at end of file + From 6119dac972860ae84318668eed2afe91268220d9 Mon Sep 17 00:00:00 2001 From: Ati1707 <152104750+Ati1707@users.noreply.github.com> Date: Thu, 26 Dec 2024 02:34:32 +0100 Subject: [PATCH 02/11] remove canBeVaalGem statement --- src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs b/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs index bb0f6902..004bbede 100644 --- a/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs +++ b/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs @@ -52,12 +52,6 @@ public Task Initialize() var itemRarity = headerParser.ParseRarity(parsingItem); - var canBeVaalGem = itemRarity == Rarity.Gem && parsingItem.Blocks.Count > 7; - if (canBeVaalGem && data.NameAndTypeDictionary.TryGetValue(parsingItem.Blocks[5].Lines[0].Text, out var vaalGem)) - { - return vaalGem.First(); - } - // Get name and type text string? name = null; string? type = null; From e89de37f2470483c6753ae7865f694553eecc549 Mon Sep 17 00:00:00 2001 From: Ati1707 <152104750+Ati1707@users.noreply.github.com> Date: Thu, 26 Dec 2024 11:58:32 +0100 Subject: [PATCH 03/11] revert changes and check if block lines exist --- .../Parser/Metadata/MetadataParser.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs b/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs index 004bbede..6db2fa6c 100644 --- a/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs +++ b/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs @@ -51,6 +51,16 @@ public Task Initialize() parsingBlock.Parsed = true; var itemRarity = headerParser.ParseRarity(parsingItem); + + var canBeVaalGem = itemRarity == Rarity.Gem && parsingItem.Blocks.Count > 7; + if (parsingItem.Blocks[5].Lines.Count > 0 && canBeVaalGem) + { + data.NameAndTypeDictionary.TryGetValue(parsingItem.Blocks[5].Lines[0].Text, value: out var vaalGem); + if (vaalGem != null) + { + return vaalGem.First(); + } + } // Get name and type text string? name = null; From f63167ca2dbd35042e3fdff82002370552d7287b Mon Sep 17 00:00:00 2001 From: Ati1707 <152104750+Ati1707@users.noreply.github.com> Date: Thu, 26 Dec 2024 12:25:06 +0100 Subject: [PATCH 04/11] fix if statement order --- src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs b/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs index 6db2fa6c..9b7e8cf3 100644 --- a/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs +++ b/src/Sidekick.Apis.Poe/Parser/Metadata/MetadataParser.cs @@ -53,9 +53,9 @@ public Task Initialize() var itemRarity = headerParser.ParseRarity(parsingItem); var canBeVaalGem = itemRarity == Rarity.Gem && parsingItem.Blocks.Count > 7; - if (parsingItem.Blocks[5].Lines.Count > 0 && canBeVaalGem) + if (canBeVaalGem && parsingItem.Blocks[5].Lines.Count > 0) { - data.NameAndTypeDictionary.TryGetValue(parsingItem.Blocks[5].Lines[0].Text, value: out var vaalGem); + data.NameAndTypeDictionary.TryGetValue(parsingItem.Blocks[5].Lines[0].Text, out var vaalGem); if (vaalGem != null) { return vaalGem.First(); From cbe2af9008113260f6e945b9d8861dba25b12bae Mon Sep 17 00:00:00 2001 From: Dominique Alexandre Date: Thu, 26 Dec 2024 11:18:22 -0500 Subject: [PATCH 05/11] Initial setup --- .../Settings/General/General.razor | 1 + .../General/SaveWindowPositionsEditor.razor | 26 +++++++++++++++++++ .../Settings/SettingsResources.fr.resx | 3 +++ .../Settings/SettingsResources.resx | 5 +++- .../Tables/ViewPreference.cs | 4 +++ .../Views/IViewPreferenceService.cs | 4 +-- .../Views/ViewPreferenceService.cs | 10 ++++--- .../Settings/DefaultSettings.cs | 2 ++ src/Sidekick.Common/Settings/SettingKeys.cs | 2 ++ src/Sidekick.Wpf/MainWindow.xaml.cs | 8 +++++- 10 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 src/Sidekick.Common.Blazor/Settings/General/SaveWindowPositionsEditor.razor diff --git a/src/Sidekick.Common.Blazor/Settings/General/General.razor b/src/Sidekick.Common.Blazor/Settings/General/General.razor index a7da6fb2..7e182df0 100644 --- a/src/Sidekick.Common.Blazor/Settings/General/General.razor +++ b/src/Sidekick.Common.Blazor/Settings/General/General.razor @@ -14,6 +14,7 @@
+
diff --git a/src/Sidekick.Common.Blazor/Settings/General/SaveWindowPositionsEditor.razor b/src/Sidekick.Common.Blazor/Settings/General/SaveWindowPositionsEditor.razor new file mode 100644 index 00000000..55141817 --- /dev/null +++ b/src/Sidekick.Common.Blazor/Settings/General/SaveWindowPositionsEditor.razor @@ -0,0 +1,26 @@ +@using Sidekick.Common.Settings + + + @Resources["SaveWindowPositions"] + + +@inject IStringLocalizer Resources +@inject ISettingsService SettingsService + +@code { + + private bool SaveWindowPositions { get; set; } + + protected override async Task OnInitializedAsync() + { + SaveWindowPositions = await SettingsService.GetBool(SettingKeys.SaveWindowPositions); + await base.OnInitializedAsync(); + } + + private async Task SaveWindowPositionsChanged(bool value) + { + SaveWindowPositions = value; + await SettingsService.Set(SettingKeys.SaveWindowPositions, value); + } +} diff --git a/src/Sidekick.Common.Blazor/Settings/SettingsResources.fr.resx b/src/Sidekick.Common.Blazor/Settings/SettingsResources.fr.resx index 6afaa2dc..a3654f46 100644 --- a/src/Sidekick.Common.Blazor/Settings/SettingsResources.fr.resx +++ b/src/Sidekick.Common.Blazor/Settings/SettingsResources.fr.resx @@ -327,4 +327,7 @@ Ouvrir le répertoire des configurations + + Conserver la position des fenêtres. Si désactivé, les fenêtres seront centrées. + \ No newline at end of file diff --git a/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx b/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx index 7ec5e3b7..3b62427e 100644 --- a/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx +++ b/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx @@ -342,4 +342,7 @@ poedb.tw / poe2db.tw - + + Save the positions of the overlays. If false, they will be centered. + + \ No newline at end of file diff --git a/src/Sidekick.Common.Database/Tables/ViewPreference.cs b/src/Sidekick.Common.Database/Tables/ViewPreference.cs index 806347db..8d4083a1 100644 --- a/src/Sidekick.Common.Database/Tables/ViewPreference.cs +++ b/src/Sidekick.Common.Database/Tables/ViewPreference.cs @@ -11,4 +11,8 @@ public class ViewPreference public int Width { get; set; } public int Height { get; set; } + + public int? X { get; set; } + + public int? Y { get; set; } } diff --git a/src/Sidekick.Common.Ui/Views/IViewPreferenceService.cs b/src/Sidekick.Common.Ui/Views/IViewPreferenceService.cs index f11382e8..b7faab9d 100644 --- a/src/Sidekick.Common.Ui/Views/IViewPreferenceService.cs +++ b/src/Sidekick.Common.Ui/Views/IViewPreferenceService.cs @@ -1,4 +1,4 @@ -using Sidekick.Common.Database.Tables; +using Sidekick.Common.Database.Tables; namespace Sidekick.Common.Ui.Views; @@ -6,5 +6,5 @@ public interface IViewPreferenceService { Task Get(string? key); - Task Set(string? key, int width, int height); + Task Set(string? key, int width, int height, int? x = null, int? y = null); } diff --git a/src/Sidekick.Common.Ui/Views/ViewPreferenceService.cs b/src/Sidekick.Common.Ui/Views/ViewPreferenceService.cs index 5ae400f7..18ebddd0 100644 --- a/src/Sidekick.Common.Ui/Views/ViewPreferenceService.cs +++ b/src/Sidekick.Common.Ui/Views/ViewPreferenceService.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Sidekick.Common.Database; using Sidekick.Common.Database.Tables; @@ -18,7 +18,7 @@ public class ViewPreferenceService(DbContextOptions dbOptions return viewPreference; } - public async Task Set(string? key, int width, int height) + public async Task Set(string? key, int width, int height, int? x = null, int? y = null) { if (string.IsNullOrEmpty(key)) { @@ -33,7 +33,9 @@ public async Task Set(string? key, int width, int height) { Key = key, Width = width, - Height = height + Height = height, + X = x, + Y = y }; dbContext.ViewPreferences.Add(viewPreference); await dbContext.SaveChangesAsync(); @@ -42,6 +44,8 @@ public async Task Set(string? key, int width, int height) { viewPreference.Width = width; viewPreference.Height = height; + viewPreference.X = x; + viewPreference.Y = y; await dbContext.SaveChangesAsync(); } } diff --git a/src/Sidekick.Common/Settings/DefaultSettings.cs b/src/Sidekick.Common/Settings/DefaultSettings.cs index 51f9a7c3..887d8f1b 100644 --- a/src/Sidekick.Common/Settings/DefaultSettings.cs +++ b/src/Sidekick.Common/Settings/DefaultSettings.cs @@ -51,4 +51,6 @@ public static class DefaultSettings new ChatSetting("Ctrl+Enter", "@last ", false), new ChatSetting("F9", "/exit", true), ]; + + public static bool SaveWindowPositions => false; } diff --git a/src/Sidekick.Common/Settings/SettingKeys.cs b/src/Sidekick.Common/Settings/SettingKeys.cs index bc7b77cb..8b46e2a7 100644 --- a/src/Sidekick.Common/Settings/SettingKeys.cs +++ b/src/Sidekick.Common/Settings/SettingKeys.cs @@ -48,6 +48,8 @@ public static class SettingKeys public const string PriceCheckCurrencyMode = nameof(PriceCheckCurrencyMode); public const string PriceCheckNormalizeValue = nameof(PriceCheckNormalizeValue); + public const string SaveWindowPositions = nameof(SaveWindowPositions); + public const string WealthEnabled = nameof(WealthEnabled); public const string WealthTrackedTabs = nameof(WealthTrackedTabs); public const string WealthItemTotalMinimum = nameof(WealthItemTotalMinimum); diff --git a/src/Sidekick.Wpf/MainWindow.xaml.cs b/src/Sidekick.Wpf/MainWindow.xaml.cs index b8c54e30..caf6fc3a 100644 --- a/src/Sidekick.Wpf/MainWindow.xaml.cs +++ b/src/Sidekick.Wpf/MainWindow.xaml.cs @@ -65,7 +65,13 @@ protected override void OnClosing(CancelEventArgs e) { var width = (int)ActualWidth; var height = (int)ActualHeight; - _ = viewLocator.ViewPreferenceService.Set(SidekickView?.CurrentView.Key, width, height); + int? x, y = null; + if (true) + { + x = (int)Left; + y = (int)Top; + } + _ = viewLocator.ViewPreferenceService.Set(SidekickView?.CurrentView.Key, width, height, x, y); } catch (Exception) { From 67d5a35be4b7e33753da2d2410496c2a1a4cc462 Mon Sep 17 00:00:00 2001 From: Dominique Alexandre Date: Thu, 26 Dec 2024 11:56:44 -0500 Subject: [PATCH 06/11] Add a setting to save the position of the overlays --- ...1226161905_SaveWindowPositions.Designer.cs | 195 ++++++++++++++++++ .../20241226161905_SaveWindowPositions.cs | 74 +++++++ .../SidekickDbContextModelSnapshot.cs | 10 +- src/Sidekick.Wpf/MainWindow.xaml | 64 +++--- src/Sidekick.Wpf/MainWindow.xaml.cs | 11 +- src/Sidekick.Wpf/Services/WpfViewLocator.cs | 19 +- 6 files changed, 339 insertions(+), 34 deletions(-) create mode 100644 src/Sidekick.Common.Database/Migrations/20241226161905_SaveWindowPositions.Designer.cs create mode 100644 src/Sidekick.Common.Database/Migrations/20241226161905_SaveWindowPositions.cs diff --git a/src/Sidekick.Common.Database/Migrations/20241226161905_SaveWindowPositions.Designer.cs b/src/Sidekick.Common.Database/Migrations/20241226161905_SaveWindowPositions.Designer.cs new file mode 100644 index 00000000..73240b95 --- /dev/null +++ b/src/Sidekick.Common.Database/Migrations/20241226161905_SaveWindowPositions.Designer.cs @@ -0,0 +1,195 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Sidekick.Common.Database; + +#nullable disable + +namespace Sidekick.Common.Database.Migrations +{ + [DbContext(typeof(SidekickDbContext))] + [Migration("20241226161905_SaveWindowPositions")] + partial class SaveWindowPositions + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.11"); + + modelBuilder.Entity("Sidekick.Common.Database.Tables.Setting", b => + { + b.Property("Key") + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("Value") + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Key"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("Sidekick.Common.Database.Tables.ViewPreference", b => + { + b.Property("Key") + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("Height") + .HasColumnType("INTEGER"); + + b.Property("Width") + .HasColumnType("INTEGER"); + + b.Property("X") + .HasColumnType("INTEGER"); + + b.Property("Y") + .HasColumnType("INTEGER"); + + b.HasKey("Key"); + + b.ToTable("ViewPreferences"); + }); + + modelBuilder.Entity("Sidekick.Common.Database.Tables.WealthFullSnapshot", b => + { + b.Property("Date") + .HasColumnType("INTEGER"); + + b.Property("League") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.HasKey("Date"); + + b.ToTable("WealthFullSnapshots"); + }); + + modelBuilder.Entity("Sidekick.Common.Database.Tables.WealthItem", b => + { + b.Property("Id") + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("Count") + .HasColumnType("INTEGER"); + + b.Property("GemLevel") + .HasColumnType("INTEGER"); + + b.Property("Icon") + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("ItemLevel") + .HasColumnType("INTEGER"); + + b.Property("League") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("MapTier") + .HasColumnType("INTEGER"); + + b.Property("MaxLinks") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("TEXT"); + + b.Property("StashId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("WealthItems"); + }); + + modelBuilder.Entity("Sidekick.Common.Database.Tables.WealthStash", b => + { + b.Property("Id") + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("LastUpdate") + .HasColumnType("INTEGER"); + + b.Property("League") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("Parent") + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("WealthStashes"); + }); + + modelBuilder.Entity("Sidekick.Common.Database.Tables.WealthStashSnapshot", b => + { + b.Property("Date") + .HasColumnType("INTEGER"); + + b.Property("StashId") + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("League") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.HasKey("Date", "StashId"); + + b.ToTable("WealthStashSnapshots"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Sidekick.Common.Database/Migrations/20241226161905_SaveWindowPositions.cs b/src/Sidekick.Common.Database/Migrations/20241226161905_SaveWindowPositions.cs new file mode 100644 index 00000000..d18dea74 --- /dev/null +++ b/src/Sidekick.Common.Database/Migrations/20241226161905_SaveWindowPositions.cs @@ -0,0 +1,74 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Sidekick.Common.Database.Migrations +{ + /// + public partial class SaveWindowPositions : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Width", + table: "ViewPreferences", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Height", + table: "ViewPreferences", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "X", + table: "ViewPreferences", + type: "INTEGER", + nullable: true); + + migrationBuilder.AddColumn( + name: "Y", + table: "ViewPreferences", + type: "INTEGER", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "X", + table: "ViewPreferences"); + + migrationBuilder.DropColumn( + name: "Y", + table: "ViewPreferences"); + + migrationBuilder.AlterColumn( + name: "Width", + table: "ViewPreferences", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "Height", + table: "ViewPreferences", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + } + } +} diff --git a/src/Sidekick.Common.Database/Migrations/SidekickDbContextModelSnapshot.cs b/src/Sidekick.Common.Database/Migrations/SidekickDbContextModelSnapshot.cs index 32162433..76a59d96 100644 --- a/src/Sidekick.Common.Database/Migrations/SidekickDbContextModelSnapshot.cs +++ b/src/Sidekick.Common.Database/Migrations/SidekickDbContextModelSnapshot.cs @@ -38,10 +38,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(64) .HasColumnType("TEXT"); - b.Property("Height") + b.Property("Height") .HasColumnType("INTEGER"); - b.Property("Width") + b.Property("Width") + .HasColumnType("INTEGER"); + + b.Property("X") + .HasColumnType("INTEGER"); + + b.Property("Y") .HasColumnType("INTEGER"); b.HasKey("Key"); diff --git a/src/Sidekick.Wpf/MainWindow.xaml b/src/Sidekick.Wpf/MainWindow.xaml index 4ad3d02b..3101d299 100644 --- a/src/Sidekick.Wpf/MainWindow.xaml +++ b/src/Sidekick.Wpf/MainWindow.xaml @@ -1,44 +1,54 @@ - + - + - - - + + + - + - + - + diff --git a/src/Sidekick.Wpf/MainWindow.xaml.cs b/src/Sidekick.Wpf/MainWindow.xaml.cs index caf6fc3a..6ce9c7d9 100644 --- a/src/Sidekick.Wpf/MainWindow.xaml.cs +++ b/src/Sidekick.Wpf/MainWindow.xaml.cs @@ -6,6 +6,7 @@ using System.Windows.Interop; using System.Windows.Media; using Microsoft.Extensions.DependencyInjection; +using Sidekick.Common.Settings; using Sidekick.Common.Ui.Views; using Sidekick.Wpf.Helpers; using Sidekick.Wpf.Services; @@ -45,7 +46,6 @@ public void Ready() Background = (Brush?)new BrushConverter().ConvertFrom("#000000"); Opacity = 0.01; - CenterHelper.Center(this); Activate(); } @@ -61,12 +61,17 @@ protected override void OnClosing(CancelEventArgs e) return; } + // Save the window position and size. try { var width = (int)ActualWidth; var height = (int)ActualHeight; - int? x, y = null; - if (true) + + var settingsService = Scope.ServiceProvider.GetRequiredService(); + var saveWindowPosition = settingsService.GetBool(SettingKeys.SaveWindowPositions).GetAwaiter().GetResult(); + + int? x = null, y = null; + if (saveWindowPosition) { x = (int)Left; y = (int)Top; diff --git a/src/Sidekick.Wpf/Services/WpfViewLocator.cs b/src/Sidekick.Wpf/Services/WpfViewLocator.cs index da78ead1..8ee1af5f 100644 --- a/src/Sidekick.Wpf/Services/WpfViewLocator.cs +++ b/src/Sidekick.Wpf/Services/WpfViewLocator.cs @@ -41,7 +41,7 @@ public async Task Initialize(SidekickView view) view.CurrentView.ViewChanged += CurrentViewOnViewChanged; var preferences = await ViewPreferenceService.Get(view.CurrentView.Key); - Application.Current.Dispatcher.Invoke(() => + _ = Application.Current.Dispatcher.Invoke(async () => { window.Title = view.CurrentView.Title.StartsWith("Sidekick") ? view.CurrentView.Title.Trim() : $"Sidekick {view.CurrentView.Title}".Trim(); window.MinHeight = view.ViewHeight + 20; @@ -77,6 +77,18 @@ public async Task Initialize(SidekickView view) window.ResizeMode = ResizeMode.CanResize; } + // Set the window position. + var saveWindowPositions = await settingsService.GetBool(SettingKeys.SaveWindowPositions); + if (saveWindowPositions && preferences != null && preferences.X.HasValue && preferences.Y.HasValue) + { + window.Left = preferences.X.Value!; + window.Top = preferences.Y.Value!; + } + else + { + CenterHelper.Center(window); + } + window.Ready(); }); } @@ -118,7 +130,10 @@ private void CurrentViewOnViewChanged(ICurrentView view) center = true; } - if (center) CenterHelper.Center(window); + if (center) + { + CenterHelper.Center(window); + } window.Title = $"Sidekick {view.Title}".Trim(); }); From 2aad10c5af990ee7ee01329c44ac67f81edf9ceb Mon Sep 17 00:00:00 2001 From: Dominique Alexandre Date: Thu, 26 Dec 2024 18:03:34 -0500 Subject: [PATCH 07/11] Add compact mode in the results view --- src/Sidekick.Common.Ui/UiIcons.cs | 11 ++++++- src/Sidekick.Common.Ui/wwwroot/css/app.css | 4 +++ .../Settings/DefaultSettings.cs | 2 ++ src/Sidekick.Common/Settings/SettingKeys.cs | 1 + .../Components/Bulk/BulkResult.razor | 10 +++---- .../Components/Items/ItemComponent.razor | 5 +++- .../Components/Items/ItemsResult.razor | 24 +++++++++++---- .../Components/Options/OpenWebsiteLink.razor | 18 ++++++++++-- .../Options/ToggleCompactView.razor | 29 +++++++++++++++++++ 9 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 src/Sidekick.Modules.Trade/Components/Options/ToggleCompactView.razor diff --git a/src/Sidekick.Common.Ui/UiIcons.cs b/src/Sidekick.Common.Ui/UiIcons.cs index 22831a42..439399b1 100644 --- a/src/Sidekick.Common.Ui/UiIcons.cs +++ b/src/Sidekick.Common.Ui/UiIcons.cs @@ -1,5 +1,9 @@ -namespace Sidekick.Common.Ui; +namespace Sidekick.Common.Ui; +/// +/// Contains SVG icons for use in the UI. +/// https://heroicons.com/ +/// public static class UiIcons { public const string ArrowForward = ""; @@ -12,4 +16,9 @@ public static class UiIcons public const string Close = ""; + public const string Expand = "\r\n \r\n\r\n"; + + public const string Collapse = "\r\n \r\n\r\n"; + + public const string External = "\r\n \r\n\r\n"; } diff --git a/src/Sidekick.Common.Ui/wwwroot/css/app.css b/src/Sidekick.Common.Ui/wwwroot/css/app.css index a2ba2311..73072351 100644 --- a/src/Sidekick.Common.Ui/wwwroot/css/app.css +++ b/src/Sidekick.Common.Ui/wwwroot/css/app.css @@ -2486,6 +2486,10 @@ video { gap: 0.75rem; } +.gap-4 { + gap: 1rem; +} + .gap-\[2px\] { gap: 2px; } diff --git a/src/Sidekick.Common/Settings/DefaultSettings.cs b/src/Sidekick.Common/Settings/DefaultSettings.cs index 51f9a7c3..91518b5d 100644 --- a/src/Sidekick.Common/Settings/DefaultSettings.cs +++ b/src/Sidekick.Common/Settings/DefaultSettings.cs @@ -44,6 +44,8 @@ public static class DefaultSettings public static double PriceCheckNormalizeValue => .1; + public static bool PriceCheckCompactMode => false; + public static List ChatCommands => [ new ChatSetting("F5", "/hideout", true), diff --git a/src/Sidekick.Common/Settings/SettingKeys.cs b/src/Sidekick.Common/Settings/SettingKeys.cs index bc7b77cb..2c60f388 100644 --- a/src/Sidekick.Common/Settings/SettingKeys.cs +++ b/src/Sidekick.Common/Settings/SettingKeys.cs @@ -47,6 +47,7 @@ public static class SettingKeys public const string PriceCheckBulkMinimumStock = nameof(PriceCheckBulkMinimumStock); public const string PriceCheckCurrencyMode = nameof(PriceCheckCurrencyMode); public const string PriceCheckNormalizeValue = nameof(PriceCheckNormalizeValue); + public const string PriceCheckCompactMode = nameof(PriceCheckCompactMode); public const string WealthEnabled = nameof(WealthEnabled); public const string WealthTrackedTabs = nameof(WealthTrackedTabs); diff --git a/src/Sidekick.Modules.Trade/Components/Bulk/BulkResult.razor b/src/Sidekick.Modules.Trade/Components/Bulk/BulkResult.razor index 291cfcc3..6b12b0c2 100644 --- a/src/Sidekick.Modules.Trade/Components/Bulk/BulkResult.razor +++ b/src/Sidekick.Modules.Trade/Components/Bulk/BulkResult.razor @@ -16,13 +16,13 @@ else if (PriceCheckService.BulkTradeResult != null) {
-
- -
+
+
+ - + Total="PriceCheckService.BulkTradeResult.TotalOffers"/>
+
@foreach (var offer in PriceCheckService.BulkTradeResult.Offers) diff --git a/src/Sidekick.Modules.Trade/Components/Items/ItemComponent.razor b/src/Sidekick.Modules.Trade/Components/Items/ItemComponent.razor index f0997869..522093d7 100644 --- a/src/Sidekick.Modules.Trade/Components/Items/ItemComponent.razor +++ b/src/Sidekick.Modules.Trade/Components/Items/ItemComponent.razor @@ -3,7 +3,7 @@ @using Sidekick.Modules.Trade.Localization @using Sidekick.Modules.Trade.Components.Prices -@if (Item.CanHaveModifiers || PriceCheckService.Item?.Metadata.Category == Category.Gem) +@if (!IsCompact && (Item.CanHaveModifiers || PriceCheckService.Item?.Metadata.Category == Category.Gem)) {
@if (PriceCheckService.ItemTradeResult != null) { -
- -
+
+
+ + Total="PriceCheckService.ItemTradeResult.Total"/> +
+
+
@@ -23,7 +27,7 @@ { foreach (var result in PriceCheckService.TradeItems) { - + } } @@ -45,17 +49,27 @@ @inject TradeResources Resources @inject PriceCheckService PriceCheckService +@inject ISettingsService SettingsService @code { private bool FullyLoaded => (PriceCheckService.TradeItems?.Count ?? 0) == (PriceCheckService.ItemTradeResult?.Result?.Count ?? 0); + private bool IsCompact { get; set; } + protected override async Task OnInitializedAsync() { + IsCompact = await SettingsService.GetBool(SettingKeys.PriceCheckCompactMode); PriceCheckService.LoadingChanged += StateHasChanged; await base.OnInitializedAsync(); } + private async void ToggleView() + { + IsCompact = !IsCompact; + await SettingsService.Set(SettingKeys.PriceCheckCompactMode, IsCompact); + } + public void Dispose() { PriceCheckService.LoadingChanged -= StateHasChanged; diff --git a/src/Sidekick.Modules.Trade/Components/Options/OpenWebsiteLink.razor b/src/Sidekick.Modules.Trade/Components/Options/OpenWebsiteLink.razor index 849e9594..c857165e 100644 --- a/src/Sidekick.Modules.Trade/Components/Options/OpenWebsiteLink.razor +++ b/src/Sidekick.Modules.Trade/Components/Options/OpenWebsiteLink.razor @@ -6,9 +6,21 @@ @if (!string.IsNullOrEmpty(QueryId)) { - - @Resources["OpenQueryInWebsite"] - + + + + + + + @Resources["OpenQueryInWebsite"] + + } @inject IStringLocalizer Resources diff --git a/src/Sidekick.Modules.Trade/Components/Options/ToggleCompactView.razor b/src/Sidekick.Modules.Trade/Components/Options/ToggleCompactView.razor new file mode 100644 index 00000000..af074cf4 --- /dev/null +++ b/src/Sidekick.Modules.Trade/Components/Options/ToggleCompactView.razor @@ -0,0 +1,29 @@ +@using Sidekick.Modules.Trade.Localization + + + + + + + + @(IsCompact ? Resources["Layout_Cards_Maximized"] : Resources["Layout_Cards_Minimized"]) + + + +@inject IStringLocalizer Resources + +@code { + + [Parameter] + public required bool IsCompact { get; set; } + + [Parameter] + public EventCallback OnClick { get; set; } + +} From 03f11d933a38a9554623e41cc9dceaf11cf8365e Mon Sep 17 00:00:00 2001 From: leMicin Date: Thu, 26 Dec 2024 21:16:34 -0500 Subject: [PATCH 08/11] Moved some logic to the view preference service --- .../Settings/SettingsResources.resx | 4 +- .../Views/IViewPreferenceService.cs | 4 +- .../Views/ViewPreferenceService.cs | 22 +++++++-- src/Sidekick.Common.Ui/wwwroot/css/app.css | 49 ------------------- src/Sidekick.Wpf/MainWindow.xaml.cs | 13 +---- 5 files changed, 23 insertions(+), 69 deletions(-) diff --git a/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx b/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx index 3b62427e..f9f0755e 100644 --- a/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx +++ b/src/Sidekick.Common.Blazor/Settings/SettingsResources.resx @@ -343,6 +343,6 @@ poedb.tw / poe2db.tw - Save the positions of the overlays. If false, they will be centered. + Save the positions of the overlays. If unchecked, they will be centered. - \ No newline at end of file + diff --git a/src/Sidekick.Common.Ui/Views/IViewPreferenceService.cs b/src/Sidekick.Common.Ui/Views/IViewPreferenceService.cs index b7faab9d..f2acc6a6 100644 --- a/src/Sidekick.Common.Ui/Views/IViewPreferenceService.cs +++ b/src/Sidekick.Common.Ui/Views/IViewPreferenceService.cs @@ -1,4 +1,4 @@ -using Sidekick.Common.Database.Tables; +using Sidekick.Common.Database.Tables; namespace Sidekick.Common.Ui.Views; @@ -6,5 +6,5 @@ public interface IViewPreferenceService { Task Get(string? key); - Task Set(string? key, int width, int height, int? x = null, int? y = null); + Task Set(string? key, int width, int height, int? x, int? y); } diff --git a/src/Sidekick.Common.Ui/Views/ViewPreferenceService.cs b/src/Sidekick.Common.Ui/Views/ViewPreferenceService.cs index 18ebddd0..4c7e4d7f 100644 --- a/src/Sidekick.Common.Ui/Views/ViewPreferenceService.cs +++ b/src/Sidekick.Common.Ui/Views/ViewPreferenceService.cs @@ -1,10 +1,15 @@ -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Sidekick.Common.Database; using Sidekick.Common.Database.Tables; +using Sidekick.Common.Settings; namespace Sidekick.Common.Ui.Views; -public class ViewPreferenceService(DbContextOptions dbOptions) : IViewPreferenceService +public class ViewPreferenceService +( + DbContextOptions dbOptions, + ISettingsService settingsService +) : IViewPreferenceService { public async Task Get(string? key) { @@ -18,15 +23,22 @@ public class ViewPreferenceService(DbContextOptions dbOptions return viewPreference; } - public async Task Set(string? key, int width, int height, int? x = null, int? y = null) + public async Task Set(string? key, int width, int height, int? x, int? y) { if (string.IsNullOrEmpty(key)) { return; } + var saveWindowPosition = await settingsService.GetBool(SettingKeys.SaveWindowPositions); + if (!saveWindowPosition) + { + x = null; + y = null; + } + var dbContext = new SidekickDbContext(dbOptions); - var viewPreference = await dbContext.ViewPreferences.FirstOrDefaultAsync(x => x.Key == key); + var viewPreference = await dbContext.ViewPreferences.FirstOrDefaultAsync(preference => preference.Key == key); if (viewPreference == null) { viewPreference = new ViewPreference @@ -35,7 +47,7 @@ public async Task Set(string? key, int width, int height, int? x = null, int? y Width = width, Height = height, X = x, - Y = y + Y = y, }; dbContext.ViewPreferences.Add(viewPreference); await dbContext.SaveChangesAsync(); diff --git a/src/Sidekick.Common.Ui/wwwroot/css/app.css b/src/Sidekick.Common.Ui/wwwroot/css/app.css index a2ba2311..eeb34fe6 100644 --- a/src/Sidekick.Common.Ui/wwwroot/css/app.css +++ b/src/Sidekick.Common.Ui/wwwroot/css/app.css @@ -1508,11 +1508,6 @@ video { margin-bottom: 0px; } -.my-1 { - margin-top: 0.25rem; - margin-bottom: 0.25rem; -} - .my-2 { margin-top: 0.5rem; margin-bottom: 0.5rem; @@ -1544,10 +1539,6 @@ video { margin-bottom: 0.75rem; } -.mb-4 { - margin-bottom: 1rem; -} - .ml-0 { margin-left: 0px; } @@ -1572,22 +1563,10 @@ video { margin-left: auto; } -.mr-1 { - margin-right: 0.25rem; -} - .mr-2 { margin-right: 0.5rem; } -.mr-3 { - margin-right: 0.75rem; -} - -.mr-4 { - margin-right: 1rem; -} - .mt-1 { margin-top: 0.25rem; } @@ -1604,10 +1583,6 @@ video { margin-top: 1rem; } -.mt-6 { - margin-top: 1.5rem; -} - .mt-9 { margin-top: 2.25rem; } @@ -1940,10 +1915,6 @@ video { flex-grow: 1; } -.flex-grow-0 { - flex-grow: 0; -} - .grow { flex-grow: 1; } @@ -3343,10 +3314,6 @@ video { padding-bottom: 1rem; } -.pb-0 { - padding-bottom: 0px; -} - .pb-2 { padding-bottom: 0.5rem; } @@ -3367,10 +3334,6 @@ video { padding-bottom: 4px; } -.pl-12 { - padding-left: 3rem; -} - .pl-2 { padding-left: 0.5rem; } @@ -3387,22 +3350,10 @@ video { padding-right: 0.5rem; } -.pr-4 { - padding-right: 1rem; -} - -.pt-0 { - padding-top: 0px; -} - .pt-2 { padding-top: 0.5rem; } -.pt-4 { - padding-top: 1rem; -} - .pt-\[4px\] { padding-top: 4px; } diff --git a/src/Sidekick.Wpf/MainWindow.xaml.cs b/src/Sidekick.Wpf/MainWindow.xaml.cs index 6ce9c7d9..a3026dd2 100644 --- a/src/Sidekick.Wpf/MainWindow.xaml.cs +++ b/src/Sidekick.Wpf/MainWindow.xaml.cs @@ -6,7 +6,6 @@ using System.Windows.Interop; using System.Windows.Media; using Microsoft.Extensions.DependencyInjection; -using Sidekick.Common.Settings; using Sidekick.Common.Ui.Views; using Sidekick.Wpf.Helpers; using Sidekick.Wpf.Services; @@ -66,16 +65,9 @@ protected override void OnClosing(CancelEventArgs e) { var width = (int)ActualWidth; var height = (int)ActualHeight; + var x = (int)Left; + var y = (int)Top; - var settingsService = Scope.ServiceProvider.GetRequiredService(); - var saveWindowPosition = settingsService.GetBool(SettingKeys.SaveWindowPositions).GetAwaiter().GetResult(); - - int? x = null, y = null; - if (saveWindowPosition) - { - x = (int)Left; - y = (int)Top; - } _ = viewLocator.ViewPreferenceService.Set(SidekickView?.CurrentView.Key, width, height, x, y); } catch (Exception) @@ -132,7 +124,6 @@ protected override void OnStateChanged(EventArgs e) Grid.Margin = WindowState == WindowState.Maximized ? new Thickness(0) : new Thickness(5); } - private void TopBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { DragMove(); From d1ae88a49132ddb4aa3df7894d7ec6987cb94d2e Mon Sep 17 00:00:00 2001 From: Dominique Alexandre Date: Fri, 27 Dec 2024 00:02:57 -0500 Subject: [PATCH 09/11] Clarify the corrupted checkbox tristate --- .../Forms/FormCheckbox.razor | 11 +---- .../Forms/FormTriStateCheckbox.razor | 17 ++----- src/Sidekick.Common.Ui/wwwroot/css/app.css | 49 +++++++++++++++++++ .../Filters/PropertyFilterComponent.razor | 14 ++++-- .../Localization/TradeResources.fr.resx | 5 +- .../Localization/TradeResources.resx | 5 +- 6 files changed, 73 insertions(+), 28 deletions(-) diff --git a/src/Sidekick.Common.Ui/Forms/FormCheckbox.razor b/src/Sidekick.Common.Ui/Forms/FormCheckbox.razor index 513e2b42..ee09f14c 100644 --- a/src/Sidekick.Common.Ui/Forms/FormCheckbox.razor +++ b/src/Sidekick.Common.Ui/Forms/FormCheckbox.razor @@ -1,12 +1,5 @@ -
- @if (Value) - { - - } - else - { - - } +
+