Display conditions - Loosened up type rules for dynamic comparisons

Display conditions - Improved static value input and added support for int and double
This commit is contained in:
Robert committed 2020-07-07 17:29:20 +02:00
1 parent 68b9a4b933
commit f617a6461a
21 files changed
+197 -172

No files matched your search

@@ -0,0 +1,18 @@
<UserControl x:Class="Artemis.UI.DataModelVisualization.Input.DoubleDataModelInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.DataModelVisualization.Input"
xmlns:System="clr-namespace:System;assembly=System.Runtime"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:behaviors="clr-namespace:Artemis.UI.Shared.Behaviors;assembly=Artemis.UI.Shared"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<TextBox VerticalAlignment="Center" Text="{Binding InputValue}" PreviewTextInput="{s:Action NumberValidationTextBox}">
<b:Interaction.Behaviors>
<behaviors:PutCursorAtEndTextBoxBehavior/>
</b:Interaction.Behaviors>
</TextBox>
</UserControl>
@@ -0,0 +1,20 @@
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 regex = new Regex("^[.|,][0-9]+$|^[0-9]*[.|,]{0,1}[0-9]*$");
e.Handled = !regex.IsMatch(e.Text);
}
}
}
@@ -0,0 +1,18 @@
<UserControl x:Class="Artemis.UI.DataModelVisualization.Input.IntDataModelInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.DataModelVisualization.Input"
xmlns:System="clr-namespace:System;assembly=System.Runtime"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:behaviors="clr-namespace:Artemis.UI.Shared.Behaviors;assembly=Artemis.UI.Shared"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<TextBox VerticalAlignment="Center" Text="{Binding InputValue}" PreviewTextInput="{s:Action NumberValidationTextBox}">
<b:Interaction.Behaviors>
<behaviors:PutCursorAtEndTextBoxBehavior/>
</b:Interaction.Behaviors>
</TextBox>
</UserControl>
@@ -0,0 +1,20 @@
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 IntDataModelInputViewModel : DataModelInputViewModel<int>
{
public IntDataModelInputViewModel(DataModelPropertyAttribute description, int initialValue) : base(description, initialValue)
{
}
public void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
var regex = new Regex("[^0-9]+");
e.Handled = regex.IsMatch(e.Text);
}
}
}
@@ -9,7 +9,7 @@
xmlns:behaviors="clr-namespace:Artemis.UI.Shared.Behaviors;assembly=Artemis.UI.Shared"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<TextBox VerticalAlignment="Center" Text="{Binding InputValue, UpdateSourceTrigger=PropertyChanged}">
<TextBox VerticalAlignment="Center" Text="{Binding InputValue}">
<b:Interaction.Behaviors>
<behaviors:PutCursorAtEndTextBoxBehavior/>
</b:Interaction.Behaviors>