Update project to .NET 8 and code improvements

This commit is contained in:
Stone_Red
2023-11-16 19:27:21 +01:00
parent adfedcb876
commit 2c883787f7
43 changed files with 2168 additions and 2790 deletions
@@ -1,22 +1,26 @@
using DesktopMagicPluginAPI;
using DesktopMagicPluginAPI.Inputs;
using System;
using System.Drawing;
using System.Drawing.Text;
namespace DesktopMagic.BuiltInWindowElements
{
namespace DesktopMagic.BuiltInWindowElements;
internal class DatePlugin : Plugin
{
public override int UpdateInterval => 1000;
[Element("Short date:")]
private readonly CheckBox shortDatecheckBox = new CheckBox(true);
private DateTime oldDateTime = new DateTime();
private DateTime oldDateTime = DateTime.MinValue;
private Color oldColor = Color.White;
private string oldFont;
private bool oldShortDatecheckBoxValue;
public override int UpdateInterval => 1000;
public override Bitmap Main()
{
if (oldDateTime.Date == DateTime.Now.Date && oldColor == Application.Theme.PrimaryColor && oldFont == Application.Theme.Font)
if (oldDateTime.Date == DateTime.Now.Date && oldColor == Application.Theme.PrimaryColor && oldFont == Application.Theme.Font && oldShortDatecheckBoxValue == shortDatecheckBox.Value)
{
return null;
}
@@ -24,8 +28,9 @@ namespace DesktopMagic.BuiltInWindowElements
oldDateTime = DateTime.Now;
oldColor = Application.Theme.PrimaryColor;
oldFont = Application.Theme.Font;
oldShortDatecheckBoxValue = shortDatecheckBox.Value;
string date = DateTime.Now.ToLongDateString();
string date = shortDatecheckBox.Value ? DateTime.Now.ToShortDateString() : DateTime.Now.ToLongDateString();
Font font = new Font(Application.Theme.Font, 200);
@@ -47,4 +52,3 @@ namespace DesktopMagic.BuiltInWindowElements
return bmp;
}
}
}
@@ -1,4 +1,6 @@
using DesktopMagicPluginAPI;
using DesktopMagic.Helpers;
using DesktopMagicPluginAPI;
using NAudio.Wave;
@@ -7,16 +9,19 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace DesktopMagic.BuiltInWindowElements
{
namespace DesktopMagic.BuiltInWindowElements;
internal class MusicVisualizerPlugin : Plugin
{
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 readonly Bitmap output = new Bitmap(880, 300);
private const int fftLength = 1024;
// NAudio fft wants powers of two!
private readonly SampleAggregator sampleAggregator = new SampleAggregator(fftLength);
private readonly Bitmap output = new Bitmap(880, 300);
private WasapiLoopbackCapture waveIn;
private volatile bool calculate = true;
private List<double> lastFft = [];
public override int UpdateInterval => 0;
public override void Start()
@@ -30,6 +35,17 @@ namespace DesktopMagic.BuiltInWindowElements
waveIn.StartRecording();
}
public override Bitmap Main()
{
return output;
}
public override void Stop()
{
calculate = false;
waveIn?.StopRecording();
}
private void OnDataAvailable(object sender, WaveInEventArgs e)
{
if (calculate)
@@ -46,8 +62,6 @@ namespace DesktopMagic.BuiltInWindowElements
}
}
private List<double> lastFft = new List<double>();
private void FftCalculated(object sender, FftEventArgs e)
{
if (!calculate)
@@ -55,7 +69,7 @@ namespace DesktopMagic.BuiltInWindowElements
return;
}
List<double> fft = new List<double>();
List<double> fft = [];
for (int i = 0; i < (e.Result.Length / 2) - 70; i++)
{
int v = i;
@@ -85,7 +99,7 @@ namespace DesktopMagic.BuiltInWindowElements
}
int barCount = 0;
List<double> scaledFft = new List<double>();
List<double> scaledFft = [];
if (barCount > 0)
{
@@ -270,16 +284,4 @@ namespace DesktopMagic.BuiltInWindowElements
break;
}
}
public override Bitmap Main()
{
return output;
}
public override void Stop()
{
calculate = false;
waveIn?.StopRecording();
}
}
}
@@ -1,31 +1,31 @@
using DesktopMagicPluginAPI;
using DesktopMagicPluginAPI.Drawing;
using DesktopMagicPluginAPI.Inputs;
using System;
using System.Drawing;
using System.Drawing.Text;
namespace DesktopMagic.BuiltInWindowElements
{
namespace DesktopMagic.BuiltInWindowElements;
internal class TimePlugin : Plugin
{
[Element("Display Seconds:")]
private readonly CheckBox checkBox = new CheckBox(true);
private readonly CheckBox displaySecondscheckBox = new CheckBox(true);
public override int UpdateInterval => 1000;
public override Bitmap Main()
{
string time = checkBox.Value ? DateTime.Now.ToLongTimeString() : DateTime.Now.ToShortTimeString();
string time = displaySecondscheckBox.Value ? DateTime.Now.ToLongTimeString() : DateTime.Now.ToShortTimeString();
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 = CalculateSize(tmpGr, font);
SizeF size = tmpGr.MeasureString(time, font);
bmp = new Bitmap((int)size.Width, (int)size.Height);
bmp.SetResolution(100, 100);
@@ -33,23 +33,8 @@ namespace DesktopMagic.BuiltInWindowElements
using Graphics gr = Graphics.FromImage(bmp);
gr.TextRenderingHint = TextRenderingHint.AntiAlias;
gr.DrawStringNoLeftPadding(time, font, new SolidBrush(Application.Theme.PrimaryColor), 0, 0);
gr.DrawString(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;
}
}
}
+6 -6
View File
@@ -12,7 +12,7 @@
<RepositoryUrl>https://github.com/Stone-Red-Code/DesktopMagic</RepositoryUrl>
<AssemblyVersion>0.0.3.2</AssemblyVersion>
<FileVersion>0.0.3.2</FileVersion>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net8.0-windows7.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -27,12 +27,12 @@
<ItemGroup>
<PackageReference Include="AlwaysUpToDate" Version="1.0.0.4" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.1.0" />
<PackageReference Include="Google.Apis.Calendar.v3" Version="1.55.0.2410" />
<PackageReference Include="MaterialDesignThemes" Version="4.0.0" />
<PackageReference Include="NAudio" Version="2.0.1" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.1" />
<PackageReference Include="Google.Apis.Calendar.v3" Version="1.64.0.3171" />
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.3.1" />
<PackageReference Include="System.Management" Version="5.0.0" />
<PackageReference Include="System.Management" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
+7 -8
View File
@@ -6,13 +6,17 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace DesktopMagic.Dialogs
{
namespace DesktopMagic.Dialogs;
/// <summary>
/// Interaction logic for ColorDialog.xaml
/// </summary>
public partial class ColorDialog : Window
{
public System.Drawing.Color ResultColor { get; private set; }
public Brush ResultBrush { get; private set; }
public ColorDialog(string content, System.Drawing.Color defaultColor, string title = "ColorDialog")
{
InitializeComponent();
@@ -26,10 +30,6 @@ namespace DesktopMagic.Dialogs
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;
@@ -111,7 +111,7 @@ namespace DesktopMagic.Dialogs
private void SetLanguageDictionary()
{
ResourceDictionary dict = new ResourceDictionary();
ResourceDictionary dict = [];
string currentCulture = Thread.CurrentThread.CurrentCulture.ToString();
if (currentCulture.Contains("de"))
@@ -125,4 +125,3 @@ namespace DesktopMagic.Dialogs
Resources.MergedDictionaries.Add(dict);
}
}
}
+9 -10
View File
@@ -2,10 +2,16 @@
using System.Threading;
using System.Windows;
namespace DesktopMagic.Dialogs
{
namespace DesktopMagic.Dialogs;
public partial class InputDialog : Window
{
public string ResponseText
{
get => textBox.Text;
set => textBox.Text = value;
}
public InputDialog(string content, string title = "InputDialog")
{
InitializeComponent();
@@ -14,12 +20,6 @@ namespace DesktopMagic.Dialogs
SetLanguageDictionary();
}
public string ResponseText
{
get => textBox.Text;
set => textBox.Text = value;
}
private void OkButton_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
@@ -32,7 +32,7 @@ namespace DesktopMagic.Dialogs
private void SetLanguageDictionary()
{
ResourceDictionary dict = new ResourceDictionary();
ResourceDictionary dict = [];
string currentCulture = Thread.CurrentThread.CurrentCulture.ToString();
if (currentCulture.Contains("de"))
@@ -46,4 +46,3 @@ namespace DesktopMagic.Dialogs
Resources.MergedDictionaries.Add(dict);
}
}
}
+2
View File
@@ -7,3 +7,5 @@ using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Windows only application")]
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "No need to")]
[assembly: SuppressMessage("Minor Code Smell", "S1075:URIs should not be hardcoded", Justification = "<Pending>")]
[assembly: SuppressMessage("Minor Code Smell", "S3604:Member initializer values should not be redundant", Justification = "False postives")]
+29 -23
View File
@@ -1,9 +1,10 @@
using System.Globalization;
using System;
using System.Globalization;
using System.Text.RegularExpressions;
namespace DesktopMagic.Helpers
{
internal static class MultiColorConverter
namespace DesktopMagic.Helpers;
internal static partial class MultiColorConverter
{
public static string ConvertToHex(System.Drawing.Color color)
{
@@ -19,21 +20,21 @@ namespace DesktopMagic.Helpers
{
hex = hex.Replace("#", "");
if (hex.Length == 8 && Regex.IsMatch(hex, "(?:[0-9a-fA-F]{8})"))
if (hex.Length == 8 && Hex8().IsMatch(hex))
{
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);
int a = int.Parse(hex.AsSpan(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int r = int.Parse(hex.AsSpan(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int g = int.Parse(hex.AsSpan(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int b = int.Parse(hex.AsSpan(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})"))
else if (hex.Length == 6 && Hex6().IsMatch(hex))
{
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);
int r = int.Parse(hex.AsSpan(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int g = int.Parse(hex.AsSpan(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int b = int.Parse(hex.AsSpan(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
color = System.Drawing.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b);
return true;
}
@@ -48,21 +49,21 @@ namespace DesktopMagic.Helpers
{
hex = hex.Replace("#", "");
if (hex.Length == 8 && Regex.IsMatch(hex, "(?:[0-9a-fA-F]{8})"))
if (hex.Length == 8 && Hex8().IsMatch(hex))
{
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);
int a = int.Parse(hex.AsSpan(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int r = int.Parse(hex.AsSpan(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int g = int.Parse(hex.AsSpan(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int b = int.Parse(hex.AsSpan(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})"))
else if (hex.Length == 6 && Hex6().IsMatch(hex))
{
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);
int r = int.Parse(hex.AsSpan(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int g = int.Parse(hex.AsSpan(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int b = int.Parse(hex.AsSpan(4, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
color = System.Windows.Media.Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b);
return true;
}
@@ -72,5 +73,10 @@ namespace DesktopMagic.Helpers
return false;
}
}
}
[GeneratedRegex("(?:[0-9a-fA-F]{8})")]
private static partial Regex Hex8();
[GeneratedRegex("(?:[0-9a-fA-F]{6})")]
private static partial Regex Hex6();
}
+14 -20
View File
@@ -1,15 +1,14 @@
using NAudio.Dsp;
using System;
namespace DesktopMagic
{
namespace DesktopMagic.Helpers;
internal class SampleAggregator
{
// FFT
public event EventHandler<FftEventArgs> FftCalculated;
public bool PerformFFT { get; set; }
// This Complex is NAudio's own!
private readonly Complex[] fftBuffer;
@@ -17,6 +16,7 @@ namespace DesktopMagic
private readonly int fftLength;
private readonly int m;
private int fftPos;
public bool PerformFFT { get; set; }
public SampleAggregator(int fftLength)
{
@@ -24,15 +24,10 @@ namespace DesktopMagic
{
throw new ArgumentException("FFT Length must be a power of two");
}
this.m = (int)Math.Log(fftLength, 2.0);
m = (int)Math.Log(fftLength, 2.0);
this.fftLength = fftLength;
this.fftBuffer = new Complex[fftLength];
this.fftArgs = new FftEventArgs(fftBuffer);
}
private bool IsPowerOfTwo(int x)
{
return (x & (x - 1)) == 0;
fftBuffer = new Complex[fftLength];
fftArgs = new FftEventArgs(fftBuffer);
}
public void Add(float value)
@@ -51,15 +46,14 @@ namespace DesktopMagic
}
}
}
private bool IsPowerOfTwo(int x)
{
return (x & (x - 1)) == 0;
}
}
public class FftEventArgs : EventArgs
public class FftEventArgs(Complex[] result) : EventArgs
{
public FftEventArgs(Complex[] result)
{
this.Result = result;
}
public Complex[] Result { get; private set; }
}
public Complex[] Result { get; private set; } = result;
}
@@ -4,16 +4,11 @@ using System;
using System.Windows;
using System.Windows.Controls;
namespace DesktopMagic.Helpers
{
internal class SettingElementGenerator
{
private readonly ComboBox optionsComboBox;
namespace DesktopMagic.Helpers;
public SettingElementGenerator(ComboBox optionsComboBox)
internal class SettingElementGenerator(ComboBox optionsComboBox)
{
this.optionsComboBox = optionsComboBox;
}
private readonly ComboBox optionsComboBox = optionsComboBox;
public void Generate(SettingElement settingElement, DockPanel dockPanel, TextBlock textBlock)
{
@@ -235,4 +230,3 @@ namespace DesktopMagic.Helpers
window?.Exit();
}
}
}
+138 -139
View File
@@ -2,8 +2,8 @@
using System.Runtime.InteropServices;
using System.Text;
namespace DesktopMagic
{
namespace DesktopMagic.Helpers;
internal class W32
{
public const int SM_CXSCREEN = 0;
@@ -17,7 +17,139 @@ namespace DesktopMagic
public const int WM_GETICON = 0x7F;
public delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
public delegate bool EnumWindowsProc(nint hwnd, nint lParam);
[DllImport("gdi32.dll", EntryPoint = "BitBlt")]
public static extern bool BitBlt(nint hdcDest, int xDest, int yDest, int wDest, int hDest, nint hdcSource, int xSrc, int ySrc, int RasterOp);
[DllImport("gdi32.dll", EntryPoint = "CreateCompatibleBitmap")]
public static extern nint CreateCompatibleBitmap(nint hdc, int nWidth, int nHeight);
[DllImport("gdi32.dll", EntryPoint = "CreateCompatibleDC")]
public static extern nint CreateCompatibleDC(nint hdc);
[DllImport("gdi32.dll", EntryPoint = "DeleteDC")]
public static extern nint DeleteDC(nint hDc);
[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
public static extern nint DeleteObject(nint hDc);
[DllImport("dwmapi.dll")]
public static extern int DwmEnableBlurBehindWindow(nint hWnd, ref BbStruct blurBehind);
[DllImport("DwmApi.dll")]
public static extern int DwmExtendFrameIntoClientArea(nint hwnd, ref Margins pMarInset);
[DllImport("dwmapi.dll", EntryPoint = "#127", PreserveSig = false)]
public static extern void DwmGetColorizationParameters(out DWM_COLORIZATION_PARAMS parameters);
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern bool DwmIsCompositionEnabled();
[DllImport("dwmapi.dll")]
public static extern int DwmIsCompositionEnabled(out bool enabled);
[DllImport("dwmapi.dll", EntryPoint = "#131", PreserveSig = false)]
public static extern void DwmSetColorizationParameters(ref DWM_COLORIZATION_PARAMS parameters, long uUnknown);
[DllImport("dwmapi.dll")]
public static extern int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, nint lParam);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumChildWindows(nint parentHandle, EnumWindowsProc lpEnumFunc, nint lParam);
[DllImport("user32.dll", SetLastError = true)]
public static extern nint FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
public static extern nint FindWindowEx(nint parentHandle, nint childAfter, string className, nint windowTitle);
[DllImport("user32.dll")]
public static extern uint GetClassLong(nint hWnd, int nIndex);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int GetClassName(nint hWnd, StringBuilder lpClassName, int nMaxCount);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int GetWindowText(nint hWnd, StringBuilder lpWindowText, int nMaxCount);
[DllImport("user32.dll", EntryPoint = "GetDC")]
public static extern nint GetDC(nint ptr);
[DllImport("user32.dll")]
public static extern nint GetDCEx(nint hWnd, nint hrgnClip, DeviceContextValues flags);
[DllImport("user32.dll", EntryPoint = "GetDesktopWindow")]
public static extern nint GetDesktopWindow();
[DllImport("user32.dll")]
public static extern nint GetForegroundWindow();
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern nint GetParent(nint hWnd);
[DllImport("user32.dll")]
public static extern nint GetShellWindow();
[DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
public static extern int GetSystemMetrics(int abc);
[DllImport("user32.dll", EntryPoint = "GetWindowDC")]
public static extern nint GetWindowDC(int ptr);
[DllImport("user32.dll")]
public static extern bool IsWindowVisible(nint hWnd);
[DllImport("user32.dll")]
public static extern bool RedrawWindow(nint hWnd, [In] ref RECT lprcUpdate, nint hrgnUpdate, RedrawWindowFlags flags);
[DllImport("user32.dll")]
public static extern bool RedrawWindow(nint hWnd, nint lprcUpdate, nint hrgnUpdate, RedrawWindowFlags flags);
[DllImport("user32.dll", EntryPoint = "ReleaseDC")]
public static extern nint ReleaseDC(nint hWnd, nint hDc);
[DllImport("gdi32.dll", EntryPoint = "SelectObject")]
public static extern nint SelectObject(nint hdc, nint bmp);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern nint SendMessage(nint hWnd, uint Msg, int wParam, nint lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern nint SendMessageTimeout(nint windowHandle, uint Msg, nint wParam, nint lParam, SendMessageTimeoutFlags flags, uint timeout, out nint result);
[DllImport("user32.dll", SetLastError = true)]
public static extern nint SetParent(nint hWndChild, nint hWndNewParent);
[DllImport("kernel32.dll")]
public static extern bool SetProcessWorkingSetSize(nint handle, int minimumWorkingSetSize, int maximumWorkingSetSize);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnableWindow(nint hWnd, bool bEnable);
/// <summary>
/// Changes an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset into the extra window memory.
/// </summary>
/// <param name="hWnd">A handle to the window and, indirectly, the class to which the window belongs..</param>
/// <param name="nIndex">GWL_EXSTYLE, GWL_HINSTANCE, GWL_ID, GWL_STYLE, GWL_USERDATA, GWL_WNDPROC </param>
/// <param name="dwNewLong">The replacement value.</param>
/// <returns>If the function succeeds, the return value is the previous value of the specified 32-bit integer.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError. </returns>
[DllImport("user32.dll")]
public static extern int SetWindowLong(nint hWnd, WindowLongFlags nIndex, int dwNewLong);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(nint hWnd, nint hWndInsertAfter, int X, int Y, int cx, int cy, SetWindowPosFlags uFlags);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SystemParametersInfo(uint action, uint uParam, string vParam, uint winIni);
[Flags]
public enum BbFlags : byte //Blur Behind Flags
@@ -460,144 +592,12 @@ namespace DesktopMagic
#pragma warning disable CA2101
[DllImport("gdi32.dll", EntryPoint = "BitBlt")]
public static extern bool BitBlt(IntPtr hdcDest, int xDest, int yDest, int wDest, int hDest, IntPtr hdcSource, int xSrc, int ySrc, int RasterOp);
[DllImport("gdi32.dll", EntryPoint = "CreateCompatibleBitmap")]
public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);
[DllImport("gdi32.dll", EntryPoint = "CreateCompatibleDC")]
public static extern IntPtr CreateCompatibleDC(IntPtr hdc);
[DllImport("gdi32.dll", EntryPoint = "DeleteDC")]
public static extern IntPtr DeleteDC(IntPtr hDc);
[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
public static extern IntPtr DeleteObject(IntPtr hDc);
[DllImport("dwmapi.dll")]
public static extern int DwmEnableBlurBehindWindow(IntPtr hWnd, ref BbStruct blurBehind);
[DllImport("DwmApi.dll")]
public static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref Margins pMarInset);
[DllImport("dwmapi.dll", EntryPoint = "#127", PreserveSig = false)]
public static extern void DwmGetColorizationParameters(out DWM_COLORIZATION_PARAMS parameters);
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern bool DwmIsCompositionEnabled();
[DllImport("dwmapi.dll")]
public static extern int DwmIsCompositionEnabled(out bool enabled);
[DllImport("dwmapi.dll", EntryPoint = "#131", PreserveSig = false)]
public static extern void DwmSetColorizationParameters(ref DWM_COLORIZATION_PARAMS parameters, long uUnknown);
[DllImport("dwmapi.dll")]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumChildWindows(IntPtr parentHandle, EnumWindowsProc lpEnumFunc, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, IntPtr windowTitle);
[DllImport("user32.dll")]
public static extern uint GetClassLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount);
[DllImport("user32.dll", EntryPoint = "GetDC")]
public static extern IntPtr GetDC(IntPtr ptr);
[DllImport("user32.dll")]
public static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, DeviceContextValues flags);
[DllImport("user32.dll", EntryPoint = "GetDesktopWindow")]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern IntPtr GetParent(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern IntPtr GetShellWindow();
[DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
public static extern int GetSystemMetrics(int abc);
[DllImport("user32.dll", EntryPoint = "GetWindowDC")]
public static extern IntPtr GetWindowDC(int ptr);
[DllImport("user32.dll")]
public static extern bool IsWindowVisible(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern bool RedrawWindow(IntPtr hWnd, [In] ref RECT lprcUpdate, IntPtr hrgnUpdate, RedrawWindowFlags flags);
[DllImport("user32.dll")]
public static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, RedrawWindowFlags flags);
[DllImport("user32.dll", EntryPoint = "ReleaseDC")]
public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc);
[DllImport("gdi32.dll", EntryPoint = "SelectObject")]
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr bmp);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
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);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("kernel32.dll")]
public static extern bool SetProcessWorkingSetSize(IntPtr handle, int minimumWorkingSetSize, int maximumWorkingSetSize);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);
/// <summary>
/// Changes an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset into the extra window memory.
/// </summary>
/// <param name="hWnd">A handle to the window and, indirectly, the class to which the window belongs..</param>
/// <param name="nIndex">GWL_EXSTYLE, GWL_HINSTANCE, GWL_ID, GWL_STYLE, GWL_USERDATA, GWL_WNDPROC </param>
/// <param name="dwNewLong">The replacement value.</param>
/// <returns>If the function succeeds, the return value is the previous value of the specified 32-bit integer.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError. </returns>
[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr hWnd, WindowLongFlags nIndex, int dwNewLong);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
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 int SystemParametersInfo(uint action, uint uParam, string vParam, uint winIni);
[StructLayout(LayoutKind.Sequential)]
public struct BbStruct //Blur Behind Structure
{
public BbFlags Flags;
public bool Enable;
public IntPtr Region;
public nint Region;
public bool TransitionOnMaximized;
}
@@ -643,13 +643,13 @@ namespace DesktopMagic
public int X
{
get => Left;
set { Right -= (Left - value); Left = value; }
set { Right -= Left - value; Left = value; }
}
public int Y
{
get => Top;
set { Bottom -= (Top - value); Top = value; }
set { Bottom -= Top - value; Top = value; }
}
public int Height
@@ -726,4 +726,3 @@ namespace DesktopMagic
}
}
}
}
+15 -17
View File
@@ -25,8 +25,8 @@ namespace DesktopMagic
{
#region Global settings
internal static Theme Theme { get; } = new Theme();
public static bool EditMode { get; private set; } = false;
internal static Theme Theme { get; } = new Theme();
#endregion Global settings
@@ -42,18 +42,16 @@ namespace DesktopMagic
#region Plugins settings
internal static Dictionary<string, List<SettingElement>> PluginsSettings { get; } = new Dictionary<string, List<SettingElement>>();
internal static Dictionary<string, List<SettingElement>> PluginsSettings { get; } = [];
#endregion Plugins settings
public static List<PluginWindow> Windows { get; } = new List<PluginWindow>();
public static List<string> WindowNames { get; } = new List<string>();
private readonly RegistryKey key;
private readonly System.Windows.Forms.NotifyIcon notifyIcon = new();
private bool loaded = false;
private bool blockWindowsClosing = true;
public static List<PluginWindow> Windows { get; } = [];
public static List<string> WindowNames { get; } = [];
public MainWindow()
{
@@ -126,7 +124,7 @@ namespace DesktopMagic
foreach (string fileName in Directory.GetFiles(PluginsPath, "*.dll"))
{
string PluginName = fileName[(fileName.LastIndexOf("\\", StringComparison.InvariantCulture) + 1)..].Replace(fileName[fileName.LastIndexOf(".", StringComparison.InvariantCulture)..], "");
string PluginName = fileName[(fileName.LastIndexOf('\\') + 1)..].Replace(fileName[fileName.LastIndexOf('.')..], "");
try
{
_ = Directory.CreateDirectory(Path.Combine(PluginsPath, PluginName));
@@ -143,10 +141,10 @@ namespace DesktopMagic
foreach (string fileName in Directory.GetFiles(directory).Where(s => s.EndsWith(".dll", StringComparison.InvariantCulture) || s.EndsWith(".cs", StringComparison.InvariantCulture)))
{
string badChars = ",#-<>?!=()*,. ";
string PluginName = fileName[(fileName.LastIndexOf("\\", StringComparison.InvariantCulture) + 1)..].Replace(fileName[fileName.LastIndexOf(".", StringComparison.InvariantCulture)..], "");
string PluginName = fileName[(fileName.LastIndexOf('\\') + 1)..].Replace(fileName[fileName.LastIndexOf('.')..], "");
string clearPluginName = PluginName;
if (PluginName == directory[(directory.LastIndexOf("\\", StringComparison.InvariantCulture) + 1)..])
if (PluginName == directory[(directory.LastIndexOf('\\') + 1)..])
{
foreach (char c in badChars)
{
@@ -156,9 +154,9 @@ namespace DesktopMagic
CheckBox checkBox = new()
{
Name = "_PluginCb_" + clearPluginName,
Content = PluginName
Content = PluginName,
Style = (Style)FindResource("MaterialDesignDarkCheckBox")
};
checkBox.Style = (Style)FindResource("MaterialDesignDarkCheckBox");
checkBox.Click += CheckBox_Click;
bool exists = false;
@@ -446,7 +444,7 @@ namespace DesktopMagic
optionsPanel.UpdateLayout();
bool success = PluginsSettings.TryGetValue(optionsComboBox.SelectedItem.ToString(), out List<SettingElement> settingElements);
if (!success || settingElements?.Count == 0)
if (!success || settingElements is null || settingElements.Count == 0)
{
_ = optionsPanel.Children.Add(new TextBlock() { Text = (string)FindResource("noOptions") });
return;
@@ -593,7 +591,7 @@ namespace DesktopMagic
string[] data = lines[layoutsComboBox.SelectedIndex].Split(';');
foreach (string dat in data.Where(dat => dat.Contains(':')))
{
string value = dat[(dat.LastIndexOf(":", StringComparison.InvariantCulture) + 1)..];
string value = dat[(dat.LastIndexOf(':') + 1)..];
string name = dat.Replace(":" + value, "");
key.SetValue(name, value);
}
@@ -638,7 +636,7 @@ namespace DesktopMagic
return;
}
List<string> lines = File.ReadAllLines(App.ApplicationDataPath + "\\layouts.save").ToList();
List<string> lines = [.. File.ReadAllLines(App.ApplicationDataPath + "\\layouts.save")];
lines.RemoveAt(layoutsComboBox.SelectedIndex);
File.WriteAllLines(App.ApplicationDataPath + "\\layouts.save", lines);
LoadLayoutNames();
@@ -656,7 +654,7 @@ namespace DesktopMagic
{
lock (App.ApplicationDataPath)
{
List<string> lines = File.ReadAllLines(App.ApplicationDataPath + "\\layouts.save").ToList();
List<string> lines = [.. File.ReadAllLines(App.ApplicationDataPath + "\\layouts.save")];
StringBuilder content = new StringBuilder();
foreach (string valueName in key.GetValueNames())
{
@@ -682,7 +680,7 @@ namespace DesktopMagic
foreach (string line in lines)
{
string name = line[(line.LastIndexOf(";", StringComparison.InvariantCulture) + 1)..];
string name = line[(line.LastIndexOf(';') + 1)..];
_ = layoutsComboBox.Items.Add(name);
}
layoutsComboBox.SelectedIndex = int.Parse(key.GetValue("SelectedLayout", "0").ToString(), CultureInfo.InvariantCulture);
@@ -857,7 +855,7 @@ namespace DesktopMagic
private void SetLanguageDictionary()
{
ResourceDictionary dict = new ResourceDictionary();
ResourceDictionary dict = [];
string currentCulture = Thread.CurrentThread.CurrentUICulture.ToString();
if (currentCulture.Contains("de"))
+2 -7
View File
@@ -4,14 +4,9 @@ using System.Drawing;
namespace DesktopMagic.Plugins;
internal class PluginData : IPluginData
internal class PluginData(PluginWindow window) : IPluginData
{
private readonly PluginWindow window;
public PluginData(PluginWindow window)
{
this.window = window;
}
private readonly PluginWindow window = window;
public string Font => Theme.Font;
+39 -46
View File
@@ -24,6 +24,10 @@ namespace DesktopMagic;
public partial class PluginWindow : Window
{
public event Action PluginLoaded;
public event Action OnExit;
private readonly RegistryKey key;
private Thread pluginThread;
private System.Timers.Timer valueTimer;
@@ -34,10 +38,6 @@ public partial class PluginWindow : Window
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();
@@ -77,6 +77,21 @@ public partial class PluginWindow : Window
this.pluginClassInstance = pluginClassInstance;
}
public void UpdatePluginWindow()
{
ValueTimer_Elapsed(valueTimer, null);
}
public void Exit()
{
IsRunning = false;
Dispatcher.Invoke(() =>
{
OnExit?.Invoke();
});
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
@@ -87,18 +102,26 @@ public partial class PluginWindow : Window
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
}
private void Window_ContentRendered(object sender, EventArgs e)
private static BitmapSource BitmapToImageSource(Bitmap bitmap)
{
pluginThread = new Thread(() =>
{
LoadPlugin();
});
pluginThread.Start();
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 UpdatePluginWindow()
private void Window_ContentRendered(object sender, EventArgs e)
{
ValueTimer_Elapsed(valueTimer, null);
pluginThread = new Thread(LoadPlugin);
pluginThread.Start();
}
private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
@@ -171,7 +194,7 @@ public partial class PluginWindow : Window
{
byte[] assemblyBytes = File.ReadAllBytes($"{PluginFolderPath}\\{PluginName}.dll");
Assembly dll = Assembly.Load(assemblyBytes);
Type instanceType = dll.GetTypes().FirstOrDefault(type => type.GetTypeInfo().BaseType == typeof(Plugin));
Type instanceType = Array.Find(dll.GetTypes(), type => type.GetTypeInfo().BaseType == typeof(Plugin));
if (instanceType is null)
{
@@ -220,7 +243,7 @@ public partial class PluginWindow : Window
FieldInfo[] props = instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.GetField);
#pragma warning restore S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields
List<SettingElement> settingElements = new List<SettingElement>();
List<SettingElement> settingElements = [];
foreach (FieldInfo prop in props)
{
if (prop.GetValue(instance) is Element element)
@@ -237,15 +260,11 @@ public partial class PluginWindow : Window
}
}
settingElements = settingElements.OrderBy(x => x.OrderIndex).ToList();
if (MainWindow.PluginsSettings.ContainsKey(PluginName))
settingElements = [.. settingElements.OrderBy(x => x.OrderIndex)];
if (!MainWindow.PluginsSettings.TryAdd(PluginName, settingElements))
{
MainWindow.PluginsSettings[PluginName] = settingElements;
}
else
{
MainWindow.PluginsSettings.Add(PluginName, settingElements);
}
}
catch (Exception ex)
{
@@ -307,32 +326,6 @@ public partial class PluginWindow : Window
}
}
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();
+4 -11
View File
@@ -2,16 +2,9 @@
namespace DesktopMagic.Plugins;
internal class SettingElement
internal class SettingElement(Element element, string name, int orderIndex)
{
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;
}
public Element Element { get; } = element;
public string Name { get; } = name;
public int OrderIndex { get; } = orderIndex;
}
@@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
+40 -41
View File
@@ -8,22 +8,22 @@ using System.Drawing.Imaging;
using System.IO;
using System.Threading.Tasks;
namespace DesktopMagicPlugin.Test
{
namespace DesktopMagicPlugin.Test;
public class GifPlugin : Plugin
{
private const string SaveFilePath = "gifPath.txt";
[Element("Gif path:")]
private readonly TextBox input = new TextBox("");
[Element]
private readonly Label info = new Label("");
private readonly List<Bitmap> bitmaps = new List<Bitmap>();
private readonly List<Bitmap> bitmaps = [];
private int frameCount = -1;
private const string SaveFilePath = "gifPath.txt";
public override void Start()
{
input.OnValueChanged += Input_OnValueChanged;
@@ -33,42 +33,6 @@ namespace DesktopMagicPlugin.Test
}
}
private void Input_OnValueChanged()
{
_ = Task.Run(() =>
{
try
{
if (File.Exists(input.Value))
{
info.Value = "Loading...";
Image gif = Image.FromFile(input.Value);
PropertyItem item = gif.GetPropertyItem(0x5100); // FrameDelay in libgdiplus
UpdateInterval = (item.Value[0] + item.Value[1] * 256) * 10; //FrameDelay in ms
bitmaps.Clear();
for (int i = 0; i < gif.GetFrameCount(FrameDimension.Time); i++)
{
gif.SelectActiveFrame(FrameDimension.Time, i);
bitmaps.Add(new Bitmap(gif));
}
File.WriteAllText(SaveFilePath, input.Value);
info.Value = string.Empty;
}
else
{
info.Value = "File not found!";
}
}
catch (Exception ex)
{
info.Value = $"Error: {ex.Message}";
}
});
}
public override Bitmap Main()
{
if (bitmaps.Count == 0)
@@ -85,5 +49,40 @@ namespace DesktopMagicPlugin.Test
return bitmaps[frameCount];
}
private void Input_OnValueChanged()
{
_ = Task.Run(() =>
{
try
{
if (File.Exists(input.Value))
{
info.Value = "Loading...";
Image gif = Image.FromFile(input.Value);
PropertyItem item = gif.GetPropertyItem(0x5100); // FrameDelay in libgdiplus
UpdateInterval = (item.Value[0] + (item.Value[1] * 256)) * 10; //FrameDelay in ms
bitmaps.Clear();
for (int i = 0; i < gif.GetFrameCount(FrameDimension.Time); i++)
{
_ = gif.SelectActiveFrame(FrameDimension.Time, i);
bitmaps.Add(new Bitmap(gif));
}
File.WriteAllText(SaveFilePath, input.Value);
info.Value = string.Empty;
}
else
{
info.Value = "File not found!";
}
}
catch (Exception ex)
{
info.Value = $"Error: {ex.Message}";
}
});
}
}
-9
View File
@@ -1,9 +0,0 @@
###############
# folder #
###############
/**/DROP/
/**/TEMP/
/**/packages/
/**/bin/
/**/obj/
_site
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Company>Stone_Red</Company>
<Product>Stone_Red</Product>
<Version>0.0.0.5</Version>
@@ -22,11 +22,7 @@
</PropertyGroup>
<ItemGroup>
<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" />
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
@@ -1,468 +0,0 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>DesktopMagicPluginAPI</name>
</assembly>
<members>
<member name="T:DesktopMagicPluginAPI.Drawing.GraphicsExtentions">
<summary>
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>
<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.DrawStringMonospace(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.DrawStringFixedWidth(System.Drawing.Graphics,System.String,System.Drawing.Font,System.Drawing.Brush,System.Single,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>
/// <param name="width">The specified width.</param>
</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>
<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>
<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.
</summary>
</member>
<member name="F:DesktopMagicPluginAPI.Drawing.RenderQuality.High">
<summary>
Slower then <see cref="F:DesktopMagicPluginAPI.Drawing.RenderQuality.Low"/> but produces higher quality output.
</summary>
</member>
<member name="F:DesktopMagicPluginAPI.Drawing.RenderQuality.Low">
<summary>
Faster then <see cref="F:DesktopMagicPluginAPI.Drawing.RenderQuality.High"/> but produces lower quality output.
</summary>
</member>
<member name="F:DesktopMagicPluginAPI.Drawing.RenderQuality.Performance">
<summary>
Provides performance benefits over <see cref="F:DesktopMagicPluginAPI.Drawing.RenderQuality.Low"/>
</summary>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.Button">
<summary>
Represents a button control.
</summary>
</member>
<member name="E:DesktopMagicPluginAPI.Inputs.Button.OnClick">
<summary>
Occurs when the button gets clicked.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.Button.Value">
<summary>
Gets or sets the text caption displayed in the <see cref="T:DesktopMagicPluginAPI.Inputs.Button"/> element.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.Button.#ctor(System.String)">
<summary>
Initializes a new instance of the <see cref="T:DesktopMagicPluginAPI.Inputs.Button"/> class with the provided <paramref name="value"/>.
</summary>
<param name="value">The text caption displayed in the <see cref="T:DesktopMagicPluginAPI.Inputs.Button"/> control.</param>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.Button.Click">
<summary>
Triggers the <see cref="E:DesktopMagicPluginAPI.Inputs.Button.OnClick"/> event.
</summary>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.CheckBox">
<summary>
Represents a check box control.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.CheckBox.Value">
<summary>
Gets or set a value indicating whether the <see cref="T:DesktopMagicPluginAPI.Inputs.CheckBox"/> is in the checked state.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.CheckBox.#ctor(System.Boolean)">
<summary>
Initializes a new instance of the <see cref="T:DesktopMagicPluginAPI.Inputs.CheckBox"/> class with the provided <paramref name="value"/>.
</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.
</summary>
</member>
<member name="E:DesktopMagicPluginAPI.Inputs.Element.OnValueChanged">
<summary>
Occurs when the value has been changed.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.Element.ValueChanged">
<summary>
Triggers the <see cref="E:DesktopMagicPluginAPI.Inputs.Element.OnValueChanged"/> event.
</summary>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.ElementAttribute">
<summary>
Marks a Property as element.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.ElementAttribute.Name">
<summary>
The name of the element.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.ElementAttribute.OrderIndex">
<summary>
The order index of the element.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.ElementAttribute.#ctor(System.String,System.Int32)">
<summary>
Marks a Property as element with the provided <paramref name="name"/> and <paramref name="orderIndex"/>.
</summary>
<param name="name">The name of the element.</param>
<param name="orderIndex">The order index of the element.</param>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.ElementAttribute.#ctor(System.Int32)">
<summary>
Marks a Property as element with the provided <paramref name="orderIndex"/>.
</summary>
<param name="orderIndex">The order index of the element.</param>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.ElementAttribute.#ctor">
<inheritdoc cref="T:DesktopMagicPluginAPI.Inputs.ElementAttribute"/>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.IntegerUpDown">
<summary>
Represents a up-down control.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.IntegerUpDown.Maximum">
<summary>
Gets or sets the maximum value for the <see cref="T:DesktopMagicPluginAPI.Inputs.IntegerUpDown"/> element.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.IntegerUpDown.Minimum">
<summary>
Gets or sets the minimum value for the <see cref="T:DesktopMagicPluginAPI.Inputs.IntegerUpDown"/> element.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.IntegerUpDown.Value">
<summary>
Gets or sets the value assigned to the <see cref="T:DesktopMagicPluginAPI.Inputs.IntegerUpDown"/> element.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.IntegerUpDown.#ctor(System.Int32,System.Int32,System.Int32)">
<summary>
Initializes a new instance of the <see cref="T:DesktopMagicPluginAPI.Inputs.IntegerUpDown"/> class with the provided <paramref name="min"/> value, <paramref name="max"/> value and <paramref name="value"/>.
</summary>
<param name="min">The maximum value for the <see cref="T:DesktopMagicPluginAPI.Inputs.IntegerUpDown"/> element.</param>
<param name="max">The minimum value for the <see cref="T:DesktopMagicPluginAPI.Inputs.IntegerUpDown"/> element.</param>
<param name="value">The value assigned to the <see cref="T:DesktopMagicPluginAPI.Inputs.IntegerUpDown"/> element.</param>
<exception cref="T:System.ArgumentException"></exception>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.Label">
<summary>
Represents a label control.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.Label.Value">
<summary>
Gets or sets the text associated with this <see cref="T:DesktopMagicPluginAPI.Inputs.Label"/>.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.Label.Bold">
<summary>
Gets or set a value indicating whether the content of the <see cref="T:DesktopMagicPluginAPI.Inputs.Label"/> is bold or not.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.Label.#ctor(System.String,System.Boolean)">
<summary>
Initializes a new instance of the <see cref="T:DesktopMagicPluginAPI.Inputs.Label"/> class with the provided <paramref name="value"/>.
</summary>
<param name="value">The text associated with this <see cref="T:DesktopMagicPluginAPI.Inputs.Label"/></param>
<param name="bold">A value indicating whether the content of the <see cref="T:DesktopMagicPluginAPI.Inputs.Label"/> is bold or not.</param>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.MouseButton">
<summary>
Mouse Buttons
</summary>
</member>
<member name="F:DesktopMagicPluginAPI.Inputs.MouseButton.Left">
<summary>
The left mouse button.
</summary>
</member>
<member name="F:DesktopMagicPluginAPI.Inputs.MouseButton.Middle">
<summary>
The middle mouse button.
</summary>
</member>
<member name="F:DesktopMagicPluginAPI.Inputs.MouseButton.Right">
<summary>
The right mouse button.
</summary>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.Slider">
<summary>
Represents a slider control.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.Slider.Maximum">
<summary>
Gets or sets the maximum value for the <see cref="T:DesktopMagicPluginAPI.Inputs.Slider"/> element.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.Slider.Minimum">
<summary>
Gets or sets the minimum value for the <see cref="T:DesktopMagicPluginAPI.Inputs.Slider"/> element.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.Slider.Value">
<summary>
Gets or sets the value assigned to the <see cref="T:DesktopMagicPluginAPI.Inputs.Slider"/> element.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.Slider.#ctor(System.Double,System.Double,System.Double)">
<summary>
Initializes a new instance of the <see cref="T:DesktopMagicPluginAPI.Inputs.Slider"/> class with the provided <paramref name="min"/> value, <paramref name="max"/> value and <paramref name="value"/>.
</summary>
<param name="min">The maximum value for the <see cref="T:DesktopMagicPluginAPI.Inputs.Slider"/> element.</param>
<param name="max">The minimum value for the <see cref="T:DesktopMagicPluginAPI.Inputs.Slider"/> element.</param>
<param name="value">The value assigned to the <see cref="T:DesktopMagicPluginAPI.Inputs.Slider"/> element.</param>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.TextBox">
<summary>
Represents a text box control.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.TextBox.Value">
<summary>
Gets or sets the text associated with this <see cref="T:DesktopMagicPluginAPI.Inputs.TextBox"/>.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.TextBox.#ctor(System.String)">
<summary>
Initializes a new instance of the <see cref="T:DesktopMagicPluginAPI.Inputs.TextBox"/> class with the provided <paramref name="value"/>.
</summary>
<param name="value">The text associated with this control.</param>
</member>
<member name="T:DesktopMagicPluginAPI.IPluginData">
<summary>
Defines properties and methods that provide information about the main application.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.IPluginData.Font">
<summary>
Gets the current font of the current theme.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.IPluginData.Color">
<summary>
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">
<summary>
Gets the window size of the plugin window.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.IPluginData.WindowPosition">
<summary>
Gets the window position of the plugin window.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.IPluginData.PluginName">
<summary>
Gets the name of the plugin.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.IPluginData.PluginPath">
<summary>
Gets the path of the parent directory of the plugin.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.IPluginData.UpdateWindow">
<summary>
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.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Plugin.Application">
<summary>
Informations about the main application.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Plugin.UpdateInterval">
<summary>
Gets or sets the interval, expressed in milliseconds, at which to call the <see cref="M:DesktopMagicPluginAPI.Plugin.Main"/> method.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Plugin.RenderQuality">
<summary>
Gets or sets the render quality of the bitmap image.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Plugin.Start">
<summary>
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">
<summary>
Occurs when the <see cref="P:DesktopMagicPluginAPI.Plugin.UpdateInterval"/> elapses.
</summary>
<returns></returns>
</member>
<member name="M:DesktopMagicPluginAPI.Plugin.OnMouseClick(System.Drawing.Point,DesktopMagicPluginAPI.Inputs.MouseButton)">
<summary>
Occurs when the window is clicked by the mouse.
</summary>
<param name="position">The x- and y-coordinates of the mouse pointer position relative to the plugin window.</param>
<param name="mouseButton">The button associated with the event.</param>
</member>
<member name="M:DesktopMagicPluginAPI.Plugin.OnMouseMove(System.Drawing.Point)">
<summary>
Occurs when the mouse pointer is moved over the control.
</summary>
<param name="position">The x- and y-coordinates of the mouse pointer position relative to the plugin window.</param>
</member>
<member name="M:DesktopMagicPluginAPI.Plugin.OnMouseWheel(System.Drawing.Point,System.Int32)">
<summary>
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>
</member>
</members>
</doc>
@@ -1,20 +1,28 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DesktopMagicPluginAPI.Drawing
{
namespace DesktopMagicPluginAPI.Drawing;
internal class FontComparer : IEqualityComparer<Font>
{
public bool Equals(Font font1, Font font2)
{
if (font1.Name != font2.Name) return false;
if (font1.SizeInPoints != font2.SizeInPoints) return false;
if (font1.Style != font2.Style) return false;
if (font1.Name != font2.Name)
{
return false;
}
if (font1.SizeInPoints != font2.SizeInPoints)
{
return false;
}
if (font1.Style != font2.Style)
{
return false;
}
return true;
}
@@ -23,4 +31,3 @@ namespace DesktopMagicPluginAPI.Drawing
return obj.GetHashCode();
}
}
}
@@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Drawing;
namespace DesktopMagicPluginAPI.Drawing
{
namespace DesktopMagicPluginAPI.Drawing;
/// <summary>
/// Extensions for the <see cref="Graphics"/> class.
/// </summary>
@@ -104,7 +104,7 @@ namespace DesktopMagicPluginAPI.Drawing
{
// measure left padding
StringFormat sf = new StringFormat(StringFormatFlags.NoClip);
sf.SetMeasurableCharacterRanges(new CharacterRange[] { new CharacterRange(0, 1) });
sf.SetMeasurableCharacterRanges([new CharacterRange(0, 1)]);
Region[] r = graphics.MeasureCharacterRanges(s, font, new RectangleF(0, 0, 1000, 100), sf);
float leftPadding = r[0].GetBounds(graphics).Left;
@@ -125,7 +125,7 @@ namespace DesktopMagicPluginAPI.Drawing
{
// measure left padding
StringFormat sf = new StringFormat(StringFormatFlags.NoClip);
sf.SetMeasurableCharacterRanges(new CharacterRange[] { new CharacterRange(0, 1) });
sf.SetMeasurableCharacterRanges([new CharacterRange(0, 1)]);
Region[] r = graphics.MeasureCharacterRanges(s, font, new RectangleF(0, 0, 1000, 100), sf);
float leftPadding = r[0].GetBounds(graphics).Left;
@@ -146,7 +146,7 @@ namespace DesktopMagicPluginAPI.Drawing
SizeF size = graphics.MeasureString(text, font, int.MaxValue);
StringFormat sf = new StringFormat(StringFormatFlags.NoClip);
sf.SetMeasurableCharacterRanges(new CharacterRange[] { new CharacterRange(0, 1) });
sf.SetMeasurableCharacterRanges([new CharacterRange(0, 1)]);
Region[] r = graphics.MeasureCharacterRanges(text, font, new RectangleF(0, 0, 1000, 100), sf);
float leftPadding = r[0].GetBounds(graphics).Left;
@@ -156,9 +156,9 @@ namespace DesktopMagicPluginAPI.Drawing
private static int GetWidestChar(this Graphics graphics, Font font)
{
if (fonts.ContainsKey(font))
if (fonts.TryGetValue(font, out int value))
{
return fonts[font];
return value;
}
float max = 0;
@@ -182,4 +182,3 @@ namespace DesktopMagicPluginAPI.Drawing
return (int)Math.Round(max, 0);
}
}
}
@@ -1,11 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DesktopMagicPluginAPI.Drawing;
namespace DesktopMagicPluginAPI.Drawing
{
/// <summary>
/// Specifies which render quality is used to display the bitmap images.
/// </summary>
@@ -26,4 +20,3 @@ namespace DesktopMagicPluginAPI.Drawing
/// </summary>
Performance
}
}
+2 -3
View File
@@ -1,8 +1,8 @@
using System;
using System.Drawing;
namespace DesktopMagicPluginAPI
{
namespace DesktopMagicPluginAPI;
/// <summary>
/// Defines properties and methods that provide information about the main application.
/// </summary>
@@ -50,4 +50,3 @@ namespace DesktopMagicPluginAPI
/// </summary>
void UpdateWindow();
}
}
+2 -3
View File
@@ -1,7 +1,7 @@
using System.Drawing;
namespace DesktopMagicPluginAPI
{
namespace DesktopMagicPluginAPI;
/// <summary>
/// The theme settings of the main application.
/// </summary>
@@ -37,4 +37,3 @@ namespace DesktopMagicPluginAPI
/// </summary>
int Margin { get; }
}
}
+2 -3
View File
@@ -1,7 +1,7 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
{
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Represents a button control.
/// </summary>
@@ -47,4 +47,3 @@ namespace DesktopMagicPluginAPI.Inputs
OnClick?.Invoke();
}
}
}
+2 -3
View File
@@ -1,5 +1,5 @@
namespace DesktopMagicPluginAPI.Inputs
{
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Represents a check box control.
/// </summary>
@@ -32,4 +32,3 @@
Value = value;
}
}
}
+3 -4
View File
@@ -1,7 +1,7 @@
using System.Collections.ObjectModel;
namespace DesktopMagicPluginAPI.Inputs
{
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Represents a selection control with a drop-down list.
/// </summary>
@@ -12,7 +12,7 @@ namespace DesktopMagicPluginAPI.Inputs
/// <summary>
/// Gets the collection used to generate the content of the <see cref="ComboBox"/>.
/// </summary>
public ObservableCollection<string> Items { get; } = new ObservableCollection<string>();
public ObservableCollection<string> Items { get; } = [];
/// <summary>
/// Gets the currently selected item associated with this <see cref="ComboBox"/>.
@@ -43,4 +43,3 @@ namespace DesktopMagicPluginAPI.Inputs
}
}
}
}
+2 -3
View File
@@ -1,7 +1,7 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
{
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// The element base class.
/// </summary>
@@ -20,4 +20,3 @@ namespace DesktopMagicPluginAPI.Inputs
OnValueChanged?.Invoke();
}
}
}
@@ -1,7 +1,7 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
{
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Marks a Property as element.
/// </summary>
@@ -43,4 +43,3 @@ namespace DesktopMagicPluginAPI.Inputs
{
}
}
}
@@ -1,7 +1,7 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
{
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Represents a up-down control.
/// </summary>
@@ -70,4 +70,3 @@ namespace DesktopMagicPluginAPI.Inputs
Value = value;
}
}
}
+2 -3
View File
@@ -1,5 +1,5 @@
namespace DesktopMagicPluginAPI.Inputs
{
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Represents a label control.
/// </summary>
@@ -39,4 +39,3 @@
Bold = bold;
}
}
}
@@ -1,11 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DesktopMagicPluginAPI.Inputs;
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Mouse Buttons
/// </summary>
@@ -26,4 +20,3 @@ namespace DesktopMagicPluginAPI.Inputs
/// </summary>
Right,
}
}
+2 -3
View File
@@ -1,7 +1,7 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
{
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Represents a slider control.
/// </summary>
@@ -69,4 +69,3 @@ namespace DesktopMagicPluginAPI.Inputs
Value = value;
}
}
}
+2 -3
View File
@@ -1,5 +1,5 @@
namespace DesktopMagicPluginAPI.Inputs
{
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Represents a text box control.
/// </summary>
@@ -32,4 +32,3 @@
Value = value;
}
}
}
+2 -3
View File
@@ -4,8 +4,8 @@ using DesktopMagicPluginAPI.Inputs;
using System;
using System.Drawing;
namespace DesktopMagicPluginAPI
{
namespace DesktopMagicPluginAPI;
/// <summary>
/// The plugin class.
/// </summary>
@@ -78,4 +78,3 @@ namespace DesktopMagicPluginAPI
{
}
}
}
-5
View File
@@ -1,5 +0,0 @@
###############
# temp file #
###############
*.yml
.manifest
-2
View File
@@ -1,2 +0,0 @@
# PLACEHOLDER
TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*!
@@ -1 +0,0 @@
# Add your introductions here!
@@ -1,2 +0,0 @@
- name: Introduction
href: intro.md
-65
View File
@@ -1,65 +0,0 @@
{
"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
@@ -1,4 +0,0 @@
# 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
@@ -1,5 +0,0 @@
- name: Articles
href: articles/
- name: Api Documentation
href: api/
homepage: api/index.md