diff options
17 files changed, 574 insertions, 111 deletions
diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs index 9efd9f5a6..4473e2879 100644 --- a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs +++ b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs @@ -31,6 +31,7 @@ namespace Tango.DragAndDrop private static bool _isMouseDown; private static DispatcherTimer _dragTimer; private static Border _dragBorder; + private static TouchDevice _touchDevice; //private const int MIN_DRAG_OFFSET = 8; #region Events @@ -445,15 +446,24 @@ namespace Tango.DragAndDrop /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private static void DragTimer_Tick(object sender, EventArgs e) { - if ((Mouse.LeftButton == MouseButtonState.Pressed) && _currentDragedElement != null) + if ((Mouse.LeftButton == MouseButtonState.Pressed || (_touchDevice != null && _touchDevice.IsActive)) && _currentDragedElement != null) { DragStarted?.Invoke(_currentDragedElement, _currentDragedElement); var surface = GetDraggingSurface(_currentDragedElement); var rootElement = surface.Parent as FrameworkElement; - DraggingSurface.SetLeft(_dragBorder, Mouse.GetPosition(surface).X - _mouseDownLocation.X); - DraggingSurface.SetTop(_dragBorder, Mouse.GetPosition(surface).Y - _mouseDownLocation.Y); + if (_touchDevice != null) + { + DraggingSurface.SetLeft(_dragBorder, _touchDevice.GetTouchPoint(surface).Position.X - _mouseDownLocation.X); + DraggingSurface.SetTop(_dragBorder, _touchDevice.GetTouchPoint(surface).Position.Y - _mouseDownLocation.Y); + } + else + { + DraggingSurface.SetLeft(_dragBorder, Mouse.GetPosition(surface).X - _mouseDownLocation.X); + DraggingSurface.SetTop(_dragBorder, Mouse.GetPosition(surface).Y - _mouseDownLocation.Y); + } + _dragBorder.Visibility = Visibility.Visible; bool found = false; @@ -475,7 +485,16 @@ namespace Tango.DragAndDrop Rect dropRect = new Rect(dropPoint, new Size(dropElementScaledSize.X, dropElementScaledSize.Y)); Rect dragRect = new Rect(Canvas.GetLeft(_dragBorder), Canvas.GetTop(_dragBorder), _dragBorder.Width / 2, _dragBorder.Height); - Point mousePoint = rootElement.PointToScreen(Mouse.GetPosition(rootElement)); + Point mousePoint = new Point(); + + if (_touchDevice != null) + { + mousePoint = rootElement.PointToScreen(_touchDevice.GetTouchPoint(rootElement).Position); + } + else + { + mousePoint = rootElement.PointToScreen(Mouse.GetPosition(rootElement)); + } if (dropRect.IntersectsWith(new Rect(mousePoint, new Size(1, 1)))) { @@ -723,6 +742,7 @@ namespace Tango.DragAndDrop _isMouseDown = false; CreateDraggingElement(); + _touchDevice = e.TouchDevice; _dragTimer.Start(); SetIsDragging(element, true); } @@ -742,6 +762,8 @@ namespace Tango.DragAndDrop if (element != null) { + e.Handled = true; + if ((e.GetPosition(element).X > _mouseDownLocation.X + 10 || e.GetPosition(element).X < _mouseDownLocation.X - 10) || (e.GetPosition(element).Y > _mouseDownLocation.Y + 10 || e.GetPosition(element).Y < _mouseDownLocation.Y - 10)) { DropDraggable(); diff --git a/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs b/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs index d4a5bd1f5..b9d3f37b5 100644 --- a/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs +++ b/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs @@ -178,6 +178,11 @@ namespace Tango.Touch.Components if (parent == null) { + parent = this.FindAncestor<Border>(); + } + + if (parent == null) + { parent = this.FindAncestor<FrameworkElement>(); } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs index 9a612d2f1..5de570bc0 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs @@ -35,10 +35,23 @@ namespace Tango.Touch.Controls private const double touch_inertia_coefficiant = 10; private const double bounce_offset_max = 100; private bool _isLoaded; + private List<LightTouchDataGridRow> _awaitingSelectionRows; + private LightTouchDataGridRow _firstMultiSelectionRow; #region Properties /// <summary> + /// Gets or sets a value indicating whether [animate sorting]. + /// </summary> + public bool AnimateSorting + { + get { return (bool)GetValue(AnimateSortingProperty); } + set { SetValue(AnimateSortingProperty, value); } + } + public static readonly DependencyProperty AnimateSortingProperty = + DependencyProperty.Register("AnimateSorting", typeof(bool), typeof(LightTouchDataGrid), new PropertyMetadata(true)); + + /// <summary> /// Gets or sets the dragging surface. /// </summary> public DraggingSurface DraggingSurface @@ -83,48 +96,50 @@ namespace Tango.Touch.Controls DependencyProperty.Register("Columns", typeof(ObservableCollection<LightTouchDataGridColumn>), typeof(LightTouchDataGrid), new PropertyMetadata(new ObservableCollection<LightTouchDataGridColumn>())); /// <summary> - /// Gets or sets the cell style. + /// Gets or sets a value indicating whether the data grid is currently scrolling. /// </summary> - public Style CellStyle + public bool IsScrolling { - get { return (Style)GetValue(CellStyleProperty); } - set { SetValue(CellStyleProperty, value); } + get { return (bool)GetValue(IsScrollingProperty); } + set { SetValue(IsScrollingProperty, value); } } - public static readonly DependencyProperty CellStyleProperty = - DependencyProperty.Register("CellStyle", typeof(Style), typeof(LightTouchDataGridCell), new PropertyMetadata(null)); + public static readonly DependencyProperty IsScrollingProperty = + DependencyProperty.Register("IsScrolling", typeof(bool), typeof(LightTouchDataGrid), new PropertyMetadata(false)); /// <summary> - /// Gets or sets the headers row style. + /// Gets or sets the selection mode. /// </summary> - public Style HeadersRowStyle + public LightTouchDataGridSelectionMode SelectionMode { - get { return (Style)GetValue(HeadersRowStyleProperty); } - set { SetValue(HeadersRowStyleProperty, value); } + get { return (LightTouchDataGridSelectionMode)GetValue(SelectionModeProperty); } + set { SetValue(SelectionModeProperty, value); } } - public static readonly DependencyProperty HeadersRowStyleProperty = - DependencyProperty.Register("HeadersRowStyle", typeof(Style), typeof(LightTouchDataGrid), new PropertyMetadata(null)); + public static readonly DependencyProperty SelectionModeProperty = + DependencyProperty.Register("SelectionMode", typeof(LightTouchDataGridSelectionMode), typeof(LightTouchDataGrid), new PropertyMetadata(LightTouchDataGridSelectionMode.Multiple)); /// <summary> - /// Gets or sets the row style. + /// Gets or sets a value indicating whether this instance is multi selecting. /// </summary> - public Style RowStyle + public bool IsMultiSelecting { - get { return (Style)GetValue(RowStyleProperty); } - set { SetValue(RowStyleProperty, value); } + get { return (bool)GetValue(IsMultiSelectingProperty); } + set { SetValue(IsMultiSelectingProperty, value); } } - public static readonly DependencyProperty RowStyleProperty = - DependencyProperty.Register("RowStyle", typeof(Style), typeof(LightTouchDataGrid), new PropertyMetadata(null)); + public static readonly DependencyProperty IsMultiSelectingProperty = + DependencyProperty.Register("IsMultiSelecting", typeof(bool), typeof(LightTouchDataGrid), new PropertyMetadata(false)); /// <summary> - /// Gets or sets a value indicating whether the data grid is currently scrolling. + /// Gets or sets the item selected command. /// </summary> - public bool IsScrolling + public RelayCommand<Object> ItemSelectedCommand { - get { return (bool)GetValue(IsScrollingProperty); } - set { SetValue(IsScrollingProperty, value); } + get { return (RelayCommand<Object>)GetValue(ItemSelectedCommandProperty); } + set { SetValue(ItemSelectedCommandProperty, value); } } - public static readonly DependencyProperty IsScrollingProperty = - DependencyProperty.Register("IsScrolling", typeof(bool), typeof(LightTouchDataGrid), new PropertyMetadata(false)); + public static readonly DependencyProperty ItemSelectedCommandProperty = + DependencyProperty.Register("ItemSelectedCommand", typeof(RelayCommand<Object>), typeof(LightTouchDataGrid), new PropertyMetadata(null)); + + #endregion @@ -169,6 +184,7 @@ namespace Tango.Touch.Controls /// </summary> public LightTouchDataGrid() { + _awaitingSelectionRows = new List<LightTouchDataGridRow>(); _last_manipulation_deltas = new List<double>(); SortCommand = new RelayCommand<LightTouchDataGridColumn>(HandleSortCommand); Loaded += LightTouchDataGrid_Loaded; @@ -268,7 +284,7 @@ namespace Tango.Touch.Controls #endregion - #region Virtual Methods + #region Touch / Mouse Handlers /// <summary> /// Called when the mouse touch has been down @@ -277,6 +293,11 @@ namespace Tango.Touch.Controls /// <param name="e">The <see cref="MouseOrTouchEventArgs"/> instance containing the event data.</param> protected virtual void OnMouseTouchDown(object sender, MouseOrTouchEventArgs e) { + if (e.OriginalSource.GetType() == typeof(DragThumb)) + { + return; + } + _mouse_down_location = new Point(e.Location.X, e.Location.Y - _items_control_rows.Margin.Top); _mouse_down = true; } @@ -316,7 +337,6 @@ namespace Tango.Touch.Controls if (_mouse_down) { _mouse_down = false; - IsScrolling = false; Mouse.Capture(null); if (e.TouchDevice != null) @@ -324,11 +344,91 @@ namespace Tango.Touch.Controls e.TouchDevice.Capture(null); } - SnapRowsToBounds(); + if (IsScrolling) + { + e.Handled = true; + SnapRowsToBounds(); + } + + IsScrolling = false; } } /// <summary> + /// Called when the row mouse touch has been up + /// </summary> + /// <param name="sender">The sender.</param> + /// <param name="e">The <see cref="MouseOrTouchEventArgs"/> instance containing the event data.</param> + private void OnRowMouseTouchUp(object sender, MouseOrTouchEventArgs e) + { + var row = (e.Source is LightTouchDataGridRow) ? e.Source as LightTouchDataGridRow : (e.Source as DependencyObject).FindAncestor<LightTouchDataGridRow>(); + var otherRows = GetRows().Where(x => x != row).ToList(); + + if (!IsMultiSelecting) + { + _awaitingSelectionRows.Remove(row); + + if (SelectionMode != LightTouchDataGridSelectionMode.Multiple) + { + otherRows.ForEach(x => x.IsSelected = false); + row.IsSelected = true; + ItemSelectedCommand?.Execute(row.DataContext); + } + } + else if (SelectionMode == LightTouchDataGridSelectionMode.Multiple && IsMultiSelecting) + { + if (!IsScrolling) + { + if (row != _firstMultiSelectionRow) + { + row.IsSelected = !row.IsSelected; + _firstMultiSelectionRow = null; + } + + if (!row.IsSelected && otherRows.All(x => !x.IsSelected)) + { + IsMultiSelecting = false; + } + } + } + } + + /// <summary> + /// Called when the row mouse touch has been down + /// </summary> + /// <param name="sender">The sender.</param> + /// <param name="e">The <see cref="MouseOrTouchEventArgs"/> instance containing the event data.</param> + /// <exception cref="NotImplementedException"></exception> + private async void OnRowMouseTouchDown(object sender, MouseOrTouchEventArgs e) + { + var row = (e.Source is LightTouchDataGridRow) ? e.Source as LightTouchDataGridRow : (e.Source as DependencyObject).FindAncestor<LightTouchDataGridRow>(); + var otherRows = GetRows().Where(x => x != row).ToList(); + + if (SelectionMode == LightTouchDataGridSelectionMode.Multiple && !IsMultiSelecting) + { + _awaitingSelectionRows.Add(row); + await Task.Delay(500); + + if (_awaitingSelectionRows.Contains(row)) + { + _awaitingSelectionRows.Remove(row); + + if (_mouse_down && !IsScrolling) + { + _firstMultiSelectionRow = row; + otherRows.ForEach(x => x.IsSelected = false); + row.IsSelected = true; + IsMultiSelecting = true; + } + } + } + } + + #endregion + + #region Properties Changed Handlers + + /// <summary> /// Called when the items source has been changed /// </summary> protected virtual void OnItemsSourceChanged() @@ -337,8 +437,7 @@ namespace Tango.Touch.Controls { if (ItemsSource is INotifyCollectionChanged) { - (ItemsSource as INotifyCollectionChanged).CollectionChanged -= Items_Source_Collection_Changed; - (ItemsSource as INotifyCollectionChanged).CollectionChanged += Items_Source_Collection_Changed; + } } } @@ -367,7 +466,7 @@ namespace Tango.Touch.Controls column.SortDirection = column.SortDirection == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending; } - LayoutRows(); + LayoutRows(true); } #endregion @@ -384,20 +483,11 @@ namespace Tango.Touch.Controls { if (_items_control_rows.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated) { + _items_control_rows.UpdateLayout(); LayoutRows(); } } - /// <summary> - /// Handles the CollectionChanged event of the ItemsSource if observable. - /// </summary> - /// <param name="sender">The source of the event.</param> - /// <param name="e">The <see cref="NotifyCollectionChangedEventArgs"/> instance containing the event data.</param> - private void Items_Source_Collection_Changed(object sender, NotifyCollectionChangedEventArgs e) - { - LayoutRows(); - } - #endregion #region Private Methods @@ -411,7 +501,7 @@ namespace Tango.Touch.Controls ani.Duration = TimeSpan.FromSeconds(0.2); ani.AccelerationRatio = 1; - if (_items_control_rows.Margin.Top > 0) + if (_items_control_rows.Margin.Top > 0 || _items_control_rows.ActualHeight < _grid_rows.ActualHeight) { ani.To = new Thickness(0); _items_control_rows.BeginAnimation(ItemsControl.MarginProperty, ani); @@ -430,7 +520,7 @@ namespace Tango.Touch.Controls /// <summary> /// Lays out the rows on the canvas according to the current sort column. /// </summary> - public void LayoutRows() + public void LayoutRows(bool allowAnimation = false) { if (_items_control_rows == null || !_isLoaded) return; @@ -460,25 +550,65 @@ namespace Tango.Touch.Controls for (int i = 0; i < ordered.Count; i++) { - UIElement uiElement = ordered[i]; + ContentPresenter contentPresenter = ordered[i]; + + if (AnimateSorting && allowAnimation) + { + if (double.IsNaN(Canvas.GetTop(contentPresenter))) + { + Canvas.SetTop(contentPresenter, current_top); + Canvas.SetLeft(contentPresenter, 0); + } + else + { + int duration = _rnd.Next(200, 500); + + DoubleAnimation aniY = new DoubleAnimation(); + aniY.To = current_top; + aniY.Duration = TimeSpan.FromMilliseconds(duration); + contentPresenter.BeginAnimation(Canvas.TopProperty, aniY); - //if (double.IsNaN(Canvas.GetTop(uiElement))) - //{ - // Canvas.SetTop(uiElement, 0); - //} + DoubleAnimation aniX = new DoubleAnimation(); + aniX.To = _rnd.Next(-20, 20); + aniX.AutoReverse = true; + aniX.Duration = TimeSpan.FromMilliseconds(duration / 2); + contentPresenter.BeginAnimation(Canvas.LeftProperty, aniX); + } + } + else + { + if (AnimateSorting) + { + contentPresenter.BeginAnimation(Canvas.TopProperty, null); + } - //DoubleAnimation ani = new DoubleAnimation(); - //ani.To = current_top; - //ani.Duration = TimeSpan.FromMilliseconds(_rnd.Next(200, 500)); - //uiElement.BeginAnimation(Canvas.TopProperty, ani); + Canvas.SetTop(contentPresenter, current_top); + Canvas.SetLeft(contentPresenter, 0); + } - Canvas.SetTop(uiElement, current_top); current_top += (ordered[i].Margin.Top + ordered[i].ActualHeight + ordered[i].Margin.Bottom); + + if (contentPresenter.Tag == null) + { + contentPresenter.Tag = 1; + LightTouchDataGridRow row = contentPresenter.FindChild<LightTouchDataGridRow>(); + row.RegisterForPreviewMouseOrTouchUp(OnRowMouseTouchUp); + row.RegisterForPreviewMouseOrTouchDown(OnRowMouseTouchDown); + } } _items_control_rows.Height = current_top; } + /// <summary> + /// Gets all the current rows visuals. + /// </summary> + /// <returns></returns> + public List<LightTouchDataGridRow> GetRows() + { + return _items_control_rows.FindVisualChildren<LightTouchDataGridRow>().ToList(); + } + #endregion } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.xaml b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.xaml index fd1369a50..faf1ba3de 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.xaml @@ -7,8 +7,81 @@ xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:local="clr-namespace:Tango.Touch.Controls"> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="../Resources/Colors.xaml" /> + <ResourceDictionary Source="../Resources/Fonts.xaml" /> + <ResourceDictionary Source="../Controls/Shared.xaml" /> + </ResourceDictionary.MergedDictionaries> + <converters:ColumnsToGridDefinitionsConverter x:Key="ColumnsToGridDefinitionsConverter" /> <converters:ColumnToColumnIndexConverter x:Key="ColumnToColumnIndexConverter" /> + <converters:LightTouchDataGridSelectionModesToBooleanConverter x:Key="LightTouchDataGridSelectionModesToBooleanConverter" /> + + <Style TargetType="{x:Type local:LightTouchDataGridHeaderRow}"> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + <Setter Property="HorizontalContentAlignment" Value="Center"></Setter> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type local:LightTouchDataGridHeaderRow}"> + <Border Background="{TemplateBinding Background}" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}" + CornerRadius="{TemplateBinding CornerRadius}" + Padding="{TemplateBinding Padding}"> + <ContentPresenter Content="{TemplateBinding Content}" /> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="{x:Type local:LightTouchDataGridRow}"> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + <Setter Property="HorizontalContentAlignment" Value="Center"></Setter> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type local:LightTouchDataGridRow}"> + <Border Background="{TemplateBinding Background}" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}" + CornerRadius="{TemplateBinding CornerRadius}" + Padding="{TemplateBinding Padding}"> + <ContentPresenter Content="{TemplateBinding Content}" /> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + <Style.Triggers> + <MultiDataTrigger> + <MultiDataTrigger.Conditions> + <Condition Binding="{Binding RelativeSource={RelativeSource Self},Path=IsSelected}" Value="True" /> + <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGrid},Path=SelectionMode,Converter={StaticResource LightTouchDataGridSelectionModesToBooleanConverter},ConverterParameter='Single,Multiple'}" Value="True" /> + </MultiDataTrigger.Conditions> + + <Setter Property="Background" Value="Blue"></Setter> + </MultiDataTrigger> + </Style.Triggers> + </Style> + + <Style TargetType="{x:Type local:LightTouchDataGridCell}"> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + <Setter Property="HorizontalContentAlignment" Value="Center"></Setter> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type local:LightTouchDataGridCell}"> + <Border Background="{TemplateBinding Background}" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}" + CornerRadius="{TemplateBinding CornerRadius}" + Padding="{TemplateBinding Padding}" + HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" + VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> + <ContentPresenter Content="{TemplateBinding Content}" /> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> <Style TargetType="{x:Type local:LightTouchDataGrid}"> <Setter Property="Template"> @@ -20,7 +93,7 @@ <DockPanel> <!--Headers--> - <local:LightTouchDataGridRow DockPanel.Dock="Top" Style="{TemplateBinding HeadersRowStyle}"> + <local:LightTouchDataGridHeaderRow DockPanel.Dock="Top"> <ItemsControl ItemsSource="{TemplateBinding Columns}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> @@ -48,21 +121,14 @@ </ItemsControl.ItemContainerStyle> <ItemsControl.ItemTemplate> <DataTemplate> - <Border> - <Border.Style> - <Style TargetType="Border"> - <Setter Property="TextElement.Foreground" Value="{Binding Foreground}"></Setter> - </Style> - </Border.Style> + <Border Background="Transparent"> <i:Interaction.Triggers> <i:EventTrigger EventName="PreviewMouseDown"> <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGrid},Path=SortCommand}" CommandParameter="{Binding}" /> </i:EventTrigger> </i:Interaction.Triggers> - - <StackPanel Orientation="Horizontal"> - <ContentControl Content="{Binding}" ContentTemplate="{Binding HeaderTemplate}"/> - <fa:ImageAwesome Margin="5 0 0 0" VerticalAlignment="Center" Foreground="{Binding Foreground}" Height="16"> + <DockPanel VerticalAlignment="{Binding VerticalContentAlignment}" HorizontalAlignment="{Binding HorizontalContentAlignment}"> + <fa:ImageAwesome DockPanel.Dock="Right" HorizontalAlignment="Left" Margin="5 0 0 0" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGridHeaderRow},Path=Foreground}" Height="10"> <fa:ImageAwesome.Style> <Style TargetType="{x:Type fa:ImageAwesome}"> <Setter Property="Visibility" Value="Hidden"></Setter> @@ -78,16 +144,20 @@ <Setter Property="Visibility" Value="Visible"></Setter> <Setter Property="Icon" Value="ChevronUp"></Setter> </DataTrigger> + <DataTrigger Binding="{Binding DisplayChevron}" Value="False"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + </DataTrigger> </Style.Triggers> </Style> </fa:ImageAwesome.Style> </fa:ImageAwesome> - </StackPanel> + <ContentControl Content="{Binding}" ContentTemplate="{Binding HeaderTemplate}" /> + </DockPanel> </Border> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> - </local:LightTouchDataGridRow> + </local:LightTouchDataGridHeaderRow> <!--Rows--> <Grid x:Name="PART_Grid_Rows" ClipToBounds="True" Background="Transparent"> @@ -110,8 +180,21 @@ dragAndDrop:DragAndDropService.Droppable="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGrid},Path=EnableDragAndDrop}" dragAndDrop:DragAndDropService.DraggingSurface="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGrid},Path=DraggingSurface}" dragAndDrop:DragAndDropService.MinDragOffset="2" - Padding="0" Canvas.Top="{Binding RelativeSource={RelativeSource AncestorType=ContentPresenter},Path=(Canvas.Top),Mode=TwoWay}" Style="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGrid},Path=RowStyle}"> - <components:Ripple RippleFactor="20" RippleBrush="Red" Disabled="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGrid},Path=IsScrolling}" CornerRadius="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGridRow},Path=CornerRadius}"> + Padding="0" Canvas.Top="{Binding RelativeSource={RelativeSource AncestorType=ContentPresenter},Path=(Canvas.Top),Mode=TwoWay}"> + <components:Ripple RippleFactor="20" RippleBrush="{StaticResource TangoRippleDarkBrush}" CornerRadius="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGridRow},Path=CornerRadius}"> + <components:Ripple.Style> + <Style TargetType="components:Ripple"> + <Setter Property="Disabled" Value="False"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGrid},Path=IsScrolling}" Value="True"> + <Setter Property="Disabled" Value="True"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGrid},Path=IsMultiSelecting}" Value="True"> + <Setter Property="Disabled" Value="True"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </components:Ripple.Style> <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGrid},Path=Columns}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> @@ -139,8 +222,14 @@ </ItemsControl.ItemContainerStyle> <ItemsControl.ItemTemplate> <DataTemplate> - <local:LightTouchDataGridCell Style="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchDataGrid},Path=CellStyle}"> - <ContentControl Content="{Binding RelativeSource={RelativeSource AncestorType=ItemsPresenter},Path=DataContext}" ContentTemplate="{Binding CellTemplate}"/> + <local:LightTouchDataGridCell> + <local:LightTouchDataGridCell.Style> + <Style TargetType="local:LightTouchDataGridCell" BasedOn="{StaticResource {x:Type local:LightTouchDataGridCell}}"> + <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment}"></Setter> + <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment}"></Setter> + </Style> + </local:LightTouchDataGridCell.Style> + <ContentControl Content="{Binding RelativeSource={RelativeSource AncestorType=ItemsPresenter},Path=DataContext}" ContentTemplate="{Binding CellTemplate}" VerticalContentAlignment="{Binding VerticalContentAlignment}" HorizontalContentAlignment="{Binding HorizontalContentAlignment}" /> </local:LightTouchDataGridCell> </DataTemplate> </ItemsControl.ItemTemplate> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridCell.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridCell.cs index db917aaf7..c35bf768f 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridCell.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridCell.cs @@ -3,11 +3,16 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; using System.Windows.Controls; namespace Tango.Touch.Controls { - public class LightTouchDataGridCell : Border + public class LightTouchDataGridCell : TouchContentControl { + static LightTouchDataGridCell() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(LightTouchDataGridCell), new FrameworkPropertyMetadata(typeof(LightTouchDataGridCell))); + } } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridColumn.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridColumn.cs index d64844154..bebf7feec 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridColumn.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridColumn.cs @@ -66,7 +66,7 @@ namespace Tango.Touch.Controls set { SetValue(ForegroundProperty, value); } } public static readonly DependencyProperty ForegroundProperty = - DependencyProperty.Register("Foreground", typeof(Brush), typeof(LightTouchDataGrid), new PropertyMetadata(Brushes.Black)); + DependencyProperty.Register("Foreground", typeof(Brush), typeof(LightTouchDataGridColumn), new PropertyMetadata(Brushes.Black)); /// <summary> /// Gets or sets the sort member. @@ -77,7 +77,43 @@ namespace Tango.Touch.Controls set { SetValue(SortMemberProperty, value); } } public static readonly DependencyProperty SortMemberProperty = - DependencyProperty.Register("SortMember", typeof(String), typeof(LightTouchDataGrid), new PropertyMetadata(null)); + DependencyProperty.Register("SortMember", typeof(String), typeof(LightTouchDataGridColumn), new PropertyMetadata(null)); + + /// <summary> + /// Gets or sets the horizontal content alignment. + /// </summary> + public HorizontalAlignment HorizontalContentAlignment + { + get { return (HorizontalAlignment)GetValue(HorizontalContentAlignmentProperty); } + set { SetValue(HorizontalContentAlignmentProperty, value); } + } + public static readonly DependencyProperty HorizontalContentAlignmentProperty = + DependencyProperty.Register("HorizontalContentAlignment", typeof(HorizontalAlignment), typeof(LightTouchDataGridColumn), new PropertyMetadata(HorizontalAlignment.Center)); + + /// <summary> + /// Gets or sets the vertical content alignment. + /// </summary> + public VerticalAlignment VerticalContentAlignment + { + get { return (VerticalAlignment)GetValue(VerticalContentAlignmentProperty); } + set { SetValue(VerticalContentAlignmentProperty, value); } + } + public static readonly DependencyProperty VerticalContentAlignmentProperty = + DependencyProperty.Register("VerticalContentAlignment", typeof(VerticalAlignment), typeof(LightTouchDataGridColumn), new PropertyMetadata(VerticalAlignment.Center)); + + /// <summary> + /// Gets or sets a value indicating whether to display the column sorting icon. + /// </summary> + public bool DisplayChevron + { + get { return (bool)GetValue(DisplayChevronProperty); } + set { SetValue(DisplayChevronProperty, value); } + } + public static readonly DependencyProperty DisplayChevronProperty = + DependencyProperty.Register("DisplayChevron", typeof(bool), typeof(LightTouchDataGridColumn), new PropertyMetadata(true)); + + + #endregion } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridHeaderRow.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridHeaderRow.cs new file mode 100644 index 000000000..3ef396f26 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridHeaderRow.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace Tango.Touch.Controls +{ + public class LightTouchDataGridHeaderRow : TouchContentControl + { + static LightTouchDataGridHeaderRow() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(LightTouchDataGridHeaderRow), new FrameworkPropertyMetadata(typeof(LightTouchDataGridHeaderRow))); + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridRow.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridRow.cs index 399f144c0..a22567278 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridRow.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridRow.cs @@ -3,17 +3,32 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; using System.Windows.Controls; +using System.Windows.Media; using Tango.DragAndDrop; using Tango.SharedUI.Helpers; namespace Tango.Touch.Controls { - public class LightTouchDataGridRow : Border + public class LightTouchDataGridRow : TouchContentControl { private bool _isLoaded; private LightTouchDataGrid _grid; + public bool IsSelected + { + get { return (bool)GetValue(IsSelectedProperty); } + set { SetValue(IsSelectedProperty, value); } + } + public static readonly DependencyProperty IsSelectedProperty = + DependencyProperty.Register("IsSelected", typeof(bool), typeof(LightTouchDataGridRow), new PropertyMetadata(false)); + + static LightTouchDataGridRow() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(LightTouchDataGridRow), new FrameworkPropertyMetadata(typeof(LightTouchDataGridRow))); + } + public LightTouchDataGridRow() { this.Loaded += LightTouchDataGridRow_Loaded; diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridSelectionMode.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridSelectionMode.cs new file mode 100644 index 000000000..45ac7928b --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridSelectionMode.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Touch.Controls +{ + public enum LightTouchDataGridSelectionMode + { + None, + Single, + Multiple + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/Shared.xaml b/Software/Visual_Studio/Tango.Touch/Controls/Shared.xaml index 96e965952..7f7495e37 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/Shared.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/Shared.xaml @@ -7,13 +7,13 @@ </ResourceDictionary.MergedDictionaries> <Style TargetType="Border" x:Key="DropShadowBorder"> - <Setter Property="CornerRadius" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ITouchControl},Path=CornerRadius}"></Setter> + <Setter Property="CornerRadius" Value="{Binding RelativeSource={RelativeSource AncestorType=local:ITouchControl},Path=CornerRadius,FallbackValue=0}"></Setter> <Setter Property="Effect" Value="{x:Null}"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:ITouchControl},Path=EnableDropShadow}" Value="True"> <Setter Property="Effect"> <Setter.Value> - <DropShadowEffect BlurRadius="{Binding RelativeSource={RelativeSource AncestorType=local:ITouchControl},Path=BlurRadius}" ShadowDepth="{Binding RelativeSource={RelativeSource AncestorType=local:ITouchControl},Path=ShadowDepth}" Color="{Binding RelativeSource={RelativeSource AncestorType=local:ITouchControl},Path=ShadowColor}" /> + <DropShadowEffect BlurRadius="{Binding RelativeSource={RelativeSource AncestorType=local:ITouchControl},Path=BlurRadius,FallbackValue=0}" ShadowDepth="{Binding RelativeSource={RelativeSource AncestorType=local:ITouchControl},Path=ShadowDepth,FallbackValue=0}" Color="{Binding RelativeSource={RelativeSource AncestorType=local:ITouchControl},Path=ShadowColor}" /> </Setter.Value> </Setter> </DataTrigger> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchContentControl.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchContentControl.cs new file mode 100644 index 000000000..c3086e743 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchContentControl.cs @@ -0,0 +1,22 @@ +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.Media; + +namespace Tango.Touch.Controls +{ + public class TouchContentControl : ContentControl + { + public CornerRadius CornerRadius + { + get { return (CornerRadius)GetValue(CornerRadiusProperty); } + set { SetValue(CornerRadiusProperty, value); } + } + public static readonly DependencyProperty CornerRadiusProperty = + DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(TouchContentControl), new PropertyMetadata(default(CornerRadius))); + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Converters/LightTouchDataGridSelectionModesToBooleanConverter.cs b/Software/Visual_Studio/Tango.Touch/Converters/LightTouchDataGridSelectionModesToBooleanConverter.cs new file mode 100644 index 000000000..5c7b08d01 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Converters/LightTouchDataGridSelectionModesToBooleanConverter.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.Touch.Controls; + +namespace Tango.Touch.Converters +{ + public class LightTouchDataGridSelectionModesToBooleanConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && parameter != null) + { + String[] modes = parameter.ToString().Split(','); + + foreach (var mode in modes) + { + var parsed = (LightTouchDataGridSelectionMode)Enum.Parse(typeof(LightTouchDataGridSelectionMode), mode); + + if (parsed == (LightTouchDataGridSelectionMode)value) + { + return true; + } + } + + return false; + } + + return false; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index c09d0ae2d..04408a95b 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -145,8 +145,11 @@ <Compile Include="Controls\LightTouchDataGrid.cs" /> <Compile Include="Controls\LightTouchDataGridCell.cs" /> <Compile Include="Controls\LightTouchDataGridColumn.cs" /> + <Compile Include="Controls\LightTouchDataGridHeaderRow.cs" /> <Compile Include="Controls\LightTouchDataGridRow.cs" /> + <Compile Include="Controls\LightTouchDataGridSelectionMode.cs" /> <Compile Include="Controls\TouchBusyIndicator.cs" /> + <Compile Include="Controls\TouchContentControl.cs" /> <Compile Include="Controls\TouchDataGridRow.cs" /> <Compile Include="Controls\TouchIconButton.cs" /> <Compile Include="Controls\TouchNavigationLinks.cs" /> @@ -161,6 +164,7 @@ <Compile Include="Converters\ColumnsToGridDefinitionsConverter.cs" /> <Compile Include="Converters\ColumnToColumnIndexConverter.cs" /> <Compile Include="Converters\LargeArcConverter.cs" /> + <Compile Include="Converters\LightTouchDataGridSelectionModesToBooleanConverter.cs" /> <Compile Include="Converters\LocalEx.cs" /> <Compile Include="Converters\NotZeroConverter.cs" /> <Compile Include="Converters\RotateTransformCentreConverter.cs" /> diff --git a/Software/Visual_Studio/TangoTouchWorkspace.sln b/Software/Visual_Studio/TangoTouchWorkspace.sln index b1fabf199..b768d7e53 100644 --- a/Software/Visual_Studio/TangoTouchWorkspace.sln +++ b/Software/Visual_Studio/TangoTouchWorkspace.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Touch", "Tango.Touch\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.UITests", "Utilities\Tango.UITests\Tango.UITests.csproj", "{5B954D98-4020-4AC6-939F-C52B5646E8E6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DragAndDrop", "Tango.DragAndDrop\Tango.DragAndDrop.csproj", "{B112D89A-A106-41AE-A0C1-4ABC84C477F5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {5B954D98-4020-4AC6-939F-C52B5646E8E6}.Debug|Any CPU.Build.0 = Debug|Any CPU {5B954D98-4020-4AC6-939F-C52B5646E8E6}.Release|Any CPU.ActiveCfg = Release|Any CPU {5B954D98-4020-4AC6-939F-C52B5646E8E6}.Release|Any CPU.Build.0 = Release|Any CPU + {B112D89A-A106-41AE-A0C1-4ABC84C477F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B112D89A-A106-41AE-A0C1-4ABC84C477F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B112D89A-A106-41AE-A0C1-4ABC84C477F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B112D89A-A106-41AE-A0C1-4ABC84C477F5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/App.xaml b/Software/Visual_Studio/Utilities/Tango.UITests/App.xaml index f0a9e77f7..75f8c4c28 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/App.xaml +++ b/Software/Visual_Studio/Utilities/Tango.UITests/App.xaml @@ -1,9 +1,57 @@ <Application x:Class="Tango.UITests.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:local="clr-namespace:Tango.UITests" StartupUri="MainWindow.xaml"> <Application.Resources> - <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchToggleButton.xaml" /> + <!--<ResourceDictionary> + <ResourceDictionary.MergedDictionaries>--> + + <ResourceDictionary> + + <ResourceDictionary.MergedDictionaries> + <!--Touch--> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Resources/Colors.xaml"/> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Resources/Fonts.xaml"/> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchToggleButton.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchButton.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchIconButton.xaml" /> + </ResourceDictionary.MergedDictionaries> + + <Style TargetType="{x:Type touch:LightTouchDataGridHeaderRow}" BasedOn="{StaticResource {x:Type touch:LightTouchDataGridHeaderRow}}"> + <Setter Property="Background" Value="{StaticResource TangoMidAccentBrush}"></Setter> + <Setter Property="Foreground" Value="{StaticResource TangoLightForegroundBrush}"></Setter> + <Setter Property="Height" Value="68"></Setter> + <Setter Property="Margin" Value="5 0 5 5"></Setter> + <Setter Property="CornerRadius" Value="5"></Setter> + <Setter Property="Effect"> + <Setter.Value> + <DropShadowEffect BlurRadius="5" ShadowDepth="1" Color="Silver" /> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="{x:Type touch:LightTouchDataGridRow}" BasedOn="{StaticResource {x:Type touch:LightTouchDataGridRow}}"> + <Setter Property="Background" Value="{StaticResource TangoPrimaryBackgroundBrush}"></Setter> + <Setter Property="Foreground" Value="{StaticResource TangoDarkForegroundBrush}"></Setter> + <Setter Property="Padding" Value="5"></Setter> + <Setter Property="CornerRadius" Value="5"></Setter> + <Setter Property="Margin" Value="5 4"></Setter> + <Setter Property="Height" Value="68"></Setter> + <Setter Property="Effect"> + <Setter.Value> + <DropShadowEffect BlurRadius="5" ShadowDepth="1" Color="Silver" /> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="{x:Type touch:LightTouchDataGridCell}" BasedOn="{StaticResource {x:Type touch:LightTouchDataGridCell}}"> + + </Style> + </ResourceDictionary> + + <!--</ResourceDictionary.MergedDictionaries> + </ResourceDictionary>--> </Application.Resources> </Application> diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml index c90aabe5f..cfea9140c 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml @@ -10,34 +10,15 @@ xmlns:keyboard="clr-namespace:Tango.Touch.Keyboard;assembly=Tango.Touch" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" mc:Ignorable="d" - Title="MainWindow" Height="500" Width="400" DataContext="{Binding RelativeSource={RelativeSource Self}}"> + Title="MainWindow" Height="800" Width="800" DataContext="{Binding RelativeSource={RelativeSource Self}}" Background="{StaticResource TangoMidBackgroundBrush}"> <Grid> - <touch:LightTouchDataGrid ItemsSource="{Binding Persons}" Margin="50" BorderThickness="1" BorderBrush="Black" OnDragAndDropCommand="{Binding DropCommand}"> - <touch:LightTouchDataGrid.CellStyle> - <Style TargetType="touch:LightTouchDataGridCell"> - <Setter Property="Padding" Value="10"></Setter> - </Style> - </touch:LightTouchDataGrid.CellStyle> - <touch:LightTouchDataGrid.HeadersRowStyle> - <Style TargetType="{x:Type touch:LightTouchDataGridRow}"> - <Setter Property="Background" Value="Gainsboro"></Setter> - <Setter Property="Padding" Value="10"></Setter> - <Setter Property="CornerRadius" Value="5"></Setter> - </Style> - </touch:LightTouchDataGrid.HeadersRowStyle> - - <touch:LightTouchDataGrid.RowStyle> - <Style TargetType="{x:Type touch:LightTouchDataGridRow}"> - <Setter Property="Background" Value="#F1F1F1"></Setter> - <Setter Property="Padding" Value="5"></Setter> - <Setter Property="CornerRadius" Value="5"></Setter> - <Setter Property="Margin" Value="0 2"></Setter> - </Style> - </touch:LightTouchDataGrid.RowStyle> + <Button HorizontalAlignment="Left" VerticalAlignment="Top" Click="Button_Click_1">ADD</Button> + + <touch:LightTouchDataGrid ItemsSource="{Binding Persons}" Margin="50" OnDragAndDropCommand="{Binding DropCommand}"> <touch:LightTouchDataGrid.Columns> - <touch:LightTouchDataGridColumn Foreground="Red" SortMember="FirstName"> + <touch:LightTouchDataGridColumn SortMember="FirstName"> <touch:LightTouchDataGridColumn.HeaderTemplate> <DataTemplate> <TextBlock Text="FIRST NAME"></TextBlock> @@ -53,7 +34,7 @@ <touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn.HeaderTemplate> <DataTemplate> - <TextBlock Text="LAST NAME" Foreground="Green"></TextBlock> + <TextBlock Text="LAST NAME"></TextBlock> </DataTemplate> </touch:LightTouchDataGridColumn.HeaderTemplate> <touch:LightTouchDataGridColumn.CellTemplate> @@ -66,7 +47,7 @@ <touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn.HeaderTemplate> <DataTemplate> - <TextBlock Text="AGE" Foreground="Blue"></TextBlock> + <TextBlock Text="AGE"></TextBlock> </DataTemplate> </touch:LightTouchDataGridColumn.HeaderTemplate> <touch:LightTouchDataGridColumn.CellTemplate> @@ -76,15 +57,30 @@ </touch:LightTouchDataGridColumn.CellTemplate> </touch:LightTouchDataGridColumn> - <touch:LightTouchDataGridColumn SortMember="Index"> + <touch:LightTouchDataGridColumn SortMember="Index" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" DisplayChevron="False"> <touch:LightTouchDataGridColumn.HeaderTemplate> <DataTemplate> - <TextBlock Text="DRAG" Foreground="Orange"></TextBlock> + <Border CornerRadius="0 5 5 0"> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="Opacity" Value="0.0"></Setter> + <Setter Property="Background" Value="Black"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding SortDirection}" Value="Ascending"> + <Setter Property="Opacity" Value="0.2"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding SortDirection}" Value="Descending"> + <Setter Property="Opacity" Value="0.5"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + </Border> </DataTemplate> </touch:LightTouchDataGridColumn.HeaderTemplate> <touch:LightTouchDataGridColumn.CellTemplate> <DataTemplate> - <dragAndDrop:DragThumb Background="Orange" Width="50" Height="50" components:Ripple.PreventRipple="True"> + <dragAndDrop:DragThumb Background="Transparent" components:Ripple.PreventRipple="True"> <TextBlock IsHitTestVisible="False" Text="{Binding Index}"></TextBlock> </dragAndDrop:DragThumb> </DataTemplate> diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs index 8dc2a96fa..b9cb9f2be 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs @@ -22,7 +22,7 @@ namespace Tango.UITests { public class Person : ExtendedObject { - public String FirstName { get; set; } + public String FirstName { get; set; } public String LastName { get; set; } private int _index; @@ -57,7 +57,7 @@ namespace Tango.UITests { Persons = new ObservableCollection<Person>(); - for (int i = 1; i < 100; i++) + for (int i = 1; i < 10; i++) { Persons.Add(new Person() { @@ -89,5 +89,16 @@ namespace Tango.UITests { MessageBox.Show("Done"); } + + private void Button_Click_1(object sender, RoutedEventArgs e) + { + Persons.Add(new Person() + { + FirstName = "New", + LastName = "Person", + Age = 200, + Index = 0 + }); + } } } |
