Revert "Fix mistake"

This reverts commit e89b2981e7.
This commit is contained in:
Stone-Red-Code
2021-08-14 21:42:06 +02:00
parent e89b2981e7
commit 1e57ec1b6a
172 changed files with 2328 additions and 780 deletions
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Represents a button control.
/// </summary>
public class Button : Element
{
/// <summary>
/// Occurs when the button is 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
{
if (_value != value)
{
_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>
/// Triggers the <see cref="OnClick"/> event.
/// </summary>
public void Click()
{
OnClick?.Invoke();
}
}
}
@@ -0,0 +1,35 @@
namespace DesktopMagicPluginAPI.Inputs
{
/// <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
{
if (_value != value)
{
_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;
}
}
}
@@ -0,0 +1,23 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// The element base class
/// </summary>
public abstract class Element
{
/// <summary>
/// Occurs when the value has been changed
/// </summary>
public event Action OnValueChanged;
/// <summary>
/// Triggers the <see cref="OnValueChanged"/> event
/// </summary>
protected void ValueChanged()
{
OnValueChanged?.Invoke();
}
}
}
@@ -0,0 +1,46 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Marks a Property as element.
/// </summary>
[AttributeUsage(AttributeTargets.Field)]
public class ElementAttribute : Attribute
{
/// <summary>
/// The name of the element.
/// </summary>
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)
{
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 = 0)
{
OrderIndex = orderIndex;
}
/// <inheritdoc cref="ElementAttribute"/>
public ElementAttribute()
{
}
}
}
@@ -0,0 +1,73 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Represents a up-down control.
/// </summary>
public class IntegerUpDown : Element
{
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
{
if (_value != value)
{
_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)
{
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)}!");
}
Minimum = min;
Maximum = max;
Value = value;
}
}
}
+42
View File
@@ -0,0 +1,42 @@
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Represents a label control.
/// </summary>
public class Label : Element
{
private string _value;
/// <summary>
/// Gets or sets the text associated with this control.
/// </summary>
public string Value
{
get => _value;
set
{
if (_value != value)
{
_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>
/// Initializes a new instance of the <see cref="Label"/> class with the provided <paramref name="value"/>.
/// </summary>
/// <param name="value"></param>
/// <param name="bold"></param>
public Label(string value, bool bold = false)
{
Value = value;
Bold = bold;
}
}
}
@@ -0,0 +1,72 @@
using System;
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Represents a slider control.
/// </summary>
public sealed class Slider : Element
{
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
{
if (_value != value)
{
_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)
{
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)}!");
}
Minimum = min;
Maximum = max;
Value = value;
}
}
}
@@ -0,0 +1,35 @@
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Represents a text box control.
/// </summary>
public class TextBox : Element
{
private string _value;
/// <summary>
/// Gets or sets the text associated with this control.
/// </summary>
public string Value
{
get => _value;
set
{
if (_value != value)
{
_value = value;
ValueChanged();
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="TextBox"/> class with the provided <paramref name="value"/>.
/// </summary>
/// <param name="value"></param>
public TextBox(string value)
{
Value = value;
}
}
}