From eb812cb5e1333bf358f5d2d018e8ddf9a9e331fb Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 31 Jul 2026 15:30:11 +0200 Subject: [PATCH] Add design mode --- .../ConfigurationBooleanItem.cs | 14 +-- .../ConfigurationInputItem.cs | 21 +++-- .../ConfigurationNumericItem.cs | 22 ++++- .../ConfigurationSection.cs | 20 ++++- .../ProfileConfiguration.cs | 62 ++++++------- src/Artemis.UI.Shared/Styles/Button.axaml | 43 ++++----- .../Items/ConfigurationBooleanItemView.axaml | 26 ++++++ .../ConfigurationBooleanItemView.axaml.cs | 11 +++ .../ConfigurationBooleanItemViewModel.cs | 14 +++ .../ConfigurationColorGradientItemView.axaml | 24 +++++ ...onfigurationColorGradientItemView.axaml.cs | 11 +++ ...ConfigurationColorGradientItemViewModel.cs | 14 +++ .../Items/ConfigurationNumericItemView.axaml | 32 +++++++ .../ConfigurationNumericItemView.axaml.cs | 11 +++ .../ConfigurationNumericItemViewModel.cs | 14 +++ .../Items/ConfigurationSKColorItemView.axaml | 25 ++++++ .../ConfigurationSKColorItemView.axaml.cs | 11 +++ .../ConfigurationSKColorItemViewModel.cs | 14 +++ .../Items/ConfigurationStringItemView.axaml | 21 +++++ .../ConfigurationStringItemView.axaml.cs | 11 +++ .../Items/ConfigurationStringItemViewModel.cs | 14 +++ .../Items/ConfigurationTextItemView.axaml} | 10 +-- .../Items/ConfigurationTextItemView.axaml.cs | 11 +++ .../Items/ConfigurationTextItemViewModel.cs | 14 +++ .../ConfigurationBooleanItemDesignView.axaml | 36 ++++---- ...onfigurationBooleanItemDesignView.axaml.cs | 3 +- ...ConfigurationBooleanItemDesignViewModel.cs | 10 +-- ...igurationColorGradientItemDesignView.axaml | 22 ++--- ...rationColorGradientItemDesignView.axaml.cs | 3 +- ...urationColorGradientItemDesignViewModel.cs | 13 +-- .../ConfigurationNumericItemDesignView.axaml | 38 ++++---- ...onfigurationNumericItemDesignView.axaml.cs | 3 +- ...ConfigurationNumericItemDesignViewModel.cs | 10 +-- .../ConfigurationSKColorItemDesignView.axaml | 21 +++-- ...onfigurationSKColorItemDesignView.axaml.cs | 3 +- ...ConfigurationSKColorItemDesignViewModel.cs | 10 +-- .../ConfigurationStringItemDesignView.axaml | 19 ++-- ...ConfigurationStringItemDesignView.axaml.cs | 3 +- .../ConfigurationStringItemDesignViewModel.cs | 10 +-- ...igurationTextItemDesignDesignView.axaml.cs | 12 --- .../ConfigurationTextItemDesignView.axaml | 17 ++++ .../ConfigurationTextItemDesignView.axaml.cs | 11 +++ .../ConfigurationTextItemDesignViewModel.cs | 18 +++- .../AddConfigurationItemDesignView.axaml | 46 ++++++++++ .../AddConfigurationItemDesignView.axaml.cs | 31 +++++++ .../AddConfigurationItemDesignViewModel.cs | 21 +++++ .../ConfigurationSectionDesignView.axaml | 19 ++-- .../ConfigurationSectionDesignViewModel.cs | 79 ++++++++++++----- .../ProfileEditor/DesignProfileView.axaml | 23 ++++- .../ProfileEditor/DesignProfileViewModel.cs | 88 ++++++++++++------- 50 files changed, 782 insertions(+), 257 deletions(-) create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemView.axaml create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemView.axaml.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemViewModel.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemView.axaml create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemView.axaml.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemViewModel.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemView.axaml create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemView.axaml.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemViewModel.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemView.axaml create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemView.axaml.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemViewModel.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemView.axaml create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemView.axaml.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemViewModel.cs rename src/Artemis.UI/Screens/ProfileEditor/{DesignPanels/Items/ConfigurationTextItemDesignDesignView.axaml => ConfigurationPanels/Items/ConfigurationTextItemView.axaml} (59%) create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationTextItemView.axaml.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationTextItemViewModel.cs delete mode 100644 src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignDesignView.axaml.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignView.axaml create mode 100644 src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignView.axaml.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignView.axaml create mode 100644 src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignView.axaml.cs create mode 100644 src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignViewModel.cs diff --git a/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationBooleanItem.cs b/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationBooleanItem.cs index 30073885d..8d2882e9b 100644 --- a/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationBooleanItem.cs +++ b/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationBooleanItem.cs @@ -1,25 +1,25 @@ namespace Artemis.Core; /// -/// Represents a configuration item that accepts boolean input from the user. +/// Represents a configuration item that accepts boolean input from the user. /// public class ConfigurationBooleanItem : ConfigurationInputItem { /// - /// Gets or sets the display text shown when the boolean value is true. + /// Gets or sets the display text shown when the boolean value is true. /// - public required string TrueText + public string TrueText { get; set => SetAndNotify(ref field, value); - } + } = "Yes"; /// - /// Gets or sets the display text shown when the boolean value is false. + /// Gets or sets the display text shown when the boolean value is false. /// - public required string FalseText + public string FalseText { get; set => SetAndNotify(ref field, value); - } + } = "No"; } \ No newline at end of file diff --git a/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationInputItem.cs b/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationInputItem.cs index b92439e5d..5120e984d 100644 --- a/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationInputItem.cs +++ b/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationInputItem.cs @@ -3,13 +3,13 @@ namespace Artemis.Core; /// -/// Represents a generic base class for configuration items that accept user input. +/// Represents a generic base class for configuration items that accept user input. /// /// The type of the value that this configuration item holds. public class ConfigurationInputItem : CorePropertyChanged, IConfigurationItem { /// - /// Gets or sets the display name of the configuration item. + /// Gets or sets the display name of the configuration item. /// public required string Name { @@ -18,7 +18,7 @@ public class ConfigurationInputItem : CorePropertyChanged, IConfigurationItem } /// - /// Gets or sets the description text that explains the purpose of this configuration item. + /// Gets or sets the description text that explains the purpose of this configuration item. /// public string? Description { @@ -27,7 +27,7 @@ public class ConfigurationInputItem : CorePropertyChanged, IConfigurationItem } /// - /// Gets or sets the current value of the configuration item. + /// Gets or sets the current value of the configuration item. /// public T? Value { @@ -36,8 +36,17 @@ public class ConfigurationInputItem : CorePropertyChanged, IConfigurationItem } /// - /// Gets or sets the collection of dropdown values for this configuration item. - /// When populated, the configuration item will be rendered as a dropdown/combo box. + /// Gets or sets the default value of the configuration item. + /// + public T? DefaultValue + { + get; + set => SetAndNotify(ref field, value); + } + + /// + /// Gets or sets the collection of dropdown values for this configuration item. + /// When populated, the configuration item will be rendered as a dropdown/combo box. /// public ObservableCollection>? DropdownValues { diff --git a/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationNumericItem.cs b/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationNumericItem.cs index 1f3b166c5..024008e79 100644 --- a/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationNumericItem.cs +++ b/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationNumericItem.cs @@ -1,11 +1,25 @@ namespace Artemis.Core; /// -/// Represents a configuration item that accepts numeric input from the user. +/// Represents a configuration item that accepts numeric input from the user. /// public class ConfigurationNumericItem : ConfigurationInputItem { - public Numeric? Minimum { get; set; } - public Numeric? Maximum { get; set; } - public bool Slider { get; set; } + public Numeric? Minimum + { + get; + set => SetAndNotify(ref field, value); + } + + public Numeric? Maximum + { + get; + set => SetAndNotify(ref field, value); + } + + public bool Slider + { + get; + set => SetAndNotify(ref field, value); + } } \ No newline at end of file diff --git a/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationSection.cs b/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationSection.cs index 5ca1cc8e0..55db6faae 100644 --- a/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationSection.cs +++ b/src/Artemis.Core/Models/ProfileConfiguration/ConfigurationSection.cs @@ -3,12 +3,26 @@ namespace Artemis.Core; /// -/// Represents a configuration section that contains a collection of configuration items. +/// Represents a configuration section that contains a collection of configuration items. /// public class ConfigurationSection : CorePropertyChanged { /// - /// Gets or sets the name of the configuration section. + /// Creates a new instance of the class. + /// + /// The profile configuration this section belongs to. + public ConfigurationSection(ProfileConfiguration profileConfiguration) + { + ProfileConfiguration = profileConfiguration; + } + + /// + /// Gets the profile configuration this section belongs to. + /// + public ProfileConfiguration ProfileConfiguration { get; } + + /// + /// Gets or sets the name of the configuration section. /// public required string Name { @@ -17,7 +31,7 @@ public class ConfigurationSection : CorePropertyChanged } /// - /// Gets the collection of configuration items in this section. + /// Gets the collection of configuration items in this section. /// public ObservableCollection Items { get; } = []; } \ No newline at end of file diff --git a/src/Artemis.Core/Models/ProfileConfiguration/ProfileConfiguration.cs b/src/Artemis.Core/Models/ProfileConfiguration/ProfileConfiguration.cs index 405cae012..847d671e1 100644 --- a/src/Artemis.Core/Models/ProfileConfiguration/ProfileConfiguration.cs +++ b/src/Artemis.Core/Models/ProfileConfiguration/ProfileConfiguration.cs @@ -13,7 +13,7 @@ namespace Artemis.Core; public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable, IPluginFeatureDependent { /// - /// Represents an empty profile. + /// Represents an empty profile. /// public static readonly ProfileConfiguration Empty = new(ProfileCategory.Empty, "Empty", "Empty"); @@ -147,7 +147,7 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable, } /// - /// Gets or sets a boolean indicating whether this profile should fade in and out when enabling or disabling + /// Gets or sets a boolean indicating whether this profile should fade in and out when enabling or disabling /// public bool FadeInAndOut { @@ -156,7 +156,7 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable, } /// - /// Gets or sets a boolean indicating whether this profile is configurable via its . + /// Gets or sets a boolean indicating whether this profile is configurable via its . /// public bool IsConfigurable { @@ -251,19 +251,6 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable, return $"[ProfileConfiguration] {nameof(Name)}: {Name}"; } - /// - public IEnumerable GetFeatureDependencies() - { - if (_disposed) - throw new ObjectDisposedException("ProfileConfiguration"); - if (Profile == null) - throw new InvalidOperationException("Cannot determine feature dependencies when the profile is not loaded."); - - return ActivationCondition.GetFeatureDependencies() - .Concat(Profile.GetFeatureDependencies()) - .Concat(Module != null ? [Module] : []); - } - internal void LoadModules(List enabledModules) { if (_disposed) @@ -280,6 +267,19 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable, ActivationCondition.Dispose(); } + /// + public IEnumerable GetFeatureDependencies() + { + if (_disposed) + throw new ObjectDisposedException("ProfileConfiguration"); + if (Profile == null) + throw new InvalidOperationException("Cannot determine feature dependencies when the profile is not loaded."); + + return ActivationCondition.GetFeatureDependencies() + .Concat(Profile.GetFeatureDependencies()) + .Concat(Module != null ? [Module] : []); + } + #region Implementation of IStorageModel /// @@ -305,27 +305,27 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable, // Placeholder configuration sections ConfigurationSections.Clear(); - ConfigurationSections.Add(new ConfigurationSection() + ConfigurationSections.Add(new ConfigurationSection(this) { - Name = "General", + Name = "General" }); - ConfigurationSections.Add(new ConfigurationSection() + ConfigurationSections.Add(new ConfigurationSection(this) { - Name = "Other", + Name = "Other" }); - ConfigurationSections.Add(new ConfigurationSection() + ConfigurationSections.Add(new ConfigurationSection(this) { - Name = "Something else", + Name = "Something else" }); - ConfigurationSections[0].Items.Add(new ConfigurationTextItem() {Text = "This is a placeholder text item in the General section."}); - ConfigurationSections[0].Items.Add(new ConfigurationNumericItem() {Name = "Numeric item", Description = "This one also has a description"}); - ConfigurationSections[0].Items.Add(new ConfigurationBooleanItem() {Name = "Do the thing?", TrueText = "Absolutely", FalseText = "Nope"}); - ConfigurationSections[1].Items.Add(new ConfigurationTextItem() {Text = "This is a placeholder text item in the Other section."}); - ConfigurationSections[2].Items.Add(new ConfigurationTextItem() {Text = "This is a placeholder text item in the Something else section."}); - ConfigurationSections[2].Items.Add(new ConfigurationTextItem() {Text = "This is another placeholder text item in the Something else section."}); - ConfigurationSections[2].Items.Add(new ConfigurationNumericItem() {Name = "Numeric item", Description = "This one uses a slider", Minimum = 0, Maximum = 10, Slider = true}); - ConfigurationSections[2].Items.Add(new ConfigurationColorGradientItem() {Name = "Color gradient"}); - ConfigurationSections[2].Items.Add(new ConfigurationSKColorItem() {Name = "A simple color", Description = "Again with a description"}); + ConfigurationSections[0].Items.Add(new ConfigurationTextItem {Text = "This is a placeholder text item in the General section."}); + ConfigurationSections[0].Items.Add(new ConfigurationNumericItem {Name = "Numeric item", Description = "This one also has a description"}); + ConfigurationSections[0].Items.Add(new ConfigurationBooleanItem {Name = "Do the thing?", TrueText = "Absolutely", FalseText = "Nope"}); + ConfigurationSections[1].Items.Add(new ConfigurationTextItem {Text = "This is a placeholder text item in the Other section."}); + ConfigurationSections[2].Items.Add(new ConfigurationTextItem {Text = "This is a placeholder text item in the Something else section."}); + ConfigurationSections[2].Items.Add(new ConfigurationTextItem {Text = "This is another placeholder text item in the Something else section."}); + ConfigurationSections[2].Items.Add(new ConfigurationNumericItem {Name = "Numeric item", Description = "This one uses a slider", Minimum = 0, Maximum = 10, Slider = true}); + ConfigurationSections[2].Items.Add(new ConfigurationColorGradientItem {Name = "Color gradient"}); + ConfigurationSections[2].Items.Add(new ConfigurationSKColorItem {Name = "A simple color", Description = "Again with a description"}); } /// diff --git a/src/Artemis.UI.Shared/Styles/Button.axaml b/src/Artemis.UI.Shared/Styles/Button.axaml index b8e7a4da4..99e1d5969 100644 --- a/src/Artemis.UI.Shared/Styles/Button.axaml +++ b/src/Artemis.UI.Shared/Styles/Button.axaml @@ -3,7 +3,7 @@ xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"> - + Button.icon-button - Button.icon-button icon-button-small + Button.icon-button icon-button-small @@ -34,15 +34,15 @@ - Button.window-button - - + Button.window-button + + - + @@ -51,6 +51,9 @@ + + @@ -79,7 +82,7 @@ - - + - + diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemView.axaml b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemView.axaml new file mode 100644 index 000000000..4a8e79be7 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemView.axaml @@ -0,0 +1,26 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemView.axaml.cs new file mode 100644 index 000000000..4a3bc62d2 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemView.axaml.cs @@ -0,0 +1,11 @@ +using ReactiveUI.Avalonia; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public partial class ConfigurationBooleanItemView : ReactiveUserControl +{ + public ConfigurationBooleanItemView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemViewModel.cs new file mode 100644 index 000000000..6dd08dee9 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationBooleanItemViewModel.cs @@ -0,0 +1,14 @@ +using Artemis.Core; +using Artemis.UI.Shared; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public class ConfigurationBooleanItemViewModel : ActivatableViewModelBase +{ + public ConfigurationBooleanItemViewModel(ConfigurationBooleanItem item) + { + Item = item; + } + + public ConfigurationBooleanItem Item { get; } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemView.axaml b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemView.axaml new file mode 100644 index 000000000..452294a54 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemView.axaml @@ -0,0 +1,24 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemView.axaml.cs new file mode 100644 index 000000000..48b738eaa --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemView.axaml.cs @@ -0,0 +1,11 @@ +using ReactiveUI.Avalonia; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public partial class ConfigurationColorGradientItemView : ReactiveUserControl +{ + public ConfigurationColorGradientItemView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemViewModel.cs new file mode 100644 index 000000000..17db44989 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationColorGradientItemViewModel.cs @@ -0,0 +1,14 @@ +using Artemis.Core; +using Artemis.UI.Shared; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public class ConfigurationColorGradientItemViewModel : ActivatableViewModelBase +{ + public ConfigurationColorGradientItemViewModel(ConfigurationColorGradientItem item) + { + Item = item; + } + + public ConfigurationColorGradientItem Item { get; } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemView.axaml b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemView.axaml new file mode 100644 index 000000000..f523f0630 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemView.axaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemView.axaml.cs new file mode 100644 index 000000000..4531b9530 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemView.axaml.cs @@ -0,0 +1,11 @@ +using ReactiveUI.Avalonia; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public partial class ConfigurationNumericItemView : ReactiveUserControl +{ + public ConfigurationNumericItemView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemViewModel.cs new file mode 100644 index 000000000..1267bd5a0 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationNumericItemViewModel.cs @@ -0,0 +1,14 @@ +using Artemis.Core; +using Artemis.UI.Shared; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public class ConfigurationNumericItemViewModel : ActivatableViewModelBase +{ + public ConfigurationNumericItemViewModel(ConfigurationNumericItem item) + { + Item = item; + } + + public ConfigurationNumericItem Item { get; } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemView.axaml b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemView.axaml new file mode 100644 index 000000000..41c2bf003 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemView.axaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemView.axaml.cs new file mode 100644 index 000000000..dd64d9bab --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemView.axaml.cs @@ -0,0 +1,11 @@ +using ReactiveUI.Avalonia; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public partial class ConfigurationSKColorItemView : ReactiveUserControl +{ + public ConfigurationSKColorItemView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemViewModel.cs new file mode 100644 index 000000000..f07903e12 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationSKColorItemViewModel.cs @@ -0,0 +1,14 @@ +using Artemis.Core; +using Artemis.UI.Shared; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public class ConfigurationSKColorItemViewModel : ActivatableViewModelBase +{ + public ConfigurationSKColorItemViewModel(ConfigurationSKColorItem item) + { + Item = item; + } + + public ConfigurationSKColorItem Item { get; } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemView.axaml b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemView.axaml new file mode 100644 index 000000000..e8cfcac38 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemView.axaml @@ -0,0 +1,21 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemView.axaml.cs new file mode 100644 index 000000000..cf4eaa65b --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemView.axaml.cs @@ -0,0 +1,11 @@ +using ReactiveUI.Avalonia; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public partial class ConfigurationStringItemView : ReactiveUserControl +{ + public ConfigurationStringItemView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemViewModel.cs new file mode 100644 index 000000000..3deee3542 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationStringItemViewModel.cs @@ -0,0 +1,14 @@ +using Artemis.Core; +using Artemis.UI.Shared; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public class ConfigurationStringItemViewModel : ActivatableViewModelBase +{ + public ConfigurationStringItemViewModel(ConfigurationStringItem item) + { + Item = item; + } + + public ConfigurationStringItem Item { get; } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignDesignView.axaml b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationTextItemView.axaml similarity index 59% rename from src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignDesignView.axaml rename to src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationTextItemView.axaml index 34bfb22c9..4daa66069 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignDesignView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationTextItemView.axaml @@ -2,9 +2,9 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:items="clr-namespace:Artemis.UI.Screens.ProfileEditor.DesignPanels.Items" + xmlns:items="clr-namespace:Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="Artemis.UI.Screens.ProfileEditor.DesignPanels.Items.ConfigurationTextItemDesignDesignView" - x:DataType="items:ConfigurationTextItemDesignViewModel"> - - + x:Class="Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items.ConfigurationTextItemView" + x:DataType="items:ConfigurationTextItemViewModel"> + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationTextItemView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationTextItemView.axaml.cs new file mode 100644 index 000000000..03454d239 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationTextItemView.axaml.cs @@ -0,0 +1,11 @@ +using ReactiveUI.Avalonia; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public partial class ConfigurationTextItemView : ReactiveUserControl +{ + public ConfigurationTextItemView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationTextItemViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationTextItemViewModel.cs new file mode 100644 index 000000000..330a418a3 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/ConfigurationPanels/Items/ConfigurationTextItemViewModel.cs @@ -0,0 +1,14 @@ +using Artemis.Core; +using Artemis.UI.Shared; + +namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; + +public class ConfigurationTextItemViewModel : ActivatableViewModelBase +{ + public ConfigurationTextItemViewModel(ConfigurationTextItem item) + { + Item = item; + } + + public ConfigurationTextItem Item { get; } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignView.axaml b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignView.axaml index 66031bfb0..7cd8544ef 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignView.axaml @@ -3,24 +3,30 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:items="clr-namespace:Artemis.UI.Screens.ProfileEditor.DesignPanels.Items" + xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.ProfileEditor.DesignPanels.Items.ConfigurationBooleanItemDesignView" x:DataType="items:ConfigurationBooleanItemDesignViewModel"> - - - - + + + + + + + + - - + + Default: + + - + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignView.axaml.cs index 3ec793798..99fc432ae 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignView.axaml.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignView.axaml.cs @@ -1,5 +1,4 @@ -using Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; -using ReactiveUI.Avalonia; +using ReactiveUI.Avalonia; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignViewModel.cs index 9333a45c6..6419ab3c2 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationBooleanItemDesignViewModel.cs @@ -1,14 +1,8 @@ using Artemis.Core; -using Artemis.UI.Shared; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; -public class ConfigurationBooleanItemDesignViewModel : ActivatableViewModelBase +public class ConfigurationBooleanItemDesignViewModel(ConfigurationBooleanItem item, ConfigurationSection configurationSection) : ConfigurationItemDesignViewModel(item, configurationSection) { - public ConfigurationBooleanItem Item { get; } - - public ConfigurationBooleanItemDesignViewModel(ConfigurationBooleanItem item) - { - Item = item; - } + public ConfigurationBooleanItem BooleanItem { get; } = item; } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignView.axaml b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignView.axaml index 8fe9f7e72..4cc64891a 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignView.axaml @@ -4,21 +4,23 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:gradientPicker="clr-namespace:Artemis.UI.Shared.Controls.GradientPicker;assembly=Artemis.UI.Shared" xmlns:items="clr-namespace:Artemis.UI.Screens.ProfileEditor.DesignPanels.Items" + xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.ProfileEditor.DesignPanels.Items.ConfigurationColorGradientItemDesignView" x:DataType="items:ConfigurationColorGradientItemDesignViewModel"> - - - - + + + + + Default: + ColorGradient="{CompiledBinding GradientItem.Value}" + VerticalAlignment="Center" /> + - + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignView.axaml.cs index 4a45fbad7..603d0bf61 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignView.axaml.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignView.axaml.cs @@ -1,5 +1,4 @@ -using Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; -using ReactiveUI.Avalonia; +using ReactiveUI.Avalonia; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignViewModel.cs index 2210f8f55..8741726f9 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationColorGradientItemDesignViewModel.cs @@ -1,14 +1,17 @@ using Artemis.Core; -using Artemis.UI.Shared; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; -public class ConfigurationColorGradientItemDesignViewModel : ActivatableViewModelBase +public class ConfigurationColorGradientItemDesignViewModel : ConfigurationItemDesignViewModel { - public ConfigurationColorGradientItemDesignViewModel(ConfigurationColorGradientItem item) + public ConfigurationColorGradientItemDesignViewModel(ConfigurationColorGradientItem item, ConfigurationSection configurationSection) : base(item, configurationSection) { - Item = item; + // The gradient picker doesn't handle null values well + item.DefaultValue ??= ColorGradient.GetUnicornBarf(); + item.Value ??= ColorGradient.GetUnicornBarf(); + + GradientItem = item; } - public ConfigurationColorGradientItem Item { get; } + public ConfigurationColorGradientItem GradientItem { get; } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignView.axaml b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignView.axaml index 0ab4abcca..06a83b467 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignView.axaml @@ -5,28 +5,36 @@ xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" xmlns:behaviors="clr-namespace:Artemis.UI.Shared.Behaviors;assembly=Artemis.UI.Shared" xmlns:items="clr-namespace:Artemis.UI.Screens.ProfileEditor.DesignPanels.Items" + xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.ProfileEditor.DesignPanels.Items.ConfigurationNumericItemDesignView" x:DataType="items:ConfigurationNumericItemDesignViewModel"> - - - - + + + + + - - + + Default: + - + - + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignView.axaml.cs index 2944e6546..1a11641f8 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignView.axaml.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignView.axaml.cs @@ -1,5 +1,4 @@ -using Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; -using ReactiveUI.Avalonia; +using ReactiveUI.Avalonia; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignViewModel.cs index 73278447e..057f48f6c 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationNumericItemDesignViewModel.cs @@ -1,14 +1,8 @@ using Artemis.Core; -using Artemis.UI.Shared; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; -public class ConfigurationNumericItemDesignViewModel : ActivatableViewModelBase +public class ConfigurationNumericItemDesignViewModel(ConfigurationNumericItem item, ConfigurationSection configurationSection) : ConfigurationItemDesignViewModel(item, configurationSection) { - public ConfigurationNumericItem Item { get; } - - public ConfigurationNumericItemDesignViewModel(ConfigurationNumericItem item) - { - Item = item; - } + public ConfigurationNumericItem NumericItem { get; } = item; } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignView.axaml b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignView.axaml index 3c27335ad..206a94c92 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignView.axaml @@ -4,22 +4,25 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" xmlns:items="clr-namespace:Artemis.UI.Screens.ProfileEditor.DesignPanels.Items" + xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.ProfileEditor.DesignPanels.Items.ConfigurationSKColorItemDesignView" x:DataType="items:ConfigurationSKColorItemDesignViewModel"> - - - - + + + + - - Default: + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignView.axaml.cs index 4df928cec..5c537d1c2 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignView.axaml.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignView.axaml.cs @@ -1,5 +1,4 @@ -using Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; -using ReactiveUI.Avalonia; +using ReactiveUI.Avalonia; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignViewModel.cs index faea3f73b..61de392e1 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationSKColorItemDesignViewModel.cs @@ -1,14 +1,8 @@ using Artemis.Core; -using Artemis.UI.Shared; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; -public class ConfigurationSKColorItemDesignViewModel : ActivatableViewModelBase +public class ConfigurationSKColorItemDesignViewModel(ConfigurationSKColorItem item, ConfigurationSection configurationSection) : ConfigurationItemDesignViewModel(item, configurationSection) { - public ConfigurationSKColorItemDesignViewModel(ConfigurationSKColorItem item) - { - Item = item; - } - - public ConfigurationSKColorItem Item { get; } + public ConfigurationSKColorItem ColorItem { get; } = item; } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignView.axaml b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignView.axaml index d3e3d473e..413d5e276 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignView.axaml @@ -3,19 +3,22 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:items="clr-namespace:Artemis.UI.Screens.ProfileEditor.DesignPanels.Items" + xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.ProfileEditor.DesignPanels.Items.ConfigurationStringItemDesignView" x:DataType="items:ConfigurationStringItemDesignViewModel"> - - - - + + + + - + Default: + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignView.axaml.cs index 512590678..38986d2ff 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignView.axaml.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignView.axaml.cs @@ -1,5 +1,4 @@ -using Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; -using ReactiveUI.Avalonia; +using ReactiveUI.Avalonia; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignViewModel.cs index 06f4b36ed..4af21c8f6 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationStringItemDesignViewModel.cs @@ -1,14 +1,8 @@ using Artemis.Core; -using Artemis.UI.Shared; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; -public class ConfigurationStringItemDesignViewModel : ActivatableViewModelBase +public class ConfigurationStringItemDesignViewModel(ConfigurationStringItem item, ConfigurationSection configurationSection) : ConfigurationItemDesignViewModel(item, configurationSection) { - public ConfigurationStringItem Item { get; } - - public ConfigurationStringItemDesignViewModel(ConfigurationStringItem item) - { - Item = item; - } + public ConfigurationStringItem StringItem { get; } = item; } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignDesignView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignDesignView.axaml.cs deleted file mode 100644 index b1b3346b8..000000000 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignDesignView.axaml.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Items; -using ReactiveUI.Avalonia; - -namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; - -public partial class ConfigurationTextItemDesignDesignView : ReactiveUserControl -{ - public ConfigurationTextItemDesignDesignView() - { - InitializeComponent(); - } -} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignView.axaml b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignView.axaml new file mode 100644 index 000000000..5f6d2e11b --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignView.axaml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignView.axaml.cs new file mode 100644 index 000000000..20177a714 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignView.axaml.cs @@ -0,0 +1,11 @@ +using ReactiveUI.Avalonia; + +namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; + +public partial class ConfigurationTextItemDesignView : ReactiveUserControl +{ + public ConfigurationTextItemDesignView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignViewModel.cs index de36b64ca..17a75a15e 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Items/ConfigurationTextItemDesignViewModel.cs @@ -3,12 +3,24 @@ using Artemis.UI.Shared; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; -public class ConfigurationTextItemDesignViewModel : ActivatableViewModelBase +public class ConfigurationTextItemDesignViewModel(ConfigurationTextItem item, ConfigurationSection configurationSection) : ConfigurationItemDesignViewModel(item, configurationSection) { - public ConfigurationTextItem Item { get; } + public ConfigurationTextItem TextItem { get; } = item; +} - public ConfigurationTextItemDesignViewModel(ConfigurationTextItem item) +public class ConfigurationItemDesignViewModel : ActivatableViewModelBase +{ + protected ConfigurationItemDesignViewModel(IConfigurationItem item, ConfigurationSection configurationSection) { Item = item; + ConfigurationSection = configurationSection; + } + + public IConfigurationItem Item { get; } + public ConfigurationSection ConfigurationSection { get; } + + public void RemoveItem() + { + ConfigurationSection.Items.Remove(Item); } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignView.axaml b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignView.axaml new file mode 100644 index 000000000..e45cf2474 --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignView.axaml @@ -0,0 +1,46 @@ + + + + + Boolean input + Allows the user enable/disable something via a toggle + + + + + Color gradient input + Allows the user create a color gradient + + + + + Color input + Allows the user to select a color + + + + + Numeric input + Allows the user to a number in either a box or via a slider + + + + + Text input + Allows the user to input arbitrary text + + + + + Text block + A simple piece of text, useful for explaining things + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignView.axaml.cs new file mode 100644 index 000000000..1f84d3c4c --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignView.axaml.cs @@ -0,0 +1,31 @@ +using Artemis.Core; +using Avalonia.Controls; +using ReactiveUI.Avalonia; + +namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Section; + +public partial class AddConfigurationItemDesignView : ReactiveUserControl +{ + public AddConfigurationItemDesignView() + { + InitializeComponent(); + } + + private void SelectingItemsControl_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) + { + if (e.AddedItems[0] is not ListBoxItem item) return; + + if (item == BooleanInputItem) + ViewModel?.AddItem(new ConfigurationBooleanItem {Name = "New Boolean"}); + else if (item == ColorGradientInputItem) + ViewModel?.AddItem(new ConfigurationColorGradientItem {Name = "New Gradient"}); + else if (item == ColorInputItem) + ViewModel?.AddItem(new ConfigurationSKColorItem {Name = "New Color"}); + else if (item == NumericInputItem) + ViewModel?.AddItem(new ConfigurationNumericItem {Name = "New Numeric"}); + else if (item == TextInputItem) + ViewModel?.AddItem(new ConfigurationStringItem {Name = "New String"}); + else if (item == TextBlockItem) + ViewModel?.AddItem(new ConfigurationTextItem {Text = "New Text"}); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignViewModel.cs new file mode 100644 index 000000000..46c4052ee --- /dev/null +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/AddConfigurationItemDesignViewModel.cs @@ -0,0 +1,21 @@ +using Artemis.Core; +using Artemis.UI.Shared; +using FluentAvalonia.UI.Controls; + +namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Section; + +public class AddConfigurationItemDesignViewModel : ContentDialogViewModelBase +{ + public AddConfigurationItemDesignViewModel(ConfigurationSection section) + { + Section = section; + } + + public ConfigurationSection Section { get; } + + public void AddItem(IConfigurationItem item) + { + Section.Items.Add(item); + ContentDialog?.Hide(ContentDialogResult.Primary); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/ConfigurationSectionDesignView.axaml b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/ConfigurationSectionDesignView.axaml index 10f26fbe7..c65ab0450 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/ConfigurationSectionDesignView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/ConfigurationSectionDesignView.axaml @@ -3,20 +3,25 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:section="clr-namespace:Artemis.UI.Screens.ProfileEditor.DesignPanels.Section" + xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.ProfileEditor.DesignPanels.Section.ConfigurationSectionDesignView" x:DataType="section:ConfigurationSectionDesignViewModel"> - + + + + - + - - + @@ -29,6 +34,10 @@ + + - + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/ConfigurationSectionDesignViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/ConfigurationSectionDesignViewModel.cs index 6b719716e..c3f73afef 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/ConfigurationSectionDesignViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignPanels/Section/ConfigurationSectionDesignViewModel.cs @@ -1,33 +1,72 @@ -using System.Collections.ObjectModel; +using System; +using System.Collections.ObjectModel; +using System.Reactive.Disposables.Fluent; +using System.Threading.Tasks; using Artemis.Core; using Artemis.UI.Screens.ProfileEditor.DesignPanels.Items; using Artemis.UI.Shared; +using Artemis.UI.Shared.Services; +using DynamicData; +using DynamicData.Binding; +using PropertyChanged.SourceGenerator; +using ReactiveUI; namespace Artemis.UI.Screens.ProfileEditor.DesignPanels.Section; -public class ConfigurationSectionDesignViewModel : ActivatableViewModelBase +public partial class ConfigurationSectionDesignViewModel : ActivatableViewModelBase { - public ConfigurationSection ConfigurationSection { get; } - public ObservableCollection Items { get; } + private readonly IWindowService _windowService; + [Notify] private ReadOnlyObservableCollection? _items; - public ConfigurationSectionDesignViewModel(ConfigurationSection configurationSection) + public ConfigurationSectionDesignViewModel(ConfigurationSection configurationSection, IWindowService windowService) { + _windowService = windowService; ConfigurationSection = configurationSection; - Items = []; - foreach (IConfigurationItem item in ConfigurationSection.Items) + + this.WhenActivated(d => { - if (item is ConfigurationTextItem textItem) - Items.Add(new ConfigurationTextItemDesignViewModel(textItem)); - else if (item is ConfigurationStringItem stringItem) - Items.Add(new ConfigurationStringItemDesignViewModel(stringItem)); - else if (item is ConfigurationBooleanItem booleanItem) - Items.Add(new ConfigurationBooleanItemDesignViewModel(booleanItem)); - else if (item is ConfigurationNumericItem numberItem) - Items.Add(new ConfigurationNumericItemDesignViewModel(numberItem)); - else if (item is ConfigurationSKColorItem colorItem) - Items.Add(new ConfigurationSKColorItemDesignViewModel(colorItem)); - else if (item is ConfigurationColorGradientItem colorGradientItem) - Items.Add(new ConfigurationColorGradientItemDesignViewModel(colorGradientItem)); - } + ConfigurationSection.Items + .ToObservableChangeSet() + .Transform(CreateViewModelForItem) + .Bind(out ReadOnlyObservableCollection items) + .Subscribe() + .DisposeWith(d); + + Items = items; + }); + } + + public ConfigurationSection ConfigurationSection { get; } + + public async Task RemoveSection() + { + ConfigurationSection.ProfileConfiguration.ConfigurationSections.Remove(ConfigurationSection); + } + + public async Task AddItem() + { + await _windowService.CreateContentDialog() + .WithTitle("Add Item") + .WithViewModel(out AddConfigurationItemDesignViewModel _, ConfigurationSection) + .ShowAsync(); + } + + public void RemoveItem(ConfigurationItemDesignViewModel viewModel) + { + ConfigurationSection.Items.Remove(viewModel.Item); + } + + private ConfigurationItemDesignViewModel CreateViewModelForItem(IConfigurationItem item) + { + return item switch + { + ConfigurationTextItem textItem => new ConfigurationTextItemDesignViewModel(textItem, ConfigurationSection), + ConfigurationStringItem stringItem => new ConfigurationStringItemDesignViewModel(stringItem, ConfigurationSection), + ConfigurationBooleanItem booleanItem => new ConfigurationBooleanItemDesignViewModel(booleanItem, ConfigurationSection), + ConfigurationNumericItem numberItem => new ConfigurationNumericItemDesignViewModel(numberItem, ConfigurationSection), + ConfigurationSKColorItem colorItem => new ConfigurationSKColorItemDesignViewModel(colorItem, ConfigurationSection), + ConfigurationColorGradientItem colorGradientItem => new ConfigurationColorGradientItemDesignViewModel(colorGradientItem, ConfigurationSection), + _ => throw new ArgumentException($"Unknown configuration item type: {item.GetType()}") + }; } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignProfileView.axaml b/src/Artemis.UI/Screens/ProfileEditor/DesignProfileView.axaml index 4cd8ad867..84e8e0967 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignProfileView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignProfileView.axaml @@ -3,12 +3,27 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:profileEditor="clr-namespace:Artemis.UI.Screens.ProfileEditor" + xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.ProfileEditor.DesignProfileView" x:DataType="profileEditor:DesignProfileViewModel"> - - - Design - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/DesignProfileViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/DesignProfileViewModel.cs index 0cecd7f7c..2c3f50613 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/DesignProfileViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/DesignProfileViewModel.cs @@ -1,65 +1,87 @@ using System; +using System.Collections.ObjectModel; using System.Linq; +using System.Reactive.Disposables.Fluent; +using System.Reactive.Linq; using System.Threading; using System.Threading.Tasks; using Artemis.Core; using Artemis.Core.Services; -using Artemis.UI.Screens.Workshop.Library.Tabs; +using Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Preview; +using Artemis.UI.Screens.ProfileEditor.DesignPanels.Section; using Artemis.UI.Shared.Routing; -using Artemis.WebClient.Workshop.Models; -using Artemis.WebClient.Workshop.Services; +using Artemis.UI.Shared.Services.ProfileEditor; +using DynamicData; +using DynamicData.Binding; using PropertyChanged.SourceGenerator; +using ReactiveUI; namespace Artemis.UI.Screens.ProfileEditor; public partial class DesignProfileViewModel : RoutableScreen { + private readonly IProfileEditorService _profileEditorService; private readonly IProfileService _profileService; - private readonly IWorkshopService _workshopService; - private readonly IRouter _router; - private readonly Func _getInstalledTabItemViewModel; [Notify] private ProfileConfiguration? _profileConfiguration; - [Notify] private InstalledEntry? _workshopEntry; - [Notify] private InstalledTabItemViewModel? _entryViewModel; + [Notify] private ReadOnlyObservableCollection? _sections; - public DesignProfileViewModel(IProfileService profileService, IWorkshopService workshopService, IRouter router, Func getInstalledTabItemViewModel) + public DesignProfileViewModel(IProfileService profileService, IProfileEditorService profileEditorService, PreviewViewModel previewViewModel, + Func getConfigurationSectionDesignViewModel) { _profileService = profileService; - _workshopService = workshopService; - _router = router; - _getInstalledTabItemViewModel = getInstalledTabItemViewModel; + _profileEditorService = profileEditorService; ParameterSource = ParameterSource.Route; + + PreviewViewModel = previewViewModel; + + this.WhenActivated(d => + { + this.WhenAnyValue(vm => vm.ProfileConfiguration) + .Select(p => p?.ConfigurationSections.ToObservableChangeSet() ?? Observable.Empty>()) + .Switch() + .Transform(getConfigurationSectionDesignViewModel) + .Bind(out ReadOnlyObservableCollection sections) + .Subscribe() + .DisposeWith(d); + + Sections = sections; + }); } - public async Task DisableAutoUpdate() - { - if (WorkshopEntry != null) - { - _workshopService.SetAutoUpdate(WorkshopEntry, false); - } + public PreviewViewModel PreviewViewModel { get; } - if (ProfileConfiguration != null) - { - await _router.Navigate($"profile/{ProfileConfiguration.ProfileId}/editor"); - } - } - - public override Task OnNavigating(ProfileViewModelParameters parameters, NavigationArguments args, CancellationToken cancellationToken) + /// + public override async Task OnNavigating(ProfileViewModelParameters parameters, NavigationArguments args, CancellationToken cancellationToken) { - ProfileConfiguration = _profileService.ProfileCategories.SelectMany(c => c.ProfileConfigurations).FirstOrDefault(c => c.ProfileId == parameters.ProfileId); + ProfileConfiguration? profileConfiguration = _profileService.ProfileCategories.SelectMany(c => c.ProfileConfigurations).FirstOrDefault(c => c.ProfileId == parameters.ProfileId); // If the profile doesn't exist, cancel navigation - if (ProfileConfiguration == null) + if (profileConfiguration == null) { args.Cancel(); - return Task.CompletedTask; + return; } - WorkshopEntry = _workshopService.GetInstalledEntryByProfile(ProfileConfiguration); - EntryViewModel = WorkshopEntry != null ? _getInstalledTabItemViewModel(WorkshopEntry) : null; - if (EntryViewModel != null) - EntryViewModel.DisplayManagement = false; - return Task.CompletedTask; + await _profileEditorService.ChangeCurrentProfileConfiguration(profileConfiguration); + ProfileConfiguration = profileConfiguration; + } + + /// + public override async Task OnClosing(NavigationArguments args) + { + if (!args.Path.StartsWith("profile")) + { + ProfileConfiguration = null; + await _profileEditorService.ChangeCurrentProfileConfiguration(null); + } + } + + public async Task AddSection() + { + ProfileConfiguration?.ConfigurationSections.Add(new ConfigurationSection(ProfileConfiguration) + { + Name = $"New Section {ProfileConfiguration.ConfigurationSections.Count(s => s.Name.StartsWith("New Section")) + 1}" + }); } } \ No newline at end of file