[PT Run > PluginAdditionalOptions] Refactoring and more settings types (#28601)

* refactor existing code

* fixes

* fix combo box layout

* improve layout

* add more settings types

* combined setting

* enabled state

* fix spelling

* improve settings.json handling on null values

* textbox improvements

* rework xaml code

* fix xaml style

* spell fixes

* spell fixes

* update comment
This commit is contained in:
Heiko
2023-09-20 19:31:40 +02:00
committed by GitHub
parent 5ddd8d72dd
commit 59f0ccebc7
5 changed files with 296 additions and 21 deletions

View File

@@ -3,17 +3,28 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Library
{
public class PluginAdditionalOption
{
public enum SelectionType
public enum AdditionalOptionType
{
Checkbox = 0,
Combobox = 1,
Textbox = 2,
Numberbox = 3,
CheckboxAndCombobox = 11,
CheckboxAndTextbox = 12,
CheckboxAndNumberbox = 13,
}
/// <summary>
/// Gets or sets the layout type of the option in settings ui (Optional; Default is checkbox)
/// </summary>
public AdditionalOptionType PluginOptionType { get; set; }
public string Key { get; set; }
public string DisplayLabel { get; set; }
@@ -21,14 +32,64 @@ namespace Microsoft.PowerToys.Settings.UI.Library
/// <summary>
/// Gets or sets a value to show a description of this setting in the settings ui. (Optional)
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string DisplayDescription { get; set; }
/// <summary>
/// Gets or sets a value to show a label for the second setting if two combined settings are shown
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string SecondDisplayLabel { get; set; }
/// <summary>
/// Gets or sets a value to show a description for the second setting in the settings ui if two combined settings are shown. (Optional)
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string SecondDisplayDescription { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the checkbox is set or not set
/// </summary>
public bool Value { get; set; }
public int ComboBoxValue { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string> ComboBoxOptions { get; set; }
public int Option { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string TextValue { get; set; }
public int SelectionTypeValue { get; set; }
/// <summary>
/// Gets or sets the value that specifies the maximum number of characters allowed for user input in the text box. (Optional; Default is 0 which means no limit.)
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? TextBoxMaxLength { get; set; }
public double NumberValue { get; set; }
/// <summary>
/// Gets or sets a minimal value for the number box. (Optional; Default is Double.MinValue)
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? NumberBoxMin { get; set; }
/// <summary>
/// Gets or sets a maximal value for the number box. (Optional; Default is Double.MaxValue)
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? NumberBoxMax { get; set; }
/// <summary>
/// Gets or sets the value for small changes of the number box. (Optional; Default is 1)
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? NumberBoxSmallChange { get; set; }
/// <summary>
/// Gets or sets the value for large changes of the number box. (Optional; Default is 10)
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? NumberBoxLargeChange { get; set; }
}
}