-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathToolkitSampleNumericOptionAttribute.cs
More file actions
66 lines (58 loc) · 2.18 KB
/
ToolkitSampleNumericOptionAttribute.cs
File metadata and controls
66 lines (58 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace CommunityToolkit.Tooling.SampleGen.Attributes;
/// <summary>
/// Represents a boolean sample option.
/// </summary>
/// <remarks>
/// Using this attribute will automatically generate an <see cref="INotifyPropertyChanged"/>-enabled property
/// that you can bind to in XAML, and displays an options pane alongside your sample which allows the user to manipulate the property.
/// <para/>
/// </remarks>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class ToolkitSampleNumericOptionAttribute : ToolkitSampleOptionBaseAttribute
{
/// <summary>
/// Creates a new instance of <see cref="ToolkitSampleNumericOptionAttribute"/>.
/// </summary>
/// <param name="bindingName">The name of the generated property, which you can bind to in XAML.</param>
/// <param name="initial"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <param name="step"></param>
/// <param name="showAsNumberBox"></param>
public ToolkitSampleNumericOptionAttribute(string bindingName, double initial = 0, double min = 0, double max = 10, double step = 1, bool showAsNumberBox = false)
: base(bindingName, null)
{
Initial = initial;
Min = min;
Max = max;
Step = step;
ShowAsNumberBox = showAsNumberBox;
}
/// <summary>
/// The default start value.
/// </summary>
public double Initial { get; }
/// <summary>
/// The minimal value.
/// </summary>
public double Min { get; }
/// <summary>
/// The maximum value.
/// </summary>
public double Max { get; }
/// <summary>
/// The step value.
/// </summary>
public double Step { get; }
/// <summary>
/// Determines if a Slider or NumberBox is shown.
/// </summary>
public bool ShowAsNumberBox { get; }
/// <summary>
/// The source generator-friendly type name used for casting.
/// </summary>
internal override string TypeName { get; } = "double";
}