diff --git a/src/DesktopMagic.Installer/DesktopMagic-Installer.exe b/src/DesktopMagic.Installer/DesktopMagic-Installer.exe index 02ef4f5..86d6a02 100644 Binary files a/src/DesktopMagic.Installer/DesktopMagic-Installer.exe and b/src/DesktopMagic.Installer/DesktopMagic-Installer.exe differ diff --git a/src/DesktopMagic/App.xaml.cs b/src/DesktopMagic/App.xaml.cs index 3b2842a..3c92c99 100644 --- a/src/DesktopMagic/App.xaml.cs +++ b/src/DesktopMagic/App.xaml.cs @@ -1,146 +1,145 @@ -using AlwaysUpToDate; +global using Stone_Red_Utilities.Logging; -using Stone_Red_Utilities.Logging; +using AlwaysUpToDate; using System; using System.IO; using System.Threading; using System.Windows; -namespace DesktopMagic +namespace DesktopMagic; + +/// +/// Interaction logic for App.xaml +/// +public partial class App : Application { - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - private readonly string logFilePath; - private readonly Mutex _mutex; + private readonly string logFilePath; + private readonly Mutex _mutex; #if DEBUG - private readonly Updater updater = new Updater(TimeSpan.FromDays(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/develop/update/updateInfo.json"); + 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.FromDays(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/main/update/updateInfo.json"); #endif - public const string AppName = "Desktop Magic"; - public static string ApplicationDataPath { get; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + AppName; + public const string AppName = "Desktop Magic"; + public static string ApplicationDataPath { get; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + AppName; - public static Logger Logger { get; } = new Logger(); + public static Logger Logger { get; } = new Logger(); - public App() + public App() + { + logFilePath = ApplicationDataPath + "\\Log.log"; + Setup(); + // Try to grab mutex + _mutex = new Mutex(true, $"Stone_Red{AppName}", out bool createdNew); + + //check if creating new was successful + if (!createdNew) { - logFilePath = ApplicationDataPath + "\\Log.log"; - Setup(); - // Try to grab mutex - _mutex = new Mutex(true, $"Stone_Red{AppName}", out bool createdNew); - - //check if creating new was successful - if (!createdNew) - { - Logger.Log("Shutting down because other instance already running.", "Setup"); - //Shutdown Application - Current.Shutdown(); - } - else - { - Exit += CloseMutexHandler; - - updater.ProgressChanged += Updater_ProgressChanged; - updater.OnException += Updater_OnException; - updater.NoUpdateAvailible += Updater_NoUpdateAvailible; - updater.UpdateAvailible += Updater_UpdateAvailible; - updater.Start(); - } + Logger.Log("Shutting down because other instance already running.", "Setup"); + //Shutdown Application + Current.Shutdown(); } - - private void Updater_UpdateAvailible(string version, string additionalInformation) + else { - updater.Update(); - } + Exit += CloseMutexHandler; - private void Updater_NoUpdateAvailible() - { - Logger.Log("No update available.", "Updater"); - } - - private void Updater_OnException(Exception exception) - { - Logger.Log(exception.ToString(), "Updater"); - } - - private void Updater_ProgressChanged(long? totalFileSize, long totalBytesDownloaded, double? progressPercentage) - { - Logger.Log($"{progressPercentage}% {totalBytesDownloaded}/{totalFileSize}", "Updater"); - } - - protected void CloseMutexHandler(object sender, EventArgs e) - { - _mutex?.Close(); - } - - private void Setup() - { - AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; - - Logger.Config = new LogConfig() - { - FatalConfig = new OutputConfig() - { - Color = ConsoleColor.DarkRed, - LogTarget = LogTarget.DebugConsole | LogTarget.File, - FilePath = logFilePath - }, - ErrorConfig = new OutputConfig() - { - Color = ConsoleColor.Red, - LogTarget = LogTarget.DebugConsole | LogTarget.File, - FilePath = logFilePath - }, - WarnConfig = new OutputConfig() - { - Color = ConsoleColor.Yellow, - LogTarget = LogTarget.DebugConsole | LogTarget.File, - FilePath = logFilePath - }, - InfoConfig = new OutputConfig() - { - Color = ConsoleColor.White, - LogTarget = LogTarget.DebugConsole | LogTarget.File, - FilePath = logFilePath - }, - DebugConfig = new OutputConfig() - { - Color = ConsoleColor.Gray, - LogTarget = LogTarget.DebugConsole, - }, - FormatConfig = new FormatConfig() - { - DebugConsoleFormat = $"> {{{LogFormatType.DateTime}:hh:mm:ss}} | {{{LogFormatType.LogSeverity},-5}} | {{{LogFormatType.Message}}}\nat {{{LogFormatType.LineNumber}}} | {{{LogFormatType.FilePath}}}" - } - }; - - try - { - if (!Directory.Exists(ApplicationDataPath)) - { - _ = Directory.CreateDirectory(ApplicationDataPath); - } - Logger.Log("Created ApplicationData Folder", "Main"); - } - catch (Exception ex) - { - Logger.Log(ex.Message, "Setup", LogSeverity.Error); - _ = MessageBox.Show(ex.ToString()); - } - - Logger.ClearLogFile(LogSeverity.Info); - Logger.Log("Log setup complete.", "Setup"); - } - - private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) - { - Exception exception = (Exception)e.ExceptionObject; - Logger.Log(exception + (e.IsTerminating ? "\t Process terminating!" : ""), exception.Source, LogSeverity.Fatal); + updater.ProgressChanged += Updater_ProgressChanged; + updater.OnException += Updater_OnException; + updater.NoUpdateAvailible += Updater_NoUpdateAvailible; + updater.UpdateAvailible += Updater_UpdateAvailible; + updater.Start(); } } + + private void Updater_UpdateAvailible(string version, string additionalInformation) + { + updater.Update(); + } + + private void Updater_NoUpdateAvailible() + { + Logger.Log("No update available.", "Updater"); + } + + private void Updater_OnException(Exception exception) + { + Logger.Log(exception.ToString(), "Updater"); + } + + private void Updater_ProgressChanged(long? totalFileSize, long totalBytesDownloaded, double? progressPercentage) + { + Logger.Log($"{progressPercentage}% {totalBytesDownloaded}/{totalFileSize}", "Updater"); + } + + protected void CloseMutexHandler(object sender, EventArgs e) + { + _mutex?.Close(); + } + + private void Setup() + { + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + + Logger.Config = new LogConfig() + { + FatalConfig = new OutputConfig() + { + Color = ConsoleColor.DarkRed, + LogTarget = LogTarget.DebugConsole | LogTarget.File, + FilePath = logFilePath + }, + ErrorConfig = new OutputConfig() + { + Color = ConsoleColor.Red, + LogTarget = LogTarget.DebugConsole | LogTarget.File, + FilePath = logFilePath + }, + WarnConfig = new OutputConfig() + { + Color = ConsoleColor.Yellow, + LogTarget = LogTarget.DebugConsole | LogTarget.File, + FilePath = logFilePath + }, + InfoConfig = new OutputConfig() + { + Color = ConsoleColor.White, + LogTarget = LogTarget.DebugConsole | LogTarget.File, + FilePath = logFilePath + }, + DebugConfig = new OutputConfig() + { + Color = ConsoleColor.Gray, + LogTarget = LogTarget.DebugConsole, + }, + FormatConfig = new FormatConfig() + { + DebugConsoleFormat = $"> {{{LogFormatType.DateTime}:hh:mm:ss}} | {{{LogFormatType.LogSeverity},-5}} | {{{LogFormatType.Message}}}\nat {{{LogFormatType.LineNumber}}} | {{{LogFormatType.FilePath}}}" + } + }; + + try + { + if (!Directory.Exists(ApplicationDataPath)) + { + _ = Directory.CreateDirectory(ApplicationDataPath); + } + Logger.Log("Created ApplicationData Folder", "Main"); + } + catch (Exception ex) + { + Logger.Log(ex.Message, "Setup", LogSeverity.Error); + _ = MessageBox.Show(ex.ToString()); + } + + Logger.ClearLogFile(LogSeverity.Info); + Logger.Log("Log setup complete.", "Setup"); + } + + private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + Exception exception = (Exception)e.ExceptionObject; + Logger.Log(exception + (e.IsTerminating ? "\t Process terminating!" : ""), exception.Source, LogSeverity.Fatal); + } } \ No newline at end of file diff --git a/src/DesktopMagic/DesktopMagic.csproj b/src/DesktopMagic/DesktopMagic.csproj index 8f180ab..4eb0a7f 100644 --- a/src/DesktopMagic/DesktopMagic.csproj +++ b/src/DesktopMagic/DesktopMagic.csproj @@ -2,7 +2,6 @@ WinExe - net5.0-windows true DesktopMagic icon.ico @@ -13,6 +12,7 @@ https://github.com/Stone-Red-Code/DesktopMagic 0.0.3.1 0.0.3.1 + net6.0-windows diff --git a/src/DesktopMagic/MainWindow.xaml.cs b/src/DesktopMagic/MainWindow.xaml.cs index 985ee05..b3a2f33 100644 --- a/src/DesktopMagic/MainWindow.xaml.cs +++ b/src/DesktopMagic/MainWindow.xaml.cs @@ -5,8 +5,6 @@ using DesktopMagic.Plugins; using Microsoft.Win32; -using Stone_Red_Utilities.Logging; - using System; using System.Collections.Generic; using System.Diagnostics; @@ -836,18 +834,22 @@ namespace DesktopMagic private void GithubButton_Click(object sender, RoutedEventArgs e) { string uri = "https://github.com/Stone-Red-Code/DesktopMagic"; - ProcessStartInfo psi = new ProcessStartInfo(); - psi.UseShellExecute = true; - psi.FileName = uri; + ProcessStartInfo psi = new ProcessStartInfo + { + UseShellExecute = true, + FileName = uri + }; _ = Process.Start(psi); } private void DownloadPluginsButton_Click(object sender, RoutedEventArgs e) { string uri = "https://github.com/Stone-Red-Code/DesktopMagic-Plugins"; - ProcessStartInfo psi = new ProcessStartInfo(); - psi.UseShellExecute = true; - psi.FileName = uri; + ProcessStartInfo psi = new ProcessStartInfo + { + UseShellExecute = true, + FileName = uri + }; _ = Process.Start(psi); } diff --git a/src/DesktopMagic/Plugins/PluginData.cs b/src/DesktopMagic/Plugins/PluginData.cs index 57ab715..9092edc 100644 --- a/src/DesktopMagic/Plugins/PluginData.cs +++ b/src/DesktopMagic/Plugins/PluginData.cs @@ -2,34 +2,33 @@ using System.Drawing; -namespace DesktopMagic.Plugins +namespace DesktopMagic.Plugins; + +internal class PluginData : IPluginData { - internal class PluginData : IPluginData + private readonly PluginWindow window; + + public PluginData(PluginWindow window) { - private readonly PluginWindow window; + this.window = window; + } - public PluginData(PluginWindow window) - { - this.window = window; - } + public string Font => Theme.Font; - public string Font => Theme.Font; + public Color Color => Theme.PrimaryColor; - public Color Color => Theme.PrimaryColor; + public ITheme Theme { get; } = MainWindow.Theme; - public ITheme Theme { get; } = MainWindow.Theme; + public Size WindowSize => new Size((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); - public Point WindowPosition => new Point((int)window.Left, (int)window.Top); + public string PluginName => window.PluginName; - public string PluginName => window.PluginName; + public string PluginPath => window.PluginFolderPath; - public string PluginPath => window.PluginFolderPath; - - public void UpdateWindow() - { - window.UpdatePluginWindow(); - } + public void UpdateWindow() + { + window.UpdatePluginWindow(); } } \ No newline at end of file diff --git a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs index 8655936..cb91b3e 100644 --- a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs +++ b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs @@ -20,388 +20,391 @@ using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; -namespace DesktopMagic +namespace DesktopMagic; + +public partial class PluginWindow : Window { - public partial class PluginWindow : Window + private readonly RegistryKey key; + private Thread pluginThread; + private System.Timers.Timer valueTimer; + + private Plugin pluginClassInstance; + + public bool IsRunning { get; private set; } = true; + public string PluginName { get; private set; } + public string PluginFolderPath { get; private set; } + + public event Action PluginLoaded; + + public event Action OnExit; + + public PluginWindow(string pluginName) { - private readonly RegistryKey key; - private Thread pluginThread; - private System.Timers.Timer valueTimer; + InitializeComponent(); - private Plugin pluginClassInstance; - - public bool IsRunning { get; private set; } = true; - public string PluginName { get; private set; } - public string PluginFolderPath { get; private set; } - - public event Action PluginLoaded; - - public event Action OnExit; - - public PluginWindow(string pluginName) + Window w = new() { - InitializeComponent(); + Top = -100, + Left = -100, + Width = 0, + Height = 0, - Window w = new() - { - Top = -100, - Left = -100, - Width = 0, - Height = 0, + WindowStyle = WindowStyle.ToolWindow, + ShowInTaskbar = false + }; + w.Show(); + Owner = w; + w.Hide(); - WindowStyle = WindowStyle.ToolWindow, - ShowInTaskbar = false - }; - w.Show(); - Owner = w; - w.Hide(); - - System.Timers.Timer t = new System.Timers.Timer(); - t.Interval = 100; - t.Elapsed += UpdateTimer_Elapsed; - t.Start(); - - PluginName = pluginName; - - key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName); - Top = double.Parse(key.GetValue(pluginName + "WindowTop", 100).ToString()); - Left = double.Parse(key.GetValue(pluginName + "WindowLeft", 100).ToString()); - Height = double.Parse(key.GetValue(pluginName + "WindowHeight", 200).ToString()); - Width = double.Parse(key.GetValue(pluginName + "WindowWidth", 500).ToString()); - } - - public PluginWindow(Plugin pluginClassInstance, string pluginName) : this(pluginName) + System.Timers.Timer t = new System.Timers.Timer { - this.pluginClassInstance = pluginClassInstance; - } + Interval = 100 + }; + t.Elapsed += UpdateTimer_Elapsed; + t.Start(); - protected override void OnSourceInitialized(EventArgs e) + PluginName = pluginName; + + key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName); + Top = double.Parse(key.GetValue(pluginName + "WindowTop", 100).ToString()); + Left = double.Parse(key.GetValue(pluginName + "WindowLeft", 100).ToString()); + Height = double.Parse(key.GetValue(pluginName + "WindowHeight", 200).ToString()); + Width = double.Parse(key.GetValue(pluginName + "WindowWidth", 500).ToString()); + } + + public PluginWindow(Plugin pluginClassInstance, string pluginName) : this(pluginName) + { + this.pluginClassInstance = pluginClassInstance; + } + + protected override void OnSourceInitialized(EventArgs e) + { + base.OnSourceInitialized(e); + + //Set the window style to noactivate. + WindowInteropHelper helper = new(this); + _ = WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE, + WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); + } + + private void Window_ContentRendered(object sender, EventArgs e) + { + pluginThread = new Thread(() => { - base.OnSourceInitialized(e); + LoadPlugin(); + }); + pluginThread.Start(); + } - //Set the window style to noactivate. - WindowInteropHelper helper = new(this); - _ = WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE, - WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); - } + public void UpdatePluginWindow() + { + ValueTimer_Elapsed(valueTimer, null); + } - private void Window_ContentRendered(object sender, EventArgs e) + private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e) + { + Dispatcher.Invoke(() => { - pluginThread = new Thread(() => + if (MainWindow.EditMode) { - LoadPlugin(); - }); - pluginThread.Start(); - } - - public void UpdatePluginWindow() - { - ValueTimer_Elapsed(valueTimer, null); - } - - private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e) - { - Dispatcher.Invoke(() => - { - if (MainWindow.EditMode) - { - panel.Visibility = Visibility.Visible; - WindowPos.SetIsLocked(this, false); - tileBar.CaptionHeight = tileBar.CaptionHeight = ActualHeight - 10 < 0 ? 0 : ActualHeight - 10; - ResizeMode = ResizeMode.CanResize; - } - else - { - panel.Visibility = Visibility.Collapsed; - WindowPos.SetIsLocked(this, true); - tileBar.CaptionHeight = 0; - ResizeMode = ResizeMode.NoResize; - } - - if (!IsRunning) - { - ((System.Timers.Timer)sender).Stop(); - } - else - { - viewBox.Margin = new Thickness(MainWindow.Theme.Margin); - border.Width = viewBox.ActualWidth + (MainWindow.Theme.Margin * 2); - border.Height = viewBox.ActualHeight + (MainWindow.Theme.Margin * 2); - rectangleGeometry.Rect = new Rect(-MainWindow.Theme.Margin, -MainWindow.Theme.Margin, border.ActualWidth, border.ActualHeight); - border.Background = MainWindow.Theme.BackgroundBrush; - border.CornerRadius = new CornerRadius(MainWindow.Theme.CornerRadius); - } - }); - } - - private void LoadPlugin() - { - if (pluginClassInstance is null) - { - PluginFolderPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\{App.AppName}\\Plugins\\{PluginName}"; - - if (!File.Exists($"{PluginFolderPath}\\{PluginName}.dll")) - { - _ = MessageBox.Show("File does not exist!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); - Exit(); - return; - } - } - - try - { - ExecuteSource(); - } - catch (Exception ex) - { - App.Logger.Log(ex.ToString(), "Plugin"); - _ = MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error); - Exit(); - return; - } - PluginLoaded?.Invoke(); - } - - private void ExecuteSource() - { - object instance = pluginClassInstance; - if (instance is null) - { - byte[] assemblyBytes = File.ReadAllBytes($"{PluginFolderPath}\\{PluginName}.dll"); - Assembly dll = Assembly.Load(assemblyBytes); - Type instanceType = dll.GetTypes().FirstOrDefault(type => type.GetTypeInfo().BaseType == typeof(Plugin)); - - if (instanceType is null) - { - _ = MessageBox.Show($"The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", "Error", MessageBoxButton.OK, MessageBoxImage.Error); - Exit(); - return; - } - - instance = Activator.CreateInstance(instanceType); - } - if (instance is Plugin) - { - pluginClassInstance = instance as Plugin; - pluginClassInstance.Application = new PluginData(this); + panel.Visibility = Visibility.Visible; + WindowPos.SetIsLocked(this, false); + tileBar.CaptionHeight = tileBar.CaptionHeight = ActualHeight - 10 < 0 ? 0 : ActualHeight - 10; + ResizeMode = ResizeMode.CanResize; } else { - _ = MessageBox.Show($"The \"Plugin\" class has to inherit from \"{typeof(Plugin).FullName}\"", "Error", MessageBoxButton.OK, MessageBoxImage.Error); - Exit(); - return; - } - - LoadOptions(instance); - - valueTimer = new System.Timers.Timer(); - valueTimer.Interval = 1000; - valueTimer.Elapsed += ValueTimer_Elapsed; - - pluginClassInstance.Start(); - UpdatePluginWindow(); - - if (pluginClassInstance.UpdateInterval > 0) - { - valueTimer.Interval = pluginClassInstance.UpdateInterval; - valueTimer.Start(); - } - } - - private void LoadOptions(object instance) - { - try - { - FieldInfo[] props = instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.GetField); - - List settingElements = new List(); - foreach (FieldInfo prop in props) - { - if (prop.GetValue(instance) is Element element) - { - object[] attributes = prop.GetCustomAttributes(true); - foreach (object attribute in attributes) - { - if (attribute is ElementAttribute elementAttribute) - { - settingElements.Add(new SettingElement(element, elementAttribute.Name, elementAttribute.OrderIndex)); - break; - } - } - } - } - - settingElements = settingElements.OrderBy(x => x.OrderIndex).ToList(); - if (MainWindow.PluginsSettings.ContainsKey(PluginName)) - { - MainWindow.PluginsSettings[PluginName] = settingElements; - } - else - { - MainWindow.PluginsSettings.Add(PluginName, settingElements); - } - } - catch (Exception ex) - { - IsRunning = false; - App.Logger.Log(ex.ToString(), "Plugin"); - _ = MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error); - Exit(); - return; - } - } - - private void ValueTimer_Elapsed(object sender, ElapsedEventArgs e) - { - try - { - if (IsRunning) - { - Bitmap result = pluginClassInstance.Main(); - - if (pluginClassInstance.UpdateInterval > 0) - { - valueTimer.Interval = pluginClassInstance.UpdateInterval; - } - else - { - valueTimer.Stop(); - } - - if (result is not null) - { - BitmapScalingMode renderOptions = pluginClassInstance.RenderQuality switch - { - RenderQuality.High => BitmapScalingMode.HighQuality, - RenderQuality.Low => BitmapScalingMode.LowQuality, - RenderQuality.Performance => BitmapScalingMode.NearestNeighbor, - _ => BitmapScalingMode.Unspecified - }; - - //Update Image - Dispatcher.Invoke(() => - { - RenderOptions.SetBitmapScalingMode(image, renderOptions); - image.Source = BitmapToImageSource(result); - }); - } - } - } - catch (Exception ex) - { - IsRunning = false; - App.Logger.Log(ex.ToString(), "Plugin"); - _ = MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error); - Exit(); - return; + panel.Visibility = Visibility.Collapsed; + WindowPos.SetIsLocked(this, true); + tileBar.CaptionHeight = 0; + ResizeMode = ResizeMode.NoResize; } if (!IsRunning) { - valueTimer.Stop(); + ((System.Timers.Timer)sender).Stop(); + } + else + { + viewBox.Margin = new Thickness(MainWindow.Theme.Margin); + border.Width = viewBox.ActualWidth + (MainWindow.Theme.Margin * 2); + border.Height = viewBox.ActualHeight + (MainWindow.Theme.Margin * 2); + rectangleGeometry.Rect = new Rect(-MainWindow.Theme.Margin, -MainWindow.Theme.Margin, border.ActualWidth, border.ActualHeight); + border.Background = MainWindow.Theme.BackgroundBrush; + border.CornerRadius = new CornerRadius(MainWindow.Theme.CornerRadius); + } + }); + } + + private void LoadPlugin() + { + if (pluginClassInstance is null) + { + PluginFolderPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\{App.AppName}\\Plugins\\{PluginName}"; + + if (!File.Exists($"{PluginFolderPath}\\{PluginName}.dll")) + { + _ = MessageBox.Show("File does not exist!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + Exit(); + return; } } - private static BitmapSource BitmapToImageSource(Bitmap bitmap) + try { - BitmapData bitmapData = bitmap.LockBits( - new Rectangle(0, 0, bitmap.Width, bitmap.Height), - ImageLockMode.ReadOnly, bitmap.PixelFormat); - - BitmapSource bitmapSource = BitmapSource.Create( - bitmapData.Width, bitmapData.Height, - bitmap.HorizontalResolution, bitmap.VerticalResolution, - PixelFormats.Bgra32, null, - bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride); - - bitmap.UnlockBits(bitmapData); - return bitmapSource; + ExecuteSource(); } - - public void Exit() + catch (Exception ex) { - IsRunning = false; - - Dispatcher.Invoke(() => - { - OnExit?.Invoke(); - }); + App.Logger.Log(ex.ToString(), "Plugin", LogSeverity.Error); + _ = MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + Exit(); + return; } - - private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) - { - pluginClassInstance?.Stop(); - IsRunning = false; - } - - #region Window Events - - private void Window_LocationChanged(object sender, EventArgs e) - { - key.SetValue(PluginName + "WindowTop", Top); - key.SetValue(PluginName + "WindowLeft", Left); - } - - private void Window_SizeChanged(object sender, SizeChangedEventArgs e) - { - key.SetValue(PluginName + "WindowHeight", Height); - key.SetValue(PluginName + "WindowWidth", Width); - tileBar.CaptionHeight = ActualHeight - 10; - } - - private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) - { - ImageSource imageSource = image.Source; - BitmapSource bitmapImage = (BitmapSource)imageSource; - double pixelMousePositionX = e.GetPosition(image).X * bitmapImage.PixelWidth / image.ActualHeight; - double pixelMousePositionY = e.GetPosition(image).Y * bitmapImage.PixelHeight / image.ActualHeight; - - MouseButton mouseButton; - - switch (e.ChangedButton) - { - case System.Windows.Input.MouseButton.Left: - mouseButton = MouseButton.Left; - break; - - case System.Windows.Input.MouseButton.Middle: - mouseButton = MouseButton.Middle; - break; - - case System.Windows.Input.MouseButton.Right: - mouseButton = MouseButton.Right; - break; - - default: - return; - }; - - System.Drawing.Point point = new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY); - pluginClassInstance.OnMouseClick(point, mouseButton); - } - - private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) - { - ImageSource imageSource = image.Source; - BitmapSource bitmapImage = (BitmapSource)imageSource; - double pixelMousePositionX = e.GetPosition(image).X * bitmapImage.PixelWidth / image.ActualHeight; - double pixelMousePositionY = e.GetPosition(image).Y * bitmapImage.PixelHeight / image.ActualHeight; - - System.Drawing.Point point = new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY); - pluginClassInstance.OnMouseMove(point); - } - - private void Window_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e) - { - ImageSource imageSource = image.Source; - BitmapSource bitmapImage = (BitmapSource)imageSource; - double pixelMousePositionX = e.GetPosition(image).X * bitmapImage.PixelWidth / image.ActualHeight; - double pixelMousePositionY = e.GetPosition(image).Y * bitmapImage.PixelHeight / image.ActualHeight; - - System.Drawing.Point point = new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY); - pluginClassInstance.OnMouseWheel(point, e.Delta); - } - - #endregion Window Events + PluginLoaded?.Invoke(); } + + private void ExecuteSource() + { + object instance = pluginClassInstance; + if (instance is null) + { + byte[] assemblyBytes = File.ReadAllBytes($"{PluginFolderPath}\\{PluginName}.dll"); + Assembly dll = Assembly.Load(assemblyBytes); + Type instanceType = dll.GetTypes().FirstOrDefault(type => type.GetTypeInfo().BaseType == typeof(Plugin)); + + if (instanceType is null) + { + _ = MessageBox.Show($"The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + Exit(); + return; + } + + instance = Activator.CreateInstance(instanceType); + } + if (instance is Plugin) + { + pluginClassInstance = instance as Plugin; + pluginClassInstance.Application = new PluginData(this); + } + else + { + _ = MessageBox.Show($"The \"Plugin\" class has to inherit from \"{typeof(Plugin).FullName}\"", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + Exit(); + return; + } + + LoadOptions(instance); + + valueTimer = new System.Timers.Timer + { + Interval = 1000 + }; + valueTimer.Elapsed += ValueTimer_Elapsed; + + pluginClassInstance.Start(); + UpdatePluginWindow(); + + if (pluginClassInstance.UpdateInterval > 0) + { + valueTimer.Interval = pluginClassInstance.UpdateInterval; + valueTimer.Start(); + } + } + + private void LoadOptions(object instance) + { + try + { + FieldInfo[] props = instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.GetField); + + List settingElements = new List(); + foreach (FieldInfo prop in props) + { + if (prop.GetValue(instance) is Element element) + { + object[] attributes = prop.GetCustomAttributes(true); + foreach (object attribute in attributes) + { + if (attribute is ElementAttribute elementAttribute) + { + settingElements.Add(new SettingElement(element, elementAttribute.Name, elementAttribute.OrderIndex)); + break; + } + } + } + } + + settingElements = settingElements.OrderBy(x => x.OrderIndex).ToList(); + if (MainWindow.PluginsSettings.ContainsKey(PluginName)) + { + MainWindow.PluginsSettings[PluginName] = settingElements; + } + else + { + MainWindow.PluginsSettings.Add(PluginName, settingElements); + } + } + catch (Exception ex) + { + IsRunning = false; + App.Logger.Log(ex.ToString(), "Plugin", LogSeverity.Error); + _ = MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + Exit(); + return; + } + } + + private void ValueTimer_Elapsed(object sender, ElapsedEventArgs e) + { + try + { + if (IsRunning) + { + Bitmap result = pluginClassInstance.Main(); + + if (pluginClassInstance.UpdateInterval > 0) + { + valueTimer.Interval = pluginClassInstance.UpdateInterval; + } + else + { + valueTimer.Stop(); + } + + if (result is not null) + { + BitmapScalingMode renderOptions = pluginClassInstance.RenderQuality switch + { + RenderQuality.High => BitmapScalingMode.HighQuality, + RenderQuality.Low => BitmapScalingMode.LowQuality, + RenderQuality.Performance => BitmapScalingMode.NearestNeighbor, + _ => BitmapScalingMode.Unspecified + }; + + //Update Image + Dispatcher.Invoke(() => + { + RenderOptions.SetBitmapScalingMode(image, renderOptions); + image.Source = BitmapToImageSource(result); + }); + } + } + } + catch (Exception ex) + { + IsRunning = false; + App.Logger.Log(ex.ToString(), "Plugin", LogSeverity.Error); + _ = MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + Exit(); + return; + } + + if (!IsRunning) + { + valueTimer.Stop(); + } + } + + private static BitmapSource BitmapToImageSource(Bitmap bitmap) + { + BitmapData bitmapData = bitmap.LockBits( + new Rectangle(0, 0, bitmap.Width, bitmap.Height), + ImageLockMode.ReadOnly, bitmap.PixelFormat); + + BitmapSource bitmapSource = BitmapSource.Create( + bitmapData.Width, bitmapData.Height, + bitmap.HorizontalResolution, bitmap.VerticalResolution, + PixelFormats.Bgra32, null, + bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride); + + bitmap.UnlockBits(bitmapData); + return bitmapSource; + } + + public void Exit() + { + IsRunning = false; + + Dispatcher.Invoke(() => + { + OnExit?.Invoke(); + }); + } + + private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) + { + pluginClassInstance?.Stop(); + IsRunning = false; + } + + #region Window Events + + private void Window_LocationChanged(object sender, EventArgs e) + { + key.SetValue(PluginName + "WindowTop", Top); + key.SetValue(PluginName + "WindowLeft", Left); + } + + private void Window_SizeChanged(object sender, SizeChangedEventArgs e) + { + key.SetValue(PluginName + "WindowHeight", Height); + key.SetValue(PluginName + "WindowWidth", Width); + tileBar.CaptionHeight = ActualHeight - 10; + } + + private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + ImageSource imageSource = image.Source; + BitmapSource bitmapImage = (BitmapSource)imageSource; + double pixelMousePositionX = e.GetPosition(image).X * bitmapImage.PixelWidth / image.ActualHeight; + double pixelMousePositionY = e.GetPosition(image).Y * bitmapImage.PixelHeight / image.ActualHeight; + + MouseButton mouseButton; + + switch (e.ChangedButton) + { + case System.Windows.Input.MouseButton.Left: + mouseButton = MouseButton.Left; + break; + + case System.Windows.Input.MouseButton.Middle: + mouseButton = MouseButton.Middle; + break; + + case System.Windows.Input.MouseButton.Right: + mouseButton = MouseButton.Right; + break; + + default: + return; + }; + + System.Drawing.Point point = new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY); + pluginClassInstance.OnMouseClick(point, mouseButton); + } + + private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) + { + ImageSource imageSource = image.Source; + BitmapSource bitmapImage = (BitmapSource)imageSource; + double pixelMousePositionX = e.GetPosition(image).X * bitmapImage.PixelWidth / image.ActualHeight; + double pixelMousePositionY = e.GetPosition(image).Y * bitmapImage.PixelHeight / image.ActualHeight; + + System.Drawing.Point point = new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY); + pluginClassInstance.OnMouseMove(point); + } + + private void Window_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e) + { + ImageSource imageSource = image.Source; + BitmapSource bitmapImage = (BitmapSource)imageSource; + double pixelMousePositionX = e.GetPosition(image).X * bitmapImage.PixelWidth / image.ActualHeight; + double pixelMousePositionY = e.GetPosition(image).Y * bitmapImage.PixelHeight / image.ActualHeight; + + System.Drawing.Point point = new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY); + pluginClassInstance.OnMouseWheel(point, e.Delta); + } + + #endregion Window Events } \ No newline at end of file diff --git a/src/DesktopMagic/Plugins/SettingElement.cs b/src/DesktopMagic/Plugins/SettingElement.cs index 37c9898..2eec58d 100644 --- a/src/DesktopMagic/Plugins/SettingElement.cs +++ b/src/DesktopMagic/Plugins/SettingElement.cs @@ -1,18 +1,17 @@ using DesktopMagicPluginAPI.Inputs; -namespace DesktopMagic.Plugins -{ - internal class SettingElement - { - public Element Element { get; } - public string Name { get; } - public int OrderIndex { get; } +namespace DesktopMagic.Plugins; - public SettingElement(Element element, string name, int orderIndex) - { - Element = element; - Name = name; - OrderIndex = orderIndex; - } +internal class SettingElement +{ + public Element Element { get; } + public string Name { get; } + public int OrderIndex { get; } + + public SettingElement(Element element, string name, int orderIndex) + { + Element = element; + Name = name; + OrderIndex = orderIndex; } } \ No newline at end of file diff --git a/src/DesktopMagic/Plugins/Theme.cs b/src/DesktopMagic/Plugins/Theme.cs index 23d74bd..41d196b 100644 --- a/src/DesktopMagic/Plugins/Theme.cs +++ b/src/DesktopMagic/Plugins/Theme.cs @@ -2,20 +2,19 @@ using System.Drawing; -namespace DesktopMagic.Plugins +namespace DesktopMagic.Plugins; + +internal class Theme : ITheme { - 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 Color PrimaryColor { get; set; } = Color.White; + public Color SecondaryColor { get; set; } = Color.White; + public Color BackgroundColor { get; set; } = Color.Transparent; - public string Font { get; set; } = "Segoe UI"; - public int CornerRadius { get; set; } - public int Margin { get; set; } + public string Font { get; set; } = "Segoe UI"; + public int CornerRadius { get; set; } + public int Margin { 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; - public System.Windows.Media.Brush BackgroundBrush { get; set; } = System.Windows.Media.Brushes.Transparent; - } + 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; + public System.Windows.Media.Brush BackgroundBrush { get; set; } = System.Windows.Media.Brushes.Transparent; } \ No newline at end of file diff --git a/src/DesktopMagicPlugin.Test/DesktopMagicPlugin.Test.csproj b/src/DesktopMagicPlugin.Test/DesktopMagicPlugin.Test.csproj index d2240e9..f050f7c 100644 --- a/src/DesktopMagicPlugin.Test/DesktopMagicPlugin.Test.csproj +++ b/src/DesktopMagicPlugin.Test/DesktopMagicPlugin.Test.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 diff --git a/src/DesktopMagicPluginAPI/.gitignore b/src/DesktopMagicPluginAPI/.gitignore new file mode 100644 index 0000000..4378419 --- /dev/null +++ b/src/DesktopMagicPluginAPI/.gitignore @@ -0,0 +1,9 @@ +############### +# folder # +############### +/**/DROP/ +/**/TEMP/ +/**/packages/ +/**/bin/ +/**/obj/ +_site diff --git a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.csproj b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.csproj index bbf3af1..1276f4b 100644 --- a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.csproj +++ b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.csproj @@ -1,7 +1,7 @@ - net5.0 + net6.0 Stone_Red Stone_Red 0.0.0.5 @@ -22,11 +22,11 @@ - - + all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.md b/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.md deleted file mode 100644 index 1326acc..0000000 --- a/src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.md +++ /dev/null @@ -1,888 +0,0 @@ - -# DesktopMagicPluginAPI - -## Contents - -- [Button](#T-DesktopMagicPluginAPI-Inputs-Button 'DesktopMagicPluginAPI.Inputs.Button') - - [#ctor(value)](#M-DesktopMagicPluginAPI-Inputs-Button-#ctor-System-String- 'DesktopMagicPluginAPI.Inputs.Button.#ctor(System.String)') - - [Value](#P-DesktopMagicPluginAPI-Inputs-Button-Value 'DesktopMagicPluginAPI.Inputs.Button.Value') - - [Click()](#M-DesktopMagicPluginAPI-Inputs-Button-Click 'DesktopMagicPluginAPI.Inputs.Button.Click') -- [CheckBox](#T-DesktopMagicPluginAPI-Inputs-CheckBox 'DesktopMagicPluginAPI.Inputs.CheckBox') - - [#ctor(value)](#M-DesktopMagicPluginAPI-Inputs-CheckBox-#ctor-System-Boolean- 'DesktopMagicPluginAPI.Inputs.CheckBox.#ctor(System.Boolean)') - - [Value](#P-DesktopMagicPluginAPI-Inputs-CheckBox-Value 'DesktopMagicPluginAPI.Inputs.CheckBox.Value') -- [ComboBox](#T-DesktopMagicPluginAPI-Inputs-ComboBox 'DesktopMagicPluginAPI.Inputs.ComboBox') - - [#ctor(items)](#M-DesktopMagicPluginAPI-Inputs-ComboBox-#ctor-System-String[]- 'DesktopMagicPluginAPI.Inputs.ComboBox.#ctor(System.String[])') - - [Items](#P-DesktopMagicPluginAPI-Inputs-ComboBox-Items 'DesktopMagicPluginAPI.Inputs.ComboBox.Items') - - [Value](#P-DesktopMagicPluginAPI-Inputs-ComboBox-Value 'DesktopMagicPluginAPI.Inputs.ComboBox.Value') -- [Element](#T-DesktopMagicPluginAPI-Inputs-Element 'DesktopMagicPluginAPI.Inputs.Element') - - [ValueChanged()](#M-DesktopMagicPluginAPI-Inputs-Element-ValueChanged 'DesktopMagicPluginAPI.Inputs.Element.ValueChanged') -- [ElementAttribute](#T-DesktopMagicPluginAPI-Inputs-ElementAttribute 'DesktopMagicPluginAPI.Inputs.ElementAttribute') - - [#ctor(name,orderIndex)](#M-DesktopMagicPluginAPI-Inputs-ElementAttribute-#ctor-System-String,System-Int32- 'DesktopMagicPluginAPI.Inputs.ElementAttribute.#ctor(System.String,System.Int32)') - - [#ctor(orderIndex)](#M-DesktopMagicPluginAPI-Inputs-ElementAttribute-#ctor-System-Int32- 'DesktopMagicPluginAPI.Inputs.ElementAttribute.#ctor(System.Int32)') - - [#ctor()](#M-DesktopMagicPluginAPI-Inputs-ElementAttribute-#ctor 'DesktopMagicPluginAPI.Inputs.ElementAttribute.#ctor') - - [Name](#P-DesktopMagicPluginAPI-Inputs-ElementAttribute-Name 'DesktopMagicPluginAPI.Inputs.ElementAttribute.Name') - - [OrderIndex](#P-DesktopMagicPluginAPI-Inputs-ElementAttribute-OrderIndex 'DesktopMagicPluginAPI.Inputs.ElementAttribute.OrderIndex') -- [GraphicsExtentions](#T-DesktopMagicPluginAPI-Drawing-GraphicsExtentions 'DesktopMagicPluginAPI.Drawing.GraphicsExtentions') - - [DrawStringFixedWidth(graphics,s,font,brush,x,y,width)](#M-DesktopMagicPluginAPI-Drawing-GraphicsExtentions-DrawStringFixedWidth-System-Drawing-Graphics,System-String,System-Drawing-Font,System-Drawing-Brush,System-Single,System-Single,System-Single- 'DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringFixedWidth(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Single,System.Single,System.Single)') - - [DrawStringFixedWidth(graphics,s,font,brush,point,width)](#M-DesktopMagicPluginAPI-Drawing-GraphicsExtentions-DrawStringFixedWidth-System-Drawing-Graphics,System-String,System-Drawing-Font,System-Drawing-Brush,System-Drawing-PointF,System-Single- 'DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringFixedWidth(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Drawing.PointF,System.Single)') - - [DrawStringMonospace(graphics,s,font,brush,x,y)](#M-DesktopMagicPluginAPI-Drawing-GraphicsExtentions-DrawStringMonospace-System-Drawing-Graphics,System-String,System-Drawing-Font,System-Drawing-Brush,System-Single,System-Single- 'DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringMonospace(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Single,System.Single)') - - [DrawStringMonospace(graphics,s,font,brush,point)](#M-DesktopMagicPluginAPI-Drawing-GraphicsExtentions-DrawStringMonospace-System-Drawing-Graphics,System-String,System-Drawing-Font,System-Drawing-Brush,System-Drawing-PointF- 'DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringMonospace(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Drawing.PointF)') - - [DrawStringNoLeftPadding(graphics,s,font,brush,x,y)](#M-DesktopMagicPluginAPI-Drawing-GraphicsExtentions-DrawStringNoLeftPadding-System-Drawing-Graphics,System-String,System-Drawing-Font,System-Drawing-Brush,System-Single,System-Single- 'DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringNoLeftPadding(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Single,System.Single)') - - [DrawStringNoLeftPadding(graphics,s,font,brush,point)](#M-DesktopMagicPluginAPI-Drawing-GraphicsExtentions-DrawStringNoLeftPadding-System-Drawing-Graphics,System-String,System-Drawing-Font,System-Drawing-Brush,System-Drawing-PointF- 'DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringNoLeftPadding(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Drawing.PointF)') - - [MeasureStringNoLeftPadding(graphics,text,font)](#M-DesktopMagicPluginAPI-Drawing-GraphicsExtentions-MeasureStringNoLeftPadding-System-Drawing-Graphics,System-String,System-Drawing-Font- 'DesktopMagicPluginAPI.Drawing.GraphicsExtentions.MeasureStringNoLeftPadding(System.Drawing.Graphics,System.String,System.Drawing.Font)') -- [IPluginData](#T-DesktopMagicPluginAPI-IPluginData 'DesktopMagicPluginAPI.IPluginData') - - [Color](#P-DesktopMagicPluginAPI-IPluginData-Color 'DesktopMagicPluginAPI.IPluginData.Color') - - [Font](#P-DesktopMagicPluginAPI-IPluginData-Font 'DesktopMagicPluginAPI.IPluginData.Font') - - [PluginName](#P-DesktopMagicPluginAPI-IPluginData-PluginName 'DesktopMagicPluginAPI.IPluginData.PluginName') - - [PluginPath](#P-DesktopMagicPluginAPI-IPluginData-PluginPath 'DesktopMagicPluginAPI.IPluginData.PluginPath') - - [Theme](#P-DesktopMagicPluginAPI-IPluginData-Theme 'DesktopMagicPluginAPI.IPluginData.Theme') - - [WindowPosition](#P-DesktopMagicPluginAPI-IPluginData-WindowPosition 'DesktopMagicPluginAPI.IPluginData.WindowPosition') - - [WindowSize](#P-DesktopMagicPluginAPI-IPluginData-WindowSize 'DesktopMagicPluginAPI.IPluginData.WindowSize') - - [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') - - [Margin](#P-DesktopMagicPluginAPI-ITheme-Margin 'DesktopMagicPluginAPI.ITheme.Margin') - - [PrimaryColor](#P-DesktopMagicPluginAPI-ITheme-PrimaryColor 'DesktopMagicPluginAPI.ITheme.PrimaryColor') - - [SecondaryColor](#P-DesktopMagicPluginAPI-ITheme-SecondaryColor 'DesktopMagicPluginAPI.ITheme.SecondaryColor') -- [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)') - - [Maximum](#P-DesktopMagicPluginAPI-Inputs-IntegerUpDown-Maximum 'DesktopMagicPluginAPI.Inputs.IntegerUpDown.Maximum') - - [Minimum](#P-DesktopMagicPluginAPI-Inputs-IntegerUpDown-Minimum 'DesktopMagicPluginAPI.Inputs.IntegerUpDown.Minimum') - - [Value](#P-DesktopMagicPluginAPI-Inputs-IntegerUpDown-Value 'DesktopMagicPluginAPI.Inputs.IntegerUpDown.Value') -- [Label](#T-DesktopMagicPluginAPI-Inputs-Label 'DesktopMagicPluginAPI.Inputs.Label') - - [#ctor(value,bold)](#M-DesktopMagicPluginAPI-Inputs-Label-#ctor-System-String,System-Boolean- 'DesktopMagicPluginAPI.Inputs.Label.#ctor(System.String,System.Boolean)') - - [Bold](#P-DesktopMagicPluginAPI-Inputs-Label-Bold 'DesktopMagicPluginAPI.Inputs.Label.Bold') - - [Value](#P-DesktopMagicPluginAPI-Inputs-Label-Value 'DesktopMagicPluginAPI.Inputs.Label.Value') -- [MouseButton](#T-DesktopMagicPluginAPI-Inputs-MouseButton 'DesktopMagicPluginAPI.Inputs.MouseButton') - - [Left](#F-DesktopMagicPluginAPI-Inputs-MouseButton-Left 'DesktopMagicPluginAPI.Inputs.MouseButton.Left') - - [Middle](#F-DesktopMagicPluginAPI-Inputs-MouseButton-Middle 'DesktopMagicPluginAPI.Inputs.MouseButton.Middle') - - [Right](#F-DesktopMagicPluginAPI-Inputs-MouseButton-Right 'DesktopMagicPluginAPI.Inputs.MouseButton.Right') -- [Plugin](#T-DesktopMagicPluginAPI-Plugin 'DesktopMagicPluginAPI.Plugin') - - [Application](#P-DesktopMagicPluginAPI-Plugin-Application 'DesktopMagicPluginAPI.Plugin.Application') - - [RenderQuality](#P-DesktopMagicPluginAPI-Plugin-RenderQuality 'DesktopMagicPluginAPI.Plugin.RenderQuality') - - [UpdateInterval](#P-DesktopMagicPluginAPI-Plugin-UpdateInterval 'DesktopMagicPluginAPI.Plugin.UpdateInterval') - - [Main()](#M-DesktopMagicPluginAPI-Plugin-Main 'DesktopMagicPluginAPI.Plugin.Main') - - [OnMouseClick(position,mouseButton)](#M-DesktopMagicPluginAPI-Plugin-OnMouseClick-System-Drawing-Point,DesktopMagicPluginAPI-Inputs-MouseButton- 'DesktopMagicPluginAPI.Plugin.OnMouseClick(System.Drawing.Point,DesktopMagicPluginAPI.Inputs.MouseButton)') - - [OnMouseMove(position)](#M-DesktopMagicPluginAPI-Plugin-OnMouseMove-System-Drawing-Point- 'DesktopMagicPluginAPI.Plugin.OnMouseMove(System.Drawing.Point)') - - [OnMouseWheel(position,delta)](#M-DesktopMagicPluginAPI-Plugin-OnMouseWheel-System-Drawing-Point,System-Int32- 'DesktopMagicPluginAPI.Plugin.OnMouseWheel(System.Drawing.Point,System.Int32)') - - [Start()](#M-DesktopMagicPluginAPI-Plugin-Start 'DesktopMagicPluginAPI.Plugin.Start') - - [Stop()](#M-DesktopMagicPluginAPI-Plugin-Stop 'DesktopMagicPluginAPI.Plugin.Stop') -- [RenderQuality](#T-DesktopMagicPluginAPI-Drawing-RenderQuality 'DesktopMagicPluginAPI.Drawing.RenderQuality') - - [High](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-High 'DesktopMagicPluginAPI.Drawing.RenderQuality.High') - - [Low](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-Low 'DesktopMagicPluginAPI.Drawing.RenderQuality.Low') - - [Performance](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-Performance 'DesktopMagicPluginAPI.Drawing.RenderQuality.Performance') -- [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') - - [#ctor(min,max,value)](#M-DesktopMagicPluginAPI-Inputs-Slider-#ctor-System-Double,System-Double,System-Double- 'DesktopMagicPluginAPI.Inputs.Slider.#ctor(System.Double,System.Double,System.Double)') - - [Maximum](#P-DesktopMagicPluginAPI-Inputs-Slider-Maximum 'DesktopMagicPluginAPI.Inputs.Slider.Maximum') - - [Minimum](#P-DesktopMagicPluginAPI-Inputs-Slider-Minimum 'DesktopMagicPluginAPI.Inputs.Slider.Minimum') - - [Value](#P-DesktopMagicPluginAPI-Inputs-Slider-Value 'DesktopMagicPluginAPI.Inputs.Slider.Value') -- [TextBox](#T-DesktopMagicPluginAPI-Inputs-TextBox 'DesktopMagicPluginAPI.Inputs.TextBox') - - [#ctor(value)](#M-DesktopMagicPluginAPI-Inputs-TextBox-#ctor-System-String- 'DesktopMagicPluginAPI.Inputs.TextBox.#ctor(System.String)') - - [Value](#P-DesktopMagicPluginAPI-Inputs-TextBox-Value 'DesktopMagicPluginAPI.Inputs.TextBox.Value') - - -## Button `type` - -##### Namespace - -DesktopMagicPluginAPI.Inputs - -##### Summary - -Represents a button control. - - -### #ctor(value) `constructor` - -##### Summary - -Initializes a new instance of the [Button](#T-DesktopMagicPluginAPI-Inputs-Button 'DesktopMagicPluginAPI.Inputs.Button') class with the provided `value`. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| value | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The text caption displayed in the [Button](#T-DesktopMagicPluginAPI-Inputs-Button 'DesktopMagicPluginAPI.Inputs.Button') control. | - - -### Value `property` - -##### Summary - -Gets or sets the text caption displayed in the [Button](#T-DesktopMagicPluginAPI-Inputs-Button 'DesktopMagicPluginAPI.Inputs.Button') element. - - -### Click() `method` - -##### Summary - -Triggers the [](#E-DesktopMagicPluginAPI-Inputs-Button-OnClick 'DesktopMagicPluginAPI.Inputs.Button.OnClick') event. - -##### Parameters - -This method has no parameters. - - -## CheckBox `type` - -##### Namespace - -DesktopMagicPluginAPI.Inputs - -##### Summary - -Represents a check box control. - - -### #ctor(value) `constructor` - -##### Summary - -Initializes a new instance of the [CheckBox](#T-DesktopMagicPluginAPI-Inputs-CheckBox 'DesktopMagicPluginAPI.Inputs.CheckBox') class with the provided `value`. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| value | [System.Boolean](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Boolean 'System.Boolean') | A value indicating whether the [CheckBox](#T-DesktopMagicPluginAPI-Inputs-CheckBox 'DesktopMagicPluginAPI.Inputs.CheckBox') is in the checked state. | - - -### Value `property` - -##### Summary - -Gets or set a value indicating whether the [CheckBox](#T-DesktopMagicPluginAPI-Inputs-CheckBox 'DesktopMagicPluginAPI.Inputs.CheckBox') is in the checked state. - - -## ComboBox `type` - -##### Namespace - -DesktopMagicPluginAPI.Inputs - -##### Summary - -Represents a selection control with a drop-down list. - - -### #ctor(items) `constructor` - -##### Summary - -Initializes a new instance of the [Label](#T-DesktopMagicPluginAPI-Inputs-Label 'DesktopMagicPluginAPI.Inputs.Label') class with the provided `items`. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| items | [System.String[]](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String[] 'System.String[]') | | - - -### Items `property` - -##### Summary - -Gets the collection used to generate the content of the [ComboBox](#T-DesktopMagicPluginAPI-Inputs-ComboBox 'DesktopMagicPluginAPI.Inputs.ComboBox'). - - -### Value `property` - -##### Summary - -Gets the currently selected item associated with this [ComboBox](#T-DesktopMagicPluginAPI-Inputs-ComboBox 'DesktopMagicPluginAPI.Inputs.ComboBox'). - -##### Remarks - -If you assign a value to this property, the displayed text in the user interface will not be changed. - - -## Element `type` - -##### Namespace - -DesktopMagicPluginAPI.Inputs - -##### Summary - -The element base class. - - -### ValueChanged() `method` - -##### Summary - -Triggers the [](#E-DesktopMagicPluginAPI-Inputs-Element-OnValueChanged 'DesktopMagicPluginAPI.Inputs.Element.OnValueChanged') event. - -##### Parameters - -This method has no parameters. - - -## ElementAttribute `type` - -##### Namespace - -DesktopMagicPluginAPI.Inputs - -##### Summary - -Marks a Property as element. - - -### #ctor(name,orderIndex) `constructor` - -##### Summary - -Marks a Property as element with the provided `name` and `orderIndex`. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| name | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The name of the element. | -| orderIndex | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The order index of the element. | - - -### #ctor(orderIndex) `constructor` - -##### Summary - -Marks a Property as element with the provided `orderIndex`. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| orderIndex | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The order index of the element. | - - -### #ctor() `constructor` - -##### Summary - -*Inherit from parent.* - -##### Parameters - -This constructor has no parameters. - - -### Name `property` - -##### Summary - -The name of the element. - - -### OrderIndex `property` - -##### Summary - -The order index of the element. - - -## GraphicsExtentions `type` - -##### Namespace - -DesktopMagicPluginAPI.Drawing - -##### Summary - -Extensions for the [Graphics](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Graphics 'System.Drawing.Graphics') class. - - -### DrawStringFixedWidth(graphics,s,font,brush,x,y,width) `method` - -##### Summary - - - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| graphics | [System.Drawing.Graphics](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Graphics 'System.Drawing.Graphics') | Graphics object. | -| s | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | String to draw. | -| font | [System.Drawing.Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') | [Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') that defines the text format of the string. | -| brush | [System.Drawing.Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') | [Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') that determines the color and texture of the drawn text. | -| x | [System.Single](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Single 'System.Single') | The x-coordinate of the upper-left corner of the drawn text. | -| y | [System.Single](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Single 'System.Single') | The y-coordinate of the upper-left corner of the drawn text. | -| width | [System.Single](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Single 'System.Single') | The specified width. | - - -### DrawStringFixedWidth(graphics,s,font,brush,point,width) `method` - -##### Summary - - - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| graphics | [System.Drawing.Graphics](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Graphics 'System.Drawing.Graphics') | Graphics object. | -| s | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | String to draw. | -| font | [System.Drawing.Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') | [Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') that defines the text format of the string. | -| brush | [System.Drawing.Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') | [Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') that determines the color and texture of the drawn text. | -| point | [System.Drawing.PointF](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.PointF 'System.Drawing.PointF') | [PointF](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.PointF 'System.Drawing.PointF') structure that specifies the upper-left corner of the drawn text. | -| width | [System.Single](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Single 'System.Single') | The specified width. | - - -### DrawStringMonospace(graphics,s,font,brush,x,y) `method` - -##### Summary - - - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| graphics | [System.Drawing.Graphics](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Graphics 'System.Drawing.Graphics') | Graphics object. | -| s | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | String to draw. | -| font | [System.Drawing.Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') | [Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') that defines the text format of the string. | -| brush | [System.Drawing.Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') | [Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') that determines the color and texture of the drawn text. | -| x | [System.Single](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Single 'System.Single') | The x-coordinate of the upper-left corner of the drawn text. | -| y | [System.Single](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Single 'System.Single') | The y-coordinate of the upper-left corner of the drawn text. | - - -### DrawStringMonospace(graphics,s,font,brush,point) `method` - -##### Summary - - - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| graphics | [System.Drawing.Graphics](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Graphics 'System.Drawing.Graphics') | Graphics object. | -| s | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | String to draw. | -| font | [System.Drawing.Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') | [Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') that defines the text format of the string. | -| brush | [System.Drawing.Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') | [Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') that determines the color and texture of the drawn text. | -| point | [System.Drawing.PointF](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.PointF 'System.Drawing.PointF') | [PointF](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.PointF 'System.Drawing.PointF') structure that specifies the upper-left corner of the drawn text. | - - -### DrawStringNoLeftPadding(graphics,s,font,brush,x,y) `method` - -##### Summary - - - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| graphics | [System.Drawing.Graphics](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Graphics 'System.Drawing.Graphics') | Graphics object. | -| s | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | String to draw. | -| font | [System.Drawing.Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') | [Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') that defines the text format of the string. | -| brush | [System.Drawing.Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') | [Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') that determines the color and texture of the drawn text. | -| x | [System.Single](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Single 'System.Single') | The x-coordinate of the upper-left corner of the drawn text. | -| y | [System.Single](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Single 'System.Single') | The y-coordinate of the upper-left corner of the drawn text. | - - -### DrawStringNoLeftPadding(graphics,s,font,brush,point) `method` - -##### Summary - - - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| graphics | [System.Drawing.Graphics](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Graphics 'System.Drawing.Graphics') | Graphics object. | -| s | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | String to draw. | -| font | [System.Drawing.Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') | [Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') that defines the text format of the string. | -| brush | [System.Drawing.Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') | [Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') that determines the color and texture of the drawn text. | -| point | [System.Drawing.PointF](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.PointF 'System.Drawing.PointF') | [PointF](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.PointF 'System.Drawing.PointF') structure that specifies the upper-left corner of the drawn text. | - - -### MeasureStringNoLeftPadding(graphics,text,font) `method` - -##### Summary - - - -##### Returns - - - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| graphics | [System.Drawing.Graphics](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Graphics 'System.Drawing.Graphics') | Graphics object. | -| text | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | String to measure. | -| font | [System.Drawing.Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') | [Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') that defines the text format of the string. | - - -## IPluginData `type` - -##### Namespace - -DesktopMagicPluginAPI - -##### Summary - -Defines properties and methods that provide information about the main application. - - -### Color `property` - -##### Summary - -Gets the current color of the current theme. - - -### Font `property` - -##### Summary - -Gets the current font of the current theme. - - -### PluginName `property` - -##### Summary - -Gets the name of the plugin. - - -### PluginPath `property` - -##### Summary - -Gets the path of the parent directory of the plugin. - - -### Theme `property` - -##### Summary - -Gets the current theme setting of the main application. - - -### WindowPosition `property` - -##### Summary - -Gets the window position of the plugin window. - - -### WindowSize `property` - -##### Summary - -Gets the window size of the plugin window. - - -### UpdateWindow() `method` - -##### Summary - -Updates the plugin window. - -##### Parameters - -This method has no parameters. - - -## ITheme `type` - -##### Namespace - -DesktopMagicPluginAPI - -##### Summary - -The theme settings of the main application. - - -### BackgroundColor `property` - -##### Summary - -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 current theme. - - -### Margin `property` - -##### Summary - -Gets the corner radius of the current theme. - - -### PrimaryColor `property` - -##### Summary - -Gets the primary color of the current theme. - - -### SecondaryColor `property` - -##### Summary - -Gets the secondary color of the current theme. - - -## IntegerUpDown `type` - -##### Namespace - -DesktopMagicPluginAPI.Inputs - -##### Summary - -Represents a up-down control. - - -### #ctor(min,max,value) `constructor` - -##### Summary - -Initializes a new instance of the [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown') class with the provided `min` value, `max` value and `value`. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| min | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The maximum value for the [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown') element. | -| max | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The minimum value for the [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown') element. | -| value | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The value assigned to the [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown') element. | - -##### Exceptions - -| Name | Description | -| ---- | ----------- | -| [System.ArgumentException](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.ArgumentException 'System.ArgumentException') | | - - -### Maximum `property` - -##### Summary - -Gets or sets the maximum value for the [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown') element. - - -### Minimum `property` - -##### Summary - -Gets or sets the minimum value for the [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown') element. - - -### Value `property` - -##### Summary - -Gets or sets the value assigned to the [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown') element. - - -## Label `type` - -##### Namespace - -DesktopMagicPluginAPI.Inputs - -##### Summary - -Represents a label control. - - -### #ctor(value,bold) `constructor` - -##### Summary - -Initializes a new instance of the [Label](#T-DesktopMagicPluginAPI-Inputs-Label 'DesktopMagicPluginAPI.Inputs.Label') class with the provided `value`. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| value | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The text associated with this [Label](#T-DesktopMagicPluginAPI-Inputs-Label 'DesktopMagicPluginAPI.Inputs.Label') | -| bold | [System.Boolean](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Boolean 'System.Boolean') | A value indicating whether the content of the [Label](#T-DesktopMagicPluginAPI-Inputs-Label 'DesktopMagicPluginAPI.Inputs.Label') is bold or not. | - - -### Bold `property` - -##### Summary - -Gets or set a value indicating whether the content of the [Label](#T-DesktopMagicPluginAPI-Inputs-Label 'DesktopMagicPluginAPI.Inputs.Label') is bold or not. - - -### Value `property` - -##### Summary - -Gets or sets the text associated with this [Label](#T-DesktopMagicPluginAPI-Inputs-Label 'DesktopMagicPluginAPI.Inputs.Label'). - - -## MouseButton `type` - -##### Namespace - -DesktopMagicPluginAPI.Inputs - -##### Summary - -Mouse Buttons - - -### Left `constants` - -##### Summary - -The left mouse button. - - -### Middle `constants` - -##### Summary - -The middle mouse button. - - -### Right `constants` - -##### Summary - -The right mouse button. - - -## Plugin `type` - -##### Namespace - -DesktopMagicPluginAPI - -##### Summary - -The plugin class. - - -### Application `property` - -##### Summary - -Informations about the main application. - - -### RenderQuality `property` - -##### Summary - -Gets or sets the render quality of the bitmap image. - - -### UpdateInterval `property` - -##### Summary - -Gets or sets the interval, expressed in milliseconds, at which to call the [Main](#M-DesktopMagicPluginAPI-Plugin-Main 'DesktopMagicPluginAPI.Plugin.Main') method. - - -### Main() `method` - -##### Summary - -Occurs when the [UpdateInterval](#P-DesktopMagicPluginAPI-Plugin-UpdateInterval 'DesktopMagicPluginAPI.Plugin.UpdateInterval') elapses. - -##### Returns - - - -##### Parameters - -This method has no parameters. - - -### OnMouseClick(position,mouseButton) `method` - -##### Summary - -Occurs when the window is clicked by the mouse. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| position | [System.Drawing.Point](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Point 'System.Drawing.Point') | The x- and y-coordinates of the mouse pointer position relative to the plugin window. | -| mouseButton | [DesktopMagicPluginAPI.Inputs.MouseButton](#T-DesktopMagicPluginAPI-Inputs-MouseButton 'DesktopMagicPluginAPI.Inputs.MouseButton') | The button associated with the event. | - - -### OnMouseMove(position) `method` - -##### Summary - -Occurs when the mouse pointer is moved over the control. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| position | [System.Drawing.Point](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Point 'System.Drawing.Point') | The x- and y-coordinates of the mouse pointer position relative to the plugin window. | - - -### OnMouseWheel(position,delta) `method` - -##### Summary - -Occurs when the user rotates the mouse wheel while the mouse pointer is over this element. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| position | [System.Drawing.Point](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Point 'System.Drawing.Point') | The x- and y-coordinates of the mouse pointer position relative to the plugin window. | -| delta | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | A value that indicates the amount that the mouse wheel has changed. | - - -### Start() `method` - -##### Summary - -Occurs once when the plugin gets activated. - -##### Parameters - -This method has no parameters. - - -### Stop() `method` - -##### Summary - -Occurs once when the plugin gets deactivated. - -##### Parameters - -This method has no parameters. - - -## RenderQuality `type` - -##### Namespace - -DesktopMagicPluginAPI.Drawing - -##### Summary - -Specifies which render quality is used to display the bitmap images. - - -### High `constants` - -##### Summary - -Slower then [Low](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-Low 'DesktopMagicPluginAPI.Drawing.RenderQuality.Low') but produces higher quality output. - - -### Low `constants` - -##### Summary - -Faster then [High](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-High 'DesktopMagicPluginAPI.Drawing.RenderQuality.High') but produces lower quality output. - - -### Performance `constants` - -##### Summary - -Provides performance benefits over [Low](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-Low 'DesktopMagicPluginAPI.Drawing.RenderQuality.Low') - - -## Slider `type` - -##### Namespace - -DesktopMagicPluginAPI.Inputs - -##### Summary - -Represents a slider control. - - -### #ctor(min,max,value) `constructor` - -##### Summary - -Initializes a new instance of the [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') class with the provided `min` value, `max` value and `value`. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| min | [System.Double](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Double 'System.Double') | The maximum value for the [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') element. | -| max | [System.Double](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Double 'System.Double') | The minimum value for the [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') element. | -| value | [System.Double](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Double 'System.Double') | The value assigned to the [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') element. | - - -### Maximum `property` - -##### Summary - -Gets or sets the maximum value for the [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') element. - - -### Minimum `property` - -##### Summary - -Gets or sets the minimum value for the [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') element. - - -### Value `property` - -##### Summary - -Gets or sets the value assigned to the [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') element. - - -## TextBox `type` - -##### Namespace - -DesktopMagicPluginAPI.Inputs - -##### Summary - -Represents a text box control. - - -### #ctor(value) `constructor` - -##### Summary - -Initializes a new instance of the [TextBox](#T-DesktopMagicPluginAPI-Inputs-TextBox 'DesktopMagicPluginAPI.Inputs.TextBox') class with the provided `value`. - -##### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| value | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The text associated with this control. | - - -### Value `property` - -##### Summary - -Gets or sets the text associated with this [TextBox](#T-DesktopMagicPluginAPI-Inputs-TextBox 'DesktopMagicPluginAPI.Inputs.TextBox'). diff --git a/src/DesktopMagicPluginAPI/api/.gitignore b/src/DesktopMagicPluginAPI/api/.gitignore new file mode 100644 index 0000000..e8079a3 --- /dev/null +++ b/src/DesktopMagicPluginAPI/api/.gitignore @@ -0,0 +1,5 @@ +############### +# temp file # +############### +*.yml +.manifest diff --git a/src/DesktopMagicPluginAPI/api/index.md b/src/DesktopMagicPluginAPI/api/index.md new file mode 100644 index 0000000..78dc9c0 --- /dev/null +++ b/src/DesktopMagicPluginAPI/api/index.md @@ -0,0 +1,2 @@ +# PLACEHOLDER +TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*! diff --git a/src/DesktopMagicPluginAPI/articles/intro.md b/src/DesktopMagicPluginAPI/articles/intro.md new file mode 100644 index 0000000..c0478ce --- /dev/null +++ b/src/DesktopMagicPluginAPI/articles/intro.md @@ -0,0 +1 @@ +# Add your introductions here! diff --git a/src/DesktopMagicPluginAPI/articles/toc.yml b/src/DesktopMagicPluginAPI/articles/toc.yml new file mode 100644 index 0000000..ff89ef1 --- /dev/null +++ b/src/DesktopMagicPluginAPI/articles/toc.yml @@ -0,0 +1,2 @@ +- name: Introduction + href: intro.md diff --git a/src/DesktopMagicPluginAPI/docfx.json b/src/DesktopMagicPluginAPI/docfx.json new file mode 100644 index 0000000..ac49d2d --- /dev/null +++ b/src/DesktopMagicPluginAPI/docfx.json @@ -0,0 +1,65 @@ +{ + "metadata": [ + { + "src": [ + { + "files": [ + "**.csproj" + ], + "src": "C:\\Users\\David\\Programmieren\\DesktopMagic\\src\\DesktopMagicPluginAPI" + } + ], + "dest": "api", + "disableGitFeatures": false, + "disableDefaultFilter": false + } + ], + "build": { + "content": [ + { + "files": [ + "api/**.yml", + "api/index.md" + ] + }, + { + "files": [ + "articles/**.md", + "articles/**/toc.yml", + "toc.yml", + "*.md" + ] + } + ], + "resource": [ + { + "files": [ + "images/**" + ] + } + ], + "overwrite": [ + { + "files": [ + "apidoc/**.md" + ], + "exclude": [ + "obj/**", + "_site/**" + ] + } + ], + "dest": "_site", + "globalMetadataFiles": [], + "fileMetadataFiles": [], + "template": [ + "default" + ], + "postProcessors": [], + "markdownEngineName": "markdig", + "noLangKeyword": false, + "keepFileLink": false, + "cleanupCacheHistory": false, + "disableGitFeatures": false + } +} \ No newline at end of file diff --git a/src/DesktopMagicPluginAPI/index.md b/src/DesktopMagicPluginAPI/index.md new file mode 100644 index 0000000..3ae2506 --- /dev/null +++ b/src/DesktopMagicPluginAPI/index.md @@ -0,0 +1,4 @@ +# This is the **HOMEPAGE**. +Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files. +## Quick Start Notes: +1. Add images to the *images* folder if the file is referencing an image. diff --git a/src/DesktopMagicPluginAPI/toc.yml b/src/DesktopMagicPluginAPI/toc.yml new file mode 100644 index 0000000..59f8010 --- /dev/null +++ b/src/DesktopMagicPluginAPI/toc.yml @@ -0,0 +1,5 @@ +- name: Articles + href: articles/ +- name: Api Documentation + href: api/ + homepage: api/index.md