diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch')
4 files changed, 223 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/SliderContentControl.cs b/Software/Visual_Studio/Tango.Touch/Controls/SliderContentControl.cs new file mode 100644 index 000000000..a6b05f472 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/SliderContentControl.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.Touch.Controls +{ + [ContentProperty(nameof(Content))] + public class SliderContentControl : Slider + { + private bool m_isBlocked; + + #region DependencyProperties + + public UIElement Content + { + get { return (UIElement)GetValue(ContentProperty); } + set { SetValue(ContentProperty, value); } + } + public static readonly DependencyProperty ContentProperty = + DependencyProperty.Register("Content", typeof(UIElement), typeof(SliderContentControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender, (d, e) => (d as SliderContentControl).OnContentChanged())); + + public static readonly DependencyProperty ThumbHeightProperty = + DependencyProperty.Register("ThumbHeight", typeof(double), typeof(SliderContentControl), new FrameworkPropertyMetadata((double)32, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); + + public double ThumbHeight + { + get { return (double)GetValue(ThumbHeightProperty); } + set { SetValue(ThumbHeightProperty, value); } + } + + public Color ThumbColor + { + get { return (Color)GetValue(ThumbColorProperty); } + set { SetValue(ThumbColorProperty, value); } + } + + + + /// <summary> + /// The thumb color property + /// </summary> + public static readonly DependencyProperty ThumbColorProperty = + DependencyProperty.Register("ThumbColor", typeof(Color), typeof(SliderContentControl), new UIPropertyMetadata(Colors.LightGray, null)); + + + + #endregion + + static SliderContentControl() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(SliderContentControl), new FrameworkPropertyMetadata(typeof(SliderContentControl))); + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + TouchDown -= TouchDownSlider; + TouchDown += TouchDownSlider; + OnValueChanged(Double.NaN, Value); + IsMoveToPointEnabled = true; + } + + private void TouchDownSlider(object sender, TouchEventArgs e) + { + e.Handled = true; + } + + private double ValidateValue(double value) + { + if (value >= Minimum && value <= Maximum) + return value; + if ((value) > Maximum) + return Maximum; + if ((value) < Minimum) + return Minimum; + return double.NaN; + } + + private void OnContentChanged() + { + RemoveLogicalChild(Content); + AddLogicalChild(Content); + } + + protected override void OnValueChanged(double oldValue, double newValue) + { + if (m_isBlocked) return; + + m_isBlocked = true; + + var validatedValue = ValidateValue(newValue); + + if (!double.IsNaN(validatedValue)) + { + Value = validatedValue; + + } + + m_isBlocked = false; + + + } + + protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) + { + e.Handled = true; + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/SliderContentControl.xaml b/Software/Visual_Studio/Tango.Touch/Controls/SliderContentControl.xaml new file mode 100644 index 000000000..9e2b85c60 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/SliderContentControl.xaml @@ -0,0 +1,92 @@ +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="clr-namespace:Tango.Touch.Controls" + > + + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="../Resources/Colors.xaml" /> + </ResourceDictionary.MergedDictionaries> + + <Style x:Key="RepeatButtonTransparent" TargetType="{x:Type RepeatButton}"> + <Setter Property="OverridesDefaultStyle" Value="true"/> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="Focusable" Value="false"/> + <Setter Property="IsTabStop" Value="false"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type RepeatButton}"> + <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style x:Key="ThumbSlider" Style.TargetType="{x:Type Thumb}" > + <Setter Setter.Property="SnapsToDevicePixels" Setter.Value="True" /> + <Setter Setter.Property="OverridesDefaultStyle" Setter.Value="True" /> + <Setter Setter.Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type Thumb}"> + <Grid x:Name="grip" HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center"> + <Ellipse HorizontalAlignment="Center" VerticalAlignment="Center" + Height="{Binding ActualWidth, RelativeSource={RelativeSource Self}}" + Width="{Binding ThumbHeight, RelativeSource={RelativeSource AncestorType=local:SliderContentControl}}" > + <Ellipse.Fill> + <SolidColorBrush Color="{Binding ThumbColor, RelativeSource={RelativeSource AncestorType=local:SliderContentControl}}"/> + </Ellipse.Fill> + </Ellipse> + + <!--<Ellipse x:Name="knob" Grid.Column="0" Grid.Row="1" Stroke="{StaticResource TangoGrayBrush}" StrokeThickness="0" Fill="{StaticResource TangoPrimaryAccentBrush}" Opacity="0.5"></Ellipse>--> + <Grid.Effect> + <DropShadowEffect BlurRadius="10" RenderingBias="Quality" ShadowDepth="1" Color="{StaticResource TangoDropShadowColor}"/> + </Grid.Effect> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="{x:Type local:SliderContentControl}"> + <Setter Property="Background" Value="{StaticResource TangoNotificationBarMaskBrush}"/> + + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type local:SliderContentControl}"> + <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True" CornerRadius="6"> + <Grid> + <!--<ContentPresenter Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" />--> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="1*" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="1*" /> + </Grid.RowDefinitions> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="*"/> + </Grid.ColumnDefinitions> + <Border x:Name="PART_ColorPickerDisplay" Grid.Row="1" Background="Transparent" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" + MinHeight="14" Margin="5 0 0 0" VerticalAlignment="center" CornerRadius="6" > + <ContentPresenter Panel.ZIndex="1" Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" /> + </Border> + + <Track Track.Name="PART_Track" Grid.Row="0" Margin="0 -2 0 0" VerticalAlignment="Center" Grid.RowSpan="3"> + <!--<Track.DecreaseRepeatButton> + <RepeatButton Style="{StaticResource RepeatButtonTransparent}" /> + </Track.DecreaseRepeatButton> + <Track.IncreaseRepeatButton> + <RepeatButton Style="{StaticResource RepeatButtonTransparent}" /> + </Track.IncreaseRepeatButton>--> + <Track.Thumb> + <Thumb Thumb.Name="PART_Thumb" UIElement.Focusable="False" Height="Auto" Style="{StaticResource ThumbSlider}" VerticalAlignment="Top" Width="Auto" VerticalContentAlignment="Top"/> + </Track.Thumb> + </Track> + </Grid> + </Grid> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + +</ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index 1096ec112..a0a42f3b6 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -67,6 +67,7 @@ <Compile Include="Controls\FocusSelectionMode.cs" /> <Compile Include="Controls\IValueControl.cs" /> <Compile Include="Controls\MessageBoxVM.cs" /> + <Compile Include="Controls\SliderContentControl.cs" /> <Compile Include="Controls\TouchArcProgress.cs" /> <Compile Include="Controls\TouchAutoComplete.cs" /> <Compile Include="Controls\TouchCalendar.cs" /> @@ -133,6 +134,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Controls\SliderContentControl.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Controls\TouchArcProgress.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -502,7 +507,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml index 8b49ccc6b..14231fb3a 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -67,6 +67,8 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchPanel.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchPanelEureka.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/SliderContentControl.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/TouchColorPickerControls/TouchColorPickerSlider.xaml"/> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/TouchColorPickerControls/TouchColorPickerControl.xaml"/> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/TouchColorPickerControls/TouchColorPickerHSBControl.xaml"/> @@ -75,6 +77,7 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/TouchColorPickerControls/TouchColorPickerCMYKControl.xaml"/> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/TouchColorPickerControls/MultiRangeSlider.xaml"/> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/TouchColorPickerControls/TouchSliderThreeThumbs.xaml"/> + </ResourceDictionary.MergedDictionaries> </ResourceDictionary> |
