aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml
blob: bfe65cbd1ffe90342ec706c7a568c2e2c46ca06c (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:keyboard="clr-namespace:Tango.Touch.Keyboard"
                    xmlns:components="clr-namespace:Tango.Touch.Components"
                    xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
                    xmlns:localConverters="clr-namespace:Tango.Touch.Converters"
                    xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI"
                    xmlns:local="clr-namespace:Tango.Touch.Controls">

    <ResourceDictionary.MergedDictionaries>
        <!--<ResourceDictionary Source="../Resources/Colors.xaml" />-->
        <components:SharedResourceDictionary Source="../Resources/Colors.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <converters:StringNullOrEmptyToBooleanConverter x:Key="StringNullOrEmptyToBooleanConverter" />
    <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter" />
    <converters:MathOperatorConverter x:Key="MathOperatorConverter" />
    <localConverters:NumericTextBoxIntegerConverter x:Key="NumericTextBoxIntegerConverter" />
    <localConverters:NumericTextBoxDoubleConverter x:Key="NumericTextBoxDoubleConverter" />

    <Style TargetType="{x:Type local:TouchNumericTextBox}">
        <Setter Property="Foreground" Value="{StaticResource TangoDarkForegroundBrush}"></Setter>
        <Setter Property="Focusable" Value="False"></Setter>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
        <Setter Property="KeyboardMode" Value="Integer"></Setter>
        <Setter Property="FocusSelectionMode" Value="SelectAll"></Setter>
        <Setter Property="local:LightTouchScrollViewer.PreventScroll" Value="True"></Setter>
        <Setter Property="keyboard:KeyboardView.Mode" Value="{Binding RelativeSource={RelativeSource Self},Path=KeyboardMode}"></Setter>
        <Setter Property="keyboard:KeyboardView.Action" Value="{Binding RelativeSource={RelativeSource Self},Path=KeyboardAction}"></Setter>
        <Setter Property="keyboard:KeyboardView.Container" Value="{Binding RelativeSource={RelativeSource Self},Path=KeyboardContainer}"></Setter>
        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"></Setter>
        <Setter Property="VerticalContentAlignment" Value="Bottom"></Setter>
        <Setter Property="MinHeight" Value="40"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:TouchNumericTextBox}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}" keyboard:KeyboardView.Container="{TemplateBinding KeyboardContainer}">
                        <DockPanel>
                            <Canvas DockPanel.Dock="Bottom" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNumericTextBox},Path=(Validation.HasError),Converter={StaticResource BooleanToVisibilityConverter}}">
                                <controls:FastTextBlock FontSize="12" Foreground="{StaticResource TangoValidationErrorBrush}" Margin="0 5 0 0" Text="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNumericTextBox},Path=(Validation.Errors).CurrentItem.ErrorContent}"></controls:FastTextBlock>
                            </Canvas>
                            <DockPanel>
                                <Grid DockPanel.Dock="Bottom" Height="2">
                                    <Rectangle Height="1" Fill="{StaticResource TangoTextWatermarkBrush}" />
                                    <Rectangle Height="2" RenderTransformOrigin="0.5,0.5" >
                                        <Rectangle.Style>
                                            <Style TargetType="Rectangle">
                                                <Setter Property="Fill" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter>
                                                <Setter Property="RenderTransform">
                                                    <Setter.Value>
                                                        <ScaleTransform ScaleY="1" ScaleX="0" />
                                                    </Setter.Value>
                                                </Setter>
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding ElementName=PART_TextBox,Path=IsFocused}" Value="True">
                                                        <DataTrigger.EnterActions>
                                                            <BeginStoryboard>
                                                                <Storyboard>
                                                                    <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1" Duration="00:00:0.4" />
                                                                </Storyboard>
                                                            </BeginStoryboard>
                                                        </DataTrigger.EnterActions>
                                                        <DataTrigger.ExitActions>
                                                            <BeginStoryboard>
                                                                <Storyboard>
                                                                    <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="0" Duration="00:00:0.4" />
                                                                </Storyboard>
                                                            </BeginStoryboard>
                                                        </DataTrigger.ExitActions>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNumericTextBox},Path=(Validation.HasError)}" Value="True">
                                                        <Setter Property="Fill" Value="{StaticResource TangoValidationErrorBrush}"></Setter>
                                                        <Setter Property="RenderTransform">
                                                            <Setter.Value>
                                                                <ScaleTransform ScaleY="1" ScaleX="1" />
                                                            </Setter.Value>
                                                        </Setter>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Rectangle.Style>
                                    </Rectangle>
                                </Grid>

                                <Grid>
                                    <!--<components:Ripple RippleBrush="{StaticResource TangoRippleDarkBrush}" RippleFactor="15">
                                        <Grid>-->
                                            <TextBox VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Foreground="{TemplateBinding Foreground}" Padding="0 0 0 4" CaretBrush="{StaticResource TangoPrimaryAccentBrush}" FocusVisualStyle="{x:Null}" x:Name="PART_TextBox" BorderThickness="0" Background="Transparent">
                                                <TextBox.Style>
                                                    <Style TargetType="TextBox">
                                                        <Setter Property="Opacity" Value="0"></Setter>
                                                        <Style.Triggers>
                                                            <Trigger Property="IsFocused" Value="True">
                                                                <Setter Property="Opacity" Value="1"></Setter>
                                                            </Trigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </TextBox.Style>
                                            </TextBox>
                                            <controls:FastTextBlock x:Name="PART_TextDisplay" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" IsHitTestVisible="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Foreground="{TemplateBinding Foreground}" Padding="0 0 0 4" FocusVisualStyle="{x:Null}" Visibility="{Binding ElementName=PART_TextBox,Path=IsFocused,Converter={StaticResource BooleanToVisibilityInverseConverter}}"></controls:FastTextBlock>
                                        <!--</Grid>
                                    </components:Ripple>-->


                                </Grid>
                            </DockPanel>
                        </DockPanel>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource TangoGrayTextBrush}"></Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="HasDecimalPoint" Value="True">
                <Setter Property="KeyboardMode" Value="Float"></Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>