- Improve code structure

- Improve log output format
This commit is contained in:
Stone-Red-Code
2021-10-24 19:38:45 +02:00
parent 77a1383e7b
commit 520f145eb0
30 changed files with 216 additions and 129 deletions
+4 -4
View File
@@ -33,11 +33,11 @@ namespace DesktopMagic
// Try to grab mutex // Try to grab mutex
_mutex = new Mutex(true, $"Stone_Red{AppName}", out bool createdNew); _mutex = new Mutex(true, $"Stone_Red{AppName}", out bool createdNew);
//check if creating new was succesfull //check if creating new was successful
if (!createdNew) if (!createdNew)
{ {
Logger.Log("Shutting down because other instance already running.", "Setup"); Logger.Log("Shutting down because other instance already running.", "Setup");
//Shutdown Aplication //Shutdown Application
Current.Shutdown(); Current.Shutdown();
} }
else else
@@ -59,7 +59,7 @@ namespace DesktopMagic
private void Updater_NoUpdateAvailible() private void Updater_NoUpdateAvailible()
{ {
Logger.Log("No update avalible.", "Updater"); Logger.Log("No update available.", "Updater");
} }
private void Updater_OnException(Exception exception) private void Updater_OnException(Exception exception)
@@ -114,7 +114,7 @@ namespace DesktopMagic
}, },
FormatConfig = new FormatConfig() FormatConfig = new FormatConfig()
{ {
DebugConsoleFormat = $"> {{{LogFormatType.DateTime}:hh:mm:ss}} | {{{LogFormatType.LogSeverity},-5}} | {{{LogFormatType.Message}}}\n> at {{{LogFormatType.LineNumber},3}} | {{{LogFormatType.FilePath}}}" DebugConsoleFormat = $"> {{{LogFormatType.DateTime}:hh:mm:ss}} | {{{LogFormatType.LogSeverity},-5}} | {{{LogFormatType.Message}}}\nat {{{LogFormatType.LineNumber}}} | {{{LogFormatType.FilePath}}}"
} }
}; };
Logger.ClearLogFile(LogSeverity.Info); Logger.ClearLogFile(LogSeverity.Info);
@@ -10,9 +10,6 @@ using System.Windows.Media;
namespace DesktopMagic namespace DesktopMagic
{ {
/// <summary>
/// Interaktionslogik für TimeWindow.xaml
/// </summary>
[Obsolete("Disabled due to lack of support (too much work)")] [Obsolete("Disabled due to lack of support (too much work)")]
public partial class CalendarWindow : Window public partial class CalendarWindow : Window
{ {
@@ -40,7 +37,7 @@ namespace DesktopMagic
Timer t = new Timer(); Timer t = new Timer();
t.Interval = 100; t.Interval = 100;
t.Elapsed += T_Elapsed; t.Elapsed += UpdateTimer_Elapsed;
t.Start(); t.Start();
Timer valueTimer = new Timer(); Timer valueTimer = new Timer();
@@ -88,7 +85,7 @@ namespace DesktopMagic
}); });
} }
private void T_Elapsed(object sender, ElapsedEventArgs e) private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
@@ -102,10 +99,10 @@ namespace DesktopMagic
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
WindowPos.SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
} }
if (MainWindow.GlobalFont != oldFont || MainWindow.GlobalColor != oldColor) if (MainWindow.Theme.Font != oldFont || MainWindow.Theme.PrimaryBrush != oldColor)
{ {
oldColor = MainWindow.GlobalColor; oldColor = MainWindow.Theme.PrimaryBrush;
oldFont = MainWindow.GlobalFont; oldFont = MainWindow.Theme.Font;
LoadEvents(); LoadEvents();
} }
listBox.SelectedIndex = -1; listBox.SelectedIndex = -1;
@@ -117,22 +114,19 @@ namespace DesktopMagic
listBox.Items.Clear(); listBox.Items.Clear();
CalendarItems calendarItem = new CalendarItems(); CalendarItems calendarItem = new CalendarItems();
calendarItem.eventname = "Termine: "; calendarItem.eventname = "Termine: ";
calendarItem.font = MainWindow.GlobalFont; calendarItem.font = MainWindow.Theme.Font;
calendarItem.color = MainWindow.GlobalColor.ToString(); calendarItem.color = MainWindow.Theme.PrimaryColor.ToString();
listBox.Items.Add(calendarItem); listBox.Items.Add(calendarItem);
for (int i = 0; i < upcomingEventNames.Count; i++) for (int i = 0; i < upcomingEventNames.Count; i++)
{ {
DateTime dateTime = DateTime.Now;
DateTime.TryParse(upcomingEventTimes[i], out dateTime);
calendarItem = new CalendarItems(); calendarItem = new CalendarItems();
calendarItem.eventname = upcomingEventNames[i]; calendarItem.eventname = upcomingEventNames[i];
calendarItem.dateTime = dateTime.ToString("dd-MM-yyyy"); calendarItem.dateTime = DateTime.Now.ToString("dd-MM-yyyy");
calendarItem.font = MainWindow.GlobalFont; calendarItem.font = MainWindow.Theme.Font;
calendarItem.color = MainWindow.GlobalColor.ToString(); calendarItem.color = MainWindow.Theme.PrimaryBrush.ToString();
if (dateTime < DateTime.Today.AddMonths(12) || upcomingEventTimes[i] == "-") if (DateTime.Now < DateTime.Today.AddMonths(12) || upcomingEventTimes[i] == "-")
{ {
listBox.Items.Add(calendarItem); listBox.Items.Add(calendarItem);
} }
@@ -6,12 +6,10 @@ using System.Timers;
using System.Windows; using System.Windows;
using System.Windows.Interop; using System.Windows.Interop;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Threading;
namespace DesktopMagic namespace DesktopMagic
{ {
/// <summary>
/// Interaktionslogik für TimeWindow.xaml
/// </summary>
public partial class CpuUsageWindow : Window public partial class CpuUsageWindow : Window
{ {
private RegistryKey key; private RegistryKey key;
@@ -41,7 +39,7 @@ namespace DesktopMagic
Timer t = new Timer(); Timer t = new Timer();
t.Interval = 100; t.Interval = 100;
t.Elapsed += T_Elapsed; t.Elapsed += UpdateTimer_Elapsed;
t.Start(); t.Start();
Timer valueTimer = new Timer(); Timer valueTimer = new Timer();
@@ -68,7 +66,7 @@ namespace DesktopMagic
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
} }
private void T_Elapsed(object sender, ElapsedEventArgs e) private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
@@ -83,8 +81,8 @@ namespace DesktopMagic
WindowPos.SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
} }
textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont); textBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
textBlock.Foreground = MainWindow.GlobalColor; textBlock.Foreground = MainWindow.Theme.PrimaryBrush;
}); });
} }
@@ -8,9 +8,6 @@ using System.Windows.Media;
namespace DesktopMagic namespace DesktopMagic
{ {
/// <summary>
/// Interaktionslogik für TimeWindow.xaml
/// </summary>
public partial class DateWindow : Window public partial class DateWindow : Window
{ {
private RegistryKey key; private RegistryKey key;
@@ -33,7 +30,7 @@ namespace DesktopMagic
Timer t = new Timer(); Timer t = new Timer();
t.Interval = 100; t.Interval = 100;
t.Elapsed += T_Elapsed; t.Elapsed += UpdateTimer_Elapsed;
t.Start(); t.Start();
key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName); key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName);
@@ -54,7 +51,7 @@ namespace DesktopMagic
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
} }
private void T_Elapsed(object sender, ElapsedEventArgs e) private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
@@ -68,8 +65,8 @@ namespace DesktopMagic
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
WindowPos.SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
} }
textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont); textBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
textBlock.Foreground = MainWindow.GlobalColor; textBlock.Foreground = MainWindow.Theme.PrimaryBrush;
textBlock.Text = DateTime.Now.ToString("D"); textBlock.Text = DateTime.Now.ToString("D");
}); });
} }
@@ -57,7 +57,7 @@ namespace DesktopMagic
Timer t = new Timer(); Timer t = new Timer();
t.Interval = 100; t.Interval = 100;
t.Elapsed += T_Elapsed; t.Elapsed += UpdateTimer_Elapsed;
t.Start(); t.Start();
key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName); key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName);
@@ -83,7 +83,7 @@ namespace DesktopMagic
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
} }
private void T_Elapsed(object sender, ElapsedEventArgs e) private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
@@ -299,13 +299,13 @@ namespace DesktopMagic
SetPoints(points, bm.Width, bm.Height, offset); SetPoints(points, bm.Width, bm.Height, offset);
Brush brush; Brush brush;
if (MainWindow.MusicVisualzerColor == null) if (MainWindow.MusicVisualzerColor.HasValue)
{ {
brush = MainWindow.GlobalSystemColor; brush = new SolidBrush(MainWindow.MusicVisualzerColor.Value);
} }
else else
{ {
brush = MainWindow.MusicVisualzerColor; brush = new SolidBrush(MainWindow.Theme.PrimaryColor);
} }
if (MainWindow.LineMode) if (MainWindow.LineMode)
@@ -340,7 +340,7 @@ namespace DesktopMagic
{ {
case 1: case 1:
points[0] = new PointF(width, height / 2); points[0] = new PointF(width, height / 2);
points[points.Length - 1] = new PointF(0, height / 2); points[^1] = new PointF(0, height / 2);
points[points.Length / 2] = new PointF(width, height / 2); points[points.Length / 2] = new PointF(width, height / 2);
points[points.Length / 2 - 1] = new PointF(0, height / 2); points[points.Length / 2 - 1] = new PointF(0, height / 2);
@@ -348,12 +348,12 @@ namespace DesktopMagic
case 2: case 2:
points[0] = new PointF(0, 0 - offset); points[0] = new PointF(0, 0 - offset);
points[points.Length - 1] = new PointF(points[points.Length - 2].X, 0 - offset); points[^1] = new PointF(points[^2].X, 0 - offset);
break; break;
default: default:
points[0] = new PointF(0, height); points[0] = new PointF(0, height);
points[points.Length - 1] = new PointF(points[points.Length - 2].X, height); points[^1] = new PointF(points[^2].X, height);
break; break;
} }
} }
@@ -376,8 +376,8 @@ namespace DesktopMagic
private void Window_LocationChanged(object sender, EventArgs e) private void Window_LocationChanged(object sender, EventArgs e)
{ {
key.SetValue("MusicVisualizerWindowTop", this.Top); key.SetValue("MusicVisualizerWindowTop", Top);
key.SetValue("MusicVisualizerWindowLeft", this.Left); key.SetValue("MusicVisualizerWindowLeft", Left);
} }
private void Window_SizeChanged(object sender, SizeChangedEventArgs e) private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
@@ -8,9 +8,6 @@ using System.Windows.Media;
namespace DesktopMagic namespace DesktopMagic
{ {
/// <summary>
/// Interaktionslogik für TimeWindow.xaml
/// </summary>
public partial class TimeWindow : Window public partial class TimeWindow : Window
{ {
private RegistryKey key; private RegistryKey key;
@@ -33,7 +30,7 @@ namespace DesktopMagic
Timer t = new Timer(); Timer t = new Timer();
t.Interval = 100; t.Interval = 100;
t.Elapsed += T_Elapsed; t.Elapsed += UpdateTimer_Elapsed;
t.Start(); t.Start();
key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName); key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName);
@@ -54,7 +51,7 @@ namespace DesktopMagic
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
} }
private void T_Elapsed(object sender, ElapsedEventArgs e) private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
@@ -69,8 +66,8 @@ namespace DesktopMagic
WindowPos.SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
} }
textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont); textBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
textBlock.Foreground = MainWindow.GlobalColor; textBlock.Foreground = MainWindow.Theme.PrimaryBrush;
//textBlock.Text = DateTime.Now.ToString("hh:mm:ss tt"); //textBlock.Text = DateTime.Now.ToString("hh:mm:ss tt");
textBlock.Text = DateTime.Now.ToString("HH:mm:ss"); textBlock.Text = DateTime.Now.ToString("HH:mm:ss");
}); });
+1 -2
View File
@@ -5,5 +5,4 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Performance", "CA1822:Member als statisch markieren", Justification = "<Ausstehend>", Scope = "member", Target = "~M:DesktopMagic.PluginWindow.LoadOptions(System.Object)")] [assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Windows only application")]
[assembly: SuppressMessage("Style", "IDE0090:Use 'new(...)'", Justification = "<Pending>", Scope = "member", Target = "~M:DesktopMagic.MainWindow.GithubButton_Click(System.Object,System.Windows.RoutedEventArgs)")]
+4 -7
View File
@@ -4,23 +4,20 @@ using System.Windows;
namespace DesktopMagic namespace DesktopMagic
{ {
/// <summary>
/// Interaktionslogik für InputDialog.xaml
/// </summary>
public partial class InputDialog : Window public partial class InputDialog : Window
{ {
public InputDialog(string content, string title = "InputDialog") public InputDialog(string content, string title = "InputDialog")
{ {
InitializeComponent(); InitializeComponent();
label.Content = content; label.Content = content;
this.Title = title; Title = title;
SetLanguageDictionary(); SetLanguageDictionary();
} }
public string ResponseText public string ResponseText
{ {
get { return textBox.Text; } get => textBox.Text;
set { textBox.Text = value; } set => textBox.Text = value;
} }
private void OkButton_Click(object sender, RoutedEventArgs e) private void OkButton_Click(object sender, RoutedEventArgs e)
@@ -46,7 +43,7 @@ namespace DesktopMagic
{ {
dict.Source = new Uri("..\\Resources\\StringResources.en.xaml", UriKind.Relative); dict.Source = new Uri("..\\Resources\\StringResources.en.xaml", UriKind.Relative);
} }
this.Resources.MergedDictionaries.Add(dict); Resources.MergedDictionaries.Add(dict);
} }
} }
} }
+16 -22
View File
@@ -1,4 +1,6 @@
using Microsoft.Win32; using DesktopMagic.Plugins;
using Microsoft.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -14,17 +16,11 @@ using System.Windows.Media;
namespace DesktopMagic namespace DesktopMagic
{ {
/// <summary>
/// Interaktionslogik für MainWindow.xaml
/// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
#region Global settings #region Global settings
public static string GlobalFont { get; protected set; } = "Segoe UI"; internal static Theme Theme = new Theme();
public static Brush GlobalColor { get; protected set; } = Brushes.White;
public static System.Drawing.Brush GlobalSystemColor { get; protected set; } = System.Drawing.Brushes.White;
public static bool EditMode { get; protected set; } = false; public static bool EditMode { get; protected set; } = false;
#endregion Global settings #endregion Global settings
@@ -35,7 +31,7 @@ namespace DesktopMagic
public static int AmplifierLevel { get; protected set; } = 0; public static int AmplifierLevel { get; protected set; } = 0;
public static bool MirrorMode { get; protected set; } = false; public static bool MirrorMode { get; protected set; } = false;
public static bool LineMode { get; protected set; } = false; public static bool LineMode { get; protected set; } = false;
public static System.Drawing.Brush MusicVisualzerColor { get; protected set; } public static System.Drawing.Color? MusicVisualzerColor { get; protected set; }
#endregion Music Visualizer Settings #endregion Music Visualizer Settings
@@ -160,17 +156,17 @@ namespace DesktopMagic
checkBox.Style = (Style)FindResource("MaterialDesignDarkCheckBox"); checkBox.Style = (Style)FindResource("MaterialDesignDarkCheckBox");
checkBox.Click += CheckBox_Click; checkBox.Click += CheckBox_Click;
bool exsists = false; bool exists = false;
foreach (UIElement item in stackPanel.Children) foreach (UIElement item in stackPanel.Children)
{ {
if (((CheckBox)item).Name == "_PluginCb_" + clearPluginName) if (((CheckBox)item).Name == "_PluginCb_" + clearPluginName)
{ {
exsists = true; exists = true;
break; break;
} }
} }
if (!exsists) if (!exists)
{ {
_ = stackPanel.Children.Add(checkBox); _ = stackPanel.Children.Add(checkBox);
} }
@@ -396,9 +392,8 @@ namespace DesktopMagic
hex = hex.Replace("#", ""); hex = hex.Replace("#", "");
System.Drawing.Color systemColor = System.Drawing.Color.FromArgb((byte)int.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber), (byte)int.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber), (byte)int.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber)); System.Drawing.Color systemColor = System.Drawing.Color.FromArgb((byte)int.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber), (byte)int.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber), (byte)int.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber));
System.Drawing.Brush systemBrush = new System.Drawing.SolidBrush(systemColor);
MusicVisualzerColor = systemBrush; MusicVisualzerColor = systemColor;
musicVisualizerColorTextBox.Foreground = Brushes.Black; musicVisualizerColorTextBox.Foreground = Brushes.Black;
key.SetValue("MusicVisualizerColor", musicVisualizerColorTextBox.Text); key.SetValue("MusicVisualizerColor", musicVisualizerColorTextBox.Text);
@@ -419,8 +414,8 @@ namespace DesktopMagic
private void FontComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) private void FontComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
GlobalFont = fontComboBox.SelectedValue.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", ""); Theme.Font = fontComboBox.SelectedValue.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
key.SetValue("Font", GlobalFont); key.SetValue("Font", Theme.Font);
SaveLayout(); SaveLayout();
} }
@@ -679,7 +674,7 @@ namespace DesktopMagic
}; };
_ = fontComboBox.Items.Add(comboBoxItem); _ = fontComboBox.Items.Add(comboBoxItem);
if (ff.ToString() == GlobalFont) if (ff.ToString() == Theme.Font)
{ {
fontComboBox.SelectedIndex = index; fontComboBox.SelectedIndex = index;
} }
@@ -738,10 +733,9 @@ namespace DesktopMagic
blueSlider.Value = color.B; blueSlider.Value = color.B;
Brush brush = new SolidColorBrush(color); Brush brush = new SolidColorBrush(color);
System.Drawing.Brush systemBrush = new System.Drawing.SolidBrush(systemColor);
GlobalColor = brush; Theme.PrimaryBrush = brush;
GlobalSystemColor = systemBrush; Theme.PrimaryColor = systemColor;
colorRechtangle.Fill = brush; colorRechtangle.Fill = brush;
colorHexTextBox.Foreground = Brushes.Black; colorHexTextBox.Foreground = Brushes.Black;
@@ -784,7 +778,7 @@ namespace DesktopMagic
for (int i = 0; i < fontComboBox.Items.Count; i++) for (int i = 0; i < fontComboBox.Items.Count; i++)
{ {
ComboBoxItem comboBoxItem = (ComboBoxItem)fontComboBox.Items[i]; ComboBoxItem comboBoxItem = (ComboBoxItem)fontComboBox.Items[i];
if (comboBoxItem.FontFamily.ToString() == GlobalFont) if (comboBoxItem.FontFamily.ToString() == Theme.Font)
{ {
fontComboBox.SelectedIndex = i; fontComboBox.SelectedIndex = i;
} }
@@ -867,7 +861,7 @@ namespace DesktopMagic
private void LoadLayout(bool minimize = true) private void LoadLayout(bool minimize = true)
{ {
GlobalFont = key.GetValue("Font", "Segoe UI").ToString(); Theme.Font = key.GetValue("Font", "Segoe UI").ToString();
spectrumModeComboBox.SelectedIndex = int.Parse(key.GetValue("SpectrumMode", "0").ToString()); spectrumModeComboBox.SelectedIndex = int.Parse(key.GetValue("SpectrumMode", "0").ToString());
amplifierLevelSlider.Value = int.Parse(key.GetValue("AmplifierLevel", "0").ToString()); amplifierLevelSlider.Value = int.Parse(key.GetValue("AmplifierLevel", "0").ToString());
mirrorModeCheckBox.IsChecked = bool.Parse(key.GetValue("MirrorMode", "false").ToString()); mirrorModeCheckBox.IsChecked = bool.Parse(key.GetValue("MirrorMode", "false").ToString());
@@ -1,20 +1,24 @@
using DesktopMagicPluginAPI; using DesktopMagicPluginAPI;
using System.Drawing; using System.Drawing;
namespace DesktopMagic namespace DesktopMagic.Plugins
{ {
internal class PluginData : IPluginData internal class PluginData : IPluginData
{ {
private readonly PluginWindow window; private readonly PluginWindow window;
public PluginData(PluginWindow win) public PluginData(PluginWindow window)
{ {
window = win; this.window = window;
Theme = MainWindow.Theme;
} }
public string Font => MainWindow.GlobalFont; public string Font => Theme.Font;
public Color Color => (MainWindow.GlobalSystemColor as SolidBrush).Color; public Color Color => Theme.PrimaryColor;
public ITheme Theme { get; }
public Point WindowSize => new Point((int)window.ActualWidth, (int)window.ActualHeight); public Point WindowSize => new Point((int)window.ActualWidth, (int)window.ActualHeight);
@@ -24,6 +28,9 @@ namespace DesktopMagic
public string PluginPath => window.PluginFolderPath; public string PluginPath => window.PluginFolderPath;
public void UpdateWindow() => window.UpdatePluginWindow(); public void UpdateWindow()
{
window.UpdatePluginWindow();
}
} }
} }
@@ -1,4 +1,6 @@
using DesktopMagicPluginAPI; using DesktopMagic.Plugins;
using DesktopMagicPluginAPI;
using DesktopMagicPluginAPI.Drawing; using DesktopMagicPluginAPI.Drawing;
using DesktopMagicPluginAPI.Inputs; using DesktopMagicPluginAPI.Inputs;
@@ -20,20 +22,16 @@ using System.Windows.Media.Imaging;
namespace DesktopMagic namespace DesktopMagic
{ {
/// <summary>
/// Interaktionslogik für PluginWindow.xaml
/// </summary>
///
public partial class PluginWindow : Window public partial class PluginWindow : Window
{ {
private readonly RegistryKey key; private readonly RegistryKey key;
private Thread pluginThread; private Thread pluginThread;
private System.Timers.Timer valueTimer; private System.Timers.Timer valueTimer;
private bool stop = false;
private Plugin pluginClassInstance; private Plugin pluginClassInstance;
public string PluginName { get; private set; } public string PluginName { get; private set; }
public string PluginFolderPath { get; private set; } public string PluginFolderPath { get; private set; }
private bool stop = false;
public event Action PluginLoaded; public event Action PluginLoaded;
@@ -59,7 +57,7 @@ namespace DesktopMagic
System.Timers.Timer t = new System.Timers.Timer(); System.Timers.Timer t = new System.Timers.Timer();
t.Interval = 100; t.Interval = 100;
t.Elapsed += Elapsed; t.Elapsed += UpdateTimer_Elapsed;
t.Start(); t.Start();
PluginName = pluginName; PluginName = pluginName;
@@ -95,7 +93,7 @@ namespace DesktopMagic
ValueTimer_Elapsed(valueTimer, null); ValueTimer_Elapsed(valueTimer, null);
} }
private void Elapsed(object sender, ElapsedEventArgs e) private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
@@ -1,11 +1,6 @@
using DesktopMagicPluginAPI.Inputs; using DesktopMagicPluginAPI.Inputs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DesktopMagic namespace DesktopMagic.Plugins
{ {
internal class SettingElement internal class SettingElement
{ {
+18
View File
@@ -0,0 +1,18 @@
using DesktopMagicPluginAPI;
using System.Drawing;
namespace DesktopMagic.Plugins
{
internal class Theme : ITheme
{
public Color PrimaryColor { get; internal set; } = Color.White;
public Color SecondaryColor { get; internal set; } = Color.White;
public string Font { get; internal set; } = "Segoe UI";
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;
}
}
-14
View File
@@ -1,14 +0,0 @@
{
"installed": {
"client_id": "347834359081-0cgj2l2f6a11m25dckg9beuvsclfsd8b.apps.googleusercontent.com",
"project_id": "helfer-1600602266879",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "IlzL9Hh_AycZ5qOTFDIGmF6w",
"redirect_uris": [
"urn:ietf:wg:oauth:2.0:oob",
"http://localhost"
]
}
}
+7 -2
View File
@@ -1,11 +1,12 @@
using DesktopMagicPluginAPI; using DesktopMagicPluginAPI;
using DesktopMagicPluginAPI.Inputs; using DesktopMagicPluginAPI.Inputs;
using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using System;
namespace DesktopMagicPlugin.Test namespace DesktopMagicPlugin.Test
{ {
@@ -71,12 +72,16 @@ namespace DesktopMagicPlugin.Test
public override Bitmap Main() public override Bitmap Main()
{ {
if (bitmaps.Count == 0) if (bitmaps.Count == 0)
{
return new Bitmap(1, 1); return new Bitmap(1, 1);
}
frameCount++; frameCount++;
if (frameCount >= bitmaps.Count) if (frameCount >= bitmaps.Count)
{
frameCount = 0; frameCount = 0;
}
return bitmaps[frameCount]; return bitmaps[frameCount];
} }
@@ -28,9 +28,14 @@
- [Font](#P-DesktopMagicPluginAPI-IPluginData-Font 'DesktopMagicPluginAPI.IPluginData.Font') - [Font](#P-DesktopMagicPluginAPI-IPluginData-Font 'DesktopMagicPluginAPI.IPluginData.Font')
- [PluginName](#P-DesktopMagicPluginAPI-IPluginData-PluginName 'DesktopMagicPluginAPI.IPluginData.PluginName') - [PluginName](#P-DesktopMagicPluginAPI-IPluginData-PluginName 'DesktopMagicPluginAPI.IPluginData.PluginName')
- [PluginPath](#P-DesktopMagicPluginAPI-IPluginData-PluginPath 'DesktopMagicPluginAPI.IPluginData.PluginPath') - [PluginPath](#P-DesktopMagicPluginAPI-IPluginData-PluginPath 'DesktopMagicPluginAPI.IPluginData.PluginPath')
- [Theme](#P-DesktopMagicPluginAPI-IPluginData-Theme 'DesktopMagicPluginAPI.IPluginData.Theme')
- [WindowPosition](#P-DesktopMagicPluginAPI-IPluginData-WindowPosition 'DesktopMagicPluginAPI.IPluginData.WindowPosition') - [WindowPosition](#P-DesktopMagicPluginAPI-IPluginData-WindowPosition 'DesktopMagicPluginAPI.IPluginData.WindowPosition')
- [WindowSize](#P-DesktopMagicPluginAPI-IPluginData-WindowSize 'DesktopMagicPluginAPI.IPluginData.WindowSize') - [WindowSize](#P-DesktopMagicPluginAPI-IPluginData-WindowSize 'DesktopMagicPluginAPI.IPluginData.WindowSize')
- [UpdateWindow()](#M-DesktopMagicPluginAPI-IPluginData-UpdateWindow 'DesktopMagicPluginAPI.IPluginData.UpdateWindow') - [UpdateWindow()](#M-DesktopMagicPluginAPI-IPluginData-UpdateWindow 'DesktopMagicPluginAPI.IPluginData.UpdateWindow')
- [ITheme](#T-DesktopMagicPluginAPI-ITheme 'DesktopMagicPluginAPI.ITheme')
- [Font](#P-DesktopMagicPluginAPI-ITheme-Font 'DesktopMagicPluginAPI.ITheme.Font')
- [PrimaryColor](#P-DesktopMagicPluginAPI-ITheme-PrimaryColor 'DesktopMagicPluginAPI.ITheme.PrimaryColor')
- [SecondaryColor](#P-DesktopMagicPluginAPI-ITheme-SecondaryColor 'DesktopMagicPluginAPI.ITheme.SecondaryColor')
- [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown') - [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown')
- [#ctor(min,max,value)](#M-DesktopMagicPluginAPI-Inputs-IntegerUpDown-#ctor-System-Int32,System-Int32,System-Int32- 'DesktopMagicPluginAPI.Inputs.IntegerUpDown.#ctor(System.Int32,System.Int32,System.Int32)') - [#ctor(min,max,value)](#M-DesktopMagicPluginAPI-Inputs-IntegerUpDown-#ctor-System-Int32,System-Int32,System-Int32- 'DesktopMagicPluginAPI.Inputs.IntegerUpDown.#ctor(System.Int32,System.Int32,System.Int32)')
- [Maximum](#P-DesktopMagicPluginAPI-Inputs-IntegerUpDown-Maximum 'DesktopMagicPluginAPI.Inputs.IntegerUpDown.Maximum') - [Maximum](#P-DesktopMagicPluginAPI-Inputs-IntegerUpDown-Maximum 'DesktopMagicPluginAPI.Inputs.IntegerUpDown.Maximum')
@@ -323,14 +328,14 @@ Defines properties and methods that provide information about the main applicati
##### Summary ##### Summary
Gets the color of the main application. Gets the current color of the main application.
<a name='P-DesktopMagicPluginAPI-IPluginData-Font'></a> <a name='P-DesktopMagicPluginAPI-IPluginData-Font'></a>
### Font `property` ### Font `property`
##### Summary ##### Summary
Gets the font of the main application. Gets the current font of the main application.
<a name='P-DesktopMagicPluginAPI-IPluginData-PluginName'></a> <a name='P-DesktopMagicPluginAPI-IPluginData-PluginName'></a>
### PluginName `property` ### PluginName `property`
@@ -346,6 +351,13 @@ Gets the name of the plugin.
Gets the path of the parent directory of the plugin. Gets the path of the parent directory of the plugin.
<a name='P-DesktopMagicPluginAPI-IPluginData-Theme'></a>
### Theme `property`
##### Summary
Gets the current theme setting of the main application.
<a name='P-DesktopMagicPluginAPI-IPluginData-WindowPosition'></a> <a name='P-DesktopMagicPluginAPI-IPluginData-WindowPosition'></a>
### WindowPosition `property` ### WindowPosition `property`
@@ -371,6 +383,38 @@ Updates the plugin window.
This method has no parameters. This method has no parameters.
<a name='T-DesktopMagicPluginAPI-ITheme'></a>
## ITheme `type`
##### Namespace
DesktopMagicPluginAPI
##### Summary
The theme settings of the main application.
<a name='P-DesktopMagicPluginAPI-ITheme-Font'></a>
### Font `property`
##### Summary
Gets the font of the main application.
<a name='P-DesktopMagicPluginAPI-ITheme-PrimaryColor'></a>
### PrimaryColor `property`
##### Summary
Gets the primary color of the main application.
<a name='P-DesktopMagicPluginAPI-ITheme-SecondaryColor'></a>
### SecondaryColor `property`
##### Summary
Gets the secondary color of the main application.
<a name='T-DesktopMagicPluginAPI-Inputs-IntegerUpDown'></a> <a name='T-DesktopMagicPluginAPI-Inputs-IntegerUpDown'></a>
## IntegerUpDown `type` ## IntegerUpDown `type`
@@ -588,7 +632,7 @@ Occurs when the user rotates the mouse wheel while the mouse pointer is over thi
##### Summary ##### Summary
Occurs once when the pugin gets activated. Occurs once when the plugin gets activated.
##### Parameters ##### Parameters
@@ -283,12 +283,17 @@
</member> </member>
<member name="P:DesktopMagicPluginAPI.IPluginData.Font"> <member name="P:DesktopMagicPluginAPI.IPluginData.Font">
<summary> <summary>
Gets the font of the main application. Gets the current font of the main application.
</summary> </summary>
</member> </member>
<member name="P:DesktopMagicPluginAPI.IPluginData.Color"> <member name="P:DesktopMagicPluginAPI.IPluginData.Color">
<summary> <summary>
Gets the color of the main application. Gets the current color of the main application.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.IPluginData.Theme">
<summary>
Gets the current theme setting of the main application.
</summary> </summary>
</member> </member>
<member name="P:DesktopMagicPluginAPI.IPluginData.WindowSize"> <member name="P:DesktopMagicPluginAPI.IPluginData.WindowSize">
@@ -316,6 +321,26 @@
Updates the plugin window. Updates the plugin window.
</summary> </summary>
</member> </member>
<member name="T:DesktopMagicPluginAPI.ITheme">
<summary>
The theme settings of the main application.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.ITheme.PrimaryColor">
<summary>
Gets the primary color of the main application.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.ITheme.SecondaryColor">
<summary>
Gets the secondary color of the main application.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.ITheme.Font">
<summary>
Gets the font of the main application.
</summary>
</member>
<member name="T:DesktopMagicPluginAPI.Plugin"> <member name="T:DesktopMagicPluginAPI.Plugin">
<summary> <summary>
The plugin class. The plugin class.
@@ -338,7 +363,7 @@
</member> </member>
<member name="M:DesktopMagicPluginAPI.Plugin.Start"> <member name="M:DesktopMagicPluginAPI.Plugin.Start">
<summary> <summary>
Occurs once when the pugin gets activated. Occurs once when the plugin gets activated.
</summary> </summary>
</member> </member>
<member name="M:DesktopMagicPluginAPI.Plugin.Main"> <member name="M:DesktopMagicPluginAPI.Plugin.Main">
+11 -3
View File
@@ -1,4 +1,5 @@
using System.Drawing; using System;
using System.Drawing;
namespace DesktopMagicPluginAPI namespace DesktopMagicPluginAPI
{ {
@@ -8,15 +9,22 @@ namespace DesktopMagicPluginAPI
public interface IPluginData public interface IPluginData
{ {
/// <summary> /// <summary>
/// Gets the font of the main application. /// Gets the current font of the main application.
/// </summary> /// </summary>
[Obsolete("Use the \"Theme\" property instead")]
string Font { get; } string Font { get; }
/// <summary> /// <summary>
/// Gets the color of the main application. /// Gets the current color of the main application.
/// </summary> /// </summary>
[Obsolete("Use the \"Theme\" property instead")]
Color Color { get; } Color Color { get; }
/// <summary>
/// Gets the current theme setting of the main application.
/// </summary>
ITheme Theme { get; }
/// <summary> /// <summary>
/// Gets the window size of the plugin window. /// Gets the window size of the plugin window.
/// </summary> /// </summary>
+25
View File
@@ -0,0 +1,25 @@
using System.Drawing;
namespace DesktopMagicPluginAPI
{
/// <summary>
/// The theme settings of the main application.
/// </summary>
public interface ITheme
{
/// <summary>
/// Gets the primary color of the main application.
/// </summary>
Color PrimaryColor { get; }
/// <summary>
/// Gets the secondary color of the main application.
/// </summary>
Color SecondaryColor { get; }
/// <summary>
/// Gets the font of the main application.
/// </summary>
string Font { get; }
}
}
+1 -1
View File
@@ -43,7 +43,7 @@ namespace DesktopMagicPluginAPI
public virtual RenderQuality RenderQuality { get; set; } = RenderQuality.High; public virtual RenderQuality RenderQuality { get; set; } = RenderQuality.High;
/// <summary> /// <summary>
/// Occurs once when the pugin gets activated. /// Occurs once when the plugin gets activated.
/// </summary> /// </summary>
public virtual void Start() public virtual void Start()
{ {