mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 03:19:56 +00:00
Add design mode
This commit is contained in:
1 parent
5a681a0480
commit
eb812cb5e1
50 files changed
+782
-257
No files matched your search
@@ -1,25 +1,25 @@
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a configuration item that accepts boolean input from the user.
|
||||
/// Represents a configuration item that accepts boolean input from the user.
|
||||
/// </summary>
|
||||
public class ConfigurationBooleanItem : ConfigurationInputItem<bool>
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public required string TrueText
|
||||
public string TrueText
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
} = "Yes";
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public required string FalseText
|
||||
public string FalseText
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
} = "No";
|
||||
}
|
||||
@@ -3,13 +3,13 @@
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a generic base class for configuration items that accept user input.
|
||||
/// Represents a generic base class for configuration items that accept user input.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the value that this configuration item holds.</typeparam>
|
||||
public class ConfigurationInputItem<T> : CorePropertyChanged, IConfigurationItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the display name of the configuration item.
|
||||
/// Gets or sets the display name of the configuration item.
|
||||
/// </summary>
|
||||
public required string Name
|
||||
{
|
||||
@@ -18,7 +18,7 @@ public class ConfigurationInputItem<T> : CorePropertyChanged, IConfigurationItem
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public string? Description
|
||||
{
|
||||
@@ -27,7 +27,7 @@ public class ConfigurationInputItem<T> : CorePropertyChanged, IConfigurationItem
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current value of the configuration item.
|
||||
/// Gets or sets the current value of the configuration item.
|
||||
/// </summary>
|
||||
public T? Value
|
||||
{
|
||||
@@ -36,8 +36,17 @@ public class ConfigurationInputItem<T> : CorePropertyChanged, IConfigurationItem
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public T? DefaultValue
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public ObservableCollection<ConfigurationDropdownValue<T>>? DropdownValues
|
||||
{
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a configuration item that accepts numeric input from the user.
|
||||
/// Represents a configuration item that accepts numeric input from the user.
|
||||
/// </summary>
|
||||
public class ConfigurationNumericItem : ConfigurationInputItem<Numeric>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,26 @@
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a configuration section that contains a collection of configuration items.
|
||||
/// Represents a configuration section that contains a collection of configuration items.
|
||||
/// </summary>
|
||||
public class ConfigurationSection : CorePropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the configuration section.
|
||||
/// Creates a new instance of the <see cref="ProfileConfiguration" /> class.
|
||||
/// </summary>
|
||||
/// <param name="profileConfiguration">The profile configuration this section belongs to.</param>
|
||||
public ConfigurationSection(ProfileConfiguration profileConfiguration)
|
||||
{
|
||||
ProfileConfiguration = profileConfiguration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the profile configuration this section belongs to.
|
||||
/// </summary>
|
||||
public ProfileConfiguration ProfileConfiguration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the configuration section.
|
||||
/// </summary>
|
||||
public required string Name
|
||||
{
|
||||
@@ -17,7 +31,7 @@ public class ConfigurationSection : CorePropertyChanged
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of configuration items in this section.
|
||||
/// Gets the collection of configuration items in this section.
|
||||
/// </summary>
|
||||
public ObservableCollection<IConfigurationItem> Items { get; } = [];
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace Artemis.Core;
|
||||
public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable, IPluginFeatureDependent
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an empty profile.
|
||||
/// Represents an empty profile.
|
||||
/// </summary>
|
||||
public static readonly ProfileConfiguration Empty = new(ProfileCategory.Empty, "Empty", "Empty");
|
||||
|
||||
@@ -147,7 +147,7 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public bool FadeInAndOut
|
||||
{
|
||||
@@ -156,7 +156,7 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether this profile is configurable via its <see cref="ConfigurationSections"/>.
|
||||
/// Gets or sets a boolean indicating whether this profile is configurable via its <see cref="ConfigurationSections" />.
|
||||
/// </summary>
|
||||
public bool IsConfigurable
|
||||
{
|
||||
@@ -251,19 +251,6 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
return $"[ProfileConfiguration] {nameof(Name)}: {Name}";
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PluginFeature> 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<Module> enabledModules)
|
||||
{
|
||||
if (_disposed)
|
||||
@@ -280,6 +267,19 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
ActivationCondition.Dispose();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PluginFeature> 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
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -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"});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in new issue
Block a user