From cd2af4e2f3fdf379797077dfc2c9c8a179f88047 Mon Sep 17 00:00:00 2001 From: Hendrik Mennen Date: Wed, 13 Nov 2024 08:33:20 -0500 Subject: [PATCH 1/6] . --- src/OneWare.Essentials/Models/Setting.cs | 6 +++++- src/OneWare.Essentials/Services/ISettingsService.cs | 13 +++++++++---- src/OneWare.Settings/SettingsService.cs | 5 +++++ .../SettingTypes/CheckBoxSettingViewModel.cs | 4 ++-- .../SettingTypes/ColorPickerSettingViewModel.cs | 2 +- .../SettingTypes/ComboBoxSearchSettingViewModel.cs | 2 +- .../SettingTypes/ComboBoxSettingViewModel.cs | 2 +- .../SettingTypes/ListBoxSettingViewModel.cs | 2 +- .../SettingTypes/SliderSettingViewModel.cs | 2 +- .../SettingTypes/TextBoxSettingViewModel.cs | 2 +- .../SettingTypes/TitledSettingViewModel.cs | 8 +------- 11 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/OneWare.Essentials/Models/Setting.cs b/src/OneWare.Essentials/Models/Setting.cs index df8d7363..31eb5189 100644 --- a/src/OneWare.Essentials/Models/Setting.cs +++ b/src/OneWare.Essentials/Models/Setting.cs @@ -41,8 +41,12 @@ public TitledSetting(string title, string description, object defaultValue) : ba } public string Title { get; } - + public string Description { get; } + + public IObservable? IsEnabledObservable { get; init; } + + public IObservable? IsVisibleObservable { get; init; } } public class TextBoxSetting : TitledSetting diff --git a/src/OneWare.Essentials/Services/ISettingsService.cs b/src/OneWare.Essentials/Services/ISettingsService.cs index b76683cb..f339cb64 100644 --- a/src/OneWare.Essentials/Services/ISettingsService.cs +++ b/src/OneWare.Essentials/Services/ISettingsService.cs @@ -14,33 +14,38 @@ public void RegisterSettingSubCategory(string category, string subCategory, int public IObservable Bind(string key, IObservable observable); + [Obsolete("Use RegisterSetting instead")] public void RegisterTitled(string category, string subCategory, string key, string title, string description, T defaultValue); - - [Obsolete("Use RegisterTitledFolderPath instead")] - public void RegisterTitledPath(string category, string subCategory, string key, string title, string description, - string defaultValue, string? watermark, string? startDir, Func? validate); + [Obsolete("Use RegisterSetting instead")] public void RegisterTitledFolderPath(string category, string subCategory, string key, string title, string description, string defaultValue, string? watermark, string? startDir, Func? validate); + [Obsolete("Use RegisterSetting instead")] public void RegisterTitledFilePath(string category, string subCategory, string key, string title, string description, string defaultValue, string? watermark, string? startDir, Func? validate, params FilePickerFileType[] fileTypes); + [Obsolete("Use RegisterSetting instead")] public void RegisterTitledSlider(string category, string subCategory, string key, string title, string description, double defaultValue, double min, double max, double step); + [Obsolete("Use RegisterSetting instead")] public void RegisterTitledCombo(string category, string subCategory, string key, string title, string description, T defaultValue, params T[] options); + [Obsolete("Use RegisterSetting instead")] public void RegisterTitledComboSearch(string category, string subCategory, string key, string title, string description, T defaultValue, params T[] options); + [Obsolete("Use RegisterSetting instead")] public void RegisterTitledListBox(string category, string subCategory, string key, string title, string description, params string[] defaultValue); + public void RegisterSetting(string cateogory, string subCategory, string key, TitledSetting setting); + public void RegisterCustom(string category, string subCategory, string key, CustomSetting customSetting); public T GetSettingValue(string key); diff --git a/src/OneWare.Settings/SettingsService.cs b/src/OneWare.Settings/SettingsService.cs index 053ec55a..8227fc2d 100644 --- a/src/OneWare.Settings/SettingsService.cs +++ b/src/OneWare.Settings/SettingsService.cs @@ -45,6 +45,11 @@ public void Register(string key, T defaultValue) if (defaultValue == null) throw new NullReferenceException(nameof(defaultValue)); AddSetting(key, new Setting(defaultValue)); } + + public void RegisterSetting(string category, string subCategory, string key, TitledSetting setting) + { + AddSetting(category, subCategory, key, setting); + } public IObservable Bind(string key, IObservable observable) { diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/CheckBoxSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/CheckBoxSettingViewModel.cs index 3f2740e0..434b15b2 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/CheckBoxSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/CheckBoxSettingViewModel.cs @@ -4,8 +4,8 @@ namespace OneWare.Settings.ViewModels.SettingTypes; public class CheckBoxSettingViewModel : TitledSettingViewModel { - public CheckBoxSettingViewModel(TitledSetting setting, IObservable? needEnabled = null) : - base(setting, needEnabled) + public CheckBoxSettingViewModel(TitledSetting setting) : + base(setting) { } diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/ColorPickerSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/ColorPickerSettingViewModel.cs index cd41630a..554f2cb9 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/ColorPickerSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/ColorPickerSettingViewModel.cs @@ -4,7 +4,7 @@ namespace OneWare.Settings.ViewModels.SettingTypes; public class ColorPickerSettingViewModel : TitledSettingViewModel { - public ColorPickerSettingViewModel(TitledSetting setting, IObservable? needEnabled = null) : base(setting, needEnabled) + public ColorPickerSettingViewModel(TitledSetting setting) : base(setting) { } } \ No newline at end of file diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/ComboBoxSearchSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/ComboBoxSearchSettingViewModel.cs index 8cab3e26..b5237a0a 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/ComboBoxSearchSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/ComboBoxSearchSettingViewModel.cs @@ -4,7 +4,7 @@ namespace OneWare.Settings.ViewModels.SettingTypes; public class ComboBoxSearchSettingViewModel : TitledSettingViewModel { - public ComboBoxSearchSettingViewModel(ComboBoxSetting setting, IObservable? needEnabled = null) : base(setting, needEnabled) + public ComboBoxSearchSettingViewModel(ComboBoxSetting setting) : base(setting) { Setting = setting; } diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/ComboBoxSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/ComboBoxSettingViewModel.cs index 0921f15c..d1d1cddb 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/ComboBoxSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/ComboBoxSettingViewModel.cs @@ -4,7 +4,7 @@ namespace OneWare.Settings.ViewModels.SettingTypes; public class ComboBoxSettingViewModel : TitledSettingViewModel { - public ComboBoxSettingViewModel(ComboBoxSetting setting, IObservable? needEnabled = null) : base(setting, needEnabled) + public ComboBoxSettingViewModel(ComboBoxSetting setting) : base(setting) { Setting = setting; } diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/ListBoxSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/ListBoxSettingViewModel.cs index 5a7fd926..618e91b1 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/ListBoxSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/ListBoxSettingViewModel.cs @@ -10,7 +10,7 @@ public class ListBoxSettingViewModel : TitledSettingViewModel { private int _selectedIndex; - public ListBoxSettingViewModel(ListBoxSetting setting, IObservable? needEnabled = null) : base(setting, needEnabled) + public ListBoxSettingViewModel(ListBoxSetting setting, IObservable? needEnabled = null) : base(setting) { Setting = setting; } diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/SliderSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/SliderSettingViewModel.cs index 8d58c6e8..1becf696 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/SliderSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/SliderSettingViewModel.cs @@ -5,7 +5,7 @@ namespace OneWare.Settings.ViewModels.SettingTypes; public class SliderSettingViewModel : TitledSettingViewModel { - public SliderSettingViewModel(SliderSetting setting, IObservable? needEnabled = null) : base(setting, needEnabled) + public SliderSettingViewModel(SliderSetting setting, IObservable? needEnabled = null) : base(setting) { Setting = setting; diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/TextBoxSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/TextBoxSettingViewModel.cs index 01a25a82..66f04b16 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/TextBoxSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/TextBoxSettingViewModel.cs @@ -4,7 +4,7 @@ namespace OneWare.Settings.ViewModels.SettingTypes; public class TextBoxSettingViewModel : TitledSettingViewModel { - public TextBoxSettingViewModel(TitledSetting setting, IObservable? needEnabled = null) : base(setting, needEnabled) + public TextBoxSettingViewModel(TitledSetting setting) : base(setting) { if (setting is TextBoxSetting tbs) { diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/TitledSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/TitledSettingViewModel.cs index a3b12c29..51da0a18 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/TitledSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/TitledSettingViewModel.cs @@ -6,15 +6,9 @@ public abstract class TitledSettingViewModel : SettingViewModel { private bool _isEnabled = true; - protected TitledSettingViewModel(TitledSetting setting, IObservable? needEnabled) + protected TitledSettingViewModel(TitledSetting setting) { Setting = setting; - - needEnabled?.Subscribe(x => - { - IsEnabled = x; - if (!x) setting.Value = false; - }); } public override TitledSetting Setting { get; } From 1fa3eaf846c4d50036a8b46de4606f39c7b2f290 Mon Sep 17 00:00:00 2001 From: Hendrik Mennen Date: Wed, 13 Nov 2024 08:45:32 -0500 Subject: [PATCH 2/6] progress --- src/OneWare.Core/App.axaml.cs | 1 + src/OneWare.Essentials/Models/Setting.cs | 9 ++++++++- src/OneWare.Settings/SettingsService.cs | 10 +++++++++- .../ViewModels/SettingTypes/TitledSettingViewModel.cs | 6 ------ .../Views/SettingTypes/CheckBoxSettingView.axaml | 5 +++-- .../Views/SettingTypes/ColorPickerSettingView.axaml | 5 +++-- .../SettingTypes/ComboBoxSearchSettingView.axaml | 5 +++-- .../Views/SettingTypes/ComboBoxSettingView.axaml | 5 +++-- .../Views/SettingTypes/ListBoxSettingView.axaml | 11 ++++++----- .../Views/SettingTypes/PathSettingView.axaml | 7 ++++--- .../Views/SettingTypes/SliderSettingView.axaml | 6 +++--- .../Views/SettingTypes/TextBoxSettingView.axaml | 5 +++-- .../UniversalFpgaProjectCreatorViewModel.cs | 2 +- 13 files changed, 47 insertions(+), 30 deletions(-) diff --git a/src/OneWare.Core/App.axaml.cs b/src/OneWare.Core/App.axaml.cs index 5fecdf30..82037554 100644 --- a/src/OneWare.Core/App.axaml.cs +++ b/src/OneWare.Core/App.axaml.cs @@ -19,6 +19,7 @@ using OneWare.Essentials.Commands; using OneWare.Essentials.Helpers; using OneWare.Essentials.LanguageService; +using OneWare.Essentials.Models; using OneWare.Essentials.Services; using OneWare.Essentials.ViewModels; using OneWare.FolderProjectSystem; diff --git a/src/OneWare.Essentials/Models/Setting.cs b/src/OneWare.Essentials/Models/Setting.cs index 31eb5189..ab258a97 100644 --- a/src/OneWare.Essentials/Models/Setting.cs +++ b/src/OneWare.Essentials/Models/Setting.cs @@ -32,7 +32,7 @@ public virtual object Value public object DefaultValue { get; } } -public class TitledSetting : Setting +public abstract class TitledSetting : Setting { public TitledSetting(string title, string description, object defaultValue) : base(defaultValue) { @@ -49,6 +49,13 @@ public TitledSetting(string title, string description, object defaultValue) : ba public IObservable? IsVisibleObservable { get; init; } } +public class CheckBoxSetting : TitledSetting +{ + public CheckBoxSetting(string title, string description, bool defaultValue) : base(title, description, defaultValue) + { + } +} + public class TextBoxSetting : TitledSetting { public TextBoxSetting(string title, string description, object defaultValue, string? watermark) : base(title, diff --git a/src/OneWare.Settings/SettingsService.cs b/src/OneWare.Settings/SettingsService.cs index 8227fc2d..dd0b43a3 100644 --- a/src/OneWare.Settings/SettingsService.cs +++ b/src/OneWare.Settings/SettingsService.cs @@ -64,7 +64,15 @@ public void RegisterTitled(string category, string subCategory, string key, s T defaultValue) { if (defaultValue == null) throw new NullReferenceException(nameof(defaultValue)); - AddSetting(category, subCategory, key, new TitledSetting(title, description, defaultValue)); + switch (defaultValue) + { + case bool b: + AddSetting(category, subCategory, key, new CheckBoxSetting(title, description, b)); + break; + default: + AddSetting(category, subCategory, key, new TextBoxSetting(title, description, defaultValue, null)); + break; + } } public void RegisterTitledPath(string category, string subCategory, string key, string title, string description, diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/TitledSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/TitledSettingViewModel.cs index 51da0a18..9dca4167 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/TitledSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/TitledSettingViewModel.cs @@ -12,10 +12,4 @@ protected TitledSettingViewModel(TitledSetting setting) } public override TitledSetting Setting { get; } - - public bool IsEnabled - { - get => _isEnabled; - set => SetProperty(ref _isEnabled, value); - } } \ No newline at end of file diff --git a/src/OneWare.Settings/Views/SettingTypes/CheckBoxSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/CheckBoxSettingView.axaml index 4acd9f3d..76cdf340 100644 --- a/src/OneWare.Settings/Views/SettingTypes/CheckBoxSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/CheckBoxSettingView.axaml @@ -5,11 +5,12 @@ xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.CheckBoxSettingView" - x:DataType="settingTypes:CheckBoxSettingViewModel"> + x:DataType="settingTypes:CheckBoxSettingViewModel" + IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> + IsEnabled="{Binding Setting.IsEnabledObservable^, FallbackValue={x:True}}" /> diff --git a/src/OneWare.Settings/Views/SettingTypes/ColorPickerSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/ColorPickerSettingView.axaml index 57b74590..c1946507 100644 --- a/src/OneWare.Settings/Views/SettingTypes/ColorPickerSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/ColorPickerSettingView.axaml @@ -5,11 +5,12 @@ xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.ColorPickerSettingView" - x:DataType="settingTypes:ColorPickerSettingViewModel"> + x:DataType="settingTypes:ColorPickerSettingViewModel" + IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> - \ No newline at end of file diff --git a/src/OneWare.Settings/Views/SettingTypes/ComboBoxSearchSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/ComboBoxSearchSettingView.axaml index 85482045..f439991a 100644 --- a/src/OneWare.Settings/Views/SettingTypes/ComboBoxSearchSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/ComboBoxSearchSettingView.axaml @@ -6,12 +6,13 @@ xmlns:controls="clr-namespace:OneWare.Essentials.Controls;assembly=OneWare.Essentials" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.ComboBoxSearchSettingView" - x:DataType="settingTypes:ComboBoxSearchSettingViewModel"> + x:DataType="settingTypes:ComboBoxSearchSettingViewModel" + IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> \ No newline at end of file diff --git a/src/OneWare.Settings/Views/SettingTypes/ComboBoxSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/ComboBoxSettingView.axaml index 3f9a6306..beaff91b 100644 --- a/src/OneWare.Settings/Views/SettingTypes/ComboBoxSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/ComboBoxSettingView.axaml @@ -5,12 +5,13 @@ xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.ComboBoxSettingView" - x:DataType="settingTypes:ComboBoxSettingViewModel"> + x:DataType="settingTypes:ComboBoxSettingViewModel" + IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> \ No newline at end of file diff --git a/src/OneWare.Settings/Views/SettingTypes/ListBoxSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/ListBoxSettingView.axaml index c18d538b..4a5490bd 100644 --- a/src/OneWare.Settings/Views/SettingTypes/ListBoxSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/ListBoxSettingView.axaml @@ -5,7 +5,8 @@ xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.ListBoxSettingView" - x:DataType="settingTypes:ListBoxSettingViewModel"> + x:DataType="settingTypes:ListBoxSettingViewModel" + IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> @@ -13,18 +14,18 @@ BorderThickness="1"> - - - + x:DataType="settingTypes:PathSettingViewModel" + IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> - @@ -26,7 +27,7 @@ Source="{DynamicResource BoxIcons.RegularCheck.Green}" /> - + diff --git a/src/OneWare.Settings/Views/SettingTypes/SliderSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/SliderSettingView.axaml index c22621d2..a379bdc5 100644 --- a/src/OneWare.Settings/Views/SettingTypes/SliderSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/SliderSettingView.axaml @@ -5,17 +5,17 @@ xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.SliderSettingView" - x:DataType="settingTypes:SliderSettingViewModel"> + x:DataType="settingTypes:SliderSettingViewModel" IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> + x:DataType="settingTypes:TextBoxSettingViewModel" + IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> - diff --git a/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectCreatorViewModel.cs b/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectCreatorViewModel.cs index 6535d87b..002666e5 100644 --- a/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectCreatorViewModel.cs +++ b/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectCreatorViewModel.cs @@ -42,7 +42,7 @@ public UniversalFpgaProjectCreatorViewModel(IPaths paths, IProjectExplorerServic _folderPathSetting = new FolderPathSetting("Location", "Set the location where the new project is created", paths.ProjectsDirectory, "Enter path...", paths.ProjectsDirectory, Directory.Exists); - _createNewFolderSetting = new TitledSetting("Create new Folder", + _createNewFolderSetting = new CheckBoxSetting("Create new Folder", "Set if a new folder should be created in the selected location", true); _toolchainSetting = new ComboBoxSetting("Toolchain", From 374b237bdfb04ca1e7f73220952f16246a199e17 Mon Sep 17 00:00:00 2001 From: Hendrik Mennen Date: Wed, 13 Nov 2024 09:12:08 -0500 Subject: [PATCH 3/6] progress --- src/OneWare.Essentials/Models/Setting.cs | 9 +++++++ .../ApplicationSettingsViewModel.cs | 25 ++++++------------- .../ColorPickerSettingViewModel.cs | 2 +- .../SettingTypes/TextBoxSettingViewModel.cs | 7 ++---- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/OneWare.Essentials/Models/Setting.cs b/src/OneWare.Essentials/Models/Setting.cs index ab258a97..89d92d16 100644 --- a/src/OneWare.Essentials/Models/Setting.cs +++ b/src/OneWare.Essentials/Models/Setting.cs @@ -1,5 +1,6 @@ using System.Collections.ObjectModel; using Avalonia.Controls; +using Avalonia.Media; using Avalonia.Platform.Storage; using CommunityToolkit.Mvvm.ComponentModel; using DynamicData.Binding; @@ -173,6 +174,14 @@ public override async Task SelectPathAsync(TopLevel topLevel) } } +public class ColorSetting : TitledSetting +{ + public ColorSetting(string title, string description, Color defaultValue) : base(title, description, defaultValue) + { + + } +} + public abstract class CustomSetting : Setting { public CustomSetting(object defaultValue) : base(defaultValue) diff --git a/src/OneWare.Settings/ViewModels/ApplicationSettingsViewModel.cs b/src/OneWare.Settings/ViewModels/ApplicationSettingsViewModel.cs index 2046f2f8..c45c97a5 100644 --- a/src/OneWare.Settings/ViewModels/ApplicationSettingsViewModel.cs +++ b/src/OneWare.Settings/ViewModels/ApplicationSettingsViewModel.cs @@ -67,23 +67,14 @@ public ApplicationSettingsViewModel(ISettingsService settingsService, IPaths pat case ListBoxSetting lS: subCategoryModel.SettingModels.Add(new ListBoxSettingViewModel(lS)); break; - case TitledSetting tS: - switch (setting.Value) - { - case bool: - subCategoryModel.SettingModels.Add(new CheckBoxSettingViewModel(tS)); - break; - case string: - case int: - case float: - case double: - subCategoryModel.SettingModels.Add(new TextBoxSettingViewModel(tS)); - break; - case Color: - subCategoryModel.SettingModels.Add(new ColorPickerSettingViewModel(tS)); - break; - } - + case CheckBoxSetting cbS: + subCategoryModel.SettingModels.Add(new CheckBoxSettingViewModel(cbS)); + break; + case TextBoxSetting tS: + subCategoryModel.SettingModels.Add(new TextBoxSettingViewModel(tS)); + break; + case ColorSetting cS: + subCategoryModel.SettingModels.Add(new ColorPickerSettingViewModel(cS)); break; } diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/ColorPickerSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/ColorPickerSettingViewModel.cs index 554f2cb9..a5f0e4ca 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/ColorPickerSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/ColorPickerSettingViewModel.cs @@ -4,7 +4,7 @@ namespace OneWare.Settings.ViewModels.SettingTypes; public class ColorPickerSettingViewModel : TitledSettingViewModel { - public ColorPickerSettingViewModel(TitledSetting setting) : base(setting) + public ColorPickerSettingViewModel(ColorSetting setting) : base(setting) { } } \ No newline at end of file diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/TextBoxSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/TextBoxSettingViewModel.cs index 66f04b16..40b7c644 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/TextBoxSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/TextBoxSettingViewModel.cs @@ -4,12 +4,9 @@ namespace OneWare.Settings.ViewModels.SettingTypes; public class TextBoxSettingViewModel : TitledSettingViewModel { - public TextBoxSettingViewModel(TitledSetting setting) : base(setting) + public TextBoxSettingViewModel(TextBoxSetting setting) : base(setting) { - if (setting is TextBoxSetting tbs) - { - Watermark = tbs.Watermark; - } + Watermark = setting.Watermark; } public string? Watermark { get; } From 78563c826c3339e8f03fbed55f2ce748d6114fdb Mon Sep 17 00:00:00 2001 From: Hendrik Mennen Date: Wed, 13 Nov 2024 10:47:14 -0500 Subject: [PATCH 4/6] remove needenabled --- .../ViewModels/SettingTypes/ListBoxSettingViewModel.cs | 2 +- .../ViewModels/SettingTypes/SliderSettingViewModel.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/ListBoxSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/ListBoxSettingViewModel.cs index 618e91b1..2e35f5cb 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/ListBoxSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/ListBoxSettingViewModel.cs @@ -10,7 +10,7 @@ public class ListBoxSettingViewModel : TitledSettingViewModel { private int _selectedIndex; - public ListBoxSettingViewModel(ListBoxSetting setting, IObservable? needEnabled = null) : base(setting) + public ListBoxSettingViewModel(ListBoxSetting setting) : base(setting) { Setting = setting; } diff --git a/src/OneWare.Settings/ViewModels/SettingTypes/SliderSettingViewModel.cs b/src/OneWare.Settings/ViewModels/SettingTypes/SliderSettingViewModel.cs index 1becf696..c145f680 100644 --- a/src/OneWare.Settings/ViewModels/SettingTypes/SliderSettingViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingTypes/SliderSettingViewModel.cs @@ -5,7 +5,7 @@ namespace OneWare.Settings.ViewModels.SettingTypes; public class SliderSettingViewModel : TitledSettingViewModel { - public SliderSettingViewModel(SliderSetting setting, IObservable? needEnabled = null) : base(setting) + public SliderSettingViewModel(SliderSetting setting) : base(setting) { Setting = setting; From 8fca58908e603eccf155e678d1da1b9e513ce267 Mon Sep 17 00:00:00 2001 From: Hendrik Mennen Date: Wed, 13 Nov 2024 11:09:15 -0500 Subject: [PATCH 5/6] update to .NET 9.0 --- .github/workflows/publish-nuget.yml | 2 +- .github/workflows/publish-studio-linux-snap.yml | 2 +- .github/workflows/publish-studio-linux.yaml | 2 +- .github/workflows/publish-studio-macos.yml | 2 +- .github/workflows/publish-studio-web.yml | 2 +- .github/workflows/publish-studio-windows.yml | 2 +- .github/workflows/test.yml | 2 +- build/props/OneWare.Module.props | 2 +- build/props/XUnit.props | 14 +++++++------- .../OneWare.Demo.Desktop.csproj | 2 +- .../OneWare.SourceControl.csproj | 2 +- src/OneWare.Vcd.Parser/OneWare.Vcd.Parser.csproj | 2 +- .../OneWare.Studio.Browser.csproj | 2 +- .../OneWare.Studio.Desktop.csproj | 2 +- .../OneWare.Essentials.UnitTests.csproj | 2 +- .../OneWare.Studio.Desktop.UnitTests.csproj | 2 +- ...OneWare.UniversalFpgaProjectSystem.Tests.csproj | 2 +- .../OneWare.Vcd.Parser.UnitTests.csproj | 2 +- .../OneWare.Vhdl.UnitTests.csproj | 2 +- .../OneWare.WaveFormViewer.Tests.csproj | 2 +- 20 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index beefee69..04bd63cd 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -27,7 +27,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x # Create the NuGet packages in the folder from the environment variable NuGetDirectory - run: dotnet pack ./src/OneWare.Essentials/OneWare.Essentials.csproj --configuration Release --output ${{ env.NuGetDirectory }} diff --git a/.github/workflows/publish-studio-linux-snap.yml b/.github/workflows/publish-studio-linux-snap.yml index 6ff79c63..2cb1ebb1 100644 --- a/.github/workflows/publish-studio-linux-snap.yml +++ b/.github/workflows/publish-studio-linux-snap.yml @@ -27,7 +27,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Build Snap uses: snapcore/action-build@v1 id: build diff --git a/.github/workflows/publish-studio-linux.yaml b/.github/workflows/publish-studio-linux.yaml index b8f9cc15..44c1547f 100644 --- a/.github/workflows/publish-studio-linux.yaml +++ b/.github/workflows/publish-studio-linux.yaml @@ -29,7 +29,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Publish run: dotnet publish ./studio/OneWare.Studio.Desktop/OneWare.Studio.Desktop.csproj -c Release -r linux-x64 -o ./out - name: Compress diff --git a/.github/workflows/publish-studio-macos.yml b/.github/workflows/publish-studio-macos.yml index e2e6735c..983e71cc 100644 --- a/.github/workflows/publish-studio-macos.yml +++ b/.github/workflows/publish-studio-macos.yml @@ -29,7 +29,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Set up Homebrew id: set-up-homebrew uses: Homebrew/actions/setup-homebrew@master diff --git a/.github/workflows/publish-studio-web.yml b/.github/workflows/publish-studio-web.yml index e5955898..fe609d63 100644 --- a/.github/workflows/publish-studio-web.yml +++ b/.github/workflows/publish-studio-web.yml @@ -15,7 +15,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Install Wasm-Tools run: dotnet workload install wasm-tools - name: Publish diff --git a/.github/workflows/publish-studio-windows.yml b/.github/workflows/publish-studio-windows.yml index da73f2a4..6e1d1901 100644 --- a/.github/workflows/publish-studio-windows.yml +++ b/.github/workflows/publish-studio-windows.yml @@ -30,7 +30,7 @@ jobs: # - name: Setup .NET # uses: actions/setup-dotnet@v4 # with: - # dotnet-version: 8.0.x + # dotnet-version: 9.0.x # - name: Install Wix # run: dotnet tool install --global wix - name: Publish diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c0cfbf8e..ffe089ce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Workload Restore run: dotnet workload restore - name: Restore dependencies diff --git a/build/props/OneWare.Module.props b/build/props/OneWare.Module.props index 355e1ace..ea322b8f 100644 --- a/build/props/OneWare.Module.props +++ b/build/props/OneWare.Module.props @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable latest diff --git a/build/props/XUnit.props b/build/props/XUnit.props index c6fbe620..ad529716 100644 --- a/build/props/XUnit.props +++ b/build/props/XUnit.props @@ -1,14 +1,14 @@ - + - - - - - + + + + + - + \ No newline at end of file diff --git a/demo/OneWare.Demo.Desktop/OneWare.Demo.Desktop.csproj b/demo/OneWare.Demo.Desktop/OneWare.Demo.Desktop.csproj index 80de5e0d..4771adb6 100644 --- a/demo/OneWare.Demo.Desktop/OneWare.Demo.Desktop.csproj +++ b/demo/OneWare.Demo.Desktop/OneWare.Demo.Desktop.csproj @@ -7,7 +7,7 @@ app.manifest WinExe Exe - net8.0 + net9.0 ..\OneWare.Demo\Assets\icon.ico latest enable diff --git a/src/OneWare.SourceControl/OneWare.SourceControl.csproj b/src/OneWare.SourceControl/OneWare.SourceControl.csproj index 8dcf9292..1149cbfe 100644 --- a/src/OneWare.SourceControl/OneWare.SourceControl.csproj +++ b/src/OneWare.SourceControl/OneWare.SourceControl.csproj @@ -10,6 +10,6 @@ - + diff --git a/src/OneWare.Vcd.Parser/OneWare.Vcd.Parser.csproj b/src/OneWare.Vcd.Parser/OneWare.Vcd.Parser.csproj index 8a215b24..79f3916b 100644 --- a/src/OneWare.Vcd.Parser/OneWare.Vcd.Parser.csproj +++ b/src/OneWare.Vcd.Parser/OneWare.Vcd.Parser.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 enable enable diff --git a/studio/OneWare.Studio.Browser/OneWare.Studio.Browser.csproj b/studio/OneWare.Studio.Browser/OneWare.Studio.Browser.csproj index 93e3250d..6e29b9ef 100644 --- a/studio/OneWare.Studio.Browser/OneWare.Studio.Browser.csproj +++ b/studio/OneWare.Studio.Browser/OneWare.Studio.Browser.csproj @@ -6,7 +6,7 @@ $(StudioVersion) - net8.0-browser + net9.0-browser Exe true true diff --git a/studio/OneWare.Studio.Desktop/OneWare.Studio.Desktop.csproj b/studio/OneWare.Studio.Desktop/OneWare.Studio.Desktop.csproj index b3bf69a9..ec092029 100644 --- a/studio/OneWare.Studio.Desktop/OneWare.Studio.Desktop.csproj +++ b/studio/OneWare.Studio.Desktop/OneWare.Studio.Desktop.csproj @@ -8,7 +8,7 @@ app.manifest WinExe Exe - net8.0 + net9.0 ..\OneWare.Studio\Assets\icon.ico latest enable diff --git a/tests/OneWare.Essentials.UnitTests/OneWare.Essentials.UnitTests.csproj b/tests/OneWare.Essentials.UnitTests/OneWare.Essentials.UnitTests.csproj index 0476bf1e..92f217eb 100644 --- a/tests/OneWare.Essentials.UnitTests/OneWare.Essentials.UnitTests.csproj +++ b/tests/OneWare.Essentials.UnitTests/OneWare.Essentials.UnitTests.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 Library False True diff --git a/tests/OneWare.Studio.Desktop.UnitTests/OneWare.Studio.Desktop.UnitTests.csproj b/tests/OneWare.Studio.Desktop.UnitTests/OneWare.Studio.Desktop.UnitTests.csproj index c65bc7f9..ce058137 100644 --- a/tests/OneWare.Studio.Desktop.UnitTests/OneWare.Studio.Desktop.UnitTests.csproj +++ b/tests/OneWare.Studio.Desktop.UnitTests/OneWare.Studio.Desktop.UnitTests.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 Library False True diff --git a/tests/OneWare.UniversalFpgaProjectSystem.Tests/OneWare.UniversalFpgaProjectSystem.Tests.csproj b/tests/OneWare.UniversalFpgaProjectSystem.Tests/OneWare.UniversalFpgaProjectSystem.Tests.csproj index c49bb278..45a05c16 100644 --- a/tests/OneWare.UniversalFpgaProjectSystem.Tests/OneWare.UniversalFpgaProjectSystem.Tests.csproj +++ b/tests/OneWare.UniversalFpgaProjectSystem.Tests/OneWare.UniversalFpgaProjectSystem.Tests.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 Library False True diff --git a/tests/OneWare.Vcd.Parser.UnitTests/OneWare.Vcd.Parser.UnitTests.csproj b/tests/OneWare.Vcd.Parser.UnitTests/OneWare.Vcd.Parser.UnitTests.csproj index ca484c0c..b76a3573 100644 --- a/tests/OneWare.Vcd.Parser.UnitTests/OneWare.Vcd.Parser.UnitTests.csproj +++ b/tests/OneWare.Vcd.Parser.UnitTests/OneWare.Vcd.Parser.UnitTests.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 Library False True diff --git a/tests/OneWare.Vhdl.UnitTests/OneWare.Vhdl.UnitTests.csproj b/tests/OneWare.Vhdl.UnitTests/OneWare.Vhdl.UnitTests.csproj index 076cb132..a854c419 100644 --- a/tests/OneWare.Vhdl.UnitTests/OneWare.Vhdl.UnitTests.csproj +++ b/tests/OneWare.Vhdl.UnitTests/OneWare.Vhdl.UnitTests.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 Library False True diff --git a/tests/OneWare.WaveFormViewer.Tests/OneWare.WaveFormViewer.Tests.csproj b/tests/OneWare.WaveFormViewer.Tests/OneWare.WaveFormViewer.Tests.csproj index 7b44754f..112a9b14 100644 --- a/tests/OneWare.WaveFormViewer.Tests/OneWare.WaveFormViewer.Tests.csproj +++ b/tests/OneWare.WaveFormViewer.Tests/OneWare.WaveFormViewer.Tests.csproj @@ -2,7 +2,7 @@ - net8.0 + net9.0 Library False True From 0458cc55ea617860771cb481e90dd081806ddd6d Mon Sep 17 00:00:00 2001 From: Hendrik Mennen Date: Wed, 13 Nov 2024 12:42:18 -0500 Subject: [PATCH 6/6] continue settings refactor --- src/OneWare.Core/App.axaml.cs | 57 +++++++++------- src/OneWare.Essentials/Models/Setting.cs | 38 +++++------ .../OpenFpgaLoaderSettingsViewModel.cs | 26 +++++--- .../YosysCompileSettingsViewModel.cs | 64 +++++++++++------- .../PackageManagerModule.cs | 11 +++- src/OneWare.Settings/OneWare.Settings.csproj | 16 +---- src/OneWare.Settings/SettingsService.cs | 44 ++++++++++--- .../ApplicationSettingsViewModel.cs | 43 ++---------- .../ViewModels/SettingsCollectionViewModel.cs | 57 +++++++++++++++- .../SettingTypes/CheckBoxSettingView.axaml | 18 ++++- .../SettingTypes/ColorPickerSettingView.axaml | 18 ++++- .../ComboBoxSearchSettingView.axaml | 18 ++++- .../SettingTypes/ComboBoxSettingView.axaml | 18 ++++- .../SettingTypes/ListBoxSettingView.axaml | 18 ++++- .../Views/SettingTypes/PathSettingView.axaml | 18 ++++- .../SettingTypes/SliderSettingView.axaml | 18 ++++- .../SettingTypes/TextBoxSettingView.axaml | 18 ++++- .../Views/SettingsCollectionView.axaml | 5 +- .../UniversalFpgaProjectCreatorViewModel.cs | 66 ++++++++++++------- ...ersalFpgaProjectSettingsEditorViewModel.cs | 18 ++--- 20 files changed, 395 insertions(+), 194 deletions(-) diff --git a/src/OneWare.Core/App.axaml.cs b/src/OneWare.Core/App.axaml.cs index 82037554..3cc4fc0c 100644 --- a/src/OneWare.Core/App.axaml.cs +++ b/src/OneWare.Core/App.axaml.cs @@ -130,30 +130,29 @@ protected override AvaloniaObject CreateShell() settingsService.RegisterSettingCategory("Tools", 0, "FeatherIcons.Tool"); settingsService.RegisterSettingCategory("Languages", 0, "FluentIcons.ProofreadLanguageRegular"); + + settingsService.RegisterSetting("Editor", "Appearance", "Editor_FontFamily", + new ComboBoxSetting("Editor Font Family", "JetBrains Mono NL", ["JetBrains Mono NL", "IntelOne Mono", "Consolas", "Comic Sans MS", "Fira Code"])); + + settingsService.RegisterSetting("Editor", "Appearance", "Editor_FontSize", + new ComboBoxSetting("Font Size", 15,Enumerable.Range(10, 30).Cast())); - settingsService.RegisterTitledCombo("Editor", "Appearance", "Editor_FontFamily", "Font", - "Editor Font Family", - "JetBrains Mono NL", - "JetBrains Mono NL", "IntelOne Mono", "Consolas", "Comic Sans MS", "Fira Code"); - - settingsService.RegisterTitledCombo("Editor", "Appearance", "Editor_FontSize", "Font Size", - "Editor Font Size", 15, Enumerable.Range(10, 30).ToArray()); - - settingsService.RegisterTitledCombo("Editor", "Appearance", "Editor_SyntaxTheme_Dark", "Editor Theme Dark", - "Setts the theme for Syntax Highlighting in Dark Mode", ThemeName.DarkPlus, - Enum.GetValues()); - - settingsService.RegisterTitledCombo("Editor", "Appearance", "Editor_SyntaxTheme_Light", - "Editor Theme Light", - "Setts the theme for Syntax Highlighting in Light Mode", ThemeName.LightPlus, - Enum.GetValues()); - - //settingsService.RegisterTitled("Editor", "Appearance", "Editor_ErrorMarking_Mode", "Error Marking mode"); dfdf - - settingsService.RegisterTitled("Editor", "Formatting", "Editor_UseAutoFormatting", "Use Auto Formatting", - "Use Auto Formatting in Editor", true); - settingsService.RegisterTitled("Editor", "Formatting", "Editor_UseAutoBracket", "Use Auto Bracket", - "Use Auto Bracket in Editor", true); + settingsService.RegisterSetting("Editor", "Appearance", "Editor_SyntaxTheme_Dark", + new ComboBoxSetting("Editor Theme Dark", ThemeName.DarkPlus,Enum.GetValues().Cast()) + { + HoverDescription = "Sets the theme for Syntax Highlighting in Dark Mode" + }); + + settingsService.RegisterSetting("Editor", "Appearance", "Editor_SyntaxTheme_Light", + new ComboBoxSetting("Editor Theme Light", ThemeName.LightPlus,Enum.GetValues().Cast()) + { + HoverDescription = "Sets the theme for Syntax Highlighting in Light Mode" + }); + + settingsService.RegisterSetting("Editor", "Formatting", "Editor_UseAutoFormatting", + new CheckBoxSetting("Use Auto Formatting", true)); + + settingsService.RegisterSetting("Editor", "Formatting", "Editor_UseAutoBracket", new CheckBoxSetting("Use Auto Bracket", true)); settingsService.RegisterTitled("Editor", "Folding", "Editor_UseFolding", "Use Folding", "Use Folding in Editor", true); @@ -257,11 +256,19 @@ protected override AvaloniaObject CreateShell() var applicationCommandService = Container.Resolve(); applicationCommandService.RegisterCommand(new SimpleApplicationCommand("Active light theme", - () => settingsService.SetSettingValue("General_SelectedTheme", "Light"), + () => + { + settingsService.SetSettingValue("General_SelectedTheme", "Light"); + settingsService.Save(paths.SettingsPath); + }, () => settingsService.GetSettingValue("General_SelectedTheme") != "Light")); applicationCommandService.RegisterCommand(new SimpleApplicationCommand("Active dark theme", - () => settingsService.SetSettingValue("General_SelectedTheme", "Dark"), + () => + { + settingsService.SetSettingValue("General_SelectedTheme", "Dark"); + settingsService.Save(paths.SettingsPath); + }, () => settingsService.GetSettingValue("General_SelectedTheme") != "Dark")); // applicationCommandService.RegisterCommand(new SimpleApplicationCommand("Show Success Notification", diff --git a/src/OneWare.Essentials/Models/Setting.cs b/src/OneWare.Essentials/Models/Setting.cs index 89d92d16..ec1f26fb 100644 --- a/src/OneWare.Essentials/Models/Setting.cs +++ b/src/OneWare.Essentials/Models/Setting.cs @@ -35,15 +35,16 @@ public virtual object Value public abstract class TitledSetting : Setting { - public TitledSetting(string title, string description, object defaultValue) : base(defaultValue) + public TitledSetting(string title, object defaultValue) : base(defaultValue) { Title = title; - Description = description; } public string Title { get; } - public string Description { get; } + public string? HoverDescription { get; init; } + + public string? MarkdownDocumentation { get; init; } public IObservable? IsEnabledObservable { get; init; } @@ -52,15 +53,14 @@ public TitledSetting(string title, string description, object defaultValue) : ba public class CheckBoxSetting : TitledSetting { - public CheckBoxSetting(string title, string description, bool defaultValue) : base(title, description, defaultValue) + public CheckBoxSetting(string title, bool defaultValue) : base(title, defaultValue) { } } public class TextBoxSetting : TitledSetting { - public TextBoxSetting(string title, string description, object defaultValue, string? watermark) : base(title, - description, defaultValue) + public TextBoxSetting(string title, object defaultValue, string? watermark) : base(title, defaultValue) { Watermark = watermark; } @@ -70,8 +70,7 @@ public TextBoxSetting(string title, string description, object defaultValue, str public class ComboBoxSetting : TitledSetting { - public ComboBoxSetting(string title, string description, object defaultValue, IEnumerable options) : base( - title, description, defaultValue) + public ComboBoxSetting(string title, object defaultValue, IEnumerable options) : base(title, defaultValue) { Options = options.ToArray(); } @@ -81,8 +80,7 @@ public ComboBoxSetting(string title, string description, object defaultValue, IE public class ListBoxSetting : TitledSetting { - public ListBoxSetting(string title, string description, params string[] defaultValue) : base( - title, description, new ObservableCollection(defaultValue)) + public ListBoxSetting(string title, params string[] defaultValue) : base(title, new ObservableCollection(defaultValue)) { } @@ -93,13 +91,13 @@ public ObservableCollection Items } } -public class ComboBoxSearchSetting(string title, string description, object defaultValue, IEnumerable options) - : ComboBoxSetting(title, description, defaultValue, options); +public class ComboBoxSearchSetting(string title, object defaultValue, IEnumerable options) + : ComboBoxSetting(title, defaultValue, options); public class SliderSetting : TitledSetting { public SliderSetting(string title, string description, double defaultValue, double min, double max, double step) : base( - title, description, defaultValue) + title, defaultValue) { Min = min; Max = max; @@ -117,8 +115,8 @@ public abstract class PathSetting : TextBoxSetting { private bool _isValid = true; - protected PathSetting(string title, string description, object defaultValue, string? watermark, - string? startDirectory, Func? checkPath) : base(title, description, defaultValue, watermark) + protected PathSetting(string title, string defaultValue, string? watermark, + string? startDirectory, Func? checkPath) : base(title, defaultValue, watermark) { StartDirectory = startDirectory; @@ -143,9 +141,9 @@ public bool IsValid public class FolderPathSetting : PathSetting { - public FolderPathSetting(string title, string description, object defaultValue, string? watermark, + public FolderPathSetting(string title, string defaultValue, string? watermark, string? startDirectory, Func? checkPath) - : base(title, description, defaultValue, watermark, startDirectory, checkPath) + : base(title, defaultValue, watermark, startDirectory, checkPath) { } @@ -158,9 +156,9 @@ public override async Task SelectPathAsync(TopLevel topLevel) public class FilePathSetting : PathSetting { - public FilePathSetting(string title, string description, object defaultValue, string? watermark, + public FilePathSetting(string title, string defaultValue, string? watermark, string? startDirectory, Func? checkPath, params FilePickerFileType[] filters) - : base(title, description, defaultValue, watermark, startDirectory, checkPath) + : base(title, defaultValue, watermark, startDirectory, checkPath) { Filters = filters; } @@ -176,7 +174,7 @@ public override async Task SelectPathAsync(TopLevel topLevel) public class ColorSetting : TitledSetting { - public ColorSetting(string title, string description, Color defaultValue) : base(title, description, defaultValue) + public ColorSetting(string title, Color defaultValue) : base(title, defaultValue) { } diff --git a/src/OneWare.OssCadSuiteIntegration/ViewModels/OpenFpgaLoaderSettingsViewModel.cs b/src/OneWare.OssCadSuiteIntegration/ViewModels/OpenFpgaLoaderSettingsViewModel.cs index eca98c2e..167a255f 100644 --- a/src/OneWare.OssCadSuiteIntegration/ViewModels/OpenFpgaLoaderSettingsViewModel.cs +++ b/src/OneWare.OssCadSuiteIntegration/ViewModels/OpenFpgaLoaderSettingsViewModel.cs @@ -30,16 +30,22 @@ public OpenFpgaLoaderSettingsViewModel(UniversalFpgaProjectRoot projectRoot, IFp var defaultProperties = fpga.Properties; _settings = FpgaSettingsParser.LoadSettings(projectRoot, fpga.Name); - _boardSetting = new TextBoxSetting("Board", "OpenFPGALoader Board", - defaultProperties.GetValueOrDefault("openFpgaLoaderBoard") ?? "", null); + _boardSetting = new TextBoxSetting("Board", defaultProperties.GetValueOrDefault("openFpgaLoaderBoard") ?? "", null) + { + HoverDescription = "OpenFPGALoader Board" + }; _shortTermFlagsSetting = new TextBoxSetting("Short Term Arguments", - "OpenFPGALoader Flags for Short Term Programming", - defaultProperties.GetValueOrDefault("openFpgaLoaderShortTermFlags") ?? "", null); + defaultProperties.GetValueOrDefault("openFpgaLoaderShortTermFlags") ?? "", null) + { + HoverDescription = "OpenFPGALoader Flags for Short Term Programming" + }; _longTermFlagsSetting = new TextBoxSetting("Long Term Arguments", - "OpenFPGALoader Flags for Long Term Programming", - defaultProperties.GetValueOrDefault("openFpgaLoaderLongTermFlags") ?? "", null); + defaultProperties.GetValueOrDefault("openFpgaLoaderLongTermFlags") ?? "", null) + { + HoverDescription = "OpenFPGALoader Flags for Long Term Programming", + }; if (_settings.TryGetValue("openFpgaLoaderBoard", out var oflBoard)) _boardSetting.Value = oflBoard; @@ -50,9 +56,9 @@ public OpenFpgaLoaderSettingsViewModel(UniversalFpgaProjectRoot projectRoot, IFp if (_settings.TryGetValue("openFpgaLoaderLongTermFlags", out var oflLFlags)) _longTermFlagsSetting.Value = oflLFlags; - SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_boardSetting)); - SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_shortTermFlagsSetting)); - SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_longTermFlagsSetting)); + SettingsCollection.SettingModels.Add(_boardSetting); + SettingsCollection.SettingModels.Add(_shortTermFlagsSetting); + SettingsCollection.SettingModels.Add(_longTermFlagsSetting); } public SettingsCollectionViewModel SettingsCollection { get; } = new("OpenFPGALoader Settings") @@ -73,6 +79,6 @@ public void Save(FlexibleWindow flexibleWindow) public void Reset() { - foreach (var setting in SettingsCollection.SettingModels) setting.Setting.Value = setting.Setting.DefaultValue; + foreach (var setting in SettingsCollection.SettingModels) setting.Value = setting.DefaultValue; } } \ No newline at end of file diff --git a/src/OneWare.OssCadSuiteIntegration/ViewModels/YosysCompileSettingsViewModel.cs b/src/OneWare.OssCadSuiteIntegration/ViewModels/YosysCompileSettingsViewModel.cs index 6989e3ff..c181c559 100644 --- a/src/OneWare.OssCadSuiteIntegration/ViewModels/YosysCompileSettingsViewModel.cs +++ b/src/OneWare.OssCadSuiteIntegration/ViewModels/YosysCompileSettingsViewModel.cs @@ -29,7 +29,7 @@ public YosysCompileSettingsViewModel(UniversalFpgaProjectRoot fpgaProjectRoot, I { _fpgaProjectRoot = fpgaProjectRoot; _selectedFpga = selectedFpga; - + Title = "Yosys Compile Settings"; Id = "YosysCompileSettings"; @@ -39,7 +39,7 @@ public YosysCompileSettingsViewModel(UniversalFpgaProjectRoot fpgaProjectRoot, I //Add missing default properties foreach (var property in defaultProperties) _settings.TryAdd(property.Key, property.Value); - _yosysSynthToolSetting = new ComboBoxSetting("Yosys Synth Tool", "Set Yosys Synth tool", + _yosysSynthToolSetting = new ComboBoxSetting("Yosys Synth Tool", defaultProperties.GetValueOrDefault("yosysToolchainYosysSynthTool") ?? "", [ "synth_achronix", "synth_anlogic", @@ -59,11 +59,17 @@ public YosysCompileSettingsViewModel(UniversalFpgaProjectRoot fpgaProjectRoot, I "synth_quicklogic", "synth_sf2", "synth_xilinx" - ]); - _yosysFlagSetting = new TextBoxSetting("Yosys Flags", "Set Yosys flags", - defaultProperties.GetValueOrDefault("yosysToolchainYosysFlags") ?? "", null); - - _nextPnrToolSetting = new ComboBoxSetting("NextPnr Tool", "Set NextPnr tool", + ]) + { + HoverDescription = "Set Yosys Synth tool" + }; + _yosysFlagSetting = new TextBoxSetting("Yosys Flags", + defaultProperties.GetValueOrDefault("yosysToolchainYosysFlags") ?? "", null) + { + HoverDescription = "Set Yosys flags" + }; + + _nextPnrToolSetting = new ComboBoxSetting("NextPnr Tool", defaultProperties.GetValueOrDefault("yosysToolchainNextPnrTool") ?? "", [ "nextpnr-ecp5", "nextpnr-generic", @@ -71,27 +77,41 @@ public YosysCompileSettingsViewModel(UniversalFpgaProjectRoot fpgaProjectRoot, I "nextpnr-ice40", "nextpnr-machxo2", "nextpnr-nexus" - ]); - _nextPnrFlagSetting = new TextBoxSetting("NextPnR Flags", "Set NextPnr flags", - defaultProperties.GetValueOrDefault("yosysToolchainNextPnrFlags") ?? "", null); - - _packToolSetting = new ComboBoxSetting("Pack Tool", "Set Pack tool", + ]) + { + HoverDescription = "Set NextPnr tool" + }; + + _nextPnrFlagSetting = new TextBoxSetting("NextPnR Flags", + defaultProperties.GetValueOrDefault("yosysToolchainNextPnrFlags") ?? "", null) + { + HoverDescription = "Set NextPnr flags" + }; + + _packToolSetting = new ComboBoxSetting("Pack Tool", defaultProperties.GetValueOrDefault("yosysToolchainPackTool") ?? "", [ "ecppack", "gowin_pack", "icepack" - ]); - _packToolFlagSetting = new TextBoxSetting("Pack Flags", "Set Pack flags", - defaultProperties.GetValueOrDefault("yosysToolchainPackFlags") ?? "", null); + ]) + { + HoverDescription = "Set Pack tool" + }; + + _packToolFlagSetting = new TextBoxSetting("Pack Flags", + defaultProperties.GetValueOrDefault("yosysToolchainPackFlags") ?? "", null) + { + HoverDescription = "Set Pack flags" + }; - SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_yosysSynthToolSetting)); - SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_yosysFlagSetting)); + SettingsCollection.SettingModels.Add(_yosysSynthToolSetting); + SettingsCollection.SettingModels.Add(_yosysFlagSetting); - SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_nextPnrToolSetting)); - SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_nextPnrFlagSetting)); + SettingsCollection.SettingModels.Add(_nextPnrToolSetting); + SettingsCollection.SettingModels.Add(_nextPnrFlagSetting); - SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_packToolSetting)); - SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_packToolFlagSetting)); + SettingsCollection.SettingModels.Add(_packToolSetting); + SettingsCollection.SettingModels.Add(_packToolFlagSetting); if (_settings.TryGetValue("yosysToolchainYosysSynthTool", out var yTool)) _yosysSynthToolSetting.Value = yTool; @@ -130,6 +150,6 @@ public void Save(FlexibleWindow flexibleWindow) public void Reset() { - foreach (var setting in SettingsCollection.SettingModels) setting.Setting.Value = setting.Setting.DefaultValue; + foreach (var setting in SettingsCollection.SettingModels) setting.Value = setting.DefaultValue; } } \ No newline at end of file diff --git a/src/OneWare.PackageManager/PackageManagerModule.cs b/src/OneWare.PackageManager/PackageManagerModule.cs index a9209bc5..b0e6e77d 100644 --- a/src/OneWare.PackageManager/PackageManagerModule.cs +++ b/src/OneWare.PackageManager/PackageManagerModule.cs @@ -1,6 +1,7 @@ using Avalonia; using Avalonia.Controls; using CommunityToolkit.Mvvm.Input; +using OneWare.Essentials.Models; using OneWare.Essentials.Services; using OneWare.Essentials.ViewModels; using OneWare.PackageManager.Services; @@ -36,6 +37,14 @@ public void OnInitialized(IContainerProvider containerProvider) ContainerLocator.Container.Resolve().RegisterSettingCategory("Package Manager", 0, "PackageManager"); ContainerLocator.Container.Resolve() - .RegisterTitledListBox("Package Manager", "Sources", "PackageManager_Sources", "Custom Package Sources", "Manage the sources to look for packages"); + .RegisterSetting("Package Manager", "Sources", "PackageManager_Sources", new ListBoxSetting("Custom Package Sources", []) + { + MarkdownDocumentation = """ + Add custom package sources to the package manager. These sources will be used to search for and install packages. + You can add either: + - A Package Repository + - A Direct link to a package manifest + """, + }); } } \ No newline at end of file diff --git a/src/OneWare.Settings/OneWare.Settings.csproj b/src/OneWare.Settings/OneWare.Settings.csproj index ab4f1e62..4d69fc6f 100644 --- a/src/OneWare.Settings/OneWare.Settings.csproj +++ b/src/OneWare.Settings/OneWare.Settings.csproj @@ -1,24 +1,10 @@ + - - - ComboBoxSearchSettingView.axaml - Code - - - CustomSettingView.axaml - Code - - - ListBoxSettingView.axaml - Code - - - \ No newline at end of file diff --git a/src/OneWare.Settings/SettingsService.cs b/src/OneWare.Settings/SettingsService.cs index dd0b43a3..8fa93122 100644 --- a/src/OneWare.Settings/SettingsService.cs +++ b/src/OneWare.Settings/SettingsService.cs @@ -45,7 +45,7 @@ public void Register(string key, T defaultValue) if (defaultValue == null) throw new NullReferenceException(nameof(defaultValue)); AddSetting(key, new Setting(defaultValue)); } - + public void RegisterSetting(string category, string subCategory, string key, TitledSetting setting) { AddSetting(category, subCategory, key, setting); @@ -67,10 +67,16 @@ public void RegisterTitled(string category, string subCategory, string key, s switch (defaultValue) { case bool b: - AddSetting(category, subCategory, key, new CheckBoxSetting(title, description, b)); + AddSetting(category, subCategory, key, new CheckBoxSetting(title, b) + { + HoverDescription = description + }); break; default: - AddSetting(category, subCategory, key, new TextBoxSetting(title, description, defaultValue, null)); + AddSetting(category, subCategory, key, new TextBoxSetting(title, defaultValue, null) + { + HoverDescription = description + }); break; } } @@ -79,7 +85,10 @@ public void RegisterTitledPath(string category, string subCategory, string key, string defaultValue, string? watermark, string? startDir, Func? validate) { AddSetting(category, subCategory, key, - new FolderPathSetting(title, description, defaultValue, watermark, startDir, validate)); + new FolderPathSetting(title, defaultValue, watermark, startDir, validate) + { + HoverDescription = description + }); } public void RegisterTitledFolderPath(string category, string subCategory, string key, string title, @@ -87,7 +96,10 @@ public void RegisterTitledFolderPath(string category, string subCategory, string string defaultValue, string? watermark, string? startDir, Func? validate) { AddSetting(category, subCategory, key, - new FolderPathSetting(title, description, defaultValue, watermark, startDir, validate)); + new FolderPathSetting(title, defaultValue, watermark, startDir, validate) + { + HoverDescription = description + }); } public void RegisterTitledFilePath(string category, string subCategory, string key, string title, @@ -96,7 +108,10 @@ public void RegisterTitledFilePath(string category, string subCategory, string k params FilePickerFileType[] filters) { AddSetting(category, subCategory, key, - new FilePathSetting(title, description, defaultValue, watermark, startDir, validate, filters)); + new FilePathSetting(title, defaultValue, watermark, startDir, validate, filters) + { + HoverDescription = description + }); } public void RegisterTitledSlider(string category, string subCategory, string key, string title, @@ -110,7 +125,10 @@ public void RegisterTitledCombo(string category, string subCategory, string k { if (defaultValue == null) throw new NullReferenceException(nameof(defaultValue)); AddSetting(category, subCategory, key, - new ComboBoxSetting(title, description, defaultValue, options.Cast())); + new ComboBoxSetting(title, defaultValue, options.Cast()) + { + HoverDescription = description + }); } public void RegisterTitledComboSearch(string category, string subCategory, string key, string title, @@ -118,15 +136,21 @@ public void RegisterTitledComboSearch(string category, string subCategory, st { if (defaultValue == null) throw new NullReferenceException(nameof(defaultValue)); AddSetting(category, subCategory, key, - new ComboBoxSearchSetting(title, description, defaultValue, options.Cast())); + new ComboBoxSearchSetting(title, defaultValue, options.Cast()) + { + HoverDescription = description + }); } - + public void RegisterTitledListBox(string category, string subCategory, string key, string title, string description, params string[] defaultValue) { if (defaultValue == null) throw new NullReferenceException(nameof(defaultValue)); AddSetting(category, subCategory, key, - new ListBoxSetting(title, description, defaultValue)); + new ListBoxSetting(title, defaultValue) + { + HoverDescription = description + }); } public void RegisterCustom(string category, string subCategory, string key, CustomSetting customSetting) diff --git a/src/OneWare.Settings/ViewModels/ApplicationSettingsViewModel.cs b/src/OneWare.Settings/ViewModels/ApplicationSettingsViewModel.cs index c45c97a5..092d2a36 100644 --- a/src/OneWare.Settings/ViewModels/ApplicationSettingsViewModel.cs +++ b/src/OneWare.Settings/ViewModels/ApplicationSettingsViewModel.cs @@ -38,45 +38,10 @@ public ApplicationSettingsViewModel(ISettingsService settingsService, IPaths pat foreach (var subCategory in category.Value.SettingSubCategories.OrderBy(x => x.Value.Priority)) { - var subCategoryModel = new SettingsCollectionViewModel(subCategory.Key, subCategory.Value.IconKey); - - foreach (var setting in subCategory.Value.Settings) - switch (setting) - { - case ComboBoxSearchSetting csS: - subCategoryModel.SettingModels.Add(new ComboBoxSearchSettingViewModel(csS)); - break; - case ComboBoxSetting cS: - subCategoryModel.SettingModels.Add(new ComboBoxSettingViewModel(cS)); - break; - case SliderSetting ss: - subCategoryModel.SettingModels.Add(new SliderSettingViewModel(ss)); - break; - case FolderPathSetting pS: - subCategoryModel.SettingModels.Add(new PathSettingViewModel(pS)); - break; - case FilePathSetting pS: - subCategoryModel.SettingModels.Add(new PathSettingViewModel(pS)); - break; - case PathSetting pS: - subCategoryModel.SettingModels.Add(new PathSettingViewModel(pS)); - break; - case CustomSetting cS: - subCategoryModel.SettingModels.Add(new CustomSettingViewModel(cS)); - break; - case ListBoxSetting lS: - subCategoryModel.SettingModels.Add(new ListBoxSettingViewModel(lS)); - break; - case CheckBoxSetting cbS: - subCategoryModel.SettingModels.Add(new CheckBoxSettingViewModel(cbS)); - break; - case TextBoxSetting tS: - subCategoryModel.SettingModels.Add(new TextBoxSettingViewModel(tS)); - break; - case ColorSetting cS: - subCategoryModel.SettingModels.Add(new ColorPickerSettingViewModel(cS)); - break; - } + var subCategoryModel = new SettingsCollectionViewModel(subCategory.Key, subCategory.Value.IconKey) + { + SettingModels = { subCategory.Value.Settings } + }; pageModel.SettingCollections.Add(subCategoryModel); } diff --git a/src/OneWare.Settings/ViewModels/SettingsCollectionViewModel.cs b/src/OneWare.Settings/ViewModels/SettingsCollectionViewModel.cs index 810cf113..6ea5bee8 100644 --- a/src/OneWare.Settings/ViewModels/SettingsCollectionViewModel.cs +++ b/src/OneWare.Settings/ViewModels/SettingsCollectionViewModel.cs @@ -1,7 +1,9 @@ +using System.Collections.ObjectModel; using Avalonia; using Avalonia.Controls; using Avalonia.Media; using CommunityToolkit.Mvvm.ComponentModel; +using OneWare.Essentials.Models; using OneWare.Settings.ViewModels.SettingTypes; namespace OneWare.Settings.ViewModels; @@ -14,6 +16,14 @@ public SettingsCollectionViewModel(string label, string? iconKey = null, string? SidebarHeader = label.Split(" ")[0]; IconKey = iconKey; + SettingModels.CollectionChanged += (sender, args) => + { + if (args.NewItems != null) + { + ConstructViewModels(args.NewItems.Cast()); + } + }; + if (Application.Current == null) throw new NullReferenceException("Application.Current is null"); if (iconKey == null) return; @@ -24,9 +34,54 @@ public SettingsCollectionViewModel(string label, string? iconKey = null, string? public bool ShowTitle { get; set; } = true; public IImage? Icon { get; set; } - public List SettingModels { get; } = new(); + public ObservableCollection SettingModels { get; } = []; + + public ObservableCollection SettingViewModels { get; } = []; public string? IconKey { get; } public string Header { get; } public string SidebarHeader { get; } + + private void ConstructViewModels(IEnumerable source) + { + foreach (var setting in source) + { + switch (setting) + { + case ComboBoxSearchSetting csS: + SettingViewModels.Add(new ComboBoxSearchSettingViewModel(csS)); + break; + case ComboBoxSetting cS: + SettingViewModels.Add(new ComboBoxSettingViewModel(cS)); + break; + case SliderSetting ss: + SettingViewModels.Add(new SliderSettingViewModel(ss)); + break; + case FolderPathSetting pS: + SettingViewModels.Add(new PathSettingViewModel(pS)); + break; + case FilePathSetting pS: + SettingViewModels.Add(new PathSettingViewModel(pS)); + break; + case PathSetting pS: + SettingViewModels.Add(new PathSettingViewModel(pS)); + break; + case ListBoxSetting lS: + SettingViewModels.Add(new ListBoxSettingViewModel(lS)); + break; + case CheckBoxSetting cbS: + SettingViewModels.Add(new CheckBoxSettingViewModel(cbS)); + break; + case TextBoxSetting tS: + SettingViewModels.Add(new TextBoxSettingViewModel(tS)); + break; + case ColorSetting cS: + SettingViewModels.Add(new ColorPickerSettingViewModel(cS)); + break; + case CustomSetting cS: + SettingViewModels.Add(new CustomSettingViewModel(cS)); + break; + } + } + } } \ No newline at end of file diff --git a/src/OneWare.Settings/Views/SettingTypes/CheckBoxSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/CheckBoxSettingView.axaml index 76cdf340..a90e38f0 100644 --- a/src/OneWare.Settings/Views/SettingTypes/CheckBoxSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/CheckBoxSettingView.axaml @@ -3,6 +3,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" + xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.CheckBoxSettingView" x:DataType="settingTypes:CheckBoxSettingViewModel" @@ -11,8 +12,21 @@ - + + + + \ No newline at end of file diff --git a/src/OneWare.Settings/Views/SettingTypes/ColorPickerSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/ColorPickerSettingView.axaml index c1946507..20dfdf0c 100644 --- a/src/OneWare.Settings/Views/SettingTypes/ColorPickerSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/ColorPickerSettingView.axaml @@ -3,13 +3,27 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" + xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.ColorPickerSettingView" x:DataType="settingTypes:ColorPickerSettingViewModel" IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> - + + + + diff --git a/src/OneWare.Settings/Views/SettingTypes/ComboBoxSearchSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/ComboBoxSearchSettingView.axaml index f439991a..9e143d2d 100644 --- a/src/OneWare.Settings/Views/SettingTypes/ComboBoxSearchSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/ComboBoxSearchSettingView.axaml @@ -4,13 +4,27 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" xmlns:controls="clr-namespace:OneWare.Essentials.Controls;assembly=OneWare.Essentials" + xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.ComboBoxSearchSettingView" x:DataType="settingTypes:ComboBoxSearchSettingViewModel" IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> - + + + + diff --git a/src/OneWare.Settings/Views/SettingTypes/ComboBoxSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/ComboBoxSettingView.axaml index beaff91b..91d1050f 100644 --- a/src/OneWare.Settings/Views/SettingTypes/ComboBoxSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/ComboBoxSettingView.axaml @@ -3,13 +3,27 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" + xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.ComboBoxSettingView" x:DataType="settingTypes:ComboBoxSettingViewModel" IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> - + + + + diff --git a/src/OneWare.Settings/Views/SettingTypes/ListBoxSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/ListBoxSettingView.axaml index 4a5490bd..8a2d8ca6 100644 --- a/src/OneWare.Settings/Views/SettingTypes/ListBoxSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/ListBoxSettingView.axaml @@ -3,13 +3,27 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" + xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.ListBoxSettingView" x:DataType="settingTypes:ListBoxSettingViewModel" IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> - + + + + diff --git a/src/OneWare.Settings/Views/SettingTypes/PathSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/PathSettingView.axaml index 5d628e56..c46165bb 100644 --- a/src/OneWare.Settings/Views/SettingTypes/PathSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/PathSettingView.axaml @@ -3,13 +3,27 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" + xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.PathSettingView" x:DataType="settingTypes:PathSettingViewModel" IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> - + + + + diff --git a/src/OneWare.Settings/Views/SettingTypes/SliderSettingView.axaml b/src/OneWare.Settings/Views/SettingTypes/SliderSettingView.axaml index a379bdc5..1e935fca 100644 --- a/src/OneWare.Settings/Views/SettingTypes/SliderSettingView.axaml +++ b/src/OneWare.Settings/Views/SettingTypes/SliderSettingView.axaml @@ -3,12 +3,26 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" + xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingTypes.SliderSettingView" x:DataType="settingTypes:SliderSettingViewModel" IsVisible="{Binding Setting.IsVisibleObservable^, FallbackValue={x:True}}"> - + + + + - + + + + diff --git a/src/OneWare.Settings/Views/SettingsCollectionView.axaml b/src/OneWare.Settings/Views/SettingsCollectionView.axaml index 71fa68a9..c74516b2 100644 --- a/src/OneWare.Settings/Views/SettingsCollectionView.axaml +++ b/src/OneWare.Settings/Views/SettingsCollectionView.axaml @@ -3,6 +3,9 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewModels="clr-namespace:OneWare.Settings.ViewModels" + xmlns:models="clr-namespace:OneWare.Essentials.Models;assembly=OneWare.Essentials" + xmlns:settingTypes="clr-namespace:OneWare.Settings.Views.SettingTypes" + xmlns:settingTypes1="clr-namespace:OneWare.Settings.ViewModels.SettingTypes" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="OneWare.Settings.Views.SettingsCollectionView" x:DataType="viewModels:SettingsCollectionViewModel"> @@ -16,7 +19,7 @@ Height="1" VerticalAlignment="Center" /> - diff --git a/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectCreatorViewModel.cs b/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectCreatorViewModel.cs index 002666e5..42a744cd 100644 --- a/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectCreatorViewModel.cs +++ b/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectCreatorViewModel.cs @@ -34,35 +34,50 @@ public UniversalFpgaProjectCreatorViewModel(IPaths paths, IProjectExplorerServic _manager = manager; Paths = paths; - _nameSetting = new TextBoxSetting("Name", "Set the name for the project", "", "Enter name..."); + _nameSetting = new TextBoxSetting("Name", "", "Enter name...") + { + HoverDescription = "Set the name for the project" + }; - _templateSetting = new ComboBoxSearchSetting("Template", "Set the template used for this project", "Empty", - new[] { "Empty" }.Concat(fpgaService.Templates.Select(x => x.Name))); + _templateSetting = new ComboBoxSearchSetting("Template", "Empty", + new[] { "Empty" }.Concat(fpgaService.Templates.Select(x => x.Name))) + { + HoverDescription = "Set the template used for this project" + }; - _folderPathSetting = new FolderPathSetting("Location", "Set the location where the new project is created", - paths.ProjectsDirectory, "Enter path...", paths.ProjectsDirectory, Directory.Exists); + _folderPathSetting = new FolderPathSetting("Location", + paths.ProjectsDirectory, "Enter path...", paths.ProjectsDirectory, Directory.Exists) + { + HoverDescription = "Set the location where the new project is created" + }; - _createNewFolderSetting = new CheckBoxSetting("Create new Folder", - "Set if a new folder should be created in the selected location", true); + _createNewFolderSetting = new CheckBoxSetting("Create new Folder", true) + { + HoverDescription = "Set if a new folder should be created in the selected location" + }; _toolchainSetting = new ComboBoxSetting("Toolchain", - "Set the toolchain to use for the project (can be changed later)", fpgaService.Toolchains.FirstOrDefault()?.Name ?? "Unset", new[] { "Unset" }.Concat(fpgaService.Toolchains - .Select(x => x.Name))); + .Select(x => x.Name))) + { + HoverDescription = "Set the toolchain to use for the project (can be changed later)" + }; _loaderSetting = new ComboBoxSetting("Loader", - "Set the loader to use for the project (can be changed later)", fpgaService.Loaders.FirstOrDefault()?.Name ?? "Unset", new[] { "Unset" }.Concat(fpgaService.Loaders - .Select(x => x.Name))); - - SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_nameSetting)); - SettingsCollection.SettingModels.Add(new ComboBoxSearchSettingViewModel(_templateSetting)); - SettingsCollection.SettingModels.Add(new PathSettingViewModel(_folderPathSetting)); - SettingsCollection.SettingModels.Add(new CheckBoxSettingViewModel(_createNewFolderSetting)); - SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_toolchainSetting)); - SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_loaderSetting)); + .Select(x => x.Name))) + { + HoverDescription = "Set the loader to use for the project (can be changed later)" + }; + + SettingsCollection.SettingModels.Add(_nameSetting); + SettingsCollection.SettingModels.Add(_templateSetting); + SettingsCollection.SettingModels.Add(_folderPathSetting); + SettingsCollection.SettingModels.Add(_createNewFolderSetting); + SettingsCollection.SettingModels.Add(_toolchainSetting); + SettingsCollection.SettingModels.Add(_loaderSetting); } public IPaths Paths { get; } @@ -106,19 +121,20 @@ public async Task SaveAsync(FlexibleWindow window) ["Exclude"] = new JsonArray("build") }; var root = new UniversalFpgaProjectRoot(projectFile, defaultProperties); - + if (_fpgaService.Loaders.FirstOrDefault(x => x.Name == _loaderSetting.Value.ToString()) is { } loader) root.Loader = loader; - - if (_fpgaService.Toolchains.FirstOrDefault(x => x.Name == _toolchainSetting.Value.ToString()) is { } tc) { + + if (_fpgaService.Toolchains.FirstOrDefault(x => x.Name == _toolchainSetting.Value.ToString()) is { } tc) + { root.Toolchain = tc; - tc.OnProjectCreated(root); + tc.OnProjectCreated(root); } - + await _manager.SaveProjectAsync(root); - + _projectExplorerService.Insert(root); - + _projectExplorerService.ActiveProject = root; if (_fpgaService.Templates.FirstOrDefault(x => x.Name == _templateSetting.Value.ToString()) is { } template) diff --git a/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectSettingsEditorViewModel.cs b/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectSettingsEditorViewModel.cs index 593ffdc1..425718d3 100644 --- a/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectSettingsEditorViewModel.cs +++ b/src/OneWare.UniversalFpgaProjectSystem/ViewModels/UniversalFpgaProjectSettingsEditorViewModel.cs @@ -47,19 +47,19 @@ public UniversalFpgaProjectSettingsEditorViewModel(UniversalFpgaProjectRoot root var toolchains = ContainerLocator.Container.Resolve().Toolchains.Select(toolchain => toolchain.Name); var currentToolchain = _root.Properties["Toolchain"]!.ToString(); - _toolchain = new ComboBoxSetting("Toolchain", "test", currentToolchain, toolchains); + _toolchain = new ComboBoxSetting("Toolchain", currentToolchain, toolchains); var loader = ContainerLocator.Container.Resolve().Loaders.Select(loader => loader.Name); var currentLoader = _root.Properties["Loader"]!.ToString(); - _loader = new ComboBoxSetting("Loader", "test", currentLoader, loader); + _loader = new ComboBoxSetting("Loader", currentLoader, loader); - _includesSettings = new ListBoxSetting("Files to Include", "test", includes); - _excludesSettings = new ListBoxSetting("Files to Exclude", "test", exclude); - - SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_toolchain) ); - SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_loader) ); - SettingsCollection.SettingModels.Add(new ListBoxSettingViewModel(_includesSettings) ); - SettingsCollection.SettingModels.Add(new ListBoxSettingViewModel(_excludesSettings) ); + _includesSettings = new ListBoxSetting("Files to Include", includes); + _excludesSettings = new ListBoxSetting("Files to Exclude", exclude); + + SettingsCollection.SettingModels.Add(_toolchain); + SettingsCollection.SettingModels.Add(_loader); + SettingsCollection.SettingModels.Add(_includesSettings); + SettingsCollection.SettingModels.Add(_excludesSettings); } private async Task SaveAsync()