29 Commits
Author SHA1 Message Date
Stone_Red ae2bee3125 Merge branch 'develop' 2021-12-23 11:30:25 +01:00
Stone_Red 3d48777224 - Add stuff 2021-12-23 11:30:16 +01:00
Stone_Red 0a3b4060de - Remove stuff 2021-12-23 11:25:09 +01:00
Stone_Red b2dfec2ed3 - Fix git fuckup 2021-12-23 11:22:16 +01:00
Stone_Red d1c598505e Revert "- Rename src to _src"
This reverts commit 441a8b00cc.
2021-12-23 11:12:51 +01:00
Stone_Red 441a8b00cc - Rename src to _src 2021-12-23 11:11:06 +01:00
Stone_Red 7a8503ea9f - Add new releases 2021-12-23 11:00:49 +01:00
Stone_Red de80a58b54 - Fix installer 2021-12-23 10:44:02 +01:00
Stone_Red f62ea316a1 - Fix logging issues 2021-12-23 10:20:58 +01:00
Stone-Red-Code 668c393a1b - Minor code improvements 2021-11-12 15:58:29 +01:00
Stone-Red-Code ed84fe37ed Merge branch 'develop'
# Conflicts:
#	update/DesktopMagic.zip
#	update/updateInfo.json
2021-11-06 19:04:04 +01:00
Stone-Red-Code 24dac76057 - Preparation for release 0.0.3.1 2021-11-06 18:56:34 +01:00
Stone-Red-Code 5e3642e539 - Add ComboBox element to the API 2021-10-30 21:06:53 +02:00
Stone-Red-Code 2f6662caea - Add Margin option
- Add `Margin` property to `ITheme`
- Add `Stop` method to the `Plugin` API
- Add `DrawStringNoLeftPadding` and `MeasureStringNoLeftPadding` to `GraphicsExtentions`
- Convert most inbuilt components to plugins.
- Minor code improvements
2021-10-29 20:35:01 +02:00
Stone-Red-Code aeb31af2f9 - Minor code impovemnets 2021-10-28 17:53:01 +02:00
Stone-Red-Code 8f650ac35a - Add Corner Radius option
- Improved API documentation
- Fix updater check time
- Fix logging
2021-10-27 22:01:20 +02:00
Stone-Red-Code b69bba68bb - Fix resize courser showing when windows are not in edit mode.
- Add more logging
- Implement some IntelliSense suggestions
2021-10-26 23:16:38 +02:00
Stone-Red-Code d75aef7460 - Code Cleanup 2021-10-26 18:40:45 +02:00
Stone-Red-Code 9dd40c7ae8 - Better theming system
- More code structure inmrovements
2021-10-25 22:38:45 +02:00
Stone_Red 921d6dfc20 Update README.md 2021-10-24 19:41:39 +02:00
Stone-Red-Code 520f145eb0 - Improve code structure
- Improve log output format
2021-10-24 19:38:45 +02:00
Stone-Red-Code 77a1383e7b - Fix Obsolete warning messages 2021-10-03 18:30:33 +02:00
Stone-Red-Code 4e5502977d - Fix some spelling mistakes 2021-09-27 16:14:50 +02:00
Stone_Red 7761f505b1 Add files via upload 2021-09-23 22:52:43 +02:00
Stone_Red 05271e5f51 Update updateInfo.json 2021-09-23 22:52:32 +02:00
Stone_Red 3d7caf2011 Delete DesktopMagic-Standalone.zip 2021-09-23 22:51:57 +02:00
Stone_Red c25c270bd9 Add files via upload 2021-09-23 22:33:25 +02:00
Stone_Red c29d70ef0d Delete DesktopMagic.zip 2021-09-23 22:32:40 +02:00
Stone_Red 528d1161fe Update updateInfo.json 2021-09-23 22:31:56 +02:00
63 changed files with 2111 additions and 2502 deletions
+1
View File
@@ -12,6 +12,7 @@ obj/
*.user
*.userosscache
*.sln.docstates
*GPUCache/
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
+1 -1
View File
@@ -8,7 +8,7 @@
- [Plugin Documentation](https://github.com/Stone-Red-Code/DesktopMagic/wiki)
- [Licence](https://github.com/Stone-Red-Code/DesktopMagic/blob/main/LICENSE)
## Usage
## Setup
1. Download one of the [releases](https://github.com/Stone-Red-Code/DesktopMagic/releases).
1. Follow one of the steps below.
+3 -3
View File
@@ -2,14 +2,14 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "DesktopMagic"
#define MyAppVersion "0.0.3.0"
#define MyAppVersion "0.0.3.2"
#define MyAppPublisher "Stone_Red"
#define MyAppExeName "DesktopMagic.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{61FE5CE9-47C3-4255-A1F4-5BCF4ACA0876}
AppId={{61FE5CE9-47C3-4255-A1F4-5BCF4ACA0879}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
@@ -36,7 +36,7 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
[Files]
Source: "..\DesktopMagic\bin\Release\net5.0-windows\publish\DesktopMagic.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net6.0-windows\publish\*"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
+131 -110
View File
@@ -1,130 +1,151 @@
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;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
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.FromHours(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/main/update/updateInfo.json");
private readonly Updater updater = new Updater(TimeSpan.FromDays(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/main/update/updateInfo.json");
#endif
public const string AppName = "Desktop Magic";
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";
// 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 succesfull
if (!createdNew)
{
Logger.Log("Shutting down because other instance already running.", "Setup");
//Shutdown Aplication
Current.Shutdown();
}
else
{
Exit += CloseMutexHandler;
updater.ProgressChanged += Updater_ProgressChanged;
updater.OnException += Updater_OnException;
updater.NoUpdateAvailible += Updater_NoUpdateAvailible;
updater.UpdateAvailible += Updater_UpdateAvailible;
updater.Start();
}
Setup(false);
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();
}
Setup(true);
Exit += CloseMutexHandler;
private void Updater_NoUpdateAvailible()
{
Logger.Log("No update avalible.", "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.Console | 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}}}\n> at {{{LogFormatType.LineNumber},3}} | {{{LogFormatType.FilePath}}}"
}
};
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($"Downloading: {progressPercentage}% {totalBytesDownloaded}/{totalFileSize}", "Updater");
}
protected void CloseMutexHandler(object sender, EventArgs e)
{
_mutex?.Close();
}
private void Setup(bool clearLogFile)
{
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)
{
_ = MessageBox.Show(ex.ToString());
Logger.Log(ex.Message, "Setup", LogSeverity.Error);
}
if (clearLogFile)
{
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);
}
}
@@ -14,8 +14,15 @@
x:Name="window">
<Grid>
<Rectangle x:Name="panel" Fill="#4CBAFFEF" Stroke="White" Margin="0,0,0,0" Visibility="Collapsed" />
<Viewbox StretchDirection="DownOnly" Stretch="Uniform">
<TextBlock x:Name="textBlock" FontSize="999" Foreground="White" Text="CPU: 000%" IsHitTestVisible="False" />
<Border x:Name="border"/>
<Viewbox x:Name="viewBox" StretchDirection="Both" Stretch="Uniform">
<Viewbox.Clip>
<RectangleGeometry x:Name="rectangleGeometry" RadiusX="{Binding ElementName=border, Path=CornerRadius.TopLeft}" RadiusY="{Binding ElementName=border, Path=CornerRadius.TopLeft}" Rect="{Binding ElementName=border}"/>
</Viewbox.Clip>
<DockPanel x:Name="dockPanel">
<TextBlock x:Name="textBlock" Foreground="White" FontSize="100" Text="CPU: " IsHitTestVisible="False" />
<TextBlock x:Name="valueTextBlock" TextAlignment="Right" FontSize="100" Foreground="White" Text="000%" IsHitTestVisible="False" />
</DockPanel>
</Viewbox>
</Grid>
<WindowChrome.WindowChrome>
@@ -1,4 +1,6 @@
using Microsoft.Win32;
using DesktopMagic.Helpers;
using Microsoft.Win32;
using System;
using System.Diagnostics;
@@ -6,12 +8,10 @@ using System.Timers;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Threading;
namespace DesktopMagic
{
/// <summary>
/// Interaktionslogik für TimeWindow.xaml
/// </summary>
public partial class CpuUsageWindow : Window
{
private RegistryKey key;
@@ -41,7 +41,7 @@ namespace DesktopMagic
Timer t = new Timer();
t.Interval = 100;
t.Elapsed += T_Elapsed;
t.Elapsed += UpdateTimer_Elapsed;
t.Start();
Timer valueTimer = new Timer();
@@ -68,23 +68,37 @@ namespace DesktopMagic
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(() =>
{
if (MainWindow.EditMode)
{
panel.Visibility = Visibility.Visible;
tileBar.CaptionHeight = tileBar.CaptionHeight = ActualHeight - 10 < 0 ? 0 : ActualHeight - 10;
WindowPos.SetIsLocked(this, false);
ResizeMode = ResizeMode.CanResize;
}
else
{
panel.Visibility = Visibility.Collapsed;
tileBar.CaptionHeight = 0;
WindowPos.SetIsLocked(this, true);
ResizeMode = ResizeMode.NoResize;
}
textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont);
textBlock.Foreground = MainWindow.GlobalColor;
rectangleGeometry.Rect = new Rect(0, 0, border.ActualWidth, border.ActualHeight);
border.Background = MainWindow.Theme.BackgroundBrush;
border.CornerRadius = new CornerRadius(MainWindow.Theme.CornerRadius);
viewBox.Margin = new Thickness(MainWindow.Theme.Margin);
border.Width = viewBox.ActualWidth + MainWindow.Theme.Margin * 2;
border.Height = viewBox.ActualHeight + MainWindow.Theme.Margin * 2;
textBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
textBlock.Foreground = MainWindow.Theme.PrimaryBrush;
valueTextBlock.FontFamily = new FontFamily(MainWindow.Theme.Font);
valueTextBlock.Foreground = MainWindow.Theme.PrimaryBrush;
ClculateWidth();
});
}
@@ -93,13 +107,24 @@ namespace DesktopMagic
string cpuUsage = GetCpuUsage();
Dispatcher.Invoke(() =>
{
textBlock.Text = cpuUsage;
valueTextBlock.Text = cpuUsage;
});
}
private void ClculateWidth()
{
string template = "CPU: ###%";
double lenght = 0;
for (int i = 0; i < 9; i++)
{
lenght = Math.Max(StringUtilities.MeasureString(template.Replace('#', i.ToString()[0]), textBlock).Width, lenght);
}
dockPanel.Width = lenght;
}
private string GetCpuUsage()
{
return "CPU: " + ((int)cpuCounter.NextValue()).ToString().PadLeft(3, '0') + "%";
return $"{(int)cpuCounter.NextValue()}%";
}
private void Window_LocationChanged(object sender, EventArgs e)
@@ -0,0 +1,50 @@
using DesktopMagicPluginAPI;
using System;
using System.Drawing;
using System.Drawing.Text;
namespace DesktopMagic.BuiltInWindowElements
{
internal class DatePlugin : Plugin
{
public override int UpdateInterval => 1000;
private DateTime oldDateTime = new DateTime();
private Color oldColor = Color.White;
private string oldFont;
public override Bitmap Main()
{
if (oldDateTime.Date == DateTime.Now.Date && oldColor == Application.Theme.PrimaryColor && oldFont == Application.Theme.Font)
{
return null;
}
oldDateTime = DateTime.Now;
oldColor = Application.Theme.PrimaryColor;
oldFont = Application.Theme.Font;
string date = DateTime.Now.ToLongDateString();
Font font = new Font(Application.Theme.Font, 200);
Bitmap bmp = new Bitmap(1, 1);
bmp.SetResolution(100, 100);
using Graphics tmpGr = Graphics.FromImage(bmp);
tmpGr.TextRenderingHint = TextRenderingHint.AntiAlias;
SizeF size = tmpGr.MeasureString(date, font);
bmp = new Bitmap((int)size.Width, (int)size.Height);
bmp.SetResolution(100, 100);
using Graphics gr = Graphics.FromImage(bmp);
gr.TextRenderingHint = TextRenderingHint.AntiAlias;
gr.DrawString(date, font, new SolidBrush(Application.Theme.PrimaryColor), 0, 0);
return bmp;
}
}
}
@@ -1,111 +1,33 @@
using Microsoft.Win32;
using DesktopMagicPluginAPI;
using NAudio.Wave;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Timers;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
namespace DesktopMagic
namespace DesktopMagic.BuiltInWindowElements
{
public partial class MusicVisualizerWindow : Window
internal class MusicVisualizerPlugin : Plugin
{
[DllImport("user32.dll")]
private static extern void SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
private readonly RegistryKey key;
private readonly IWaveIn waveIn;
private IWaveIn waveIn;
private const int fftLength = 1024; // NAudio fft wants powers of two!
private readonly SampleAggregator sampleAggregator = new SampleAggregator(fftLength);
private volatile bool calculate = true;
private Bitmap output = new Bitmap(880, 300);
public MusicVisualizerWindow()
public override int UpdateInterval => 0;
public override void Start()
{
InitializeComponent();
Window w = new()
{
Top = -100,
Left = -100,
Width = 0,
Height = 0,
WindowStyle = WindowStyle.ToolWindow,
ShowInTaskbar = false
};
w.Show();
Owner = w;
w.Hide();
sampleAggregator.FftCalculated += new EventHandler<FftEventArgs>(FftCalculated);
sampleAggregator.FftCalculated += FftCalculated;
sampleAggregator.PerformFFT = true;
waveIn = new WasapiLoopbackCapture();
waveIn.DataAvailable += OnDataAvailable;
waveIn.StartRecording();
Timer t = new Timer();
t.Interval = 100;
t.Elapsed += T_Elapsed;
t.Start();
key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName);
Top = double.Parse(key.GetValue("MusicVisualizerWindowTop", 100).ToString());
Left = double.Parse(key.GetValue("MusicVisualizerWindowLeft", 100).ToString());
Height = double.Parse(key.GetValue("MusicVisualizerWindowHeight", 200).ToString());
Width = double.Parse(key.GetValue("MusicVisualizerWindowWidth", 500).ToString());
IsEnabled = false;
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
//Set the window style to noactivate.
WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
}
private void T_Elapsed(object sender, ElapsedEventArgs e)
{
Dispatcher.Invoke(() =>
{
if (MainWindow.EditMode)
{
panel.Visibility = Visibility.Visible;
WindowPos.SetIsLocked(this, false);
}
else
{
panel.Visibility = Visibility.Collapsed;
WindowPos.SetIsLocked(this, true);
}
if (!IsLoaded)
{
calculate = false;
}
else
{
calculate = true;
}
});
}
private void OnDataAvailable(object sender, WaveInEventArgs e)
@@ -134,7 +56,7 @@ namespace DesktopMagic
}
List<double> fft = new List<double>();
for (int i = 0; i < e.Result.Length / 2 - 70; i++)
for (int i = 0; i < (e.Result.Length / 2) - 70; i++)
{
int v = i;
if (v < 20)
@@ -142,7 +64,7 @@ namespace DesktopMagic
v = 20;
}
int multiplier = 100 - MainWindow.AmplifierLevel * 2;
int multiplier = 100 - (MainWindow.AmplifierLevel * 2);
multiplier = multiplier == 0 ? 1 : multiplier;
fft.Add(Math.Abs(e.Result[i].Y * v / multiplier));
}
@@ -173,7 +95,7 @@ namespace DesktopMagic
{
double temp = 0;
int j;
for (j = i * count; j < count + i * count; j++)
for (j = i * count; j < count + (i * count); j++)
{
temp += fft[j];
}
@@ -227,9 +149,6 @@ namespace DesktopMagic
lastFft = fft;
try
{
Stopwatch sw = new Stopwatch();
sw.Start();
Bitmap bm = new Bitmap(885, 300);
int offset = 0;
if (!MainWindow.MirrorMode && MainWindow.SpectrumMode != 1)
@@ -242,9 +161,9 @@ namespace DesktopMagic
offset = 1;
}
using (Graphics gr = Graphics.FromImage(bm))
using (Graphics gr = Graphics.FromImage(output))
{
gr.SmoothingMode = SmoothingMode.None;
gr.Clear(Color.Transparent);
PointF[] points = new PointF[scaledFft.Count + 2];
int fftIndex = 0;
@@ -264,8 +183,8 @@ namespace DesktopMagic
if (!fftIndexReverse)
{
points[pointIndex + 1] = new PointF(bm.Width - 4 * pointIndex, bm.Height / 2 + value);
points[points.Length / 2 + pointIndex + 1] = new PointF(bm.Width - 4 * pointIndex, bm.Height / 2 - value);
points[pointIndex + 1] = new PointF(output.Width - (4 * pointIndex), (output.Height / 2) + value);
points[(points.Length / 2) + pointIndex + 1] = new PointF(output.Width - (4 * pointIndex), (output.Height / 2) - value);
}
break;
@@ -274,7 +193,7 @@ namespace DesktopMagic
break;
default:
points[pointIndex + 1] = new PointF(2 * pointIndex, bm.Height - value - 1 + offset);
points[pointIndex + 1] = new PointF(2 * pointIndex, output.Height - value - 1 + offset);
break;
}
@@ -296,17 +215,11 @@ namespace DesktopMagic
}
}
SetPoints(points, bm.Width, bm.Height, offset);
SetPoints(points, output.Width, output.Height, offset);
Brush brush;
if (MainWindow.MusicVisualzerColor == null)
{
brush = MainWindow.GlobalSystemColor;
}
else
{
brush = MainWindow.MusicVisualzerColor;
}
Brush brush = MainWindow.MusicVisualzerColor.HasValue
? new SolidBrush(MainWindow.MusicVisualzerColor.Value)
: new SolidBrush(MainWindow.Theme.PrimaryColor);
if (MainWindow.LineMode)
{
@@ -326,10 +239,7 @@ namespace DesktopMagic
}
}
Dispatcher.BeginInvoke((Action)delegate
{
image.Source = BitmapToImageSource(bm);
});
Application.UpdateWindow();
}
catch { }
}
@@ -340,51 +250,33 @@ namespace DesktopMagic
{
case 1:
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 - 1] = new PointF(0, height / 2);
points[(points.Length / 2) - 1] = new PointF(0, height / 2);
break;
case 2:
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;
default:
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;
}
}
private BitmapSource BitmapToImageSource(Bitmap bitmap)
public override Bitmap Main()
{
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,
System.Windows.Media.PixelFormats.Bgra32, null,
bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride);
bitmap.UnlockBits(bitmapData);
return bitmapSource;
return output;
}
private void Window_LocationChanged(object sender, EventArgs e)
public override void Stop()
{
key.SetValue("MusicVisualizerWindowTop", this.Top);
key.SetValue("MusicVisualizerWindowLeft", this.Left);
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
key.SetValue("MusicVisualizerWindowHeight", Height);
key.SetValue("MusicVisualizerWindowWidth", Width);
tileBar.CaptionHeight = ActualHeight - 10;
calculate = false;
waveIn?.StopRecording();
}
}
}
@@ -0,0 +1,55 @@
using DesktopMagicPluginAPI;
using DesktopMagicPluginAPI.Drawing;
using DesktopMagicPluginAPI.Inputs;
using System;
using System.Drawing;
using System.Drawing.Text;
namespace DesktopMagic.BuiltInWindowElements
{
internal class TimePlugin : Plugin
{
[Element("Display Seconds:")]
private CheckBox checkBox = new CheckBox(true);
public override int UpdateInterval => 1000;
public override Bitmap Main()
{
string time = checkBox.Value ? DateTime.Now.ToLongTimeString() : DateTime.Now.ToShortTimeString();
Font font = new Font(Application.Theme.Font, 200);
Bitmap bmp = new Bitmap(1, 1);
using Graphics tmpGr = Graphics.FromImage(bmp);
tmpGr.TextRenderingHint = TextRenderingHint.AntiAlias;
SizeF size = CalculateSize(tmpGr, font);
bmp = new Bitmap((int)size.Width, (int)size.Height);
bmp.SetResolution(100, 100);
using Graphics gr = Graphics.FromImage(bmp);
gr.TextRenderingHint = TextRenderingHint.AntiAlias;
gr.DrawStringNoLeftPadding(time, font, new SolidBrush(Application.Theme.PrimaryColor), 0, 0);
return bmp;
}
private SizeF CalculateSize(Graphics graphics, Font font)
{
string template = checkBox.Value ? "##:##:##" : "##:##";
SizeF size = new SizeF();
for (int i = 0; i < 9; i++)
{
SizeF newSize = graphics.MeasureStringNoLeftPadding(template.Replace("#", i.ToString()), font);
size.Width = Math.Max(size.Width, newSize.Width);
size.Height = Math.Max(size.Height, newSize.Height);
}
return size;
}
}
}
-91
View File
@@ -1,91 +0,0 @@
using Google.Apis.Auth.OAuth2;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
namespace DesktopMagic
{
internal class CalendarManagment
{
private static string[] Scopes = { CalendarService.Scope.CalendarReadonly };
private static string ApplicationName = "Google Calendar API .NET " + App.AppName;
[Obsolete]
public (List<string>, List<string>) GetEvents()
{
List<string> upcomingEventNames = new List<string>();
List<string> upcomingEventTimes = new List<string>();
UserCredential credential;
if (!File.Exists("credentials.json"))
{
return (new(), new());
}
using (FileStream stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
// The file token.json stores the user's access and refresh tokens, and is created
// automatically when the authorization flow completes for the first time.
string credPath = "token.json";
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Debug.WriteLine("Credential file saved to: " + credPath);
}
// Create Google Calendar API service.
CalendarService service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
// Define parameters of request.
EventsResource.ListRequest request = service.Events.List("primary");
request.TimeMin = DateTime.Now;
request.ShowDeleted = false;
request.SingleEvents = true;
request.MaxResults = 10;
request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;
// List events.
Events events = request.Execute();
if (events.Items != null && events.Items.Count > 0)
{
foreach (Event eventItem in events.Items)
{
if (upcomingEventNames.Count < 10)
{
string when = eventItem.Start.DateTime.ToString();
if (string.IsNullOrEmpty(when))
{
when = eventItem.Start.Date;
}
upcomingEventNames.Add(eventItem.Summary);
upcomingEventTimes.Add(when);
}
}
}
return (upcomingEventNames, upcomingEventTimes);
}
}
internal class CalendarItems
{
public string eventname { get; set; }
public string dateTime { get; set; }
public string font { get; set; }
public string color { get; set; }
}
}
-38
View File
@@ -1,38 +0,0 @@
<Window x:Class="DesktopMagic.CalendarWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="CalendarWindow" Height="450" Width="800"
Background="Transparent"
WindowStyle="None"
AllowsTransparency="True"
LocationChanged="Window_LocationChanged"
SizeChanged="Window_SizeChanged"
x:Name="window">
<Grid>
<Rectangle x:Name="panel" Fill="#4CBAFFEF" Stroke="White" Margin="0,0,0,0" Visibility="Collapsed" />
<Viewbox StretchDirection="Both" Stretch="Uniform">
<ListView x:Name="listBox" Height="Auto" Width="Auto" Background="Transparent" BorderBrush="Transparent" FontSize="999" Foreground="White">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="{Binding eventname}" FontSize="10" FontFamily="{Binding font}" Foreground="{Binding color}" Margin="0,0" />
<TextBlock Text="{Binding dateTime}" FontSize="7" FontFamily="{Binding font}" Foreground="Gray" Margin="0,-3" />
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Viewbox>
</Grid>
<WindowChrome.WindowChrome>
<WindowChrome x:Name="tileBar" CaptionHeight="3000" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>
</Window>
-159
View File
@@ -1,159 +0,0 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
namespace DesktopMagic
{
/// <summary>
/// Interaktionslogik für TimeWindow.xaml
/// </summary>
public partial class CalendarWindow : Window
{
private RegistryKey key;
private string oldFont = "";
private Brush oldColor;
private List<string> upcomingEventNames = new List<string>();
private List<string> upcomingEventTimes = new List<string>();
public CalendarWindow()
{
InitializeComponent();
Window w = new Window();
w.Top = -100;
w.Left = -100;
w.Width = 0;
w.Height = 0;
w.WindowStyle = WindowStyle.ToolWindow;
w.ShowInTaskbar = false;
w.Show();
Owner = w;
w.Hide();
Timer t = new Timer();
t.Interval = 100;
t.Elapsed += T_Elapsed;
t.Start();
Timer valueTimer = new Timer();
valueTimer.Interval = 600000;
valueTimer.Elapsed += ValueTimer_Elapsed;
;
valueTimer.Start();
key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName);
Top = double.Parse(key.GetValue("CalendarWindowTop", 100).ToString());
Left = double.Parse(key.GetValue("CalendarWindowLeft", 100).ToString());
Height = double.Parse(key.GetValue("CalendarWindowHeight", 200).ToString());
Width = double.Parse(key.GetValue("CalendarWindowWidth", 500).ToString());
//this.IsEnabled = false;
Task.Run(() =>
{
(upcomingEventNames, upcomingEventTimes) = new CalendarManagment().GetEvents();
Dispatcher.Invoke(() =>
{
LoadEvents();
});
});
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
//Set the window style to noactivate.
WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
}
private void ValueTimer_Elapsed(object sender, ElapsedEventArgs e)
{
Task.Run(() =>
{
(upcomingEventNames, upcomingEventTimes) = new CalendarManagment().GetEvents();
Dispatcher.Invoke(() =>
{
LoadEvents();
});
});
}
private void T_Elapsed(object sender, ElapsedEventArgs e)
{
Dispatcher.Invoke(() =>
{
if (MainWindow.EditMode)
{
panel.Visibility = Visibility.Visible;
WindowPos.SetIsLocked(this, false);
}
else
{
panel.Visibility = Visibility.Collapsed;
WindowPos.SetIsLocked(this, true);
}
if (MainWindow.GlobalFont != oldFont || MainWindow.GlobalColor != oldColor)
{
oldColor = MainWindow.GlobalColor;
oldFont = MainWindow.GlobalFont;
LoadEvents();
}
listBox.SelectedIndex = -1;
});
}
private void LoadEvents()
{
listBox.Items.Clear();
CalendarItems calendarItem = new CalendarItems();
calendarItem.eventname = "Termine: ";
calendarItem.font = MainWindow.GlobalFont;
calendarItem.color = MainWindow.GlobalColor.ToString();
listBox.Items.Add(calendarItem);
for (int i = 0; i < upcomingEventNames.Count; i++)
{
DateTime dateTime = DateTime.Now;
DateTime.TryParse(upcomingEventTimes[i], out dateTime);
calendarItem = new CalendarItems();
calendarItem.eventname = upcomingEventNames[i];
calendarItem.dateTime = dateTime.ToString("dd-MM-yyyy");
calendarItem.font = MainWindow.GlobalFont;
calendarItem.color = MainWindow.GlobalColor.ToString();
if (dateTime < DateTime.Today.AddMonths(12) || upcomingEventTimes[i] == "-")
{
listBox.Items.Add(calendarItem);
}
}
while (listBox.Items.Count < 10)
{
listBox.Items.Add("");
}
}
private void Window_LocationChanged(object sender, EventArgs e)
{
key.SetValue("CalendarWindowTop", Top);
key.SetValue("CalendarWindowLeft", Left);
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
key.SetValue("CalendarWindowHeight", Height);
key.SetValue("CalendarWindowWidth", Width);
tileBar.CaptionHeight = ActualHeight - 10;
}
}
}
-23
View File
@@ -1,23 +0,0 @@
<Window x:Class="DesktopMagic.DateWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="DateWindow" Height="450" Width="800"
Background="Transparent"
WindowStyle="None"
AllowsTransparency="True"
LocationChanged="Window_LocationChanged"
SizeChanged="Window_SizeChanged"
x:Name="window">
<Grid>
<Rectangle x:Name="panel" Fill="#4CBAFFEF" Stroke="White" Margin="0,0,0,0" Visibility="Collapsed" />
<Viewbox StretchDirection="DownOnly" Stretch="Uniform">
<TextBlock x:Name="textBlock" FontSize="999" Foreground="White" Text=" " IsHitTestVisible="False" />
</Viewbox>
</Grid>
<WindowChrome.WindowChrome>
<WindowChrome x:Name="tileBar" CaptionHeight="3000" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>
</Window>
-90
View File
@@ -1,90 +0,0 @@
using Microsoft.Win32;
using System;
using System.Timers;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
namespace DesktopMagic
{
/// <summary>
/// Interaktionslogik für TimeWindow.xaml
/// </summary>
public partial class DateWindow : Window
{
private RegistryKey key;
public DateWindow()
{
InitializeComponent();
Window w = new Window();
w.Top = -100;
w.Left = -100;
w.Width = 0;
w.Height = 0;
w.WindowStyle = WindowStyle.ToolWindow;
w.ShowInTaskbar = false;
w.Show();
Owner = w;
w.Hide();
Timer t = new Timer();
t.Interval = 100;
t.Elapsed += T_Elapsed;
t.Start();
key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName);
Top = double.Parse(key.GetValue("DateWindowTop", 100).ToString());
Left = double.Parse(key.GetValue("DateWindowLeft", 100).ToString());
Height = double.Parse(key.GetValue("DateWindowHeight", 200).ToString());
Width = double.Parse(key.GetValue("DateWindowWidth", 500).ToString());
IsEnabled = false;
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
//Set the window style to noactivate.
WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
}
private void T_Elapsed(object sender, ElapsedEventArgs e)
{
Dispatcher.Invoke(() =>
{
if (MainWindow.EditMode)
{
panel.Visibility = Visibility.Visible;
WindowPos.SetIsLocked(this, false);
}
else
{
panel.Visibility = Visibility.Collapsed;
WindowPos.SetIsLocked(this, true);
}
textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont);
textBlock.Foreground = MainWindow.GlobalColor;
textBlock.Text = DateTime.Now.ToString("D");
});
}
private void Window_LocationChanged(object sender, EventArgs e)
{
key.SetValue("DateWindowTop", Top);
key.SetValue("DateWindowLeft", Left);
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
key.SetValue("DateWindowHeight", Height);
key.SetValue("DateWindowWidth", Width);
tileBar.CaptionHeight = ActualHeight - 10;
}
}
}
+4 -4
View File
@@ -2,17 +2,17 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<RootNamespace>DesktopMagic</RootNamespace>
<ApplicationIcon>icon.ico</ApplicationIcon>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<Authors>Stone_Red</Authors>
<Version>0.0.3.0</Version>
<Version>0.0.3.2</Version>
<PackageProjectUrl>https://github.com/Stone-Red-Code/DesktopMagic</PackageProjectUrl>
<RepositoryUrl>https://github.com/Stone-Red-Code/DesktopMagic</RepositoryUrl>
<AssemblyVersion>0.0.3.0</AssemblyVersion>
<FileVersion>0.0.3.0</FileVersion>
<AssemblyVersion>0.0.3.2</AssemblyVersion>
<FileVersion>0.0.3.2</FileVersion>
<TargetFramework>net6.0-windows</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+49
View File
@@ -0,0 +1,49 @@
<Window x:Class="DesktopMagic.Dialogs.ColorDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:DesktopMagic.Dialogs"
mc:Ignorable="d"
ResizeMode="NoResize"
Title="ColorDialog"
SizeToContent="WidthAndHeight">
<Grid>
<StackPanel Margin="15">
<Label x:Name="label" Content="Label" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<DockPanel>
<Label Content="A:" Width="20" />
<Slider x:Name="alphaSlider" VerticalAlignment="Center" Maximum="255" ValueChanged="ColorSliders_ValueChanged" TickFrequency="1" IsSnapToTickEnabled="True" Background="#00030000" />
</DockPanel>
<DockPanel>
<Label Content="R:" Width="20" />
<Slider x:Name="redSlider" VerticalAlignment="Center" Maximum="255" ValueChanged="ColorSliders_ValueChanged" TickFrequency="1" IsSnapToTickEnabled="True" Background="#00030000" />
</DockPanel>
<DockPanel>
<Label Content="G:" Width="20" />
<Slider x:Name="greenSlider" VerticalAlignment="Center" Maximum="255" ValueChanged="ColorSliders_ValueChanged" TickFrequency="1" IsSnapToTickEnabled="True" Background="#0000FF00" />
</DockPanel>
<DockPanel>
<Label Content="B:" Width="20" />
<Slider x:Name="blueSlider" VerticalAlignment="Center" Maximum="255" ValueChanged="ColorSliders_ValueChanged" TickFrequency="1" IsSnapToTickEnabled="True" Background="#000000FF" />
</DockPanel>
<StackPanel Orientation="Horizontal">
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
<Rectangle x:Name="colorRechtangle" Fill="White" />
</Border>
<TextBox x:Name="colorHexTextBox" MaxLength="9" CharacterCasing="Upper" Height="23" TextWrapping="Wrap" Width="350" TextChanged="ColorHexTextBox_TextChanged" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center">
<materialDesign:TextFieldAssist.CharacterCounterStyle>
<Style TargetType="TextBlock" />
</materialDesign:TextFieldAssist.CharacterCounterStyle>
</TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0">
<Button x:Name="okButton" Content="{DynamicResource ok }" HorizontalAlignment="Left" Margin="0,0,10,0" VerticalAlignment="Top" Width="100" Click="OkButton_Click" Cursor="Hand"/>
<Button x:Name="cancelButton" Content="{DynamicResource cancel }" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="100" Click="CancelButton_Click"/>
</StackPanel>
</StackPanel>
</Grid>
</Window>
@@ -0,0 +1,130 @@
using DesktopMagic.Helpers;
using System;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace DesktopMagic.Dialogs
{
/// <summary>
/// Interaction logic for ColorDialog.xaml
/// </summary>
public partial class ColorDialog : Window
{
public ColorDialog(string content, System.Drawing.Color defaultColor, string title = "ColorDialog")
{
InitializeComponent();
label.Content = content;
Title = title;
SetLanguageDictionary();
alphaSlider.Value = defaultColor.A;
redSlider.Value = defaultColor.R;
greenSlider.Value = defaultColor.G;
blueSlider.Value = defaultColor.B;
}
public System.Drawing.Color ResultColor { get; private set; }
public Brush ResultBrush { get; private set; }
private void OkButton_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
}
private void ColorSliders_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
colorHexTextBox.Select(colorHexTextBox.Text.Length, 0);
SetColorText();
}
private void ColorHexTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (colorHexTextBox.Text.Length > 0)
{
if (colorHexTextBox.Text.ToCharArray()[0] != '#')
{
colorHexTextBox.Text = "#" + colorHexTextBox.Text.Replace("#", "");
}
}
else
{
colorHexTextBox.Text = "#";
colorHexTextBox.Select(colorHexTextBox.Text.Length, 0);
}
if (colorHexTextBox.SelectionStart == 0)
{
if (colorHexTextBox.Text.Length <= 2)
{
colorHexTextBox.Select(colorHexTextBox.Text.Length, 0);
}
else
{
colorHexTextBox.Select(1, 0);
}
}
string hex = colorHexTextBox.Text;
if (MultiColorConverter.TryConvertToMediaColor(hex, out Color color) && MultiColorConverter.TryConvertToSystemColor(hex, out System.Drawing.Color systemColor))
{
alphaSlider.Value = color.A;
redSlider.Value = color.R;
greenSlider.Value = color.G;
blueSlider.Value = color.B;
Brush brush = new SolidColorBrush(color);
ResultBrush = brush;
ResultColor = systemColor;
colorRechtangle.Fill = brush;
colorHexTextBox.Foreground = Brushes.Black;
return;
}
else
{
colorHexTextBox.Foreground = Brushes.Red;
}
}
private void SetColorText()
{
if (alphaSlider.Value == 255)
{
colorHexTextBox.Text = "#";
}
else
{
colorHexTextBox.Text = "#" + ((int)alphaSlider.Value).ToString("X2");
}
colorHexTextBox.Text += ((int)redSlider.Value).ToString("X2") + ((int)greenSlider.Value).ToString("X2") + ((int)blueSlider.Value).ToString("X2");
}
private void SetLanguageDictionary()
{
ResourceDictionary dict = new ResourceDictionary();
string currentCulture = Thread.CurrentThread.CurrentCulture.ToString();
if (currentCulture.Contains("de"))
{
dict.Source = new Uri("..\\Resources\\StringResources.de.xaml", UriKind.Relative);
}
else
{
dict.Source = new Uri("..\\Resources\\StringResources.en.xaml", UriKind.Relative);
}
Resources.MergedDictionaries.Add(dict);
}
}
}
@@ -1,16 +1,17 @@
<Window x:Class="DesktopMagic.InputDialog"
<Window x:Class="DesktopMagic.Dialogs.InputDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DesktopMagic"
xmlns:local="clr-namespace:DesktopMagic.Dialogs"
mc:Ignorable="d"
Title="InputDialog" Height="152.812" Width="322.812"
ResizeMode="NoResize">
Title="InputDialog"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight">
<Grid>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Margin="15">
<Label x:Name="label" Content="Label" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="279" VerticalContentAlignment="Center"/>
<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="280" VerticalContentAlignment="Center"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0">
<Button x:Name="okButton" Content="{DynamicResource ok }" HorizontalAlignment="Left" Margin="0,0,10,0" VerticalAlignment="Top" Width="100" Click="OkButton_Click" Cursor="Hand"/>
<Button x:Name="cancelButton" Content="{DynamicResource cancel }" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="100" Click="CancelButton_Click"/>
@@ -2,25 +2,22 @@
using System.Threading;
using System.Windows;
namespace DesktopMagic
namespace DesktopMagic.Dialogs
{
/// <summary>
/// Interaktionslogik für InputDialog.xaml
/// </summary>
public partial class InputDialog : Window
{
public InputDialog(string content, string title = "InputDialog")
{
InitializeComponent();
label.Content = content;
this.Title = title;
Title = title;
SetLanguageDictionary();
}
public string ResponseText
{
get { return textBox.Text; }
set { textBox.Text = value; }
get => textBox.Text;
set => textBox.Text = value;
}
private void OkButton_Click(object sender, RoutedEventArgs e)
@@ -46,7 +43,7 @@ namespace DesktopMagic
{
dict.Source = new Uri("..\\Resources\\StringResources.en.xaml", UriKind.Relative);
}
this.Resources.MergedDictionaries.Add(dict);
Resources.MergedDictionaries.Add(dict);
}
}
}
+2 -2
View File
@@ -5,5 +5,5 @@
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("Style", "IDE0090:Use 'new(...)'", Justification = "<Pending>", Scope = "member", Target = "~M:DesktopMagic.MainWindow.GithubButton_Click(System.Object,System.Windows.RoutedEventArgs)")]
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Windows only application")]
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "No need to")]
@@ -0,0 +1,76 @@
using System.Globalization;
using System.Text.RegularExpressions;
namespace DesktopMagic.Helpers
{
internal static class MultiColorConverter
{
public static string ConvertToHex(System.Drawing.Color color)
{
return $"#{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}";
}
public static string ConvertToHex(System.Windows.Media.Color color)
{
return $"#{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}";
}
public static bool TryConvertToSystemColor(string hex, out System.Drawing.Color color)
{
hex = hex.Replace("#", "");
if (hex.Length == 8 && Regex.IsMatch(hex, "(?:[0-9a-fA-F]{8})"))
{
int a = int.Parse(hex.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int r = int.Parse(hex.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int g = int.Parse(hex.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int b = int.Parse(hex.Substring(6, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
color = System.Drawing.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b);
return true;
}
else if (hex.Length == 6 && Regex.IsMatch(hex, "(?:[0-9a-fA-F]{6})"))
{
int a = 255;
int r = int.Parse(hex.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int g = int.Parse(hex.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int b = int.Parse(hex.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
color = System.Drawing.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b);
return true;
}
else
{
color = System.Drawing.Color.Transparent;
return false;
}
}
public static bool TryConvertToMediaColor(string hex, out System.Windows.Media.Color color)
{
hex = hex.Replace("#", "");
if (hex.Length == 8 && Regex.IsMatch(hex, "(?:[0-9a-fA-F]{8})"))
{
int a = int.Parse(hex.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int r = int.Parse(hex.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int g = int.Parse(hex.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int b = int.Parse(hex.Substring(6, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
color = System.Windows.Media.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b);
return true;
}
else if (hex.Length == 6 && Regex.IsMatch(hex, "(?:[0-9a-fA-F]{6})"))
{
int a = 255;
int r = int.Parse(hex.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int g = int.Parse(hex.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int b = int.Parse(hex.Substring(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
color = System.Windows.Media.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b);
return true;
}
else
{
color = System.Windows.Media.Colors.Transparent;
return false;
}
}
}
}
@@ -0,0 +1,238 @@
using DesktopMagic.Plugins;
using System;
using System.Windows;
using System.Windows.Controls;
namespace DesktopMagic.Helpers
{
internal class SettingElementGenerator
{
private readonly ComboBox optionsComboBox;
public SettingElementGenerator(ComboBox optionsComboBox)
{
this.optionsComboBox = optionsComboBox;
}
public void Generate(SettingElement settingElement, DockPanel dockPanel, TextBlock textBlock)
{
dockPanel.UpdateLayout();
textBlock.UpdateLayout();
if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Label eLabel)
{
textBlock.Text = eLabel.Value;
textBlock.Margin = new Thickness(0, 5, 3, 0);
textBlock.HorizontalAlignment = HorizontalAlignment.Stretch;
textBlock.TextWrapping = TextWrapping.WrapWithOverflow;
if (eLabel.Bold)
{
textBlock.FontWeight = FontWeights.Bold;
}
eLabel.OnValueChanged += () =>
{
textBlock.Dispatcher.Invoke(() =>
{
textBlock.Text = eLabel.Value;
});
};
}
else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Button eButton)
{
Button button = new()
{
Content = eButton.Value,
FontSize = 10,
Height = 20,
Margin = new Thickness(0, 10, 0, 10),
Padding = new Thickness(0),
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch
};
button.Click += (_s, _e) =>
{
try
{
eButton.Click();
}
catch (Exception ex)
{
DisplayException(ex.Message);
}
};
eButton.OnValueChanged += () =>
{
button.Dispatcher.Invoke(() =>
{
button.Content = eButton.Value;
});
};
_ = dockPanel.Children.Add(button);
}
else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.CheckBox eCheckBox)
{
CheckBox checkBox = new()
{
IsChecked = eCheckBox.Value,
Style = (Style)dockPanel.FindResource("MaterialDesignDarkCheckBox"),
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch
};
checkBox.Click += (_s, _e) =>
{
try
{
eCheckBox.Value = checkBox.IsChecked.GetValueOrDefault();
}
catch (Exception ex)
{
DisplayException(ex.Message);
}
};
eCheckBox.OnValueChanged += () =>
{
checkBox.Dispatcher.Invoke(() =>
{
checkBox.IsChecked = eCheckBox.Value;
});
};
_ = dockPanel.Children.Add(checkBox);
}
else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.TextBox eTextBox)
{
TextBox textBox = new()
{
Text = eTextBox.Value,
TextWrapping = TextWrapping.Wrap,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch
};
textBox.TextChanged += (_s, _e) =>
{
try
{
eTextBox.Value = textBox.Text;
}
catch (Exception ex)
{
DisplayException(ex.Message);
}
};
eTextBox.OnValueChanged += () =>
{
textBox.Dispatcher.Invoke(() =>
{
textBox.Text = eTextBox.Value;
});
};
_ = dockPanel.Children.Add(textBox);
}
else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.IntegerUpDown eIntegerUpDown)
{
Xceed.Wpf.Toolkit.IntegerUpDown integerUpDown = new()
{
Value = eIntegerUpDown.Value,
Minimum = eIntegerUpDown.Minimum,
Maximum = eIntegerUpDown.Maximum,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch
};
integerUpDown.ValueChanged += (_s, _e) =>
{
try
{
eIntegerUpDown.Value = integerUpDown.Value.GetValueOrDefault();
}
catch (Exception ex)
{
DisplayException(ex.Message);
}
};
eIntegerUpDown.OnValueChanged += () =>
{
integerUpDown.Dispatcher.Invoke(() =>
{
integerUpDown.Value = eIntegerUpDown.Value;
});
};
_ = dockPanel.Children.Add(integerUpDown);
}
else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.Slider eSlider)
{
Slider slider = new()
{
Value = eSlider.Value,
Minimum = eSlider.Minimum,
Maximum = eSlider.Maximum,
TickFrequency = 1,
IsSnapToTickEnabled = true,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch
};
slider.ValueChanged += (_s, _e) =>
{
try
{
eSlider.Value = slider.Value;
}
catch (Exception ex)
{
DisplayException(ex.Message);
}
};
eSlider.OnValueChanged += () =>
{
slider.Dispatcher.Invoke(() =>
{
slider.Value = eSlider.Value;
});
};
_ = dockPanel.Children.Add(slider);
}
else if (settingElement.Element is DesktopMagicPluginAPI.Inputs.ComboBox eComboBox)
{
ComboBox comboBox = new()
{
ItemsSource = eComboBox.Items,
IsEditable = false,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch,
SelectedIndex = 0
};
comboBox.SelectionChanged += (_s, _e) =>
{
try
{
eComboBox.Value = comboBox.Text;
}
catch (Exception ex)
{
DisplayException(ex.Message);
}
};
eComboBox.OnValueChanged += () =>
{
comboBox.SelectedItem = eComboBox.Value;
};
_ = dockPanel.Children.Add(comboBox);
}
}
private void DisplayException(string message)
{
App.Logger.Log(message, "PluginInput");
_ = MessageBox.Show("File execution error:\n" + message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
int index = MainWindow.WindowNames.IndexOf(optionsComboBox.SelectedItem.ToString());
PluginWindow window = MainWindow.Windows[index];
window?.Exit();
}
}
}
@@ -0,0 +1,25 @@
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace DesktopMagic.Helpers
{
internal static class StringUtilities
{
public static Size MeasureString(string input, TextBlock element)
{
FormattedText formattedText = new FormattedText(
input,
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface(element.FontFamily, element.FontStyle, element.FontWeight, element.FontStretch),
element.FontSize,
Brushes.Black,
new NumberSubstitution(),
1);
return new Size(formattedText.Width, formattedText.Height);
}
}
}
@@ -541,7 +541,7 @@ namespace DesktopMagic
public static extern int GetSystemMetrics(int abc);
[DllImport("user32.dll", EntryPoint = "GetWindowDC")]
public static extern IntPtr GetWindowDC(Int32 ptr);
public static extern IntPtr GetWindowDC(int ptr);
[DllImport("user32.dll")]
public static extern bool IsWindowVisible(IntPtr hWnd);
@@ -559,7 +559,7 @@ namespace DesktopMagic
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr bmp);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, IntPtr lParam);
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(IntPtr windowHandle, uint Msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags flags, uint timeout, out IntPtr result);
@@ -590,7 +590,7 @@ namespace DesktopMagic
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SetWindowPosFlags uFlags);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern Int32 SystemParametersInfo(UInt32 action, UInt32 uParam, string vParam, UInt32 winIni);
public static extern int SystemParametersInfo(uint action, uint uParam, string vParam, uint winIni);
[StructLayout(LayoutKind.Sequential)]
public struct BbStruct //Blur Behind Structure
@@ -642,37 +642,37 @@ namespace DesktopMagic
public int X
{
get { return Left; }
get => Left;
set { Right -= (Left - value); Left = value; }
}
public int Y
{
get { return Top; }
get => Top;
set { Bottom -= (Top - value); Top = value; }
}
public int Height
{
get { return Bottom - Top; }
set { Bottom = value + Top; }
get => Bottom - Top;
set => Bottom = value + Top;
}
public int Width
{
get { return Right - Left; }
set { Right = value + Left; }
get => Right - Left;
set => Right = value + Left;
}
public System.Drawing.Point Location
{
get { return new System.Drawing.Point(Left, Top); }
get => new System.Drawing.Point(Left, Top);
set { X = value.X; Y = value.Y; }
}
public System.Drawing.Size Size
{
get { return new System.Drawing.Size(Width, Height); }
get => new System.Drawing.Size(Width, Height);
set { Width = value.Width; Height = value.Height; }
}
@@ -703,10 +703,15 @@ namespace DesktopMagic
public override bool Equals(object obj)
{
if (obj is RECT)
return Equals((RECT)obj);
else if (obj is System.Drawing.Rectangle)
return Equals(new RECT((System.Drawing.Rectangle)obj));
if (obj is RECT rECT)
{
return Equals(rECT);
}
else if (obj is System.Drawing.Rectangle rectangle)
{
return Equals(new RECT(rectangle));
}
return false;
}
@@ -29,8 +29,8 @@ namespace DesktopMagic
int cy,
uint uFlags);
private const UInt32 SWP_NOSIZE1 = 0x0001;
private const UInt32 SWP_NOMOVE1 = 0x0002;
private const uint SWP_NOSIZE1 = 0x0001;
private const uint SWP_NOMOVE1 = 0x0002;
private static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
@@ -42,7 +42,7 @@ namespace DesktopMagic
public static void SendWpfWindowBack(Window window)
{
var hWnd = new WindowInteropHelper(window).Handle;
IntPtr hWnd = new WindowInteropHelper(window).Handle;
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE1 | SWP_NOMOVE1);
}
@@ -62,12 +62,12 @@ namespace DesktopMagic
private static void IsLocked_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var window = (Window)d;
var isHooked = d.GetValue(IsHookedProperty) != null;
Window window = (Window)d;
bool isHooked = d.GetValue(IsHookedProperty) != null;
if (!isHooked)
{
var hook = new WindowLockHook(window);
WindowLockHook hook = new WindowLockHook(window);
d.SetValue(IsHookedProperty, hook);
}
}
@@ -82,10 +82,9 @@ namespace DesktopMagic
public WindowLockHook(Window window)
{
this.Window = window;
Window = window;
var source = PresentationSource.FromVisual(window) as HwndSource;
if (source == null)
if (PresentationSource.FromVisual(window) is not HwndSource source)
{
// If there is no hWnd, we need to wait until there is
window.SourceInitialized += Window_SourceInitialized;
@@ -98,7 +97,7 @@ namespace DesktopMagic
private void Window_SourceInitialized(object sender, EventArgs e)
{
var source = (HwndSource)PresentationSource.FromVisual(Window);
HwndSource source = (HwndSource)PresentationSource.FromVisual(Window);
source.AddHook(WndProc);
}
@@ -106,7 +105,7 @@ namespace DesktopMagic
{
if (msg == WM_WINDOWPOSCHANGING && GetIsLocked(Window))
{
var wp = Marshal.PtrToStructure<WINDOWPOS>(lParam);
WINDOWPOS wp = Marshal.PtrToStructure<WINDOWPOS>(lParam);
wp.flags |= SWP_NOMOVE | SWP_NOSIZE;
Marshal.StructureToPtr(wp, lParam, false);
}
+55 -29
View File
@@ -38,14 +38,15 @@
<CheckBox x:Name="TimeCb" Content="{DynamicResource time}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
<CheckBox x:Name="DateCb" Content="{DynamicResource date}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
<CheckBox x:Name="CpuUsageCb" Content="{DynamicResource cpuUsage}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
<CheckBox x:Name="CalendarCb" Content="{DynamicResource googleCalendar}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" Visibility="Collapsed"/> <!--Currently disabled because it's not working-->
<CheckBox x:Name="CalendarCb" Content="{DynamicResource googleCalendar}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" Visibility="Collapsed"/>
<!--Currently disabled because it's not working-->
<CheckBox x:Name="MusicVisualizerCb" Content="{DynamicResource musicVisualizer}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
<DockPanel Grid.Column="1" Margin="2.5,0,0,0">
<ComboBox x:Name="optionsComboBox" DockPanel.Dock="Top" Height="24" SelectedIndex="0" DisplayMemberPath="Item1" SelectionChanged="OptionsComboBox_SelectionChanged" Background="#FFECECEC" Padding="4" VerticalAlignment="Center"/>
<ComboBox x:Name="optionsComboBox" DockPanel.Dock="Top" Height="24" SelectedIndex="0" SelectionChanged="OptionsComboBox_SelectionChanged" Background="#FFECECEC" Padding="4" VerticalAlignment="Center"/>
<ScrollViewer Background="#FFBBBBBB">
<Grid>
<StackPanel x:Name="optionsPanel" Margin="3,3,3,0" HorizontalAlignment="Stretch" Visibility="Collapsed" >
@@ -57,11 +58,11 @@
<Style TargetType="TextBlock" />
</materialDesign:TextFieldAssist.CharacterCounterStyle>
</TextBox>
<ComboBox x:Name="spectrumPlugineComboBox" ItemsSource="{DynamicResource musicVisualizerOptionsComboboxItems}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" SelectionChanged="SpectrumPlugineComboBox_SelectionChanged" />
<CheckBox x:Name="mirrorPlugineCheckBox" Content="{DynamicResource mirrorPlugine}" Click="MirrorPlugineCheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
<CheckBox x:Name="linePlugineCheckBox" Content="{DynamicResource linePlugine}" Click="LinePlugineCheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
<ComboBox x:Name="spectrumModeComboBox" ItemsSource="{DynamicResource musicVisualizerOptionsComboboxItems}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" SelectionChanged="SpectrumModeComboBox_SelectionChanged" />
<CheckBox x:Name="mirrorModeCheckBox" Content="{DynamicResource mirrorMode}" Click="MirrorModeCheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
<CheckBox x:Name="lineModeCheckBox" Content="{DynamicResource lineMode}" Click="LineModeCheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
<Label Content="{DynamicResource amplifier}" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="0,1" />
<Slider x:Name="amplifierLevelSlider" Margin="-2,0,10,0" HorizontalAlignment="Stretch" VerticalAlignment="Top" ValueChanged="AmplifierLevelSlider_ValueChanged" Maximum="50" Minimum="-50" SmallChange="1" LargeChange="5" Foreground="Gray" />
<Slider x:Name="amplifierLevelSlider" HorizontalAlignment="Stretch" VerticalAlignment="Top" ValueChanged="AmplifierLevelSlider_ValueChanged" Maximum="50" Minimum="-50" SmallChange="1" LargeChange="5" Foreground="Gray" />
<Label x:Name="amplifierLevelLabel" Content="Label" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="0,1" />
</StackPanel>
</Grid>
@@ -73,34 +74,59 @@
<RowDefinition Height="*" />
<RowDefinition Height="110" />
</Grid.RowDefinitions>
<StackPanel DockPanel.Dock="Top" Margin="{StaticResource DefaultMargin}">
<ComboBox x:Name="fontComboBox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="181" SelectionChanged="FontComboBox_SelectionChanged" Margin="0,0,0,5" />
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="Display Font: " Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"></TextBlock>
<ComboBox x:Name="fontComboBox" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" SelectionChanged="FontComboBox_SelectionChanged" Margin="0,0,0,5" />
<DockPanel>
<Label Content="R:" Width="20" />
<Slider x:Name="redSlider" Maximum="255" ValueChanged="ColorSliders_ValueChanged" TickFrequency="1" IsSnapToTickEnabled="True" Background="#00030000" />
</DockPanel>
<DockPanel>
<Label Content="G:" Width="20" />
<Slider x:Name="greenSlider" Maximum="255" ValueChanged="ColorSliders_ValueChanged" TickFrequency="1" IsSnapToTickEnabled="True" Background="#0000FF00" />
</DockPanel>
<DockPanel>
<Label Content="B:" Width="20" />
<Slider x:Name="blueSlider" Maximum="255" ValueChanged="ColorSliders_ValueChanged" TickFrequency="1" IsSnapToTickEnabled="True" Background="#000000FF" />
</DockPanel>
<TextBlock Text="Corner Radius: " Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="cornerRadiusTextBox" Grid.Column="1" Grid.Row="1" TextChanged="CornerRadiusTextBox_TextChanged" materialDesign:HintAssist.Hint="Enter a number">
<materialDesign:TextFieldAssist.CharacterCounterStyle>
<Style TargetType="TextBlock" />
</materialDesign:TextFieldAssist.CharacterCounterStyle>
</TextBox>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Margin: " Grid.Column="0" Grid.Row="3" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="marginTextBox" Grid.Column="1" Grid.Row="3" TextChanged="MarginTextBox_TextChanged" materialDesign:HintAssist.Hint="Enter a number">
<materialDesign:TextFieldAssist.CharacterCounterStyle>
<Style TargetType="TextBlock" />
</materialDesign:TextFieldAssist.CharacterCounterStyle>
</TextBox>
</Grid>
<StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
<DockPanel Margin="0,0,0,5">
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
<Rectangle x:Name="colorRechtangle" Fill="White" />
<Rectangle x:Name="primaryColorRechtangle" Fill="White" />
</Border>
<TextBox x:Name="colorHexTextBox" MaxLength="7" CharacterCasing="Upper" Height="23" TextWrapping="Wrap" Text="colorHexTextBox" Width="120" TextChanged="ColorHexTextBox_TextChanged" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center">
<materialDesign:TextFieldAssist.CharacterCounterStyle>
<Style TargetType="TextBlock" />
</materialDesign:TextFieldAssist.CharacterCounterStyle>
</TextBox>
</StackPanel>
<Button Content="Change Primary Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangePrimaryColorButton_Click"/>
</DockPanel>
<DockPanel Margin="0,0,0,5">
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
<Rectangle x:Name="secondaryColorRechtangle" Fill="White" />
</Border>
<Button Content="Change Secondary Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangeSecondaryColorButton_Click" />
</DockPanel>
<DockPanel>
<Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23" Margin="0,0,5,0">
<Rectangle x:Name="backgroundColorRechtangle" Fill="White" />
</Border>
<Button Content="Change Background Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangeBackgroundColorButton_Click" />
</DockPanel>
</StackPanel>
<Grid Grid.Row="1" VerticalAlignment="Bottom">
<Grid Grid.Row="1" Grid.ColumnSpan="2" VerticalAlignment="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
File diff suppressed because it is too large Load Diff
@@ -1,24 +0,0 @@
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:System="clr-namespace:System;assembly=mscorlib" x:Class="DesktopMagic.MusicVisualizerWindow"
mc:Ignorable="d"
Title="MusicVisualizerWindow" Height="450" Width="800"
Background="Transparent"
WindowStyle="None"
AllowsTransparency="True"
LocationChanged="Window_LocationChanged"
SizeChanged="Window_SizeChanged"
x:Name="window">
<WindowChrome.WindowChrome>
<WindowChrome x:Name="tileBar" CaptionHeight="30" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>
<Grid x:Name="grid">
<Rectangle x:Name="panel" Fill="#4CBAFFEF" Stroke="White" Margin="0,0,0,0" Visibility="Collapsed" />
<Viewbox StretchDirection="Both" Stretch="Uniform">
<Image x:Name="image" HorizontalAlignment="Left" Height="759" Margin="0,0,0,0" VerticalAlignment="Top" Width="1747" RenderTransformOrigin="0.5,0.5" Stretch="Fill" />
</Viewbox>
</Grid>
</Window>
-29
View File
@@ -1,29 +0,0 @@
using DesktopMagicPluginAPI;
using System.Drawing;
namespace DesktopMagic
{
internal class PluginData : IPluginData
{
private readonly PluginWindow window;
public PluginData(PluginWindow win)
{
window = win;
}
public string Font => MainWindow.GlobalFont;
public Color Color => (MainWindow.GlobalSystemColor as SolidBrush).Color;
public Point WindowSize => new Point((int)window.ActualWidth, (int)window.ActualHeight);
public Point WindowPosition => new Point((int)window.Left, (int)window.Top);
public string PluginName => window.PluginName;
public string PluginPath => window.PluginFolderPath;
public void UpdateWindow() => window.UpdatePluginWindow();
}
}
@@ -1,384 +0,0 @@
using DesktopMagicPluginAPI;
using DesktopMagicPluginAPI.Drawing;
using DesktopMagicPluginAPI.Inputs;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Timers;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace DesktopMagic
{
/// <summary>
/// Interaktionslogik für PluginWindow.xaml
/// </summary>
///
public partial class PluginWindow : Window
{
private readonly RegistryKey key;
private Thread pluginThread;
private System.Timers.Timer valueTimer;
private Plugin pluginClassInstance;
public string PluginName { get; private set; }
public string PluginFolderPath { get; private set; }
private bool stop = false;
public event Action PluginLoaded;
public event Action OnExit;
public PluginWindow(string pluginName)
{
InitializeComponent();
Window w = new()
{
Top = -100,
Left = -100,
Width = 0,
Height = 0,
WindowStyle = WindowStyle.ToolWindow,
ShowInTaskbar = false
};
w.Show();
Owner = w;
w.Hide();
System.Timers.Timer t = new System.Timers.Timer();
t.Interval = 100;
t.Elapsed += 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());
}
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(() =>
{
LoadPlugin();
});
pluginThread.Start();
}
public void UpdatePluginWindow()
{
ValueTimer_Elapsed(valueTimer, null);
}
private void 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 (stop)
{
((System.Timers.Timer)sender).Stop();
}
});
}
private void LoadPlugin()
{
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()
{
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;
}
object 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();
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<SettingElement> settingElements = new List<SettingElement>();
foreach (FieldInfo prop in props)
{
if (prop.GetValue(instance) is Element element)
{
object[] attrs = prop.GetCustomAttributes(true);
foreach (object attr in attrs)
{
if (attr 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)
{
stop = true;
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 (!stop)
{
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)
{
stop = true;
App.Logger.Log(ex.ToString(), "Plugin");
_ = MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Exit();
return;
}
if (stop)
{
valueTimer.Stop();
}
}
private 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,
System.Windows.Media.PixelFormats.Bgra32, null,
bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride);
bitmap.UnlockBits(bitmapData);
return bitmapSource;
}
public void Exit()
{
stop = true;
Dispatcher.Invoke(() =>
{
OnExit?.Invoke();
});
}
#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_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
stop = true;
}
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
}
}
-23
View File
@@ -1,23 +0,0 @@
using DesktopMagicPluginAPI.Inputs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DesktopMagic
{
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;
}
}
}
+34
View File
@@ -0,0 +1,34 @@
using DesktopMagicPluginAPI;
using System.Drawing;
namespace DesktopMagic.Plugins;
internal class PluginData : IPluginData
{
private readonly PluginWindow window;
public PluginData(PluginWindow window)
{
this.window = window;
}
public string Font => Theme.Font;
public Color Color => Theme.PrimaryColor;
public ITheme Theme { get; } = MainWindow.Theme;
public Size WindowSize => new Size((int)window.ActualWidth, (int)window.ActualHeight);
public Point WindowPosition => new Point((int)window.Left, (int)window.Top);
public string PluginName => window.PluginName;
public string PluginPath => window.PluginFolderPath;
public void UpdateWindow()
{
window.UpdatePluginWindow();
}
}
@@ -16,7 +16,12 @@
x:Name="window">
<Grid>
<Rectangle x:Name="panel" Fill="#4CBAFFEF" Stroke="White" Margin="0,0,0,0" Visibility="Collapsed" />
<Viewbox StretchDirection="Both" Stretch="Uniform">
<Border x:Name="border"/>
<Viewbox x:Name="viewBox" StretchDirection="Both" Stretch="Uniform">
<Viewbox.Clip>
<RectangleGeometry x:Name="rectangleGeometry" RadiusX="{Binding ElementName=border, Path=CornerRadius.TopLeft}" RadiusY="{Binding ElementName=border, Path=CornerRadius.TopLeft}"/>
</Viewbox.Clip>
<Image x:Name="image" HorizontalAlignment="Left" RenderOptions.EdgeMode="Aliased" Margin="0,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Stretch="Uniform" MouseDown="Window_MouseDown" MouseMove="Window_MouseMove" MouseWheel="Window_MouseWheel"/>
</Viewbox>
</Grid>
@@ -0,0 +1,410 @@
using DesktopMagic.Plugins;
using DesktopMagicPluginAPI;
using DesktopMagicPluginAPI.Drawing;
using DesktopMagicPluginAPI.Inputs;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Timers;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace DesktopMagic;
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)
{
InitializeComponent();
Window w = new()
{
Top = -100,
Left = -100,
Width = 0,
Height = 0,
WindowStyle = WindowStyle.ToolWindow,
ShowInTaskbar = false
};
w.Show();
Owner = w;
w.Hide();
System.Timers.Timer t = new System.Timers.Timer
{
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)
{
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(() =>
{
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", LogSeverity.Error);
_ = 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);
}
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<SettingElement> settingElements = new List<SettingElement>();
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
}
@@ -0,0 +1,17 @@
using DesktopMagicPluginAPI.Inputs;
namespace DesktopMagic.Plugins;
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;
}
}
+20
View File
@@ -0,0 +1,20 @@
using DesktopMagicPluginAPI;
using System.Drawing;
namespace DesktopMagic.Plugins;
internal class Theme : ITheme
{
public Color PrimaryColor { get; set; } = Color.White;
public Color SecondaryColor { get; set; } = Color.White;
public Color BackgroundColor { get; set; } = Color.Transparent;
public string Font { get; 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;
}
@@ -3,8 +3,8 @@
xmlns:col="clr-namespace:System.Collections;assembly=mscorlib"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="linePlugine">Linie</system:String>
<system:String x:Key="mirrorPlugine">Spiegeln</system:String>
<system:String x:Key="lineMode">Linie</system:String>
<system:String x:Key="mirrorMode">Spiegeln</system:String>
<system:String x:Key="updatePlugins">Plugins Neu Laden</system:String>
<system:String x:Key="openPluginsFolder">Plugins Ordner Öffnen</system:String>
<system:String x:Key="downloadPlugins">Plugins Herunterladen</system:String>
@@ -3,8 +3,8 @@
xmlns:col="clr-namespace:System.Collections;assembly=mscorlib"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="linePlugine">Line</system:String>
<system:String x:Key="mirrorPlugine">Mirror</system:String>
<system:String x:Key="lineMode">Line</system:String>
<system:String x:Key="mirrorMode">Mirror</system:String>
<system:String x:Key="updatePlugins">Reload Plugins</system:String>
<system:String x:Key="openPluginsFolder">Open Plugins Folder</system:String>
<system:String x:Key="downloadPlugins">Download Plugins</system:String>
-23
View File
@@ -1,23 +0,0 @@
<Window x:Class="DesktopMagic.TimeWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="TimeWindow" Height="450" Width="800"
Background="Transparent"
WindowStyle="None"
AllowsTransparency="True"
LocationChanged="Window_LocationChanged"
SizeChanged="Window_SizeChanged"
x:Name="window">
<Grid>
<Rectangle x:Name="panel" Fill="#4CBAFFEF" Stroke="White" Margin="0,0,0,0" Visibility="Collapsed" />
<Viewbox StretchDirection="DownOnly" Stretch="Uniform">
<TextBlock x:Name="textBlock" FontSize="999" Foreground="White" Text=" " IsHitTestVisible="False" />
</Viewbox>
</Grid>
<WindowChrome.WindowChrome>
<WindowChrome x:Name="tileBar" CaptionHeight="30" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>
</Window>
-92
View File
@@ -1,92 +0,0 @@
using Microsoft.Win32;
using System;
using System.Timers;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
namespace DesktopMagic
{
/// <summary>
/// Interaktionslogik für TimeWindow.xaml
/// </summary>
public partial class TimeWindow : Window
{
private RegistryKey key;
public TimeWindow()
{
InitializeComponent();
Window w = new Window();
w.Top = -100;
w.Left = -100;
w.Width = 0;
w.Height = 0;
w.WindowStyle = WindowStyle.ToolWindow;
w.ShowInTaskbar = false;
w.Show();
Owner = w;
w.Hide();
Timer t = new Timer();
t.Interval = 100;
t.Elapsed += T_Elapsed;
t.Start();
key = Registry.CurrentUser.CreateSubKey(@"Software\" + App.AppName);
Top = double.Parse(key.GetValue("TimeWindowTop", 100).ToString());
Left = double.Parse(key.GetValue("TimeWindowLeft", 100).ToString());
Height = double.Parse(key.GetValue("TimeWindowHeight", 200).ToString());
Width = double.Parse(key.GetValue("TimeWindowWidth", 500).ToString());
IsEnabled = false;
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
//Set the window style to noactivate.
WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
}
private void T_Elapsed(object sender, ElapsedEventArgs e)
{
Dispatcher.Invoke(() =>
{
if (MainWindow.EditMode)
{
panel.Visibility = Visibility.Visible;
WindowPos.SetIsLocked(this, false);
}
else
{
panel.Visibility = Visibility.Collapsed;
WindowPos.SetIsLocked(this, true);
}
textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont);
textBlock.Foreground = MainWindow.GlobalColor;
//textBlock.Text = DateTime.Now.ToString("hh:mm:ss tt");
textBlock.Text = DateTime.Now.ToString("HH:mm:ss");
});
}
private void Window_LocationChanged(object sender, EventArgs e)
{
key.SetValue("TimeWindowTop", Top);
key.SetValue("TimeWindowLeft", Left);
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
key.SetValue("TimeWindowHeight", Height);
key.SetValue("TimeWindowWidth", Width);
tileBar.CaptionHeight = ActualHeight - 10;
}
}
}
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
+7 -2
View File
@@ -1,11 +1,12 @@
using DesktopMagicPluginAPI;
using DesktopMagicPluginAPI.Inputs;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Collections.Generic;
using System.Threading.Tasks;
using System;
namespace DesktopMagicPlugin.Test
{
@@ -71,12 +72,16 @@ namespace DesktopMagicPlugin.Test
public override Bitmap Main()
{
if (bitmaps.Count == 0)
{
return new Bitmap(1, 1);
}
frameCount++;
if (frameCount >= bitmaps.Count)
{
frameCount = 0;
}
return bitmaps[frameCount];
}
+9
View File
@@ -0,0 +1,9 @@
###############
# folder #
###############
/**/DROP/
/**/TEMP/
/**/packages/
/**/bin/
/**/obj/
_site
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Company>Stone_Red</Company>
<Product>Stone_Red</Product>
<Version>0.0.0.4</Version>
<Version>0.0.0.5</Version>
<RepositoryUrl>https://github.com/Stone-Red-Code/DesktopMagic</RepositoryUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>0.0.0.4</AssemblyVersion>
<AssemblyVersion>0.0.0.5</AssemblyVersion>
<PackageProjectUrl></PackageProjectUrl>
<FileVersion>0.0.0.4</FileVersion>
<FileVersion>0.0.0.5</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -22,11 +22,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
<PackageReference Include="Vsxmd" Version="1.4.5">
<PackageReference Include="docfx.console" Version="2.58.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
</ItemGroup>
<ItemGroup>
@@ -1,705 +0,0 @@
<a name='assembly'></a>
# 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')
- [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)')
- [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')
- [WindowPosition](#P-DesktopMagicPluginAPI-IPluginData-WindowPosition 'DesktopMagicPluginAPI.IPluginData.WindowPosition')
- [WindowSize](#P-DesktopMagicPluginAPI-IPluginData-WindowSize 'DesktopMagicPluginAPI.IPluginData.WindowSize')
- [UpdateWindow()](#M-DesktopMagicPluginAPI-IPluginData-UpdateWindow 'DesktopMagicPluginAPI.IPluginData.UpdateWindow')
- [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')
- [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')
<a name='T-DesktopMagicPluginAPI-Inputs-Button'></a>
## Button `type`
##### Namespace
DesktopMagicPluginAPI.Inputs
##### Summary
Represents a button control.
<a name='M-DesktopMagicPluginAPI-Inputs-Button-#ctor-System-String-'></a>
### #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. |
<a name='P-DesktopMagicPluginAPI-Inputs-Button-Value'></a>
### Value `property`
##### Summary
Gets or sets the text caption displayed in the [Button](#T-DesktopMagicPluginAPI-Inputs-Button 'DesktopMagicPluginAPI.Inputs.Button') element.
<a name='M-DesktopMagicPluginAPI-Inputs-Button-Click'></a>
### Click() `method`
##### Summary
Triggers the [](#E-DesktopMagicPluginAPI-Inputs-Button-OnClick 'DesktopMagicPluginAPI.Inputs.Button.OnClick') event.
##### Parameters
This method has no parameters.
<a name='T-DesktopMagicPluginAPI-Inputs-CheckBox'></a>
## CheckBox `type`
##### Namespace
DesktopMagicPluginAPI.Inputs
##### Summary
Represents a check box control.
<a name='M-DesktopMagicPluginAPI-Inputs-CheckBox-#ctor-System-Boolean-'></a>
### #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. |
<a name='P-DesktopMagicPluginAPI-Inputs-CheckBox-Value'></a>
### Value `property`
##### Summary
Gets or set a value indicating whether the [CheckBox](#T-DesktopMagicPluginAPI-Inputs-CheckBox 'DesktopMagicPluginAPI.Inputs.CheckBox') is in the checked state.
<a name='T-DesktopMagicPluginAPI-Inputs-Element'></a>
## Element `type`
##### Namespace
DesktopMagicPluginAPI.Inputs
##### Summary
The element base class.
<a name='M-DesktopMagicPluginAPI-Inputs-Element-ValueChanged'></a>
### ValueChanged() `method`
##### Summary
Triggers the [](#E-DesktopMagicPluginAPI-Inputs-Element-OnValueChanged 'DesktopMagicPluginAPI.Inputs.Element.OnValueChanged') event.
##### Parameters
This method has no parameters.
<a name='T-DesktopMagicPluginAPI-Inputs-ElementAttribute'></a>
## ElementAttribute `type`
##### Namespace
DesktopMagicPluginAPI.Inputs
##### Summary
Marks a Property as element.
<a name='M-DesktopMagicPluginAPI-Inputs-ElementAttribute-#ctor-System-String,System-Int32-'></a>
### #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. |
<a name='M-DesktopMagicPluginAPI-Inputs-ElementAttribute-#ctor-System-Int32-'></a>
### #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. |
<a name='M-DesktopMagicPluginAPI-Inputs-ElementAttribute-#ctor'></a>
### #ctor() `constructor`
##### Summary
*Inherit from parent.*
##### Parameters
This constructor has no parameters.
<a name='P-DesktopMagicPluginAPI-Inputs-ElementAttribute-Name'></a>
### Name `property`
##### Summary
The name of the element.
<a name='P-DesktopMagicPluginAPI-Inputs-ElementAttribute-OrderIndex'></a>
### OrderIndex `property`
##### Summary
The order index of the element.
<a name='T-DesktopMagicPluginAPI-Drawing-GraphicsExtentions'></a>
## GraphicsExtentions `type`
##### Namespace
DesktopMagicPluginAPI.Drawing
##### Summary
Extentions for the [Graphics](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Graphics 'System.Drawing.Graphics') class.
<a name='M-DesktopMagicPluginAPI-Drawing-GraphicsExtentions-DrawStringFixedWidth-System-Drawing-Graphics,System-String,System-Drawing-Font,System-Drawing-Brush,System-Single,System-Single,System-Single-'></a>
### DrawStringFixedWidth(graphics,s,font,brush,x,y,width) `method`
##### Summary
Draws the specified text string at the specified location with the specified [Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') and [Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') objects.
##### 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. |
<a name='M-DesktopMagicPluginAPI-Drawing-GraphicsExtentions-DrawStringFixedWidth-System-Drawing-Graphics,System-String,System-Drawing-Font,System-Drawing-Brush,System-Drawing-PointF,System-Single-'></a>
### DrawStringFixedWidth(graphics,s,font,brush,point,width) `method`
##### Summary
Draws the specified text string at the specified location with the specified [Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') and [Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') objects.
##### 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. |
<a name='M-DesktopMagicPluginAPI-Drawing-GraphicsExtentions-DrawStringMonospace-System-Drawing-Graphics,System-String,System-Drawing-Font,System-Drawing-Brush,System-Single,System-Single-'></a>
### DrawStringMonospace(graphics,s,font,brush,x,y) `method`
##### Summary
Draws the specified text string at the specified location with the specified [Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') and [Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') objects.
##### 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. |
<a name='M-DesktopMagicPluginAPI-Drawing-GraphicsExtentions-DrawStringMonospace-System-Drawing-Graphics,System-String,System-Drawing-Font,System-Drawing-Brush,System-Drawing-PointF-'></a>
### DrawStringMonospace(graphics,s,font,brush,point) `method`
##### Summary
Draws the specified text string at the specified location with the specified [Brush](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Brush 'System.Drawing.Brush') and [Font](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Font 'System.Drawing.Font') objects.
##### 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. |
<a name='T-DesktopMagicPluginAPI-IPluginData'></a>
## IPluginData `type`
##### Namespace
DesktopMagicPluginAPI
##### Summary
Defines properties and methods that provide information about the main application.
<a name='P-DesktopMagicPluginAPI-IPluginData-Color'></a>
### Color `property`
##### Summary
Gets the color of the main application.
<a name='P-DesktopMagicPluginAPI-IPluginData-Font'></a>
### Font `property`
##### Summary
Gets the font of the main application.
<a name='P-DesktopMagicPluginAPI-IPluginData-PluginName'></a>
### PluginName `property`
##### Summary
Gets the name of the plugin.
<a name='P-DesktopMagicPluginAPI-IPluginData-PluginPath'></a>
### PluginPath `property`
##### Summary
Gets the path of the parent directory of the plugin.
<a name='P-DesktopMagicPluginAPI-IPluginData-WindowPosition'></a>
### WindowPosition `property`
##### Summary
Gets the window position of the plugin window.
<a name='P-DesktopMagicPluginAPI-IPluginData-WindowSize'></a>
### WindowSize `property`
##### Summary
Gets the window size of the plugin window.
<a name='M-DesktopMagicPluginAPI-IPluginData-UpdateWindow'></a>
### UpdateWindow() `method`
##### Summary
Updates the plugin window.
##### Parameters
This method has no parameters.
<a name='T-DesktopMagicPluginAPI-Inputs-IntegerUpDown'></a>
## IntegerUpDown `type`
##### Namespace
DesktopMagicPluginAPI.Inputs
##### Summary
Represents a up-down control.
<a name='M-DesktopMagicPluginAPI-Inputs-IntegerUpDown-#ctor-System-Int32,System-Int32,System-Int32-'></a>
### #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') | |
<a name='P-DesktopMagicPluginAPI-Inputs-IntegerUpDown-Maximum'></a>
### Maximum `property`
##### Summary
Gets or sets the maximum value for the [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown') element.
<a name='P-DesktopMagicPluginAPI-Inputs-IntegerUpDown-Minimum'></a>
### Minimum `property`
##### Summary
Gets or sets the minimum value for the [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown') element.
<a name='P-DesktopMagicPluginAPI-Inputs-IntegerUpDown-Value'></a>
### Value `property`
##### Summary
Gets or sets the value assigned to the [IntegerUpDown](#T-DesktopMagicPluginAPI-Inputs-IntegerUpDown 'DesktopMagicPluginAPI.Inputs.IntegerUpDown') element.
<a name='T-DesktopMagicPluginAPI-Inputs-Label'></a>
## Label `type`
##### Namespace
DesktopMagicPluginAPI.Inputs
##### Summary
Represents a label control.
<a name='M-DesktopMagicPluginAPI-Inputs-Label-#ctor-System-String,System-Boolean-'></a>
### #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. |
<a name='P-DesktopMagicPluginAPI-Inputs-Label-Bold'></a>
### 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.
<a name='P-DesktopMagicPluginAPI-Inputs-Label-Value'></a>
### Value `property`
##### Summary
Gets or sets the text associated with this [Label](#T-DesktopMagicPluginAPI-Inputs-Label 'DesktopMagicPluginAPI.Inputs.Label').
<a name='T-DesktopMagicPluginAPI-Inputs-MouseButton'></a>
## MouseButton `type`
##### Namespace
DesktopMagicPluginAPI.Inputs
##### Summary
Mouse Buttons
<a name='F-DesktopMagicPluginAPI-Inputs-MouseButton-Left'></a>
### Left `constants`
##### Summary
The left mouse button.
<a name='F-DesktopMagicPluginAPI-Inputs-MouseButton-Middle'></a>
### Middle `constants`
##### Summary
The middle mouse button.
<a name='F-DesktopMagicPluginAPI-Inputs-MouseButton-Right'></a>
### Right `constants`
##### Summary
The right mouse button.
<a name='T-DesktopMagicPluginAPI-Plugin'></a>
## Plugin `type`
##### Namespace
DesktopMagicPluginAPI
##### Summary
The plugin class.
<a name='P-DesktopMagicPluginAPI-Plugin-Application'></a>
### Application `property`
##### Summary
Informations about the main application.
<a name='P-DesktopMagicPluginAPI-Plugin-RenderQuality'></a>
### RenderQuality `property`
##### Summary
Gets or sets the render quality of the bitmap image.
<a name='P-DesktopMagicPluginAPI-Plugin-UpdateInterval'></a>
### 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.
<a name='M-DesktopMagicPluginAPI-Plugin-Main'></a>
### Main() `method`
##### Summary
Occurs when the [UpdateInterval](#P-DesktopMagicPluginAPI-Plugin-UpdateInterval 'DesktopMagicPluginAPI.Plugin.UpdateInterval') elapses.
##### Returns
##### Parameters
This method has no parameters.
<a name='M-DesktopMagicPluginAPI-Plugin-OnMouseClick-System-Drawing-Point,DesktopMagicPluginAPI-Inputs-MouseButton-'></a>
### 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. |
<a name='M-DesktopMagicPluginAPI-Plugin-OnMouseMove-System-Drawing-Point-'></a>
### 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. |
<a name='M-DesktopMagicPluginAPI-Plugin-OnMouseWheel-System-Drawing-Point,System-Int32-'></a>
### 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. |
<a name='M-DesktopMagicPluginAPI-Plugin-Start'></a>
### Start() `method`
##### Summary
Occurs once when the pugin gets activated.
##### Parameters
This method has no parameters.
<a name='T-DesktopMagicPluginAPI-Drawing-RenderQuality'></a>
## RenderQuality `type`
##### Namespace
DesktopMagicPluginAPI.Drawing
##### Summary
Specifies which render quality is used to display the bitmap images.
<a name='F-DesktopMagicPluginAPI-Drawing-RenderQuality-High'></a>
### High `constants`
##### Summary
Slower then [Low](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-Low 'DesktopMagicPluginAPI.Drawing.RenderQuality.Low') but produces higher quality output.
<a name='F-DesktopMagicPluginAPI-Drawing-RenderQuality-Low'></a>
### Low `constants`
##### Summary
Faster then [High](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-High 'DesktopMagicPluginAPI.Drawing.RenderQuality.High') but produces lower quality output.
<a name='F-DesktopMagicPluginAPI-Drawing-RenderQuality-Performance'></a>
### Performance `constants`
##### Summary
Provides performance benefits over [Low](#F-DesktopMagicPluginAPI-Drawing-RenderQuality-Low 'DesktopMagicPluginAPI.Drawing.RenderQuality.Low')
<a name='T-DesktopMagicPluginAPI-Inputs-Slider'></a>
## Slider `type`
##### Namespace
DesktopMagicPluginAPI.Inputs
##### Summary
Represents a slider control.
<a name='M-DesktopMagicPluginAPI-Inputs-Slider-#ctor-System-Double,System-Double,System-Double-'></a>
### #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. |
<a name='P-DesktopMagicPluginAPI-Inputs-Slider-Maximum'></a>
### Maximum `property`
##### Summary
Gets or sets the maximum value for the [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') element.
<a name='P-DesktopMagicPluginAPI-Inputs-Slider-Minimum'></a>
### Minimum `property`
##### Summary
Gets or sets the minimum value for the [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') element.
<a name='P-DesktopMagicPluginAPI-Inputs-Slider-Value'></a>
### Value `property`
##### Summary
Gets or sets the value assigned to the [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider') element.
<a name='T-DesktopMagicPluginAPI-Inputs-TextBox'></a>
## TextBox `type`
##### Namespace
DesktopMagicPluginAPI.Inputs
##### Summary
Represents a text box control.
<a name='M-DesktopMagicPluginAPI-Inputs-TextBox-#ctor-System-String-'></a>
### #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. |
<a name='P-DesktopMagicPluginAPI-Inputs-TextBox-Value'></a>
### Value `property`
##### Summary
Gets or sets the text associated with this [TextBox](#T-DesktopMagicPluginAPI-Inputs-TextBox 'DesktopMagicPluginAPI.Inputs.TextBox').
@@ -6,12 +6,12 @@
<members>
<member name="T:DesktopMagicPluginAPI.Drawing.GraphicsExtentions">
<summary>
Extentions for the <see cref="T:System.Drawing.Graphics"/> class.
Extensions for the <see cref="T:System.Drawing.Graphics"/> class.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringMonospace(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Single,System.Single)">
<summary>
Draws the specified text string at the specified location with the specified <see cref="T:System.Drawing.Brush"/> and <see cref="T:System.Drawing.Font"/> objects.
<inheritdoc cref="M:System.Drawing.Graphics.DrawString(System.String,System.Drawing.Font,System.Drawing.Brush,System.Single,System.Single)"/>
</summary>
<param name="graphics">Graphics object.</param>
<param name="s">String to draw.</param>
@@ -22,7 +22,7 @@
</member>
<member name="M:DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringMonospace(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Drawing.PointF)">
<summary>
Draws the specified text string at the specified location with the specified <see cref="T:System.Drawing.Brush"/> and <see cref="T:System.Drawing.Font"/> objects.
<inheritdoc cref="M:System.Drawing.Graphics.DrawString(System.String,System.Drawing.Font,System.Drawing.Brush,System.Drawing.PointF)"/>
</summary>
<param name="graphics">Graphics object.</param>
<param name="s">String to draw.</param>
@@ -32,7 +32,7 @@
</member>
<member name="M:DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringFixedWidth(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Single,System.Single,System.Single)">
<summary>
Draws the specified text string at the specified location with the specified <see cref="T:System.Drawing.Brush"/> and <see cref="T:System.Drawing.Font"/> objects.
<inheritdoc cref="M:System.Drawing.Graphics.DrawString(System.String,System.Drawing.Font,System.Drawing.Brush,System.Single,System.Single)"/>
</summary>
<param name="graphics">Graphics object.</param>
<param name="s">String to draw.</param>
@@ -44,7 +44,7 @@
</member>
<member name="M:DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringFixedWidth(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Drawing.PointF,System.Single)">
<summary>
Draws the specified text string at the specified location with the specified <see cref="T:System.Drawing.Brush"/> and <see cref="T:System.Drawing.Font"/> objects.
<inheritdoc cref="M:System.Drawing.Graphics.DrawString(System.String,System.Drawing.Font,System.Drawing.Brush,System.Drawing.PointF)"/>
</summary>
<param name="graphics">Graphics object.</param>
<param name="s">String to draw.</param>
@@ -53,6 +53,36 @@
<param name="point"><see cref="T:System.Drawing.PointF"/> structure that specifies the upper-left corner of the drawn text.</param>
<param name="width">The specified width.</param>
</member>
<member name="M:DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringNoLeftPadding(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Single,System.Single)">
<summary>
<inheritdoc cref="M:System.Drawing.Graphics.DrawString(System.String,System.Drawing.Font,System.Drawing.Brush,System.Single,System.Single)"/>
</summary>
<param name="graphics">Graphics object.</param>
<param name="s">String to draw.</param>
<param name="font"><see cref="T:System.Drawing.Font"/> that defines the text format of the string.</param>
<param name="brush"><see cref="T:System.Drawing.Brush"/> that determines the color and texture of the drawn text.</param>
<param name="x">The x-coordinate of the upper-left corner of the drawn text.</param>
<param name="y">The y-coordinate of the upper-left corner of the drawn text.</param>
</member>
<member name="M:DesktopMagicPluginAPI.Drawing.GraphicsExtentions.DrawStringNoLeftPadding(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Drawing.PointF)">
<summary>
<inheritdoc cref="M:System.Drawing.Graphics.DrawString(System.String,System.Drawing.Font,System.Drawing.Brush,System.Drawing.PointF)"/>
</summary>
<param name="graphics">Graphics object.</param>
<param name="s">String to draw.</param>
<param name="font"><see cref="T:System.Drawing.Font"/> that defines the text format of the string.</param>
<param name="brush"><see cref="T:System.Drawing.Brush"/> that determines the color and texture of the drawn text.</param>
<param name="point"><see cref="T:System.Drawing.PointF"/> structure that specifies the upper-left corner of the drawn text.</param>
</member>
<member name="M:DesktopMagicPluginAPI.Drawing.GraphicsExtentions.MeasureStringNoLeftPadding(System.Drawing.Graphics,System.String,System.Drawing.Font)">
<summary>
<inheritdoc cref="M:System.Drawing.Graphics.MeasureString(System.String,System.Drawing.Font)"/>
</summary>
<param name="graphics">Graphics object.</param>
<param name="text">String to measure.</param>
<param name="font"><see cref="T:System.Drawing.Font"/> that defines the text format of the string.</param>
<returns></returns>
</member>
<member name="T:DesktopMagicPluginAPI.Drawing.RenderQuality">
<summary>
Specifies which render quality is used to display the bitmap images.
@@ -115,6 +145,28 @@
</summary>
<param name="value">A value indicating whether the <see cref="T:DesktopMagicPluginAPI.Inputs.CheckBox"/> is in the checked state.</param>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.ComboBox">
<summary>
Represents a selection control with a drop-down list.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.ComboBox.Items">
<summary>
Gets the collection used to generate the content of the <see cref="T:DesktopMagicPluginAPI.Inputs.ComboBox"/>.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.ComboBox.Value">
<summary>
Gets the currently selected item associated with this <see cref="T:DesktopMagicPluginAPI.Inputs.ComboBox"/>.
</summary>
<remarks>If you assign a value to this property, the displayed text in the user interface will not be changed.</remarks>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.ComboBox.#ctor(System.String[])">
<summary>
Initializes a new instance of the <see cref="T:DesktopMagicPluginAPI.Inputs.Label"/> class with the provided <paramref name="items"/>.
</summary>
<param name="items"></param>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.Element">
<summary>
The element base class.
@@ -283,12 +335,17 @@
</member>
<member name="P:DesktopMagicPluginAPI.IPluginData.Font">
<summary>
Gets the font of the main application.
Gets the current font of the current theme.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.IPluginData.Color">
<summary>
Gets the color of the main application.
Gets the current color of the current theme.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.IPluginData.Theme">
<summary>
Gets the current theme setting of the main application.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.IPluginData.WindowSize">
@@ -316,6 +373,41 @@
Updates the plugin window.
</summary>
</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 current theme.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.ITheme.SecondaryColor">
<summary>
Gets the secondary color of the current theme.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.ITheme.BackgroundColor">
<summary>
Gets the background color of the current theme.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.ITheme.Font">
<summary>
Gets the font of the current theme.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.ITheme.CornerRadius">
<summary>
Gets the corner radius of the current theme.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.ITheme.Margin">
<summary>
Gets the corner radius of the current theme.
</summary>
</member>
<member name="T:DesktopMagicPluginAPI.Plugin">
<summary>
The plugin class.
@@ -338,7 +430,12 @@
</member>
<member name="M:DesktopMagicPluginAPI.Plugin.Start">
<summary>
Occurs once when the pugin gets activated.
Occurs once when the plugin gets activated.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Plugin.Stop">
<summary>
Occurs once when the plugin gets deactivated.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Plugin.Main">
@@ -365,7 +462,7 @@
Occurs when the user rotates the mouse wheel while the mouse pointer is over this element.
</summary>
<param name="position">The x- and y-coordinates of the mouse pointer position relative to the plugin window.</param>
<param name="Delta">A value that indicates the amount that the mouse wheel has changed.</param>
<param name="delta">A value that indicates the amount that the mouse wheel has changed.</param>
</member>
</members>
</doc>
@@ -5,14 +5,14 @@ using System.Drawing;
namespace DesktopMagicPluginAPI.Drawing
{
/// <summary>
/// Extentions for the <see cref="Graphics"/> class.
/// Extensions for the <see cref="Graphics"/> class.
/// </summary>
public static class GraphicsExtentions
{
private static readonly Dictionary<Font, int> fonts = new Dictionary<Font, int>(new FontComparer());
/// <summary>
/// Draws the specified text string at the specified location with the specified <see cref="Brush"/> and <see cref="Font"/> objects.
/// <inheritdoc cref="Graphics.DrawString(string?, Font, Brush, float, float)"/>
/// </summary>
/// <param name="graphics">Graphics object.</param>
/// <param name="s">String to draw.</param>
@@ -22,7 +22,7 @@ namespace DesktopMagicPluginAPI.Drawing
/// <param name="y">The y-coordinate of the upper-left corner of the drawn text.</param>
public static void DrawStringMonospace(this Graphics graphics, string s, Font font, Brush brush, float x, float y)
{
int widest = GetWidestChar(font);
int widest = graphics.GetWidestChar(font);
for (int i = 0; i < s.Length; i++)
{
@@ -33,7 +33,7 @@ namespace DesktopMagicPluginAPI.Drawing
}
/// <summary>
/// Draws the specified text string at the specified location with the specified <see cref="Brush"/> and <see cref="Font"/> objects.
/// <inheritdoc cref="Graphics.DrawString(string?, Font, Brush, PointF)"/>
/// </summary>
/// <param name="graphics">Graphics object.</param>
/// <param name="s">String to draw.</param>
@@ -42,7 +42,7 @@ namespace DesktopMagicPluginAPI.Drawing
/// <param name="point"><see cref="PointF"/> structure that specifies the upper-left corner of the drawn text.</param>
public static void DrawStringMonospace(this Graphics graphics, string s, Font font, Brush brush, PointF point)
{
int widest = GetWidestChar(font);
int widest = graphics.GetWidestChar(font);
for (int i = 0; i < s.Length; i++)
{
@@ -53,7 +53,7 @@ namespace DesktopMagicPluginAPI.Drawing
}
/// <summary>
/// Draws the specified text string at the specified location with the specified <see cref="Brush"/> and <see cref="Font"/> objects.
/// <inheritdoc cref="Graphics.DrawString(string?, Font, Brush, float, float)"/>
/// </summary>
/// <param name="graphics">Graphics object.</param>
/// <param name="s">String to draw.</param>
@@ -73,7 +73,7 @@ namespace DesktopMagicPluginAPI.Drawing
}
/// <summary>
/// Draws the specified text string at the specified location with the specified <see cref="Brush"/> and <see cref="Font"/> objects.
/// <inheritdoc cref="Graphics.DrawString(string?, Font, Brush, PointF)"/>
/// </summary>
/// <param name="graphics">Graphics object.</param>
/// <param name="s">String to draw.</param>
@@ -91,12 +91,76 @@ namespace DesktopMagicPluginAPI.Drawing
}
}
private static int GetWidestChar(Font font)
/// <summary>
///<inheritdoc cref="Graphics.DrawString(string?, Font, Brush, float, float)"/>
/// </summary>
/// <param name="graphics">Graphics object.</param>
/// <param name="s">String to draw.</param>
/// <param name="font"><see cref="Font"/> that defines the text format of the string.</param>
/// <param name="brush"><see cref="Brush"/> that determines the color and texture of the drawn text.</param>
/// <param name="x">The x-coordinate of the upper-left corner of the drawn text.</param>
/// <param name="y">The y-coordinate of the upper-left corner of the drawn text.</param>
public static void DrawStringNoLeftPadding(this Graphics graphics, string s, Font font, Brush brush, float x, float y)
{
// measure left padding
StringFormat sf = new StringFormat(StringFormatFlags.NoClip);
sf.SetMeasurableCharacterRanges(new CharacterRange[] { new CharacterRange(0, 1) });
Region[] r = graphics.MeasureCharacterRanges(s, font, new RectangleF(0, 0, 1000, 100), sf);
float leftPadding = r[0].GetBounds(graphics).Left;
// draw string
sf = new StringFormat(StringFormatFlags.NoClip);
graphics.DrawString(s, font, brush, x - leftPadding, y, sf);
}
/// <summary>
/// <inheritdoc cref="Graphics.DrawString(string?, Font, Brush, PointF)"/>
/// </summary>
/// <param name="graphics">Graphics object.</param>
/// <param name="s">String to draw.</param>
/// <param name="font"><see cref="Font"/> that defines the text format of the string.</param>
/// <param name="brush"><see cref="Brush"/> that determines the color and texture of the drawn text.</param>
/// <param name="point"><see cref="PointF"/> structure that specifies the upper-left corner of the drawn text.</param>
public static void DrawStringNoLeftPadding(this Graphics graphics, string s, Font font, Brush brush, PointF point)
{
// measure left padding
StringFormat sf = new StringFormat(StringFormatFlags.NoClip);
sf.SetMeasurableCharacterRanges(new CharacterRange[] { new CharacterRange(0, 1) });
Region[] r = graphics.MeasureCharacterRanges(s, font, new RectangleF(0, 0, 1000, 100), sf);
float leftPadding = r[0].GetBounds(graphics).Left;
// draw string
sf = new StringFormat(StringFormatFlags.NoClip);
graphics.DrawString(s, font, brush, point.X - leftPadding, point.Y, sf);
}
/// <summary>
/// <inheritdoc cref="Graphics.MeasureString(string, Font)"/>
/// </summary>
/// <param name="graphics">Graphics object.</param>
/// <param name="text">String to measure.</param>
/// <param name="font"><see cref="Font"/> that defines the text format of the string.</param>
/// <returns></returns>
public static SizeF MeasureStringNoLeftPadding(this Graphics graphics, string text, Font font)
{
SizeF size = graphics.MeasureString(text, font, int.MaxValue);
StringFormat sf = new StringFormat(StringFormatFlags.NoClip);
sf.SetMeasurableCharacterRanges(new CharacterRange[] { new CharacterRange(0, 1) });
Region[] r = graphics.MeasureCharacterRanges(text, font, new RectangleF(0, 0, 1000, 100), sf);
float leftPadding = r[0].GetBounds(graphics).Left;
size.Width -= leftPadding / 1.5f;
return size;
}
private static int GetWidestChar(this Graphics graphics, Font font)
{
if (fonts.ContainsKey(font))
{
return fonts[font];
}
Graphics graphics = Graphics.FromImage(new Bitmap(1, 1));
float max = 0;
char maxx = ' ';
for (int i = 0; i <= 255; i++)
+12 -4
View File
@@ -1,4 +1,5 @@
using System.Drawing;
using System;
using System.Drawing;
namespace DesktopMagicPluginAPI
{
@@ -8,19 +9,26 @@ namespace DesktopMagicPluginAPI
public interface IPluginData
{
/// <summary>
/// Gets the font of the main application.
/// Gets the current font of the current theme.
/// </summary>
[Obsolete("Use the \"Theme\" property instead")]
string Font { get; }
/// <summary>
/// Gets the color of the main application.
/// Gets the current color of the current theme.
/// </summary>
[Obsolete("Use the \"Theme\" property instead")]
Color Color { get; }
/// <summary>
/// Gets the current theme setting of the main application.
/// </summary>
ITheme Theme { get; }
/// <summary>
/// Gets the window size of the plugin window.
/// </summary>
Point WindowSize { get; }
Size WindowSize { get; }
/// <summary>
/// Gets the window position of the plugin window.
+40
View File
@@ -0,0 +1,40 @@
using System.Drawing;
namespace DesktopMagicPluginAPI
{
/// <summary>
/// The theme settings of the main application.
/// </summary>
public interface ITheme
{
/// <summary>
/// Gets the primary color of the current theme.
/// </summary>
Color PrimaryColor { get; }
/// <summary>
/// Gets the secondary color of the current theme.
/// </summary>
Color SecondaryColor { get; }
/// <summary>
/// Gets the background color of the current theme.
/// </summary>
Color BackgroundColor { get; }
/// <summary>
/// Gets the font of the current theme.
/// </summary>
string Font { get; }
/// <summary>
/// Gets the corner radius of the current theme.
/// </summary>
int CornerRadius { get; }
/// <summary>
/// Gets the corner radius of the current theme.
/// </summary>
int Margin { get; }
}
}
@@ -0,0 +1,46 @@
using System.Collections.ObjectModel;
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Represents a selection control with a drop-down list.
/// </summary>
public class ComboBox : Element
{
private string _value;
/// <summary>
/// Gets the collection used to generate the content of the <see cref="ComboBox"/>.
/// </summary>
public ObservableCollection<string> Items { get; } = new ObservableCollection<string>();
/// <summary>
/// Gets the currently selected item associated with this <see cref="ComboBox"/>.
/// </summary>
/// <remarks>If you assign a value to this property, the displayed text in the user interface will not be changed.</remarks>
public string Value
{
get => _value;
set
{
if (_value != value)
{
_value = value;
ValueChanged();
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="Label"/> class with the provided <paramref name="items"/>.
/// </summary>
/// <param name="items"></param>
public ComboBox(params string[] items)
{
foreach (string item in items)
{
Items.Add(item);
}
}
}
}
+11 -14
View File
@@ -19,17 +19,7 @@ namespace DesktopMagicPluginAPI
public IPluginData Application
{
get => application;
set
{
if (application is null)
{
application = value;
}
else
{
throw new InvalidOperationException($"You cannot set the value of the {nameof(Application)} property");
}
}
set => application = application is null ? value : throw new InvalidOperationException($"You cannot set the value of the {nameof(Application)} property");
}
/// <summary>
@@ -43,12 +33,19 @@ namespace DesktopMagicPluginAPI
public virtual RenderQuality RenderQuality { get; set; } = RenderQuality.High;
/// <summary>
/// Occurs once when the pugin gets activated.
/// Occurs once when the plugin gets activated.
/// </summary>
public virtual void Start()
{
}
/// <summary>
/// Occurs once when the plugin gets deactivated.
/// </summary>
public virtual void Stop()
{
}
/// <summary>
/// Occurs when the <see cref="UpdateInterval"/> elapses.
/// </summary>
@@ -76,8 +73,8 @@ namespace DesktopMagicPluginAPI
/// Occurs when the user rotates the mouse wheel while the mouse pointer is over this element.
/// </summary>
/// <param name="position">The x- and y-coordinates of the mouse pointer position relative to the plugin window.</param>
/// <param name="Delta">A value that indicates the amount that the mouse wheel has changed.</param>
public virtual void OnMouseWheel(Point position, int Delta)
/// <param name="delta">A value that indicates the amount that the mouse wheel has changed.</param>
public virtual void OnMouseWheel(Point position, int delta)
{
}
}
+5
View File
@@ -0,0 +1,5 @@
###############
# temp file #
###############
*.yml
.manifest
+2
View File
@@ -0,0 +1,2 @@
# PLACEHOLDER
TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*!
@@ -0,0 +1 @@
# Add your introductions here!
@@ -0,0 +1,2 @@
- name: Introduction
href: intro.md
+65
View File
@@ -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
}
}
+4
View File
@@ -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.
+5
View File
@@ -0,0 +1,5 @@
- name: Articles
href: articles/
- name: Api Documentation
href: api/
homepage: api/index.md
Binary file not shown.
+2 -2
View File
@@ -1,4 +1,4 @@
{
"Version":"0.0.2.3",
"FileUrl":"http://github.com/Stone-Red-Code/DesktopMagic/blob/develop/update/DesktopMagic.zip?raw=true"
"Version":"0.0.3.1",
"FileUrl":"http://github.com/Stone-Red-Code/DesktopMagic/blob/main/update/DesktopMagic.zip?raw=true"
}