2021-02-26 13:21:58 +02:00
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
2023-09-11 13:54:06 +03:00
using System.Collections.Generic ;
2023-09-20 19:31:40 +02:00
using System.Text.Json.Serialization ;
2023-09-11 13:54:06 +03:00
2021-02-26 13:21:58 +02:00
namespace Microsoft.PowerToys.Settings.UI.Library
{
public class PluginAdditionalOption
{
2023-09-20 19:31:40 +02:00
public enum AdditionalOptionType
2023-09-11 13:54:06 +03:00
{
Checkbox = 0 ,
Combobox = 1 ,
2023-09-20 19:31:40 +02:00
Textbox = 2 ,
Numberbox = 3 ,
2024-03-14 06:19:02 +08:00
MultilineTextbox = 4 ,
2023-09-20 19:31:40 +02:00
CheckboxAndCombobox = 11 ,
CheckboxAndTextbox = 12 ,
CheckboxAndNumberbox = 13 ,
2023-09-11 13:54:06 +03:00
}
2023-09-20 19:31:40 +02:00
/// <summary>
/// Gets or sets the layout type of the option in settings ui (Optional; Default is checkbox)
/// </summary>
public AdditionalOptionType PluginOptionType { get ; set ; }
2021-02-26 13:21:58 +02:00
public string Key { get ; set ; }
public string DisplayLabel { get ; set ; }
2022-03-21 13:47:09 +01:00
/// <summary>
/// Gets or sets a value to show a description of this setting in the settings ui. (Optional)
/// </summary>
2023-09-20 19:31:40 +02:00
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2022-03-21 13:47:09 +01:00
public string DisplayDescription { get ; set ; }
2023-09-20 19:31:40 +02:00
/// <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>
2021-02-26 13:21:58 +02:00
public bool Value { get ; set ; }
2023-09-11 13:54:06 +03:00
2023-09-20 19:31:40 +02:00
public int ComboBoxValue { get ; set ; }
2023-10-11 14:54:49 +02:00
/// <summary>
/// Gets or sets the list of dropdown items for the ComboBox. Please use the item name as Key and an integer as Value.
/// The value gets converted in settings UI to an integer and will be saved in <see cref="ComboBoxValue"/>.
/// You can define the visibility order in settings ui by arranging the list items.
/// </summary>
2023-09-20 19:31:40 +02:00
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2023-10-11 14:54:49 +02:00
public List < KeyValuePair < string , string > > ComboBoxItems { get ; set ; }
2023-09-11 13:54:06 +03:00
2023-09-20 19:31:40 +02:00
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string TextValue { get ; set ; }
2023-09-11 13:54:06 +03:00
2023-09-20 19:31:40 +02:00
/// <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 ; }
2024-03-14 06:19:02 +08:00
/// <summary>
/// Gets or sets a value for the placeholder of a textbox.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string PlaceholderText { get ; set ; }
2023-09-20 19:31:40 +02:00
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 ; }
2023-10-11 14:54:49 +02:00
// Outdated properties kept for backward compatibility with third-party plugins. (They are only required to not have old third-party plugins crashing when propagating their plugin options.)
#pragma warning disable SA1623 // Property summary documentation should match accessors
/// <summary>
/// PLEASE DON'T USE ANYMORE!! (The property was used for the list of combobox items in the past and is not functional anymore.)
/// </summary>
[JsonIgnore]
public List < string > ComboBoxOptions { get ; set ; }
#pragma warning restore SA1623 // Property summary documentation should match accessors
2021-02-26 13:21:58 +02:00
}
}