diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch')
3 files changed, 172 insertions, 6 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs index 15c516124..47b3670a7 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs @@ -112,6 +112,17 @@ namespace Tango.Touch.Controls } public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register("Maximum", typeof(double), typeof(TouchNumericTextBox), new PropertyMetadata(null)); + + public double Step + { + get { return (double)GetValue(StepProperty); } + set { SetValue(StepProperty, value); } + } + + public static readonly DependencyProperty StepProperty = + DependencyProperty.Register("Step", typeof(double), typeof(TouchNumericTextBox), new PropertyMetadata(null)); + + public double JoggingFactor { @@ -198,6 +209,14 @@ namespace Tango.Touch.Controls { value = Math.Round(value, 0); } + if (Step > 0) + { + value = Math.Round(value / Step, MidpointRounding.AwayFromZero) * Step; + } + if(Minimum > 0 && value < Minimum) + { + value = Minimum; + } if (Maximum > Minimum) { @@ -209,6 +228,7 @@ namespace Tango.Touch.Controls { value = Maximum; } + } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.cs index 79afdfaab..b1e7080fc 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.cs @@ -105,6 +105,48 @@ namespace Tango.Touch.Controls } public static readonly DependencyProperty CheckedThumbContentTemplateProperty = DependencyProperty.Register("CheckedThumbContentTemplate", typeof(DataTemplate), typeof(TouchToggleSlider), new PropertyMetadata(null)); + + public String LeftText + { + get { return (String)GetValue(LeftTextProperty); } + set { SetValue(LeftTextProperty, value); } + } + + public static readonly DependencyProperty LeftTextProperty = + DependencyProperty.Register("LeftText", typeof(String), typeof(TouchToggleSlider), new PropertyMetadata("")); + + public CornerRadius ThumbCornerRadius + { + get { return (CornerRadius)GetValue(ThumbCornerRadiusProperty); } + set { SetValue(ThumbCornerRadiusProperty, value); } + } + public static readonly DependencyProperty ThumbCornerRadiusProperty = + DependencyProperty.Register("ThumbCornerRadius", typeof(CornerRadius), typeof(TouchToggleSlider), new PropertyMetadata(default(CornerRadius))); + + public String RightText + { + get { return (String)GetValue(RightTextProperty); } + set { SetValue(RightTextProperty, value); } + } + + // Using a DependencyProperty as the backing store for RightText. This enables animation, styling, binding, etc... + public static readonly DependencyProperty RightTextProperty = + DependencyProperty.Register("RightText", typeof(String), typeof(TouchToggleSlider), new PropertyMetadata("")); + + + + public int ThumbWidth + { + get { return (int)GetValue(ThumbWidthProperty); } + set { SetValue(ThumbWidthProperty, value); } + } + + // Using a DependencyProperty as the backing store for ThumbWidth. This enables animation, styling, binding, etc... + public static readonly DependencyProperty ThumbWidthProperty = + DependencyProperty.Register("ThumbWidth", typeof(int), typeof(TouchToggleSlider), new PropertyMetadata(0)); + + + public TouchToggleSlider() { @@ -120,6 +162,7 @@ namespace Tango.Touch.Controls { base.OnApplyTemplate(); _grid_ellipse = GetTemplateChild("PART_GridEllipse") as Grid; + SetThumbPosition(); } protected override void OnChecked(RoutedEventArgs e) @@ -143,7 +186,15 @@ namespace Tango.Touch.Controls if (IsChecked.Value) { - ani.To = new Thickness(ActualWidth - _grid_ellipse.ActualWidth - 4, 0, 0, 0); + if (ActualWidth != 0 && _grid_ellipse.ActualWidth == 0) + { + ani.To = new Thickness(ActualWidth - (ActualWidth/2) - 4, 0, 0, 0); + } + else + { + ani.To = new Thickness(ActualWidth - _grid_ellipse.ActualWidth - 4, 0, 0, 0); + } + } else { diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.xaml index 7d26fdcff..adb76ebd3 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.xaml @@ -62,7 +62,7 @@ </Grid> </Grid> - <Grid HorizontalAlignment="Left" x:Name="PART_GridEllipse"> + <Grid HorizontalAlignment="Left" x:Name="PART_GridEllipse" Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}"> <Grid Margin="4" x:Name="ellipse" Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}"> <Ellipse Fill="{TemplateBinding ThumbBrush}"></Ellipse> @@ -133,16 +133,111 @@ </Style> <Style x:Key="TangoToggleButtonGreenAccent" TargetType="{x:Type local:TouchToggleSlider}" BasedOn="{StaticResource {x:Type local:TouchToggleSlider}}"> - <Setter Property="BorderBrush" Value="{StaticResource TangoGrayTextBrush}"></Setter> - <Setter Property="ThumbBrush" Value="{StaticResource TangoPrimaryBackgroundBrush}"></Setter> <Setter Property="CheckedBackground" Value="{StaticResource TangoGreenBrush}"/> <Setter Property="UncheckedBackground" Value="{StaticResource TangoDividerBrush}"/> + <Setter Property="CornerRadius" Value="20"></Setter> + <Setter Property="BorderThickness" Value="2"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource TangoRippleLightBrush}"></Setter> + <Setter Property="ThumbBrush" Value="{StaticResource TangoPrimaryBackgroundBrush}"></Setter> + <Style.Triggers> + <Trigger Property="IsChecked" Value="True"> + <Trigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" To="{StaticResource RippleLightColor}" Duration="00:00:0.2"></ColorAnimation> + <ColorAnimation Storyboard.TargetProperty="ThumbBrush.Color" To="{StaticResource TangoPrimaryBackgroundColor}" Duration="00:00:0.2"></ColorAnimation> + </Storyboard> + </BeginStoryboard> + </Trigger.EnterActions> + <Trigger.ExitActions> + <BeginStoryboard> + <Storyboard> + <ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" To="{StaticResource RippleLightColor}" Duration="00:00:0.2"></ColorAnimation> + <ColorAnimation Storyboard.TargetProperty="ThumbBrush.Color" To="{StaticResource TangoPrimaryBackgroundColor}" Duration="00:00:0.2"></ColorAnimation> + </Storyboard> + </BeginStoryboard> + </Trigger.ExitActions> + </Trigger> + </Style.Triggers> + </Style> + + <Style x:Key="TouchToggleButtonSlider" TargetType="{x:Type local:TouchToggleSlider}" BasedOn="{StaticResource {x:Type local:TouchToggleSlider}}"> + <Setter Property="BorderThickness" Value="1"></Setter> + <Setter Property="UncheckedBackground" Value="Transparent"></Setter> + <Setter Property="CheckedBackground" Value="Transparent"></Setter> + <Setter Property="ThumbBrush" Value="{StaticResource TangoPrimaryBackgroundBrush}"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource TangoDividerBrush}"/> + <Setter Property="Foreground" Value="White"/> + <Setter Property="CornerRadius" Value="20"></Setter> + <Setter Property="ThumbCornerRadius" Value="18"/> + <Setter Property="LeftText" Value="Left"/> + <Setter Property="RightText" Value="Right"/> + <Setter Property="ThumbWidth" Value="40"/> + + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type local:TouchToggleSlider}"> + <Border> + <components:Ripple CornerRadius="{TemplateBinding CornerRadius}" Centered="True" RippleBrush="{StaticResource TangoRippleDarkBrush}"> + <Border + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}"> + <Border.Effect> + <DropShadowEffect ShadowDepth="0" BlurRadius="10" Opacity="0.5"/> + </Border.Effect> + + <Border.Style> + <Style TargetType="Border"> + <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource AncestorType=local:TouchToggleSlider},Path=UncheckedBackground}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchToggleSlider},Path=IsChecked}" Value="True"> + <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource AncestorType=local:TouchToggleSlider},Path=CheckedBackground}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + <Grid> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*" /> + <ColumnDefinition Width="1*" /> + </Grid.ColumnDefinitions> + + <Grid Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchToggleSlider},Path=IsChecked,Converter={StaticResource BooleanToVisibilityInverseConverter}}"> + <TextBlock Text="{TemplateBinding RightText}" Foreground="{StaticResource TangoDisabledForegroundBrush}"></TextBlock> + </Grid> + + <Grid Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchToggleSlider},Path=IsChecked,Converter={StaticResource BooleanToVisibilityConverter}}"> + <TextBlock Text="{TemplateBinding LeftText}" Foreground="{StaticResource TangoDisabledForegroundBrush}"></TextBlock> + </Grid> + </Grid> + + <Grid HorizontalAlignment="Left" x:Name="PART_GridEllipse"> + <Grid Margin="4" x:Name="ellipse" Width="{Binding RelativeSource={ RelativeSource AncestorType=local:TouchToggleSlider},Path=ThumbWidth}"> + <Border Background="{StaticResource TangoMidAccentBrush}" CornerRadius="{TemplateBinding ThumbCornerRadius}" Width="{Binding RelativeSource={ RelativeSource AncestorType=local:TouchToggleSlider},Path=ThumbWidth}"></Border> + + <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchToggleSlider},Path=IsChecked,Converter={StaticResource BooleanToVisibilityInverseConverter}}"> + <TextBlock Text="{TemplateBinding LeftText}"></TextBlock> + </Grid> + + <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchToggleSlider},Path=IsChecked,Converter={StaticResource BooleanToVisibilityConverter}}"> + <TextBlock Text="{TemplateBinding RightText}"></TextBlock> + </Grid> + </Grid> + </Grid> + </Grid> + </Border> + </components:Ripple> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> <Style.Triggers> <Trigger Property="IsChecked" Value="True"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> - <ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" To="{StaticResource TangoGrayTextColor}" Duration="00:00:0.2"></ColorAnimation> + <ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" To="{StaticResource TangoDividerColor}" Duration="00:00:0.2"></ColorAnimation> <ColorAnimation Storyboard.TargetProperty="ThumbBrush.Color" To="{StaticResource TangoPrimaryBackgroundColor}" Duration="00:00:0.2"></ColorAnimation> </Storyboard> </BeginStoryboard> @@ -150,7 +245,7 @@ <Trigger.ExitActions> <BeginStoryboard> <Storyboard> - <ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" To="{StaticResource TangoGrayTextColor}" Duration="00:00:0.2"></ColorAnimation> + <ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" To="{StaticResource TangoDividerColor}" Duration="00:00:0.2"></ColorAnimation> <ColorAnimation Storyboard.TargetProperty="ThumbBrush.Color" To="{StaticResource TangoPrimaryBackgroundColor}" Duration="00:00:0.2"></ColorAnimation> </Storyboard> </BeginStoryboard> |
