aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-02 14:36:16 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-02 14:36:16 +0300
commit58f612e03a9bb31c2ada4eb3c5989be458ec4ff5 (patch)
treef0e27284fe4db0abf46212290486ce25db3ea0ec /Software/Visual_Studio
parent57d2810dae9d6d40c52ec33508a324582ac3113b (diff)
downloadTango-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')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml12
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml.cs28
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj7
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml57
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs60
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml41
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/DoubleValueChangedEventArgs.cs19
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs96
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.xaml76
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs7
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.xaml2
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/TouchStaticListBox.cs122
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/TouchStaticListBox.xaml38
-rw-r--r--Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj6
-rw-r--r--Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml1
15 files changed, 475 insertions, 97 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
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/DoubleValueChangedEventArgs.cs b/Software/Visual_Studio/Tango.Touch/Controls/DoubleValueChangedEventArgs.cs
new file mode 100644
index 000000000..2e1b894a9
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Touch/Controls/DoubleValueChangedEventArgs.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace Tango.Touch.Controls
+{
+ public class DoubleValueChangedEventArgs : RoutedEventArgs
+ {
+ public double Value { get; set; }
+
+ public DoubleValueChangedEventArgs(RoutedEvent routedEvent, object source, double value) : base(routedEvent, source)
+ {
+ Value = value;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs
index 8d1504f48..9840a6fd8 100644
--- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs
+++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs
@@ -38,8 +38,32 @@ namespace Tango.Touch.Controls
private const double _friction_factor_per_second = 0.9;
private DispatcherTimer _move_timer;
+ #region Events
+
+ public delegate void ScrollingEventHandler(object sender, DoubleValueChangedEventArgs e);
+
+ public static readonly RoutedEvent ScrollingEvent = EventManager.RegisterRoutedEvent("Scrolling", RoutingStrategy.Bubble, typeof(ScrollingEventHandler), typeof(LightTouchScrollViewer));
+ /// <summary>
+ /// Occurs when the scrolling position has changed.
+ /// </summary>
+ public event ScrollingEventHandler Scrolling
+ {
+ add { AddHandler(ScrollingEvent, value); }
+ remove { RemoveHandler(ScrollingEvent, value); }
+ }
+
+ #endregion
+
#region Properties
+ public Thickness InternalMargin
+ {
+ get { return (Thickness)GetValue(InternalMarginProperty); }
+ set { SetValue(InternalMarginProperty, value); }
+ }
+ public static readonly DependencyProperty InternalMarginProperty =
+ DependencyProperty.Register("InternalMargin", typeof(Thickness), typeof(LightTouchScrollViewer), new PropertyMetadata(default(Thickness), (d, e) => (d as LightTouchScrollViewer).RaiseScrollEvent()));
+
/// <summary>
/// Gets or sets the scroll bar margins.
@@ -164,6 +188,16 @@ namespace Tango.Touch.Controls
public static readonly DependencyProperty DisableScrollingProperty =
DependencyProperty.Register("DisableScrolling", typeof(bool), typeof(LightTouchScrollViewer), new PropertyMetadata(false));
+ /// <summary>
+ /// Gets or sets the scroll bar visibility.
+ /// </summary>
+ public Visibility ScrollBarVisibility
+ {
+ get { return (Visibility)GetValue(ScrollBarVisibilityProperty); }
+ set { SetValue(ScrollBarVisibilityProperty, value); }
+ }
+ public static readonly DependencyProperty ScrollBarVisibilityProperty =
+ DependencyProperty.Register("ScrollBarVisibility", typeof(Visibility), typeof(LightTouchScrollViewer), new PropertyMetadata(Visibility.Visible));
#endregion
@@ -204,6 +238,8 @@ namespace Tango.Touch.Controls
_thumb.DragDelta += _thumb_DragDelta;
_thumb.DragStarted += _thumb_DragStarted;
_thumb.DragCompleted += _thumb_DragCompleted;
+
+ this.Bind(InternalMarginProperty, _grid_content, Grid.MarginProperty, System.Windows.Data.BindingMode.OneWay);
}
private void _thumb_DragCompleted(object sender, DragCompletedEventArgs e)
@@ -630,6 +666,21 @@ namespace Tango.Touch.Controls
}
}
+ private Rect GetViewPortRect()
+ {
+ return new Rect(0, -_grid_content.Margin.Top, _border_viewport.ActualWidth, _border_viewport.ActualHeight);
+ }
+
+ private Rect GetElementRect(FrameworkElement element)
+ {
+ if (element != null)
+ {
+ return new Rect(element.TranslatePoint(new Point(0, 0), _grid_content), new Size(element.ActualWidth, element.ActualHeight));
+ }
+
+ return new Rect();
+ }
+
#endregion
#region Public Methods
@@ -710,6 +761,51 @@ namespace Tango.Touch.Controls
}
}
+ /// <summary>
+ /// Gets the most visible element.
+ /// </summary>
+ /// <returns></returns>
+ public FrameworkElement GetMostVisibleElement()
+ {
+ var elements = _grid_content.FindVisualChildren<FrameworkElement>().ToList();
+
+ if (elements.Count > 0)
+ {
+ var viewPort = GetViewPortRect();
+ var mostVisible = elements.OrderBy(x => Rect.Intersect(viewPort, GetElementRect(x)).Height).Last();
+ return mostVisible;
+ }
+
+ return null;
+ }
+
+ public T GetMostVisibleElementDataContext<T>() where T : class
+ {
+ var elements = _grid_content.FindVisualChildren<FrameworkElement>().Where(x => x.DataContext is T).ToList();
+
+ if (elements.Count > 0)
+ {
+ var viewPort = GetViewPortRect();
+ var mostVisible = elements.OrderBy(x => Rect.Intersect(viewPort, GetElementRect(x)).Height).Last();
+ return mostVisible.DataContext as T;
+ }
+
+ return null;
+ }
+
+ #endregion
+
+ #region Virtual Methods
+
+ /// <summary>
+ /// Raises the scroll event.
+ /// </summary>
+ protected virtual void RaiseScrollEvent()
+ {
+ DoubleValueChangedEventArgs e = new DoubleValueChangedEventArgs(ScrollingEvent, this, GetScrollPosition());
+ RaiseEvent(e);
+ }
+
#endregion
}
}
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.xaml b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.xaml
index c7cd71066..51738c299 100644
--- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.xaml
+++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.xaml
@@ -67,46 +67,48 @@
</Path.Data>
</Path>
- <Canvas Margin="{TemplateBinding ScrollBarMargin}" x:Name="PART_canvas" HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="{TemplateBinding ScrollBarWidth}" Background="{TemplateBinding ScrollBarBackground}">
- <Canvas.Visibility>
- <MultiBinding Converter="{StaticResource ScrollViewerScrollBarVisibilityConverter}">
- <Binding ElementName="PART_Border" Path="ActualHeight" />
- <Binding ElementName="PART_Grid_Content" Path="ActualHeight" />
- </MultiBinding>
- </Canvas.Visibility>
- <Canvas.Style>
- <Style TargetType="Canvas">
- <Setter Property="Opacity" Value="0"></Setter>
- <Style.Triggers>
- <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent},Path=IsScrolling}" Value="True">
- <DataTrigger.EnterActions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="00:00:0.2"/>
- </Storyboard>
- </BeginStoryboard>
- </DataTrigger.EnterActions>
- <DataTrigger.ExitActions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimation Storyboard.TargetProperty="Opacity" To="0" BeginTime="00:00:01" Duration="00:00:01"/>
- </Storyboard>
- </BeginStoryboard>
- </DataTrigger.ExitActions>
- </DataTrigger>
- </Style.Triggers>
- </Style>
- </Canvas.Style>
- <Border x:Name="PART_Thumb_Border" CornerRadius="{TemplateBinding ScrollBarCornerRadius}" Canvas.Top="0" Width="{Binding ElementName=PART_canvas,Path=ActualWidth}" Background="{TemplateBinding ScrollBarForeground}">
- <Border.Height>
- <MultiBinding Converter="{StaticResource ScrollViewerThumbSizeConverter}">
+ <Grid HorizontalAlignment="Right" VerticalAlignment="Stretch" Visibility="{TemplateBinding ScrollBarVisibility}">
+ <Canvas Margin="{TemplateBinding ScrollBarMargin}" x:Name="PART_canvas" HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="{TemplateBinding ScrollBarWidth}" Background="{TemplateBinding ScrollBarBackground}">
+ <Canvas.Visibility>
+ <MultiBinding Converter="{StaticResource ScrollViewerScrollBarVisibilityConverter}">
<Binding ElementName="PART_Border" Path="ActualHeight" />
<Binding ElementName="PART_Grid_Content" Path="ActualHeight" />
</MultiBinding>
- </Border.Height>
- <Thumb x:Name="PART_Thumb" Opacity="0" Background="Transparent" />
- </Border>
- </Canvas>
+ </Canvas.Visibility>
+ <Canvas.Style>
+ <Style TargetType="Canvas">
+ <Setter Property="Opacity" Value="0"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent},Path=IsScrolling}" Value="True">
+ <DataTrigger.EnterActions>
+ <BeginStoryboard>
+ <Storyboard>
+ <DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="00:00:0.2"/>
+ </Storyboard>
+ </BeginStoryboard>
+ </DataTrigger.EnterActions>
+ <DataTrigger.ExitActions>
+ <BeginStoryboard>
+ <Storyboard>
+ <DoubleAnimation Storyboard.TargetProperty="Opacity" To="0" BeginTime="00:00:01" Duration="00:00:01"/>
+ </Storyboard>
+ </BeginStoryboard>
+ </DataTrigger.ExitActions>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </Canvas.Style>
+ <Border x:Name="PART_Thumb_Border" CornerRadius="{TemplateBinding ScrollBarCornerRadius}" Canvas.Top="0" Width="{Binding ElementName=PART_canvas,Path=ActualWidth}" Background="{TemplateBinding ScrollBarForeground}">
+ <Border.Height>
+ <MultiBinding Converter="{StaticResource ScrollViewerThumbSizeConverter}">
+ <Binding ElementName="PART_Border" Path="ActualHeight" />
+ <Binding ElementName="PART_Grid_Content" Path="ActualHeight" />
+ </MultiBinding>
+ </Border.Height>
+ <Thumb x:Name="PART_Thumb" Opacity="0" Background="Transparent" />
+ </Border>
+ </Canvas>
+ </Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs
index 6512f796f..ac446b9fd 100644
--- a/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs
+++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs
@@ -129,6 +129,13 @@ namespace Tango.Touch.Controls
public static readonly DependencyProperty DisableRippleProperty =
DependencyProperty.Register("DisableRipple", typeof(bool), typeof(TouchListBox), new PropertyMetadata(false));
+ public Visibility ScrollBarVisibility
+ {
+ get { return (Visibility)GetValue(ScrollBarVisibilityProperty); }
+ set { SetValue(ScrollBarVisibilityProperty, value); }
+ }
+ public static readonly DependencyProperty ScrollBarVisibilityProperty =
+ DependencyProperty.Register("ScrollBarVisibility", typeof(Visibility), typeof(TouchListBox), new PropertyMetadata(Visibility.Visible));
public TouchListBox()
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.xaml
index be03f498c..92279d5e6 100644
--- a/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.xaml
+++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.xaml
@@ -36,7 +36,7 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:TouchListBox}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
- <local:LightTouchScrollViewer x:Name="PART_ScrollViewer" DisableScrolling="{TemplateBinding DisableScrolling}">
+ <local:LightTouchScrollViewer x:Name="PART_ScrollViewer" ScrollBarVisibility="{TemplateBinding ScrollBarVisibility}" DisableScrolling="{TemplateBinding DisableScrolling}">
<ItemsControl VirtualizingPanel.IsVirtualizing="False" x:Name="PART_ItemsControl" Style="{x:Null}" ItemsSource="{TemplateBinding ItemsSource}" VerticalAlignment="Top" ClipToBounds="True">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchStaticListBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchStaticListBox.cs
new file mode 100644
index 000000000..febd09309
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchStaticListBox.cs
@@ -0,0 +1,122 @@
+using System;
+using System.Collections;
+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;
+using Tango.Core.Commands;
+using Tango.Core.EventArguments;
+
+namespace Tango.Touch.Controls
+{
+ public class TouchStaticListBox : Control
+ {
+ public IList ItemsSource
+ {
+ get { return (IList)GetValue(ItemsSourceProperty); }
+ set { SetValue(ItemsSourceProperty, value); }
+ }
+ public static readonly DependencyProperty ItemsSourceProperty =
+ DependencyProperty.Register("ItemsSource", typeof(IList), typeof(TouchStaticListBox), new PropertyMetadata(null));
+
+ public DataTemplate ItemTemplate
+ {
+ get { return (DataTemplate)GetValue(ItemTemplateProperty); }
+ set { SetValue(ItemTemplateProperty, value); }
+ }
+ public static readonly DependencyProperty ItemTemplateProperty =
+ DependencyProperty.Register("ItemTemplate", typeof(DataTemplate), typeof(TouchStaticListBox), new PropertyMetadata(null));
+
+ public Style ItemContainerStyle
+ {
+ get { return (Style)GetValue(ItemContainerStyleProperty); }
+ set { SetValue(ItemContainerStyleProperty, value); }
+ }
+ public static readonly DependencyProperty ItemContainerStyleProperty =
+ DependencyProperty.Register("ItemContainerStyle", typeof(Style), typeof(TouchStaticListBox), new PropertyMetadata(null));
+
+ public Object SelectedItem
+ {
+ get { return (Object)GetValue(SelectedItemProperty); }
+ set { SetValue(SelectedItemProperty, value); }
+ }
+ public static readonly DependencyProperty SelectedItemProperty =
+ DependencyProperty.Register("SelectedItem", typeof(Object), typeof(TouchStaticListBox), new PropertyMetadata(null, (d, e) => (d as TouchStaticListBox).OnSelectdItemChanged()));
+
+ public RelayCommand<TouchListBoxItem> ListBoxItemLoadedCommand
+ {
+ get { return (RelayCommand<TouchListBoxItem>)GetValue(ListBoxItemLoadedCommandProperty); }
+ set { SetValue(ListBoxItemLoadedCommandProperty, value); }
+ }
+ public static readonly DependencyProperty ListBoxItemLoadedCommandProperty =
+ DependencyProperty.Register("ListBoxItemLoadedCommand", typeof(RelayCommand<TouchListBoxItem>), typeof(TouchStaticListBox), new PropertyMetadata(null));
+
+ public ItemsPanelTemplate ItemsPanel
+ {
+ get { return (ItemsPanelTemplate)GetValue(ItemsPanelProperty); }
+ set { SetValue(ItemsPanelProperty, value); }
+ }
+ public static readonly DependencyProperty ItemsPanelProperty =
+ DependencyProperty.Register("ItemsPanel", typeof(ItemsPanelTemplate), typeof(TouchStaticListBox), new PropertyMetadata(null));
+
+
+
+ static TouchStaticListBox()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchStaticListBox), new FrameworkPropertyMetadata(typeof(TouchStaticListBox)));
+ }
+
+ public TouchStaticListBox()
+ {
+ ListBoxItemLoadedCommand = new RelayCommand<TouchListBoxItem>(RegisterListBoxItemEvents);
+ }
+
+ private void RegisterListBoxItemEvents(TouchListBoxItem item)
+ {
+ if (item.Tag == null)
+ {
+ item.Tag = 1;
+ item.RegisterForPreviewMouseOrTouchUp(OnItemMouseUp);
+ }
+ }
+
+ private void OnItemMouseUp(object sender, MouseOrTouchEventArgs e)
+ {
+ var scrollViewer = this.FindAncestor<LightTouchScrollViewer>();
+ if (scrollViewer != null && scrollViewer.IsAfterScrolling) return;
+
+ var item = (e.Source is TouchListBoxItem) ? e.Source as TouchListBoxItem : (e.Source as DependencyObject).FindAncestor<TouchListBoxItem>();
+ SelectedItem = item.DataContext;
+ }
+
+ private void OnSelectdItemChanged()
+ {
+ var items = GetItems();
+ items.ForEach(x => x.IsSelected = false);
+
+ if (SelectedItem != null)
+ {
+ var selected_item = items.FirstOrDefault(x => x.DataContext == SelectedItem);
+
+ if (selected_item != null)
+ {
+ selected_item.IsSelected = true;
+ }
+ }
+ }
+
+ private List<TouchListBoxItem> GetItems()
+ {
+ return this.FindVisualChildren<TouchListBoxItem>().ToList();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchStaticListBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchStaticListBox.xaml
new file mode 100644
index 000000000..6789a0e21
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchStaticListBox.xaml
@@ -0,0 +1,38 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
+ xmlns:local="clr-namespace:Tango.Touch.Controls">
+
+ <Style TargetType="{x:Type local:TouchStaticListBox}">
+ <Setter Property="ItemsPanel">
+ <Setter.Value>
+ <ItemsPanelTemplate>
+ <StackPanel/>
+ </ItemsPanelTemplate>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="{x:Type local:TouchStaticListBox}">
+ <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
+ <ItemsControl ItemsSource="{TemplateBinding ItemsSource}" ItemsPanel="{TemplateBinding ItemsPanel}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <local:TouchListBoxItem Style="{Binding RelativeSource={RelativeSource AncestorType=local:TouchStaticListBox},Path=ItemContainerStyle}">
+ <i:Interaction.Triggers>
+ <i:EventTrigger EventName="Loaded">
+ <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource AncestorType=local:TouchStaticListBox},Path=ListBoxItemLoadedCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=local:TouchListBoxItem}}" />
+ </i:EventTrigger>
+ </i:Interaction.Triggers>
+ <ContentControl Content="{Binding}" ContentTemplate="{Binding RelativeSource={RelativeSource AncestorType=local:TouchStaticListBox},Path=ItemTemplate}"></ContentControl>
+ </local:TouchListBoxItem>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </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 9239f3298..b6242dfa2 100644
--- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj
+++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj
@@ -60,6 +60,7 @@
<Link>Core.cs</Link>
</Compile>
<Compile Include="Controls\AutoCompleteProvider.cs" />
+ <Compile Include="Controls\DoubleValueChangedEventArgs.cs" />
<Compile Include="Controls\FocusSelectionMode.cs" />
<Compile Include="Controls\IValueControl.cs" />
<Compile Include="Controls\MessageBoxVM.cs" />
@@ -75,6 +76,7 @@
<Compile Include="Controls\TouchListBoxItem.cs" />
<Compile Include="Controls\TouchNumericTextBox.cs" />
<Compile Include="Controls\TouchSlider.cs" />
+ <Compile Include="Controls\TouchStaticListBox.cs" />
<Compile Include="Controls\TouchTable.cs" />
<Compile Include="Controls\TouchTextBox.cs" />
<Compile Include="Controls\TouchPanel.cs" />
@@ -177,6 +179,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Controls\TouchStaticListBox.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="Controls\TouchTextBox.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml
index 73aa394ed..3a2c21a28 100644
--- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml
+++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml
@@ -35,6 +35,7 @@
<ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchToggleIconButton.xaml" />
<ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchNumericTextBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchSlider.xaml" />
+ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchStaticListBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchToggleButton.xaml" />
<ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchButton.xaml" />