// 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. using CommunityToolkit.Tooling.SampleGen.Attributes; namespace CommunityToolkit.Tooling.SampleGen.Metadata; /// /// An INPC-enabled metadata container for data defined in an . /// public class ToolkitSampleNumericOptionMetadataViewModel : IGeneratedToolkitSampleOptionViewModel { private string? _title; private object _value; /// /// Creates a new instance of . /// public ToolkitSampleNumericOptionMetadataViewModel(string name, double initial = 0, double min = 0, double max = 10, double step = 1, bool showAsNumberBox = false, string? title = null) { Name = name; _title = title; _value = initial; Max = max; Min = min; Step = step; ShowAsNumberBox = showAsNumberBox; } /// public event PropertyChangedEventHandler? PropertyChanged; /// /// A unique identifier for this option. /// /// /// Used by the sample system to match up to the original and the control that declared it. /// public string Name { get; } /// /// The available options presented to the user. /// /// /// The initial double value. /// public double Initial { get => (double)_value; set { _value = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(Name)); } } /// public object? Value { get => Initial; set { Initial = (double)(value ?? 0.0); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(Name)); } } /// /// The Minimum value of the slider. /// public double Min { get; } /// /// The Maximum value of the slider. /// public double Max { get; } /// /// The StepFrequency value of the slider. /// public double Step { get; } /// /// Determines if a Slider or NumberBox is shown. /// public bool ShowAsNumberBox { get; } /// /// A label to display along the slider. /// public string? Title { get => _title; set { _title = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Title))); } } }