mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 08:56:15 +02:00
Fix built in plugins and some UI issues
This commit is contained in:
@@ -11,7 +11,13 @@ namespace DesktopMagic.Api;
|
||||
/// </summary>
|
||||
public abstract class Plugin
|
||||
{
|
||||
private IPluginData application = null;
|
||||
[Setting("horizontalAlignment", "Horizontal Alignment", -999)]
|
||||
internal ComboBox horizontalAlignment = new ComboBox("Center", "Left", "Right");
|
||||
|
||||
[Setting("verticalAlignment", "Vertical Alignment", -998)]
|
||||
internal ComboBox verticalAlignment = new ComboBox("Center", "Top", "Bottom");
|
||||
|
||||
private IPluginData application = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Informations about the main application.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace DesktopMagic.Api.Settings;
|
||||
|
||||
@@ -8,7 +7,7 @@ namespace DesktopMagic.Api.Settings;
|
||||
/// </summary>
|
||||
public class ComboBox : Setting
|
||||
{
|
||||
private string _value;
|
||||
private string _value = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection used to generate the content of the <see cref="ComboBox"/>.
|
||||
@@ -38,6 +37,8 @@ public class ComboBox : Setting
|
||||
/// <param name="items"></param>
|
||||
public ComboBox(params string[] items)
|
||||
{
|
||||
Value = items[0];
|
||||
|
||||
foreach (string item in items)
|
||||
{
|
||||
Items.Add(item);
|
||||
@@ -46,7 +47,7 @@ public class ComboBox : Setting
|
||||
|
||||
internal override string GetJsonValue()
|
||||
{
|
||||
return JsonSerializer.Serialize(new { Value, Items });
|
||||
return Value;
|
||||
}
|
||||
|
||||
internal override void SetJsonValue(string value)
|
||||
@@ -56,12 +57,6 @@ public class ComboBox : Setting
|
||||
return;
|
||||
}
|
||||
|
||||
JsonElement json = JsonSerializer.Deserialize<JsonElement>(value);
|
||||
Items.Clear();
|
||||
foreach (JsonElement item in json.GetProperty(nameof(Items)).EnumerateArray())
|
||||
{
|
||||
Items.Add(item.GetString() ?? string.Empty);
|
||||
}
|
||||
Value = json.GetProperty(nameof(Value)).GetString() ?? string.Empty;
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,13 @@ namespace DesktopMagic.Api.Settings;
|
||||
/// <summary>
|
||||
/// Marks a Property as element.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class SettingAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the element.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The order index of the element.
|
||||
|
||||
Reference in New Issue
Block a user