- Add ComboBox element to the API

This commit is contained in:
Stone-Red-Code
2021-10-30 21:06:53 +02:00
parent 2f6662caea
commit 5e3642e539
10 changed files with 161 additions and 113 deletions
@@ -10,6 +10,10 @@
- [CheckBox](#T-DesktopMagicPluginAPI-Inputs-CheckBox 'DesktopMagicPluginAPI.Inputs.CheckBox')
- [#ctor(value)](#M-DesktopMagicPluginAPI-Inputs-CheckBox-#ctor-System-Boolean- 'DesktopMagicPluginAPI.Inputs.CheckBox.#ctor(System.Boolean)')
- [Value](#P-DesktopMagicPluginAPI-Inputs-CheckBox-Value 'DesktopMagicPluginAPI.Inputs.CheckBox.Value')
- [ComboBox](#T-DesktopMagicPluginAPI-Inputs-ComboBox 'DesktopMagicPluginAPI.Inputs.ComboBox')
- [#ctor(items)](#M-DesktopMagicPluginAPI-Inputs-ComboBox-#ctor-System-String[]- 'DesktopMagicPluginAPI.Inputs.ComboBox.#ctor(System.String[])')
- [Items](#P-DesktopMagicPluginAPI-Inputs-ComboBox-Items 'DesktopMagicPluginAPI.Inputs.ComboBox.Items')
- [Value](#P-DesktopMagicPluginAPI-Inputs-ComboBox-Value 'DesktopMagicPluginAPI.Inputs.ComboBox.Value')
- [Element](#T-DesktopMagicPluginAPI-Inputs-Element 'DesktopMagicPluginAPI.Inputs.Element')
- [ValueChanged()](#M-DesktopMagicPluginAPI-Inputs-Element-ValueChanged 'DesktopMagicPluginAPI.Inputs.Element.ValueChanged')
- [ElementAttribute](#T-DesktopMagicPluginAPI-Inputs-ElementAttribute 'DesktopMagicPluginAPI.Inputs.ElementAttribute')
@@ -151,6 +155,48 @@ Initializes a new instance of the [CheckBox](#T-DesktopMagicPluginAPI-Inputs-Che
Gets or set a value indicating whether the [CheckBox](#T-DesktopMagicPluginAPI-Inputs-CheckBox 'DesktopMagicPluginAPI.Inputs.CheckBox') is in the checked state.
<a name='T-DesktopMagicPluginAPI-Inputs-ComboBox'></a>
## ComboBox `type`
##### Namespace
DesktopMagicPluginAPI.Inputs
##### Summary
Represents a selection control with a drop-down list.
<a name='M-DesktopMagicPluginAPI-Inputs-ComboBox-#ctor-System-String[]-'></a>
### #ctor(items) `constructor`
##### Summary
Initializes a new instance of the [Label](#T-DesktopMagicPluginAPI-Inputs-Label 'DesktopMagicPluginAPI.Inputs.Label') class with the provided `items`.
##### Parameters
| Name | Type | Description |
| ---- | ---- | ----------- |
| items | [System.String[]](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String[] 'System.String[]') | |
<a name='P-DesktopMagicPluginAPI-Inputs-ComboBox-Items'></a>
### Items `property`
##### Summary
Gets the collection used to generate the content of the [ComboBox](#T-DesktopMagicPluginAPI-Inputs-ComboBox 'DesktopMagicPluginAPI.Inputs.ComboBox').
<a name='P-DesktopMagicPluginAPI-Inputs-ComboBox-Value'></a>
### Value `property`
##### Summary
Gets the currently selected item associated with this [ComboBox](#T-DesktopMagicPluginAPI-Inputs-ComboBox 'DesktopMagicPluginAPI.Inputs.ComboBox').
##### Remarks
If you assign a value to this property, the displayed text in the user interface will not be changed.
<a name='T-DesktopMagicPluginAPI-Inputs-Element'></a>
## Element `type`
@@ -145,6 +145,28 @@
</summary>
<param name="value">A value indicating whether the <see cref="T:DesktopMagicPluginAPI.Inputs.CheckBox"/> is in the checked state.</param>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.ComboBox">
<summary>
Represents a selection control with a drop-down list.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.ComboBox.Items">
<summary>
Gets the collection used to generate the content of the <see cref="T:DesktopMagicPluginAPI.Inputs.ComboBox"/>.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.ComboBox.Value">
<summary>
Gets the currently selected item associated with this <see cref="T:DesktopMagicPluginAPI.Inputs.ComboBox"/>.
</summary>
<remarks>If you assign a value to this property, the displayed text in the user interface will not be changed.</remarks>
</member>
<member name="M:DesktopMagicPluginAPI.Inputs.ComboBox.#ctor(System.String[])">
<summary>
Initializes a new instance of the <see cref="T:DesktopMagicPluginAPI.Inputs.Label"/> class with the provided <paramref name="items"/>.
</summary>
<param name="items"></param>
</member>
<member name="T:DesktopMagicPluginAPI.Inputs.Element">
<summary>
The element base class.
@@ -0,0 +1,46 @@
using System.Collections.ObjectModel;
namespace DesktopMagicPluginAPI.Inputs
{
/// <summary>
/// Represents a selection control with a drop-down list.
/// </summary>
public class ComboBox : Element
{
private string _value;
/// <summary>
/// Gets the collection used to generate the content of the <see cref="ComboBox"/>.
/// </summary>
public ObservableCollection<string> Items { get; } = new ObservableCollection<string>();
/// <summary>
/// Gets the currently selected item associated with this <see cref="ComboBox"/>.
/// </summary>
/// <remarks>If you assign a value to this property, the displayed text in the user interface will not be changed.</remarks>
public string Value
{
get => _value;
set
{
if (_value != value)
{
_value = value;
ValueChanged();
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="Label"/> class with the provided <paramref name="items"/>.
/// </summary>
/// <param name="items"></param>
public ComboBox(params string[] items)
{
foreach (string item in items)
{
Items.Add(item);
}
}
}
}
+1 -11
View File
@@ -19,17 +19,7 @@ namespace DesktopMagicPluginAPI
public IPluginData Application
{
get => application;
set
{
if (application is null)
{
application = value;
}
else
{
throw new InvalidOperationException($"You cannot set the value of the {nameof(Application)} property");
}
}
set => application = application is null ? value : throw new InvalidOperationException($"You cannot set the value of the {nameof(Application)} property");
}
/// <summary>