mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 00:46:12 +02:00
Add per plugin theme override
This commit is contained in:
@@ -206,7 +206,8 @@ internal class SettingElementGenerator(ComboBox optionsComboBox)
|
||||
{
|
||||
try
|
||||
{
|
||||
eComboBox.Value = comboBox.SelectedItem.ToString() ?? string.Empty;
|
||||
comboBox.SelectedItem ??= eComboBox.Value;
|
||||
eComboBox.Value = comboBox.SelectedItem?.ToString() ?? eComboBox.Value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using DesktopMagic.Api;
|
||||
using DesktopMagic.Api.Drawing;
|
||||
using DesktopMagic.Api.Settings;
|
||||
using DesktopMagic.DataContexts;
|
||||
using DesktopMagic.Helpers;
|
||||
using DesktopMagic.Plugins;
|
||||
using DesktopMagic.Settings;
|
||||
@@ -250,9 +251,15 @@ public partial class PluginWindow : Window
|
||||
{
|
||||
SetHorizontalAlignment();
|
||||
SetVerticalAlignment();
|
||||
SetThemeOverride();
|
||||
SetThemeOverrideItems();
|
||||
|
||||
pluginClassInstance.horizontalAlignment.OnValueChanged += SetHorizontalAlignment;
|
||||
pluginClassInstance.verticalAlignment.OnValueChanged += SetVerticalAlignment;
|
||||
pluginClassInstance.themeOverride.OnValueChanged += SetThemeOverride;
|
||||
|
||||
DesktopMagicSettings desktopMagicSettings = MainWindowDataContext.GetSettings();
|
||||
desktopMagicSettings.Themes.CollectionChanged += (s, e) => SetThemeOverrideItems();
|
||||
});
|
||||
|
||||
void SetVerticalAlignment()
|
||||
@@ -282,6 +289,31 @@ public partial class PluginWindow : Window
|
||||
viewBox.HorizontalAlignment = horizontalAlignment;
|
||||
border.HorizontalAlignment = horizontalAlignment;
|
||||
}
|
||||
|
||||
void SetThemeOverride()
|
||||
{
|
||||
if (pluginClassInstance.themeOverride.Value == "<None>")
|
||||
{
|
||||
settings.CurrentThemeName = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.CurrentThemeName = pluginClassInstance.themeOverride.Value;
|
||||
}
|
||||
}
|
||||
|
||||
void SetThemeOverrideItems()
|
||||
{
|
||||
DesktopMagicSettings desktopMagicSettings = MainWindowDataContext.GetSettings();
|
||||
|
||||
pluginClassInstance.themeOverride.Items.Clear();
|
||||
pluginClassInstance.themeOverride.Items.Add("<None>");
|
||||
|
||||
foreach (Theme theme in desktopMagicSettings.Themes)
|
||||
{
|
||||
pluginClassInstance.themeOverride.Items.Add(theme.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadOptions(object instance)
|
||||
|
||||
@@ -17,6 +17,9 @@ public abstract class Plugin
|
||||
[Setting("desktopmagic-vertical-alignment", "Vertical Alignment", -998)]
|
||||
internal ComboBox verticalAlignment = new ComboBox("Center", "Top", "Bottom");
|
||||
|
||||
[Setting("theme-override", "Theme Override", -997)]
|
||||
internal ComboBox themeOverride = new ComboBox("<None>");
|
||||
|
||||
private IPluginData application = null!;
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user