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
-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,26 +1,33 @@
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>
{
internal class FontComparer : IEqualityComparer<Font>
public bool Equals(Font font1, Font font2)
{
public bool Equals(Font font1, Font font2)
if (font1.Name != font2.Name)
{
if (font1.Name != font2.Name) return false;
if (font1.SizeInPoints != font2.SizeInPoints) return false;
if (font1.Style != font2.Style) return false;
return true;
return false;
}
public int GetHashCode([DisallowNull] Font obj)
if (font1.SizeInPoints != font2.SizeInPoints)
{
return obj.GetHashCode();
return false;
}
if (font1.Style != font2.Style)
{
return false;
}
return true;
}
public int GetHashCode([DisallowNull] Font obj)
{
return obj.GetHashCode();
}
}
@@ -2,184 +2,183 @@
using System.Collections.Generic;
using System.Drawing;
namespace DesktopMagicPluginAPI.Drawing
namespace DesktopMagicPluginAPI.Drawing;
/// <summary>
/// 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>
/// Extensions for the <see cref="Graphics"/> class.
/// <inheritdoc cref="Graphics.DrawString(string?, Font, Brush, float, float)"/>
/// </summary>
public static class GraphicsExtentions
/// <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 DrawStringMonospace(this Graphics graphics, string s, Font font, Brush brush, float x, float y)
{
private static readonly Dictionary<Font, int> fonts = new Dictionary<Font, int>(new FontComparer());
int widest = graphics.GetWidestChar(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 DrawStringMonospace(this Graphics graphics, string s, Font font, Brush brush, float x, float y)
for (int i = 0; i < s.Length; i++)
{
int widest = graphics.GetWidestChar(font);
graphics.DrawString(s[i].ToString(), font, brush, x, y);
for (int i = 0; i < s.Length; i++)
{
graphics.DrawString(s[i].ToString(), font, brush, x, y);
x += widest;
}
}
/// <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 DrawStringMonospace(this Graphics graphics, string s, Font font, Brush brush, PointF point)
{
int widest = graphics.GetWidestChar(font);
for (int i = 0; i < s.Length; i++)
{
graphics.DrawString(s[i].ToString(), font, brush, point);
point.X += widest;
}
}
/// <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>
/// /// <param name="width">The specified width.</param>
public static void DrawStringFixedWidth(this Graphics graphics, string s, Font font, Brush brush, float x, float y, float width)
{
for (int i = 0; i < s.Length; i++)
{
graphics.DrawString(s[i].ToString(), font, brush, x, y);
x += width;
}
}
/// <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>
/// <param name="width">The specified width.</param>
public static void DrawStringFixedWidth(this Graphics graphics, string s, Font font, Brush brush, PointF point, float width)
{
for (int i = 0; i < s.Length; i++)
{
graphics.DrawString(s[i].ToString(), font, brush, point);
point.X += width;
}
}
/// <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];
}
float max = 0;
char maxx = ' ';
for (int i = 0; i <= 255; i++)
{
char c = (char)i;
if (char.IsLetterOrDigit(c))
{
float neww = graphics.MeasureString(c.ToString(), font).Width;
if (neww >= max)
{
max = neww;
maxx = c;
}
}
}
Console.WriteLine((int)Math.Round(max, 0));
Console.WriteLine(maxx);
fonts.Add(font, (int)Math.Round(max, 0));
return (int)Math.Round(max, 0);
x += widest;
}
}
/// <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 DrawStringMonospace(this Graphics graphics, string s, Font font, Brush brush, PointF point)
{
int widest = graphics.GetWidestChar(font);
for (int i = 0; i < s.Length; i++)
{
graphics.DrawString(s[i].ToString(), font, brush, point);
point.X += widest;
}
}
/// <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>
/// /// <param name="width">The specified width.</param>
public static void DrawStringFixedWidth(this Graphics graphics, string s, Font font, Brush brush, float x, float y, float width)
{
for (int i = 0; i < s.Length; i++)
{
graphics.DrawString(s[i].ToString(), font, brush, x, y);
x += width;
}
}
/// <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>
/// <param name="width">The specified width.</param>
public static void DrawStringFixedWidth(this Graphics graphics, string s, Font font, Brush brush, PointF point, float width)
{
for (int i = 0; i < s.Length; i++)
{
graphics.DrawString(s[i].ToString(), font, brush, point);
point.X += width;
}
}
/// <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(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(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(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.TryGetValue(font, out int value))
{
return value;
}
float max = 0;
char maxx = ' ';
for (int i = 0; i <= 255; i++)
{
char c = (char)i;
if (char.IsLetterOrDigit(c))
{
float neww = graphics.MeasureString(c.ToString(), font).Width;
if (neww >= max)
{
max = neww;
maxx = c;
}
}
}
Console.WriteLine((int)Math.Round(max, 0));
Console.WriteLine(maxx);
fonts.Add(font, (int)Math.Round(max, 0));
return (int)Math.Round(max, 0);
}
}
@@ -1,29 +1,22 @@
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>
public enum RenderQuality
{
/// <summary>
/// Specifies which render quality is used to display the bitmap images.
/// Slower then <see cref="Low"/> but produces higher quality output.
/// </summary>
public enum RenderQuality
{
/// <summary>
/// Slower then <see cref="Low"/> but produces higher quality output.
/// </summary>
High,
High,
/// <summary>
/// Faster then <see cref="High"/> but produces lower quality output.
/// </summary>
Low,
/// <summary>
/// Faster then <see cref="High"/> but produces lower quality output.
/// </summary>
Low,
/// <summary>
/// Provides performance benefits over <see cref="Low"/>
/// </summary>
Performance
}
/// <summary>
/// Provides performance benefits over <see cref="Low"/>
/// </summary>
Performance
}
+38 -39
View File
@@ -1,53 +1,52 @@
using System;
using System.Drawing;
namespace DesktopMagicPluginAPI
namespace DesktopMagicPluginAPI;
/// <summary>
/// Defines properties and methods that provide information about the main application.
/// </summary>
public interface IPluginData
{
/// <summary>
/// Defines properties and methods that provide information about the main application.
/// Gets the current font of the current theme.
/// </summary>
public interface IPluginData
{
/// <summary>
/// Gets the current font of the current theme.
/// </summary>
[Obsolete("Use the \"Theme\" property instead")]
string Font { get; }
[Obsolete("Use the \"Theme\" property instead")]
string Font { get; }
/// <summary>
/// Gets the current color of the current theme.
/// </summary>
[Obsolete("Use the \"Theme\" property instead")]
Color Color { get; }
/// <summary>
/// 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 current theme setting of the main application.
/// </summary>
ITheme Theme { get; }
/// <summary>
/// Gets the window size of the plugin window.
/// </summary>
Size WindowSize { get; }
/// <summary>
/// Gets the window size of the plugin window.
/// </summary>
Size WindowSize { get; }
/// <summary>
/// Gets the window position of the plugin window.
/// </summary>
Point WindowPosition { get; }
/// <summary>
/// Gets the window position of the plugin window.
/// </summary>
Point WindowPosition { get; }
/// <summary>
/// Gets the name of the plugin.
/// </summary>
string PluginName { get; }
/// <summary>
/// Gets the name of the plugin.
/// </summary>
string PluginName { get; }
/// <summary>
/// Gets the path of the parent directory of the plugin.
/// </summary>
string PluginPath { get; }
/// <summary>
/// Gets the path of the parent directory of the plugin.
/// </summary>
string PluginPath { get; }
/// <summary>
/// Updates the plugin window.
/// </summary>
void UpdateWindow();
}
/// <summary>
/// Updates the plugin window.
/// </summary>
void UpdateWindow();
}
+28 -29
View File
@@ -1,40 +1,39 @@
using System.Drawing;
namespace DesktopMagicPluginAPI
namespace DesktopMagicPluginAPI;
/// <summary>
/// The theme settings of the main application.
/// </summary>
public interface ITheme
{
/// <summary>
/// The theme settings of the main application.
/// Gets the primary color of the current theme.
/// </summary>
public interface ITheme
{
/// <summary>
/// Gets the primary color of the current theme.
/// </summary>
Color PrimaryColor { get; }
Color PrimaryColor { get; }
/// <summary>
/// Gets the secondary color of the current theme.
/// </summary>
Color SecondaryColor { 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 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 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 CornerRadius { get; }
/// <summary>
/// Gets the corner radius of the current theme.
/// </summary>
int Margin { get; }
}
/// <summary>
/// Gets the corner radius of the current theme.
/// </summary>
int Margin { get; }
}
+35 -36
View File
@@ -1,50 +1,49 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Represents a button control.
/// </summary>
public class Button : Element
{
/// <summary>
/// Represents a button control.
/// Occurs when the button gets clicked.
/// </summary>
public class Button : Element
public event Action OnClick;
private string _value;
/// <summary>
/// Gets or sets the text caption displayed in the <see cref="Button"/> element.
/// </summary>
public string Value
{
/// <summary>
/// Occurs when the button gets clicked.
/// </summary>
public event Action OnClick;
private string _value;
/// <summary>
/// Gets or sets the text caption displayed in the <see cref="Button"/> element.
/// </summary>
public string Value
get => _value;
set
{
get => _value;
set
if (_value != value)
{
if (_value != value)
{
_value = value;
ValueChanged();
}
_value = value;
ValueChanged();
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="Button"/> class with the provided <paramref name="value"/>.
/// </summary>
/// <param name="value">The text caption displayed in the <see cref="Button"/> control.</param>
public Button(string value)
{
Value = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="Button"/> class with the provided <paramref name="value"/>.
/// </summary>
/// <param name="value">The text caption displayed in the <see cref="Button"/> control.</param>
public Button(string value)
{
Value = value;
}
/// <summary>
/// Triggers the <see cref="OnClick"/> event.
/// </summary>
public void Click()
{
OnClick?.Invoke();
}
/// <summary>
/// Triggers the <see cref="OnClick"/> event.
/// </summary>
public void Click()
{
OnClick?.Invoke();
}
}
+26 -27
View File
@@ -1,35 +1,34 @@
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Represents a check box control.
/// </summary>
public class CheckBox : Element
{
private bool _value;
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Gets or set a value indicating whether the <see cref="CheckBox"/> is in the checked state.
/// </summary>
public bool Value
/// <summary>
/// Represents a check box control.
/// </summary>
public class CheckBox : Element
{
private bool _value;
/// <summary>
/// Gets or set a value indicating whether the <see cref="CheckBox"/> is in the checked state.
/// </summary>
public bool Value
{
get => _value;
set
{
get => _value;
set
if (_value != value)
{
if (_value != value)
{
_value = value;
ValueChanged();
}
_value = value;
ValueChanged();
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="CheckBox"/> class with the provided <paramref name="value"/>.
/// </summary>
/// <param name="value">A value indicating whether the <see cref="CheckBox"/> is in the checked state.</param>
public CheckBox(bool value)
{
Value = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="CheckBox"/> class with the provided <paramref name="value"/>.
/// </summary>
/// <param name="value">A value indicating whether the <see cref="CheckBox"/> is in the checked state.</param>
public CheckBox(bool value)
{
Value = value;
}
}
+33 -34
View File
@@ -1,46 +1,45 @@
using System.Collections.ObjectModel;
namespace DesktopMagicPluginAPI.Inputs
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Represents a selection control with a drop-down list.
/// </summary>
public class ComboBox : Element
{
private string _value;
/// <summary>
/// Represents a selection control with a drop-down list.
/// Gets the collection used to generate the content of the <see cref="ComboBox"/>.
/// </summary>
public class ComboBox : Element
public ObservableCollection<string> Items { get; } = [];
/// <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
{
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
{
get => _value;
set
if (_value != value)
{
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);
_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);
}
}
}
+14 -15
View File
@@ -1,23 +1,22 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// The element base class.
/// </summary>
public abstract class Element
{
/// <summary>
/// The element base class.
/// Occurs when the value has been changed.
/// </summary>
public abstract class Element
{
/// <summary>
/// Occurs when the value has been changed.
/// </summary>
public event Action OnValueChanged;
public event Action OnValueChanged;
/// <summary>
/// Triggers the <see cref="OnValueChanged"/> event.
/// </summary>
protected void ValueChanged()
{
OnValueChanged?.Invoke();
}
/// <summary>
/// Triggers the <see cref="OnValueChanged"/> event.
/// </summary>
protected void ValueChanged()
{
OnValueChanged?.Invoke();
}
}
@@ -1,46 +1,45 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Marks a Property as element.
/// </summary>
[AttributeUsage(AttributeTargets.Field)]
public class ElementAttribute : Attribute
{
/// <summary>
/// Marks a Property as element.
/// The name of the element.
/// </summary>
[AttributeUsage(AttributeTargets.Field)]
public class ElementAttribute : Attribute
public string Name { get; }
/// <summary>
/// The order index of the element.
/// </summary>
public int OrderIndex { get; }
/// <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>
public ElementAttribute(string name, int orderIndex = 0)
{
/// <summary>
/// The name of the element.
/// </summary>
public string Name { get; }
Name = name;
OrderIndex = orderIndex;
}
/// <summary>
/// The order index of the element.
/// </summary>
public int OrderIndex { get; }
/// <summary>
/// Marks a Property as element with the provided <paramref name="orderIndex"/>.
/// </summary>
/// <param name="orderIndex">The order index of the element.</param>
public ElementAttribute(int orderIndex)
{
OrderIndex = orderIndex;
}
/// <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>
public ElementAttribute(string name, int orderIndex = 0)
{
Name = name;
OrderIndex = orderIndex;
}
/// <summary>
/// Marks a Property as element with the provided <paramref name="orderIndex"/>.
/// </summary>
/// <param name="orderIndex">The order index of the element.</param>
public ElementAttribute(int orderIndex)
{
OrderIndex = orderIndex;
}
/// <inheritdoc cref="ElementAttribute"/>
public ElementAttribute()
{
}
/// <inheritdoc cref="ElementAttribute"/>
public ElementAttribute()
{
}
}
@@ -1,73 +1,72 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Represents a up-down control.
/// </summary>
public class IntegerUpDown : Element
{
private int _value;
/// <summary>
/// Represents a up-down control.
/// Gets or sets the maximum value for the <see cref="IntegerUpDown"/> element.
/// </summary>
public class IntegerUpDown : Element
public int Maximum { get; }
/// <summary>
/// Gets or sets the minimum value for the <see cref="IntegerUpDown"/> element.
/// </summary>
public int Minimum { get; }
/// <summary>
/// Gets or sets the value assigned to the <see cref="IntegerUpDown"/> element.
/// </summary>
public int Value
{
private int _value;
/// <summary>
/// Gets or sets the maximum value for the <see cref="IntegerUpDown"/> element.
/// </summary>
public int Maximum { get; }
/// <summary>
/// Gets or sets the minimum value for the <see cref="IntegerUpDown"/> element.
/// </summary>
public int Minimum { get; }
/// <summary>
/// Gets or sets the value assigned to the <see cref="IntegerUpDown"/> element.
/// </summary>
public int Value
get => _value;
set
{
get => _value;
set
if (_value != value)
{
if (_value != value)
{
_value = value;
ValueChanged();
}
_value = value;
ValueChanged();
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="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="IntegerUpDown"/> element.</param>
/// <param name="max">The minimum value for the <see cref="IntegerUpDown"/> element.</param>
/// <param name="value">The value assigned to the <see cref="IntegerUpDown"/> element.</param>
/// <exception cref="ArgumentException"></exception>
public IntegerUpDown(int min, int max, int value = 0)
/// <summary>
/// Initializes a new instance of the <see cref="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="IntegerUpDown"/> element.</param>
/// <param name="max">The minimum value for the <see cref="IntegerUpDown"/> element.</param>
/// <param name="value">The value assigned to the <see cref="IntegerUpDown"/> element.</param>
/// <exception cref="ArgumentException"></exception>
public IntegerUpDown(int min, int max, int value = 0)
{
if (min < 0)
{
if (min < 0)
{
throw new ArgumentException("Value can not be negative!", nameof(min));
}
if (max < 0)
{
throw new ArgumentException("Value can not be negative!", nameof(max));
}
if (min > max)
{
throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!");
}
if (value > max)
{
throw new ArgumentException($"{nameof(value)} is greater than {nameof(max)}!");
}
if (value < min)
{
throw new ArgumentException($"{nameof(value)} is less than {nameof(min)}!");
}
throw new ArgumentException("Value can not be negative!", nameof(min));
}
if (max < 0)
{
throw new ArgumentException("Value can not be negative!", nameof(max));
}
if (min > max)
{
throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!");
}
if (value > max)
{
throw new ArgumentException($"{nameof(value)} is greater than {nameof(max)}!");
}
if (value < min)
{
throw new ArgumentException($"{nameof(value)} is less than {nameof(min)}!");
}
Minimum = min;
Maximum = max;
Value = value;
}
Minimum = min;
Maximum = max;
Value = value;
}
}
+32 -33
View File
@@ -1,42 +1,41 @@
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Represents a label control.
/// </summary>
public class Label : Element
{
private string _value;
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Gets or sets the text associated with this <see cref="Label"/>.
/// </summary>
public string Value
/// <summary>
/// Represents a label control.
/// </summary>
public class Label : Element
{
private string _value;
/// <summary>
/// Gets or sets the text associated with this <see cref="Label"/>.
/// </summary>
public string Value
{
get => _value;
set
{
get => _value;
set
if (_value != value)
{
if (_value != value)
{
_value = value;
ValueChanged();
}
_value = value;
ValueChanged();
}
}
}
/// <summary>
/// Gets or set a value indicating whether the content of the <see cref="Label"/> is bold or not.
/// </summary>
public bool Bold { get; set; }
/// <summary>
/// Gets or set a value indicating whether the content of the <see cref="Label"/> is bold or not.
/// </summary>
public bool Bold { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Label"/> class with the provided <paramref name="value"/>.
/// </summary>
/// <param name="value">The text associated with this <see cref="Label"/></param>
/// <param name="bold">A value indicating whether the content of the <see cref="Label"/> is bold or not.</param>
public Label(string value, bool bold = false)
{
Value = value;
Bold = bold;
}
/// <summary>
/// Initializes a new instance of the <see cref="Label"/> class with the provided <paramref name="value"/>.
/// </summary>
/// <param name="value">The text associated with this <see cref="Label"/></param>
/// <param name="bold">A value indicating whether the content of the <see cref="Label"/> is bold or not.</param>
public Label(string value, bool bold = false)
{
Value = value;
Bold = bold;
}
}
+15 -22
View File
@@ -1,29 +1,22 @@
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>
public enum MouseButton
{
/// <summary>
/// Mouse Buttons
/// The left mouse button.
/// </summary>
public enum MouseButton
{
/// <summary>
/// The left mouse button.
/// </summary>
Left,
Left,
/// <summary>
/// The middle mouse button.
/// </summary>
Middle,
/// <summary>
/// The middle mouse button.
/// </summary>
Middle,
/// <summary>
/// The right mouse button.
/// </summary>
Right,
}
/// <summary>
/// The right mouse button.
/// </summary>
Right,
}
+56 -57
View File
@@ -1,72 +1,71 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Represents a slider control.
/// </summary>
public sealed class Slider : Element
{
private double _value;
/// <summary>
/// Represents a slider control.
/// Gets or sets the maximum value for the <see cref="Slider"/> element.
/// </summary>
public sealed class Slider : Element
public double Maximum { get; }
/// <summary>
/// Gets or sets the minimum value for the <see cref="Slider"/> element.
/// </summary>
public double Minimum { get; }
/// <summary>
/// Gets or sets the value assigned to the <see cref="Slider"/> element.
/// </summary>
public double Value
{
private double _value;
/// <summary>
/// Gets or sets the maximum value for the <see cref="Slider"/> element.
/// </summary>
public double Maximum { get; }
/// <summary>
/// Gets or sets the minimum value for the <see cref="Slider"/> element.
/// </summary>
public double Minimum { get; }
/// <summary>
/// Gets or sets the value assigned to the <see cref="Slider"/> element.
/// </summary>
public double Value
get => _value;
set
{
get => _value;
set
if (_value != value)
{
if (_value != value)
{
_value = value;
ValueChanged();
}
_value = value;
ValueChanged();
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="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="Slider"/> element.</param>
/// <param name="max">The minimum value for the <see cref="Slider"/> element.</param>
/// <param name="value">The value assigned to the <see cref="Slider"/> element.</param>
public Slider(double min, double max, double value = 0)
/// <summary>
/// Initializes a new instance of the <see cref="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="Slider"/> element.</param>
/// <param name="max">The minimum value for the <see cref="Slider"/> element.</param>
/// <param name="value">The value assigned to the <see cref="Slider"/> element.</param>
public Slider(double min, double max, double value = 0)
{
if (min < 0)
{
if (min < 0)
{
throw new ArgumentException("Value can not be negative!", nameof(min));
}
if (max < 0)
{
throw new ArgumentException("Value can not be negative!", nameof(max));
}
if (min > max)
{
throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!");
}
if (value > max)
{
throw new ArgumentException($"{nameof(value)} is greater than {nameof(max)}!");
}
if (value < min)
{
throw new ArgumentException($"{nameof(value)} is less than {nameof(min)}!");
}
throw new ArgumentException("Value can not be negative!", nameof(min));
}
if (max < 0)
{
throw new ArgumentException("Value can not be negative!", nameof(max));
}
if (min > max)
{
throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!");
}
if (value > max)
{
throw new ArgumentException($"{nameof(value)} is greater than {nameof(max)}!");
}
if (value < min)
{
throw new ArgumentException($"{nameof(value)} is less than {nameof(min)}!");
}
Minimum = min;
Maximum = max;
Value = value;
}
Minimum = min;
Maximum = max;
Value = value;
}
}
+26 -27
View File
@@ -1,35 +1,34 @@
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Represents a text box control.
/// </summary>
public class TextBox : Element
{
private string _value;
namespace DesktopMagicPluginAPI.Inputs;
/// <summary>
/// Gets or sets the text associated with this <see cref="TextBox"/>.
/// </summary>
public string Value
/// <summary>
/// Represents a text box control.
/// </summary>
public class TextBox : Element
{
private string _value;
/// <summary>
/// Gets or sets the text associated with this <see cref="TextBox"/>.
/// </summary>
public string Value
{
get => _value;
set
{
get => _value;
set
if (_value != value)
{
if (_value != value)
{
_value = value;
ValueChanged();
}
_value = value;
ValueChanged();
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="TextBox"/> class with the provided <paramref name="value"/>.
/// </summary>
/// <param name="value">The text associated with this control.</param>
public TextBox(string value)
{
Value = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="TextBox"/> class with the provided <paramref name="value"/>.
/// </summary>
/// <param name="value">The text associated with this control.</param>
public TextBox(string value)
{
Value = value;
}
}
+60 -61
View File
@@ -4,78 +4,77 @@ using DesktopMagicPluginAPI.Inputs;
using System;
using System.Drawing;
namespace DesktopMagicPluginAPI
namespace DesktopMagicPluginAPI;
/// <summary>
/// The plugin class.
/// </summary>
public abstract class Plugin
{
private IPluginData application = null;
/// <summary>
/// The plugin class.
/// Informations about the main application.
/// </summary>
public abstract class Plugin
public IPluginData Application
{
private IPluginData application = null;
get => application;
set => application = application is null ? value : throw new InvalidOperationException($"You cannot set the value of the {nameof(Application)} property");
}
/// <summary>
/// Informations about the main application.
/// </summary>
public IPluginData Application
{
get => application;
set => application = application is null ? value : throw new InvalidOperationException($"You cannot set the value of the {nameof(Application)} property");
}
/// <summary>
/// Gets or sets the interval, expressed in milliseconds, at which to call the <see cref="Main"/> method.
/// </summary>
public virtual int UpdateInterval { get; set; } = 1000;
/// <summary>
/// Gets or sets the interval, expressed in milliseconds, at which to call the <see cref="Main"/> method.
/// </summary>
public virtual int UpdateInterval { get; set; } = 1000;
/// <summary>
/// Gets or sets the render quality of the bitmap image.
/// </summary>
public virtual RenderQuality RenderQuality { get; set; } = RenderQuality.High;
/// <summary>
/// Gets or sets the render quality of the bitmap image.
/// </summary>
public virtual RenderQuality RenderQuality { get; set; } = RenderQuality.High;
/// <summary>
/// Occurs once when the plugin gets activated.
/// </summary>
public virtual void Start()
{
}
/// <summary>
/// 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 once when the plugin gets deactivated.
/// </summary>
public virtual void Stop()
{
}
/// <summary>
/// Occurs when the <see cref="UpdateInterval"/> elapses.
/// </summary>
/// <returns></returns>
public abstract Bitmap Main();
/// <summary>
/// Occurs when the <see cref="UpdateInterval"/> elapses.
/// </summary>
/// <returns></returns>
public abstract Bitmap Main();
/// <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>
public virtual void OnMouseClick(Point position, MouseButton 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>
public virtual void OnMouseClick(Point position, MouseButton mouseButton)
{
}
/// <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>
public virtual void OnMouseMove(Point position)
{
}
/// <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>
public virtual void OnMouseMove(Point position)
{
}
/// <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>
public virtual void OnMouseWheel(Point position, int delta)
{
}
/// <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>
public virtual void OnMouseWheel(Point position, int delta)
{
}
}
-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