diff --git a/src/DesktopMagic/App.xaml.cs b/src/DesktopMagic/App.xaml.cs
index 3bfd725..afca6ea 100644
--- a/src/DesktopMagic/App.xaml.cs
+++ b/src/DesktopMagic/App.xaml.cs
@@ -18,7 +18,7 @@ namespace DesktopMagic
#if DEBUG
private readonly Updater updater = new Updater(TimeSpan.FromDays(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/develop/update/updateInfo.json");
#else
- private readonly Updater updater = new Updater(TimeSpan.FromHours(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/main/update/updateInfo.json");
+ private readonly Updater updater = new Updater(TimeSpan.FromDays(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/main/update/updateInfo.json");
#endif
public const string AppName = "Desktop Magic";
@@ -104,7 +104,7 @@ namespace DesktopMagic
InfoConfig = new OutputConfig()
{
Color = ConsoleColor.White,
- LogTarget = LogTarget.Console | LogTarget.File,
+ LogTarget = LogTarget.DebugConsole | LogTarget.File,
FilePath = logFilePath
},
DebugConfig = new OutputConfig()
diff --git a/src/DesktopMagic/BuiltInWindowElements/CpuUsageWindow.xaml b/src/DesktopMagic/BuiltInWindowElements/CpuUsageWindow.xaml
index 6a5cc4a..59cad89 100644
--- a/src/DesktopMagic/BuiltInWindowElements/CpuUsageWindow.xaml
+++ b/src/DesktopMagic/BuiltInWindowElements/CpuUsageWindow.xaml
@@ -14,10 +14,14 @@
x:Name="window">
-
+
+
+
+
+
-
+
diff --git a/src/DesktopMagic/BuiltInWindowElements/CpuUsageWindow.xaml.cs b/src/DesktopMagic/BuiltInWindowElements/CpuUsageWindow.xaml.cs
index df25a92..1ba4cc1 100644
--- a/src/DesktopMagic/BuiltInWindowElements/CpuUsageWindow.xaml.cs
+++ b/src/DesktopMagic/BuiltInWindowElements/CpuUsageWindow.xaml.cs
@@ -87,12 +87,13 @@ namespace DesktopMagic
ResizeMode = ResizeMode.NoResize;
}
- textBlock.Background = MainWindow.Theme.BackgroundBrush;
+ rectangleGeometry.Rect = new Rect(0, 0, border.ActualWidth, border.ActualHeight);
+ border.Background = MainWindow.Theme.BackgroundBrush;
+ border.CornerRadius = new CornerRadius(MainWindow.Theme.CornerRadius);
textBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
textBlock.Foreground = MainWindow.Theme.PrimaryBrush;
- valuetextBlock.Background = MainWindow.Theme.BackgroundBrush;
- valuetextBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
- valuetextBlock.Foreground = MainWindow.Theme.PrimaryBrush;
+ valueTextBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
+ valueTextBlock.Foreground = MainWindow.Theme.PrimaryBrush;
ClculateWidth();
});
@@ -103,7 +104,7 @@ namespace DesktopMagic
string cpuUsage = GetCpuUsage();
Dispatcher.Invoke(() =>
{
- valuetextBlock.Text = cpuUsage;
+ valueTextBlock.Text = cpuUsage;
});
}
diff --git a/src/DesktopMagic/BuiltInWindowElements/DateWindow.xaml b/src/DesktopMagic/BuiltInWindowElements/DateWindow.xaml
index 74d72b4..432daf9 100644
--- a/src/DesktopMagic/BuiltInWindowElements/DateWindow.xaml
+++ b/src/DesktopMagic/BuiltInWindowElements/DateWindow.xaml
@@ -13,8 +13,13 @@
x:Name="window">
-
-
+
+
+
+
+
+
+
diff --git a/src/DesktopMagic/BuiltInWindowElements/DateWindow.xaml.cs b/src/DesktopMagic/BuiltInWindowElements/DateWindow.xaml.cs
index 07ef217..71fe0d9 100644
--- a/src/DesktopMagic/BuiltInWindowElements/DateWindow.xaml.cs
+++ b/src/DesktopMagic/BuiltInWindowElements/DateWindow.xaml.cs
@@ -69,10 +69,13 @@ namespace DesktopMagic
WindowPos.SetIsLocked(this, true);
ResizeMode = ResizeMode.NoResize;
}
+
+ rectangleGeometry.Rect = new Rect(0, 0, border.ActualWidth, border.ActualHeight);
+ border.Background = MainWindow.Theme.BackgroundBrush;
+ border.CornerRadius = new CornerRadius(MainWindow.Theme.CornerRadius);
textBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
textBlock.Foreground = MainWindow.Theme.PrimaryBrush;
textBlock.Text = DateTime.Now.ToLongDateString();
- textBlock.Background = MainWindow.Theme.BackgroundBrush;
});
}
diff --git a/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml b/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml
index 99b632e..bca74e6 100644
--- a/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml
+++ b/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml
@@ -11,16 +11,18 @@
AllowsTransparency="True"
LocationChanged="Window_LocationChanged"
SizeChanged="Window_SizeChanged"
- x:Name="window">
+ x:Name="window">
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml.cs b/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml.cs
index 12bd3e3..82e1754 100644
--- a/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml.cs
+++ b/src/DesktopMagic/BuiltInWindowElements/MusicVisualizerWindow.xaml.cs
@@ -102,7 +102,9 @@ namespace DesktopMagic
ResizeMode = ResizeMode.NoResize;
}
calculate = IsLoaded;
- backgroundGrid.Background = MainWindow.Theme.BackgroundBrush;
+ rectangleGeometry.Rect = new Rect(0, 0, border.ActualWidth, border.ActualHeight);
+ border.CornerRadius = new CornerRadius(MainWindow.Theme.CornerRadius);
+ border.Background = MainWindow.Theme.BackgroundBrush;
});
}
diff --git a/src/DesktopMagic/BuiltInWindowElements/TimeWindow.xaml b/src/DesktopMagic/BuiltInWindowElements/TimeWindow.xaml
index c69bf64..b70eedd 100644
--- a/src/DesktopMagic/BuiltInWindowElements/TimeWindow.xaml
+++ b/src/DesktopMagic/BuiltInWindowElements/TimeWindow.xaml
@@ -13,7 +13,11 @@
x:Name="window">
-
+
+
+
+
+
diff --git a/src/DesktopMagic/BuiltInWindowElements/TimeWindow.xaml.cs b/src/DesktopMagic/BuiltInWindowElements/TimeWindow.xaml.cs
index 363184f..edc65b9 100644
--- a/src/DesktopMagic/BuiltInWindowElements/TimeWindow.xaml.cs
+++ b/src/DesktopMagic/BuiltInWindowElements/TimeWindow.xaml.cs
@@ -72,7 +72,9 @@ namespace DesktopMagic
ResizeMode = ResizeMode.NoResize;
}
- textBlock.Background = MainWindow.Theme.BackgroundBrush;
+ rectangleGeometry.Rect = new Rect(0, 0, border.ActualWidth, border.ActualHeight);
+ border.Background = MainWindow.Theme.BackgroundBrush;
+ border.CornerRadius = new CornerRadius(MainWindow.Theme.CornerRadius);
textBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
textBlock.Foreground = MainWindow.Theme.PrimaryBrush;
//textBlock.Text = DateTime.Now.ToString("hh:mm:ss tt");
diff --git a/src/DesktopMagic/Helpers/SettingElementGenerator.cs b/src/DesktopMagic/Helpers/SettingElementGenerator.cs
new file mode 100644
index 0000000..50248ef
--- /dev/null
+++ b/src/DesktopMagic/Helpers/SettingElementGenerator.cs
@@ -0,0 +1,208 @@
+using DesktopMagic.Plugins;
+
+using System;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace DesktopMagic.Helpers
+{
+ internal class SettingElementGenerator
+ {
+ private readonly ComboBox optionsComboBox;
+
+ public SettingElementGenerator(ComboBox optionsComboBox)
+ {
+ this.optionsComboBox = optionsComboBox;
+ }
+
+ public void Generate(SettingElement settingElement, DockPanel dockPanel, TextBlock textBlock)
+ {
+ dockPanel.UpdateLayout();
+ textBlock.UpdateLayout();
+ if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Label eLabel)
+ {
+ textBlock.Text = eLabel.Value;
+ textBlock.Margin = new Thickness(0, 5, 3, 0);
+ textBlock.HorizontalAlignment = HorizontalAlignment.Stretch;
+ textBlock.TextWrapping = TextWrapping.WrapWithOverflow;
+
+ if (eLabel.Bold)
+ {
+ textBlock.FontWeight = FontWeights.Bold;
+ }
+ eLabel.OnValueChanged += () =>
+ {
+ textBlock.Dispatcher.Invoke(() =>
+ {
+ textBlock.Text = eLabel.Value;
+ });
+ };
+ }
+ else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Button eButton)
+ {
+ Button button = new()
+ {
+ Content = eButton.Value,
+ FontSize = 10,
+ Height = 20,
+ Margin = new Thickness(0, 10, 0, 10),
+ Padding = new Thickness(0),
+ VerticalAlignment = VerticalAlignment.Center,
+ HorizontalAlignment = HorizontalAlignment.Stretch
+ };
+ button.Click += (_s, _e) =>
+ {
+ try
+ {
+ eButton.Click();
+ }
+ catch (Exception ex)
+ {
+ DisplayException(ex.Message);
+ }
+ };
+ eButton.OnValueChanged += () =>
+ {
+ button.Dispatcher.Invoke(() =>
+ {
+ button.Content = eButton.Value;
+ });
+ };
+
+ _ = dockPanel.Children.Add(button);
+ }
+ else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.CheckBox eCheckBox)
+ {
+ CheckBox checkBox = new()
+ {
+ IsChecked = eCheckBox.Value,
+ Style = (Style)dockPanel.FindResource("MaterialDesignDarkCheckBox"),
+ VerticalAlignment = VerticalAlignment.Center,
+ HorizontalAlignment = HorizontalAlignment.Stretch
+ };
+ checkBox.Click += (_s, _e) =>
+ {
+ try
+ {
+ eCheckBox.Value = checkBox.IsChecked.GetValueOrDefault();
+ }
+ catch (Exception ex)
+ {
+ DisplayException(ex.Message);
+ }
+ };
+ eCheckBox.OnValueChanged += () =>
+ {
+ checkBox.Dispatcher.Invoke(() =>
+ {
+ checkBox.IsChecked = eCheckBox.Value;
+ });
+ };
+
+ _ = dockPanel.Children.Add(checkBox);
+ }
+ else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.TextBox eTextBox)
+ {
+ TextBox textBox = new()
+ {
+ Text = eTextBox.Value,
+ TextWrapping = TextWrapping.Wrap,
+ VerticalAlignment = VerticalAlignment.Center,
+ HorizontalAlignment = HorizontalAlignment.Stretch
+ };
+ textBox.TextChanged += (_s, _e) =>
+ {
+ try
+ {
+ eTextBox.Value = textBox.Text;
+ }
+ catch (Exception ex)
+ {
+ DisplayException(ex.Message);
+ }
+ };
+ eTextBox.OnValueChanged += () =>
+ {
+ textBox.Dispatcher.Invoke(() =>
+ {
+ textBox.Text = eTextBox.Value;
+ });
+ };
+ _ = dockPanel.Children.Add(textBox);
+ }
+ else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.IntegerUpDown eIntegerUpDown)
+ {
+ Xceed.Wpf.Toolkit.IntegerUpDown integerUpDown = new()
+ {
+ Value = eIntegerUpDown.Value,
+ Minimum = eIntegerUpDown.Minimum,
+ Maximum = eIntegerUpDown.Maximum,
+ VerticalAlignment = VerticalAlignment.Center,
+ HorizontalAlignment = HorizontalAlignment.Stretch
+ };
+ integerUpDown.ValueChanged += (_s, _e) =>
+ {
+ try
+ {
+ eIntegerUpDown.Value = integerUpDown.Value.GetValueOrDefault();
+ }
+ catch (Exception ex)
+ {
+ DisplayException(ex.Message);
+ }
+ };
+ eIntegerUpDown.OnValueChanged += () =>
+ {
+ integerUpDown.Dispatcher.Invoke(() =>
+ {
+ integerUpDown.Value = eIntegerUpDown.Value;
+ });
+ };
+ _ = dockPanel.Children.Add(integerUpDown);
+ }
+ else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Slider eSlider)
+ {
+ Slider slider = new()
+ {
+ Value = eSlider.Value,
+ Minimum = eSlider.Minimum,
+ Maximum = eSlider.Maximum,
+ TickFrequency = 1,
+ IsSnapToTickEnabled = true,
+ VerticalAlignment = VerticalAlignment.Center,
+ HorizontalAlignment = HorizontalAlignment.Stretch
+ };
+ slider.ValueChanged += (_s, _e) =>
+ {
+ try
+ {
+ eSlider.Value = slider.Value;
+ }
+ catch (Exception ex)
+ {
+ DisplayException(ex.Message);
+ }
+ };
+ eSlider.OnValueChanged += () =>
+ {
+ slider.Dispatcher.Invoke(() =>
+ {
+ slider.Value = eSlider.Value;
+ });
+ };
+
+ _ = dockPanel.Children.Add(slider);
+ }
+ }
+
+ private void DisplayException(string message)
+ {
+ App.Logger.Log(message, "PluginInput");
+ _ = MessageBox.Show("File execution error:\n" + message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ int index = MainWindow.WindowNames.IndexOf(((Tuple)optionsComboBox.SelectedItem).Item1.ToString());
+
+ PluginWindow window = MainWindow.Windows[index] as PluginWindow;
+ window?.Exit();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/DesktopMagic/MainWindow.xaml b/src/DesktopMagic/MainWindow.xaml
index 5b7bb31..11eeeed 100644
--- a/src/DesktopMagic/MainWindow.xaml
+++ b/src/DesktopMagic/MainWindow.xaml
@@ -46,7 +46,7 @@
-
+
@@ -62,7 +62,7 @@
-
+
@@ -74,23 +74,36 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -102,14 +115,14 @@
-
+
-
+
diff --git a/src/DesktopMagic/MainWindow.xaml.cs b/src/DesktopMagic/MainWindow.xaml.cs
index 585c85b..9c4549f 100644
--- a/src/DesktopMagic/MainWindow.xaml.cs
+++ b/src/DesktopMagic/MainWindow.xaml.cs
@@ -26,28 +26,28 @@ namespace DesktopMagic
#region Global settings
internal static Theme Theme = new Theme();
- public static bool EditMode { get; protected set; } = false;
+ public static bool EditMode { get; private set; } = false;
#endregion Global settings
#region Music Visualizer Settings
- public static int SpectrumMode { get; protected set; } = 0;
- public static int AmplifierLevel { get; protected set; } = 0;
- public static bool MirrorMode { get; protected set; } = false;
- public static bool LineMode { get; protected set; } = false;
- public static System.Drawing.Color? MusicVisualzerColor { get; protected set; }
+ public static int SpectrumMode { get; private set; } = 0;
+ public static int AmplifierLevel { get; private set; } = 0;
+ public static bool MirrorMode { get; private set; } = false;
+ public static bool LineMode { get; private set; } = false;
+ public static System.Drawing.Color? MusicVisualzerColor { get; private set; }
#endregion Music Visualizer Settings
#region Plugins settings
- internal static Dictionary> PluginsSettings { get; set; } = new Dictionary>();
+ internal static Dictionary> PluginsSettings { get; } = new Dictionary>();
#endregion Plugins settings
- public static List Windows { get; protected set; } = new List();
- public static List WindowNames { get; protected set; } = new List();
+ public static List Windows { get; } = new List();
+ public static List WindowNames { get; } = new List();
private readonly RegistryKey key;
private readonly System.Windows.Forms.NotifyIcon notifyIcon = new();
@@ -66,7 +66,6 @@ namespace DesktopMagic
notifyIcon.Visible = true;
notifyIcon.Text = App.AppName;
notifyIcon.Icon = new System.Drawing.Icon(iconStream);
- notifyIcon.ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip();
InitializeComponent();
@@ -455,214 +454,30 @@ namespace DesktopMagic
return;
}
+ SettingElementGenerator settingElementGenerator = new SettingElementGenerator(optionsComboBox);
+
foreach (SettingElement settingElement in settingElements)
{
- DockPanel stackPanel = new()
+ DockPanel dockPanel = new()
{
LastChildFill = true,
HorizontalAlignment = HorizontalAlignment.Stretch
};
- _ = optionsPanel.Children.Add(stackPanel);
+ _ = optionsPanel.Children.Add(dockPanel);
- TextBlock label = new()
+ TextBlock textBlock = new()
{
Text = settingElement.Name,
Padding = new Thickness(0, 0, 3, 0),
VerticalAlignment = VerticalAlignment.Center
};
- _ = stackPanel.Children.Add(label);
- stackPanel.UpdateLayout();
- label.UpdateLayout();
-
- if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Label eLabel)
- {
- label.Text = eLabel.Value;
- label.Margin = new Thickness(0, 5, 3, 0);
- label.HorizontalAlignment = HorizontalAlignment.Stretch;
- label.TextWrapping = TextWrapping.WrapWithOverflow;
-
- if (eLabel.Bold)
- {
- label.FontWeight = FontWeights.Bold;
- }
- eLabel.OnValueChanged += () =>
- {
- Dispatcher.Invoke(() =>
- {
- label.Text = eLabel.Value;
- });
- };
- }
- else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Button eButton)
- {
- Button button = new()
- {
- Content = eButton.Value,
- FontSize = 10,
- Height = 20,
- Margin = new Thickness(0, 10, 0, 10),
- Padding = new Thickness(0),
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Stretch
- };
- button.Click += (_s, _e) =>
- {
- try
- {
- eButton.Click();
- }
- catch (Exception ex)
- {
- DisplayException(ex.Message);
- }
- };
- eButton.OnValueChanged += () =>
- {
- Dispatcher.Invoke(() =>
- {
- button.Content = eButton.Value;
- });
- };
-
- _ = stackPanel.Children.Add(button);
- }
- else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.CheckBox eCheckBox)
- {
- CheckBox checkBox = new()
- {
- IsChecked = eCheckBox.Value,
- Style = (Style)FindResource("MaterialDesignDarkCheckBox"),
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Stretch
- };
- checkBox.Click += (_s, _e) =>
- {
- try
- {
- eCheckBox.Value = checkBox.IsChecked.GetValueOrDefault();
- }
- catch (Exception ex)
- {
- DisplayException(ex.Message);
- }
- };
- eCheckBox.OnValueChanged += () =>
- {
- Dispatcher.Invoke(() =>
- {
- checkBox.IsChecked = eCheckBox.Value;
- });
- };
-
- _ = stackPanel.Children.Add(checkBox);
- }
- else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.TextBox eTextBox)
- {
- TextBox textBox = new()
- {
- Text = eTextBox.Value,
- TextWrapping = TextWrapping.Wrap,
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Stretch
- };
- textBox.TextChanged += (_s, _e) =>
- {
- try
- {
- eTextBox.Value = textBox.Text;
- }
- catch (Exception ex)
- {
- DisplayException(ex.Message);
- }
- };
- eTextBox.OnValueChanged += () =>
- {
- Dispatcher.Invoke(() =>
- {
- textBox.Text = eTextBox.Value;
- });
- };
- _ = stackPanel.Children.Add(textBox);
- }
- else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.IntegerUpDown eIntegerUpDown)
- {
- Xceed.Wpf.Toolkit.IntegerUpDown integerUpDown = new()
- {
- Value = eIntegerUpDown.Value,
- Minimum = eIntegerUpDown.Minimum,
- Maximum = eIntegerUpDown.Maximum,
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Stretch
- };
- integerUpDown.ValueChanged += (_s, _e) =>
- {
- try
- {
- eIntegerUpDown.Value = integerUpDown.Value.GetValueOrDefault();
- }
- catch (Exception ex)
- {
- DisplayException(ex.Message);
- }
- };
- eIntegerUpDown.OnValueChanged += () =>
- {
- Dispatcher.Invoke(() =>
- {
- integerUpDown.Value = eIntegerUpDown.Value;
- });
- };
- _ = stackPanel.Children.Add(integerUpDown);
- }
- else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Slider eSlider)
- {
- Slider slider = new()
- {
- Value = eSlider.Value,
- Minimum = eSlider.Minimum,
- Maximum = eSlider.Maximum,
- TickFrequency = 1,
- IsSnapToTickEnabled = true,
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Stretch
- };
- slider.ValueChanged += (_s, _e) =>
- {
- try
- {
- eSlider.Value = slider.Value;
- }
- catch (Exception ex)
- {
- DisplayException(ex.Message);
- }
- };
- eSlider.OnValueChanged += () =>
- {
- Dispatcher.Invoke(() =>
- {
- slider.Value = eSlider.Value;
- });
- };
-
- _ = stackPanel.Children.Add(slider);
- }
+ _ = dockPanel.Children.Add(textBlock);
+ settingElementGenerator.Generate(settingElement, dockPanel, textBlock);
}
}
}
- private void DisplayException(string message)
- {
- App.Logger.Log(message, "PluginInput");
- _ = MessageBox.Show("File execution error:\n" + message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- int index = WindowNames.IndexOf(((Tuple)optionsComboBox.SelectedItem).Item1.ToString());
-
- PluginWindow window = Windows[index] as PluginWindow;
- window?.Exit();
- }
-
#endregion Options
private void TextBlock_Loaded(object sender, RoutedEventArgs e)
@@ -731,6 +546,22 @@ namespace DesktopMagic
}
}
+ private void CornerRadiusTextBox_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ bool sucess = int.TryParse(cornerRadiusTextBox.Text, out int cornerRadius);
+ if (sucess)
+ {
+ cornerRadiusTextBox.Foreground = Brushes.Black;
+ Theme.CornerRadius = cornerRadius;
+ key.SetValue("CornerRadius", cornerRadius);
+ SaveLayout();
+ }
+ else
+ {
+ cornerRadiusTextBox.Foreground = Brushes.Red;
+ }
+ }
+
#region Layout
private void LayoutsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -804,27 +635,32 @@ namespace DesktopMagic
private void SaveLayout()
{
+ if (!loaded)
+ {
+ return;
+ }
+
_ = Task.Run(() =>
- {
- lock (App.ApplicationDataPath)
- {
- List lines = File.ReadAllLines(App.ApplicationDataPath + "\\layouts.save").ToList();
- string content = "";
- foreach (string valueName in key.GetValueNames())
- {
- if (valueName != "SelectedLayout")
- {
- content += valueName + ":" + key.GetValue(valueName).ToString() + ";";
- }
- }
- Dispatcher.Invoke(() =>
- {
- content += layoutsComboBox.SelectedItem.ToString();
- lines[layoutsComboBox.SelectedIndex] = content;
- });
- File.WriteAllLines(App.ApplicationDataPath + "\\layouts.save", lines);
- }
- });
+ {
+ lock (App.ApplicationDataPath)
+ {
+ List lines = File.ReadAllLines(App.ApplicationDataPath + "\\layouts.save").ToList();
+ string content = "";
+ foreach (string valueName in key.GetValueNames())
+ {
+ if (valueName != "SelectedLayout")
+ {
+ content += valueName + ":" + key.GetValue(valueName).ToString() + ";";
+ }
+ }
+ Dispatcher.Invoke(() =>
+ {
+ content += layoutsComboBox.SelectedItem.ToString();
+ lines[layoutsComboBox.SelectedIndex] = content;
+ });
+ File.WriteAllLines(App.ApplicationDataPath + "\\layouts.save", lines);
+ }
+ });
}
private void LoadLayoutNames()
@@ -848,6 +684,7 @@ namespace DesktopMagic
mirrorModeCheckBox.IsChecked = bool.Parse(key.GetValue("MirrorMode", "false").ToString());
lineModeCheckBox.IsChecked = bool.Parse(key.GetValue("LineMode", "false").ToString());
musicVisualizerColorTextBox.Text = key.GetValue("MusicVisualizerColor", "").ToString();
+ cornerRadiusTextBox.Text = key.GetValue("CornerRadius", "0").ToString();
blockWindowsClosing = false;
string primaryColorHex = key.GetValue("PrimaryColor", "#FFFFFFFF").ToString();
@@ -879,6 +716,7 @@ namespace DesktopMagic
LineModeCheckBox_Click(null, null);
SpectrumModeComboBox_SelectionChanged(null, null);
AmplifierLevelSlider_ValueChanged(null, null);
+ CornerRadiusTextBox_TextChanged(null, null);
foreach (Window window in Windows)
{
diff --git a/src/DesktopMagic/Plugins/PluginData.cs b/src/DesktopMagic/Plugins/PluginData.cs
index 3772ad7..c2ade16 100644
--- a/src/DesktopMagic/Plugins/PluginData.cs
+++ b/src/DesktopMagic/Plugins/PluginData.cs
@@ -20,7 +20,7 @@ namespace DesktopMagic.Plugins
public ITheme Theme { get; }
- public Point WindowSize => new Point((int)window.ActualWidth, (int)window.ActualHeight);
+ public Size WindowSize => new Size((int)window.ActualWidth, (int)window.ActualHeight);
public Point WindowPosition => new Point((int)window.Left, (int)window.Top);
diff --git a/src/DesktopMagic/Plugins/PluginWindow.xaml b/src/DesktopMagic/Plugins/PluginWindow.xaml
index 76db4fc..25c0ef6 100644
--- a/src/DesktopMagic/Plugins/PluginWindow.xaml
+++ b/src/DesktopMagic/Plugins/PluginWindow.xaml
@@ -16,10 +16,13 @@
x:Name="window">
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs
index 2339e03..52a7423 100644
--- a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs
+++ b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs
@@ -117,7 +117,9 @@ namespace DesktopMagic
}
else
{
- backgroundGrid.Background = MainWindow.Theme.BackgroundBrush;
+ rectangleGeometry.Rect = new Rect(0, 0, border.ActualWidth, border.ActualHeight);
+ border.Background = MainWindow.Theme.BackgroundBrush;
+ border.CornerRadius = new CornerRadius(MainWindow.Theme.CornerRadius);
}
});
}
diff --git a/src/DesktopMagic/Plugins/Theme.cs b/src/DesktopMagic/Plugins/Theme.cs
index 3398839..0cd89fe 100644
--- a/src/DesktopMagic/Plugins/Theme.cs
+++ b/src/DesktopMagic/Plugins/Theme.cs
@@ -7,12 +7,11 @@ namespace DesktopMagic.Plugins
internal class Theme : ITheme
{
public Color PrimaryColor { get; set; } = Color.White;
-
public Color SecondaryColor { get; set; } = Color.White;
-
public Color BackgroundColor { get; set; } = Color.Transparent;
- public string Font { get; internal set; } = "Segoe UI";
+ public string Font { get; set; } = "Segoe UI";
+ public int CornerRadius { get; set; }
public System.Windows.Media.Brush PrimaryBrush { get; set; } = System.Windows.Media.Brushes.White;
public System.Windows.Media.Brush SecondaryBrush { get; set; } = System.Windows.Media.Brushes.White;
diff --git a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.md b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.md
index 337e908..deaeb57 100644
--- a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.md
+++ b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.md
@@ -34,6 +34,7 @@
- [UpdateWindow()](#M-DesktopMagicPluginAPI-IPluginData-UpdateWindow 'DesktopMagicPluginAPI.IPluginData.UpdateWindow')
- [ITheme](#T-DesktopMagicPluginAPI-ITheme 'DesktopMagicPluginAPI.ITheme')
- [BackgroundColor](#P-DesktopMagicPluginAPI-ITheme-BackgroundColor 'DesktopMagicPluginAPI.ITheme.BackgroundColor')
+ - [CornerRadius](#P-DesktopMagicPluginAPI-ITheme-CornerRadius 'DesktopMagicPluginAPI.ITheme.CornerRadius')
- [Font](#P-DesktopMagicPluginAPI-ITheme-Font 'DesktopMagicPluginAPI.ITheme.Font')
- [PrimaryColor](#P-DesktopMagicPluginAPI-ITheme-PrimaryColor 'DesktopMagicPluginAPI.ITheme.PrimaryColor')
- [SecondaryColor](#P-DesktopMagicPluginAPI-ITheme-SecondaryColor 'DesktopMagicPluginAPI.ITheme.SecondaryColor')
@@ -329,14 +330,14 @@ Defines properties and methods that provide information about the main applicati
##### Summary
-Gets the current color of the main application.
+Gets the current color of the current theme.
### Font `property`
##### Summary
-Gets the current font of the main application.
+Gets the current font of the current theme.
### PluginName `property`
@@ -400,28 +401,35 @@ The theme settings of the main application.
##### Summary
-Gets the background color of the main application.
+Gets the background color of the current theme.
+
+
+### CornerRadius `property`
+
+##### Summary
+
+Gets the corner radius of the current theme.
### Font `property`
##### Summary
-Gets the font of the main application.
+Gets the font of the current theme.
### PrimaryColor `property`
##### Summary
-Gets the primary color of the main application.
+Gets the primary color of the current theme.
### SecondaryColor `property`
##### Summary
-Gets the secondary color of the main application.
+Gets the secondary color of the current theme.
## IntegerUpDown `type`
diff --git a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.xml b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.xml
index 7b63b4f..fe9d03f 100644
--- a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.xml
+++ b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.xml
@@ -283,12 +283,12 @@
- Gets the current font of the main application.
+ Gets the current font of the current theme.
- Gets the current color of the main application.
+ Gets the current color of the current theme.
@@ -328,22 +328,27 @@
- Gets the primary color of the main application.
+ Gets the primary color of the current theme.
- Gets the secondary color of the main application.
+ Gets the secondary color of the current theme.
- Gets the background color of the main application.
+ Gets the background color of the current theme.
- Gets the font of the main application.
+ Gets the font of the current theme.
+
+
+
+
+ Gets the corner radius of the current theme.
diff --git a/src/DesktopMagicPluginAPI/IPluginData.cs b/src/DesktopMagicPluginAPI/IPluginData.cs
index 823ac85..aaabd7a 100644
--- a/src/DesktopMagicPluginAPI/IPluginData.cs
+++ b/src/DesktopMagicPluginAPI/IPluginData.cs
@@ -9,13 +9,13 @@ namespace DesktopMagicPluginAPI
public interface IPluginData
{
///
- /// Gets the current font of the main application.
+ /// Gets the current font of the current theme.
///
[Obsolete("Use the \"Theme\" property instead")]
string Font { get; }
///
- /// Gets the current color of the main application.
+ /// Gets the current color of the current theme.
///
[Obsolete("Use the \"Theme\" property instead")]
Color Color { get; }
@@ -28,7 +28,7 @@ namespace DesktopMagicPluginAPI
///
/// Gets the window size of the plugin window.
///
- Point WindowSize { get; }
+ Size WindowSize { get; }
///
/// Gets the window position of the plugin window.
diff --git a/src/DesktopMagicPluginAPI/ITheme.cs b/src/DesktopMagicPluginAPI/ITheme.cs
index 43b587c..4f61901 100644
--- a/src/DesktopMagicPluginAPI/ITheme.cs
+++ b/src/DesktopMagicPluginAPI/ITheme.cs
@@ -8,23 +8,28 @@ namespace DesktopMagicPluginAPI
public interface ITheme
{
///
- /// Gets the primary color of the main application.
+ /// Gets the primary color of the current theme.
///
Color PrimaryColor { get; }
///
- /// Gets the secondary color of the main application.
+ /// Gets the secondary color of the current theme.
///
Color SecondaryColor { get; }
///
- /// Gets the background color of the main application.
+ /// Gets the background color of the current theme.
///
Color BackgroundColor { get; }
///
- /// Gets the font of the main application.
+ /// Gets the font of the current theme.
///
string Font { get; }
+
+ ///
+ /// Gets the corner radius of the current theme.
+ ///
+ int CornerRadius { get; }
}
}
\ No newline at end of file