1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00
Artemis/src/Artemis.UI/DataModelVisualization/Input/DoubleDataModelInputViewModel.cs
Robert 4d616beffb Display conditions - Implemented expression tree creation
Display conditions - Use the most appropriate number input
UI general - Use current localisation for decimal seperators and enfore in inputs
2020-07-08 19:29:33 +02:00

22 lines
862 B
C#

using System.Globalization;
using System.Text.RegularExpressions;
using System.Windows.Input;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using Artemis.UI.Shared.DataModelVisualization;
namespace Artemis.UI.DataModelVisualization.Input
{
public class DoubleDataModelInputViewModel : DataModelInputViewModel<double>
{
public DoubleDataModelInputViewModel(DataModelPropertyAttribute description, double initialValue) : base(description, initialValue)
{
}
public void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
var seperator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
var regex = new Regex("^["+ seperator + "][0-9]+$|^[0-9]*["+ seperator + "]{0,1}[0-9]*$");
e.Handled = !regex.IsMatch(e.Text);
}
}
}