diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-02 14:36:16 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-02 14:36:16 +0300 |
| commit | 58f612e03a9bb31c2ada4eb3c5989be458ec4ff5 (patch) | |
| tree | f0e27284fe4db0abf46212290486ce25db3ea0ec /Software/Visual_Studio/PPC | |
| parent | 57d2810dae9d6d40c52ec33508a324582ac3113b (diff) | |
| download | Tango-58f612e03a9bb31c2ada4eb3c5989be458ec4ff5.tar.gz Tango-58f612e03a9bb31c2ada4eb3c5989be458ec4ff5.zip | |
Implemented Twine Catalog Control.
Implemented TouchStaticListBox.
Added Scrollbar visibility, GetMostVisibleElement, Scrolling event - to LightTouchScrollviewer.
Diffstat (limited to 'Software/Visual_Studio/PPC')
6 files changed, 146 insertions, 59 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml deleted file mode 100644 index 51917b594..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml +++ /dev/null @@ -1,12 +0,0 @@ -<UserControl x:Class="Tango.PPC.Jobs.Controls.TwineCatalogControl" - 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:Tango.PPC.Jobs.Controls" - mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> - <Grid> - - </Grid> -</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml.cs deleted file mode 100644 index b1a109a75..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -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.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.PPC.Jobs.Controls -{ - /// <summary> - /// Interaction logic for TwineCatalogControl.xaml - /// </summary> - public partial class TwineCatalogControl : UserControl - { - public TwineCatalogControl() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index 7e8dc94b3..f77a47d37 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -72,10 +72,6 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="Controls\TwineCatalogControl.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> <Page Include="Dialogs\AdvancedColorCorrectionView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -112,9 +108,6 @@ <Compile Include="Controls\JobSummeryViewer.xaml.cs"> <DependentUpon>JobSummeryViewer.xaml</DependentUpon> </Compile> - <Compile Include="Controls\TwineCatalogControl.xaml.cs"> - <DependentUpon>TwineCatalogControl.xaml</DependentUpon> - </Compile> <Compile Include="Converters\JobCollectionToCategoryCountConverter.cs" /> <Compile Include="Converters\JobToPieImageConverter.cs" /> <Compile Include="Dialogs\AdvancedColorCorrectionView.xaml.cs"> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml index 142e1a10c..cc28bfddb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml @@ -15,27 +15,64 @@ <ColumnDefinition Width="1*"/> <ColumnDefinition Width="100"/> </Grid.ColumnDefinitions> - - <touch:TouchListBox ItemsSource="{Binding Groups}" x:Name="list"> + + <touch:TouchListBox ItemsSource="{Binding Groups}" x:Name="list" DisableRipple="True" ScrollBarVisibility="Collapsed" SelectionMode="None"> <touch:TouchListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock HorizontalAlignment="Center" Text="{Binding Name}"></TextBlock> - <ItemsControl ItemsSource="{Binding Items}" Margin="0 20 0 40"> - <ItemsControl.ItemsPanel> + <touch:TouchStaticListBox ItemsSource="{Binding Items}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=SelectedItem}" Margin="0 20 0 40"> + <touch:TouchStaticListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Horizontal" /> </ItemsPanelTemplate> - </ItemsControl.ItemsPanel> - <ItemsControl.ItemTemplate> + </touch:TouchStaticListBox.ItemsPanel> + <touch:TouchStaticListBox.ItemContainerStyle> + <Style TargetType="{x:Type touch:TouchListBoxItem}"> + <Setter Property="RenderTransformOrigin" Value="0.5,0.5"></Setter> + <Setter Property="RenderTransform"> + <Setter.Value> + <ScaleTransform ScaleX="1" ScaleY="1" /> + </Setter.Value> + </Setter> + <Setter Property="Effect"> + <Setter.Value> + <DropShadowEffect Color="{StaticResource TangoDarkForegroundColor}" ShadowDepth="0" BlurRadius="20" Opacity="0" /> + </Setter.Value> + </Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=IsSelected}" Value="True"> + <DataTrigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1.5" Duration="00:00:0.2" /> + <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" To="1.5" Duration="00:00:0.2" /> + <DoubleAnimation Storyboard.TargetProperty="Effect.Opacity" To="1" Duration="00:00:0.2" /> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + <DataTrigger.ExitActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1" Duration="00:00:0.2" /> + <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" To="1" Duration="00:00:0.2" /> + <DoubleAnimation Storyboard.TargetProperty="Effect.Opacity" To="0" Duration="00:00:0.2" /> + </Storyboard> + </BeginStoryboard> + </DataTrigger.ExitActions> + </DataTrigger> + </Style.Triggers> + </Style> + </touch:TouchStaticListBox.ItemContainerStyle> + <touch:TouchStaticListBox.ItemTemplate> <DataTemplate> <StackPanel Margin="10"> <Ellipse Width="60" Height="60" Fill="{Binding Brush}" /> <TextBlock Margin="0 5 0 0" HorizontalAlignment="Center" Text="{Binding Name}"></TextBlock> </StackPanel> </DataTemplate> - </ItemsControl.ItemTemplate> - </ItemsControl> + </touch:TouchStaticListBox.ItemTemplate> + </touch:TouchStaticListBox> </StackPanel> </DataTemplate> </touch:TouchListBox.ItemTemplate> @@ -79,10 +116,10 @@ </Border> <Grid Grid.Column="1"> - <touch:TouchSlider ValueChanged="TouchSlider_ValueChanged" IsSnapToTickEnabled="True" Minimum="0" Maximum="{Binding Groups.Count,Converter={StaticResource MathOperatorConverter},ConverterParameter='-1'}" Orientation="Vertical" Width="40" Height="Auto" IsSelectionRangeEnabled="False"> + <touch:TouchSlider x:Name="slider" ValueChanged="TouchSlider_ValueChanged" IsSnapToTickEnabled="True" Minimum="0" Maximum="{Binding Groups.Count,Converter={StaticResource MathOperatorConverter},ConverterParameter='-1'}" Orientation="Vertical" Width="40" Height="Auto" IsSelectionRangeEnabled="False"> <touch:TouchSlider.ThumbTemplate> <ControlTemplate> - <touch:TouchIcon Width="40" Height="40" Icon="Water" Angle="-90" /> + <touch:TouchIcon Foreground="{Binding RelativeSource={RelativeSource AncestorType=touch:TouchSlider},Path=Foreground}" Width="40" Height="40" Icon="Water" Angle="-90" /> </ControlTemplate> </touch:TouchSlider.ThumbTemplate> </touch:TouchSlider> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs index ad1c8b50c..2b376e855 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs @@ -22,24 +22,80 @@ namespace Tango.PPC.Common.Controls public partial class TwineCatalogControl : UserControl { private Catalog _catalog; + private bool _loaded; + private bool _preventChange; + + public CatalogItem SelectedItem + { + get { return (CatalogItem)GetValue(SelectedItemProperty); } + set { SetValue(SelectedItemProperty, value); } + } + public static readonly DependencyProperty SelectedItemProperty = + DependencyProperty.Register("SelectedItem", typeof(CatalogItem), typeof(TwineCatalogControl), new PropertyMetadata(null,(d,e) => (d as TwineCatalogControl).OnSelectedItemChanged())); public TwineCatalogControl() { InitializeComponent(); + Loaded += TwineCatalogControl_Loaded; DataContextChanged += (x, y) => { _catalog = DataContext as Catalog; }; } + private void ScrollViewer_Scrolling(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + { + if (!_preventChange) + { + var group = list.ScrollViewer.GetMostVisibleElementDataContext<CatalogGroup>(); + + if (group != null) + { + _preventChange = true; + slider.Value = slider.Maximum - _catalog.Groups.IndexOf(group); + _preventChange = false; + } + } + } + private void TwineCatalogControl_Loaded(object sender, RoutedEventArgs e) { - + if (!_loaded) + { + list.ScrollViewer.Scrolling += ScrollViewer_Scrolling; + + _preventChange = true; + slider.Value = slider.Maximum; + _preventChange = false; + _loaded = true; + } } private void TouchSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { + if (!_preventChange) + { + if (_catalog != null) + { + _preventChange = true; + list.ScrollToItem(_catalog.Groups.ElementAt(_catalog.Groups.Count - 1 - (int)e.NewValue)); + _preventChange = false; + } + } + if (_catalog != null) { - list.ScrollToItem(_catalog.Groups.ElementAt(_catalog.Groups.Count - 1 - (int)e.NewValue)); + slider.Foreground = new SolidColorBrush(_catalog.Groups.ElementAt(_catalog.Groups.Count - 1 - (int)e.NewValue).Color); + } + } + + private void OnSelectedItemChanged() + { + if (!_preventChange) + { + _preventChange = true; + var item = SelectedItem; + SelectedItem = null; + SelectedItem = item; + _preventChange = false; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml index adea1481c..426372688 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml @@ -2,5 +2,46 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:local="clr-namespace:Tango.PPC.Common.Resources"> + + <Style TargetType="{x:Type ListBoxItem}" x:Key="BlankListBoxItem"> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="BorderThickness" Value="0"></Setter> + <Setter Property="Foreground" Value="{Binding Path=(TextElement.Foreground), RelativeSource={RelativeSource AncestorType=ContentPresenter}}"></Setter> + <Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter> + <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> + <Setter Property="Padding" Value="0"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type ListBoxItem}"> + <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" Background="{TemplateBinding Background}" Padding="0" SnapsToDevicePixels="true"> + <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> + </Border> + <ControlTemplate.Triggers> + <Trigger Property="IsSelected" Value="true"> + <Setter Property="Background" TargetName="Bd" Value="Transparent"/> + </Trigger> + <MultiTrigger> + <MultiTrigger.Conditions> + <Condition Property="IsSelected" Value="true"/> + <Condition Property="Selector.IsSelectionActive" Value="false"/> + </MultiTrigger.Conditions> + <Setter Property="Background" TargetName="Bd" Value="Transparent"/> + </MultiTrigger> + <Trigger Property="IsEnabled" Value="false"> + <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> + </Trigger> + </ControlTemplate.Triggers> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="{x:Type ListBox}" x:Key="BlankListBox"> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"></Setter> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"></Setter> + <Setter Property="BorderThickness" Value="0"></Setter> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="ItemContainerStyle" Value="{StaticResource BlankListBoxItem}"></Setter> + </Style> </ResourceDictionary>
\ No newline at end of file |
