aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-05-29 19:44:54 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-05-29 19:44:54 +0300
commitac9090470eba25bb3c789f0e87ecf70e6a7be55f (patch)
tree0b26051e6af32d7c7181024ef942da6c36c7467e
parent378789e4c4bc694736965cb8c620883bf91b8f08 (diff)
downloadTango-ac9090470eba25bb3c789f0e87ecf70e6a7be55f.tar.gz
Tango-ac9090470eba25bb3c789f0e87ecf70e6a7be55f.zip
Working on Mouse/Touch synchronization!
-rw-r--r--Software/DB/Tango.mdfbin75497472 -> 75497472 bytes
-rw-r--r--Software/DB/Tango_log.ldfbin1572864 -> 1572864 bytes
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs6
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml19
-rw-r--r--Software/Visual_Studio/Tango.Core/EventArguments/MouseOrTouchEventArgs.cs25
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs119
-rw-r--r--Software/Visual_Studio/Tango.Core/Tango.Core.csproj2
-rw-r--r--Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs37
-rw-r--r--Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs20
-rw-r--r--Software/Visual_Studio/Tango.DragAndDrop/Tango.DragAndDrop.csproj5
-rw-r--r--Software/Visual_Studio/Tango.Touch/Components/Ripple.cs7
-rw-r--r--Software/Visual_Studio/Tango.Touch/Components/Ripple.xaml2
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.cs27
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml46
-rw-r--r--Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj4
16 files changed, 275 insertions, 46 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf
index 20cac8115..376c4cc54 100644
--- a/Software/DB/Tango.mdf
+++ b/Software/DB/Tango.mdf
Binary files differ
diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf
index b2c009e25..655eb2ca8 100644
--- a/Software/DB/Tango_log.ldf
+++ b/Software/DB/Tango_log.ldf
Binary files differ
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
index 9ca7a86b4..7ccdaa1f9 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
@@ -169,11 +169,9 @@
<ItemGroup>
<Content Include="..\..\..\DB\Tango.mdf">
<Link>DB\Tango.mdf</Link>
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\DB\Tango_log.ldf">
<Link>DB\Tango_log.ldf</Link>
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs
index 357d15171..3890686dc 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs
@@ -18,9 +18,9 @@ namespace Tango.PPC.UI
{
base.OnStartup(e);
- var s = SettingsManager.Default.GetOrCreate<Core.CoreSettings>();
- s.SQLServerAddress = "DB\\Tango.mdf";
- s.Save();
+ //var s = SettingsManager.Default.GetOrCreate<Core.CoreSettings>();
+ //s.SQLServerAddress = "DB\\Tango.mdf";
+ //s.Save();
}
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml
index c460e3b1e..1a62a9552 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml
@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels"
xmlns:global="clr-namespace:Tango.PPC.UI"
+ xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop"
xmlns:keyboard="clr-namespace:Tango.SharedUI.Keyboard;assembly=Tango.SharedUI"
xmlns:converters="clr-namespace:Tango.PPC.Common.Converters;assembly=Tango.PPC.Common"
xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch"
@@ -20,7 +21,7 @@
<sharedConverters:DateTimeUTCToShortDateConverter x:Key="DateTimeUTCToShortDateConverter" />
<sharedConverters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" />
</UserControl.Resources>
-
+
<Grid Background="{StaticResource TangoMidBackgroundBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="82"/>
@@ -94,9 +95,9 @@
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
- <StackPanel Width="30">
- <StackPanel.Style>
- <Style TargetType="StackPanel">
+ <dragAndDrop:DragThumb Height="30">
+ <dragAndDrop:DragThumb.Style>
+ <Style TargetType="dragAndDrop:DragThumb">
<Setter Property="Visibility" Value="Collapsed"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Reference userSortColumn},Path=SortDirection}" Value="Ascending">
@@ -104,10 +105,12 @@
</DataTrigger>
</Style.Triggers>
</Style>
- </StackPanel.Style>
- <Rectangle StrokeThickness="2" Stroke="{StaticResource TangoDarkForegroundBrush}" />
- <Rectangle StrokeThickness="2" Stroke="{StaticResource TangoDarkForegroundBrush}" Margin="0 5 0 0" />
- </StackPanel>
+ </dragAndDrop:DragThumb.Style>
+ <StackPanel Width="30" IsHitTestVisible="False" VerticalAlignment="Center">
+ <Rectangle StrokeThickness="2" Stroke="{StaticResource TangoDarkForegroundBrush}" />
+ <Rectangle StrokeThickness="2" Stroke="{StaticResource TangoDarkForegroundBrush}" Margin="0 5 0 0" />
+ </StackPanel>
+ </dragAndDrop:DragThumb>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
diff --git a/Software/Visual_Studio/Tango.Core/EventArguments/MouseOrTouchEventArgs.cs b/Software/Visual_Studio/Tango.Core/EventArguments/MouseOrTouchEventArgs.cs
new file mode 100644
index 000000000..b2c09e41d
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Core/EventArguments/MouseOrTouchEventArgs.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+
+namespace Tango.Core.EventArguments
+{
+ public class MouseOrTouchEventArgs : EventArgs
+ {
+ public Point Location { get; set; }
+ public Object Source { get; set; }
+ public Object OriginalSource { get; set; }
+ internal Func<IInputElement, Point> GetPositionAction { get; set; }
+ public bool Handled { get; set; }
+ public TouchDevice TouchDevice { get; set; }
+
+ public Point GetPosition(IInputElement relativeTo)
+ {
+ return GetPositionAction(relativeTo);
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs
new file mode 100644
index 000000000..8e0b9239d
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs
@@ -0,0 +1,119 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using Tango.Core.EventArguments;
+
+public static class FrameworkElementExtensions
+{
+ public static void RegisterForPreviewMouseOrTouchDown(this FrameworkElement element, FrameworkElement relativeTo, EventHandler<MouseOrTouchEventArgs> handler)
+ {
+ bool mousePressed = false;
+ bool touchDown = false;
+
+ element.PreviewMouseDown += (x, e) =>
+ {
+ if (!touchDown)
+ {
+ mousePressed = true;
+
+ var args = new MouseOrTouchEventArgs()
+ {
+ Location = new Point(e.GetPosition(relativeTo != null ? relativeTo : element).X, e.GetPosition(relativeTo != null ? relativeTo : element).Y),
+ Source = e.Source,
+ OriginalSource = e.OriginalSource,
+ Handled = e.Handled,
+ GetPositionAction = e.GetPosition
+ };
+
+ handler(element, args);
+ e.Handled = args.Handled;
+ }
+ else
+ {
+ touchDown = false;
+ }
+ };
+
+ element.PreviewTouchDown += (x, e) =>
+ {
+ if (!mousePressed)
+ {
+ touchDown = true;
+
+ var args = new MouseOrTouchEventArgs()
+ {
+ Location = new Point(e.GetTouchPoint(relativeTo != null ? relativeTo : element).Position.X, e.GetTouchPoint(relativeTo != null ? relativeTo : element).Position.Y),
+ Source = e.Source,
+ OriginalSource = e.OriginalSource,
+ Handled = e.Handled,
+ GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; },
+ };
+
+ handler(element, args);
+ e.Handled = args.Handled;
+ }
+ else
+ {
+ touchDown = false;
+ }
+ };
+
+ element.PreviewMouseUp += (_, __) =>
+ {
+ touchDown = false;
+ mousePressed = false;
+ };
+
+ element.PreviewTouchDown += (_, __) =>
+ {
+
+ };
+ }
+
+ public static void RegisterForPreviewMouseOrTouchDown(this FrameworkElement element, EventHandler<MouseOrTouchEventArgs> handler)
+ {
+ RegisterForPreviewMouseOrTouchDown(element, null, handler);
+ }
+
+ public static void RegisterForMouseOrTouchMove(this FrameworkElement element, FrameworkElement relativeTo, EventHandler<MouseOrTouchEventArgs> handler)
+ {
+ element.MouseMove += (x, e) =>
+ {
+ var args = new MouseOrTouchEventArgs()
+ {
+ Location = new Point(e.GetPosition(relativeTo != null ? relativeTo : element).X, e.GetPosition(relativeTo != null ? relativeTo : element).Y),
+ Source = e.Source,
+ OriginalSource = e.OriginalSource,
+ Handled = e.Handled,
+ GetPositionAction = e.GetPosition
+ };
+
+ handler(element, args);
+ e.Handled = args.Handled;
+ };
+
+ element.TouchMove += (x, e) =>
+ {
+ var args = new MouseOrTouchEventArgs()
+ {
+ Location = new Point(e.GetTouchPoint(relativeTo != null ? relativeTo : element).Position.X, e.GetTouchPoint(relativeTo != null ? relativeTo : element).Position.Y),
+ Source = e.Source,
+ OriginalSource = e.OriginalSource,
+ Handled = e.Handled,
+ GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; },
+ TouchDevice = e.TouchDevice,
+ };
+
+ handler(element, args);
+ e.Handled = args.Handled;
+ };
+ }
+
+ public static void RegisterForMouseOrTouchMove(this FrameworkElement element, EventHandler<MouseOrTouchEventArgs> handler)
+ {
+ RegisterForMouseOrTouchMove(element, null, handler);
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj
index b68925208..76ed595fa 100644
--- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj
+++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj
@@ -70,6 +70,7 @@
<Compile Include="DI\TangoInjectAttribute.cs" />
<Compile Include="DI\TangoIOC.cs" />
<Compile Include="DI\TangoMessenger.cs" />
+ <Compile Include="EventArguments\MouseOrTouchEventArgs.cs" />
<Compile Include="ExtendedObject.cs" />
<Compile Include="ExtensionMethods\BitmapExtensions.cs" />
<Compile Include="ExtensionMethods\BitmapSourceExtensions.cs" />
@@ -77,6 +78,7 @@
<Compile Include="ExtensionMethods\DependencyObjectExtensions.cs" />
<Compile Include="ExtensionMethods\EnumExtensions.cs" />
<Compile Include="ExtensionMethods\ExceptionExtensions.cs" />
+ <Compile Include="ExtensionMethods\FrameworkElementExtensions.cs" />
<Compile Include="ExtensionMethods\ObservableCollectionExtensions.cs" />
<Compile Include="ExtensionMethods\IEnumerableExtensions.cs" />
<Compile Include="ExtensionMethods\IMessageExtensions.cs" />
diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
index 606e8a2e5..60da36590 100644
--- a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
+++ b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
@@ -11,6 +11,7 @@ using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
+using Tango.Core.EventArguments;
using Tango.SharedUI.Helpers;
namespace Tango.DragAndDrop
@@ -489,9 +490,14 @@ namespace Tango.DragAndDrop
{
_dragElements.Add(element);
- element.PreviewMouseDown += Draggable_PreviewMouseDown;
- element.MouseMove += Draggable_MouseMove;
+ element.RegisterForPreviewMouseOrTouchDown(Draggable_PreviewMouseDown);
+ element.RegisterForMouseOrTouchMove(Draggable_MouseMove);
element.PreviewMouseUp += Draggable_PreviewMouseUp;
+ element.IsManipulationEnabled = true;
+
+ //element.AddHandler(FrameworkElement.PreviewMouseDownEvent, (MouseButtonEventHandler)Draggable_PreviewMouseDown, true);
+ //element.AddHandler(FrameworkElement.MouseMoveEvent, (MouseEventHandler)Draggable_MouseMove, true);
+ //element.AddHandler(FrameworkElement.PreviewMouseUpEvent, (MouseButtonEventHandler)Draggable_PreviewMouseUp, true);
element.Unloaded += Element_Unloaded;
}
}
@@ -630,14 +636,14 @@ namespace Tango.DragAndDrop
#region Draggable Event Handlers
- /// <summary>
- /// Handles the PreviewMouseDown event of the Draggable control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param>
- private static void Draggable_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ private static void Draggable_PreviewMouseDown(object sender, MouseOrTouchEventArgs e)
{
- if (e.Source != sender) return;
+ var dragThumb = (sender as FrameworkElement).FindChild<DragThumb>();
+
+ if ((e.Source != sender && dragThumb == null) || (dragThumb != null && dragThumb != e.OriginalSource))
+ {
+ return;
+ }
FrameworkElement element = sender as FrameworkElement;
@@ -652,13 +658,17 @@ namespace Tango.DragAndDrop
_isMouseDown = true;
}
+
+
/// <summary>
/// Handles the MouseMove event of the Draggable control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Windows.Input.MouseEventArgs"/> instance containing the event data.</param>
- private static void Draggable_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
+ private static void Draggable_MouseMove(object sender, MouseOrTouchEventArgs e)
{
+ Debug.WriteLine(e.GetPosition(_currentDragedElement));
+
if (_isMouseDown)
{
FrameworkElement element = _currentDragedElement;
@@ -673,6 +683,13 @@ namespace Tango.DragAndDrop
{
element.ReleaseMouseCapture();
surface.ReleaseMouseCapture();
+
+ if (e.TouchDevice != null)
+ {
+ element.ReleaseTouchCapture(e.TouchDevice);
+ surface.ReleaseTouchCapture(e.TouchDevice);
+ }
+
_isMouseDown = false;
CreateDraggingElement();
_dragTimer.Start();
diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs
new file mode 100644
index 000000000..952c35bb5
--- /dev/null
+++ b/Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace Tango.DragAndDrop
+{
+ public class DragThumb : Grid
+ {
+ public DragThumb()
+ {
+ Background = Brushes.Transparent;
+ IsHitTestVisible = true;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.DragAndDrop/Tango.DragAndDrop.csproj b/Software/Visual_Studio/Tango.DragAndDrop/Tango.DragAndDrop.csproj
index 324bf9f90..771ed8079 100644
--- a/Software/Visual_Studio/Tango.DragAndDrop/Tango.DragAndDrop.csproj
+++ b/Software/Visual_Studio/Tango.DragAndDrop/Tango.DragAndDrop.csproj
@@ -69,6 +69,7 @@
</Compile>
<Compile Include="DragAndDropService.cs" />
<Compile Include="DraggingSurface.cs" />
+ <Compile Include="DragThumb.cs" />
<Compile Include="DropEventArgs.cs" />
</ItemGroup>
<ItemGroup>
@@ -98,6 +99,10 @@
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\Tango.Core\Tango.Core.csproj">
+ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project>
+ <Name>Tango.Core</Name>
+ </ProjectReference>
<ProjectReference Include="..\Tango.SharedUI\Tango.SharedUI.csproj">
<Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project>
<Name>Tango.SharedUI</Name>
diff --git a/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs b/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs
index 95e51c576..ae0b693af 100644
--- a/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs
+++ b/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs
@@ -104,12 +104,13 @@ namespace Tango.Touch.Components
//parent.TouchMove += (_, __) => CancelRipple();
//parent.PreviewTouchUp += Parent_PreviewTouchUp;
+ parent.RegisterForPreviewMouseOrTouchDown(this, (x, e) => OnRippleDown(e.Location));
//parent.PreviewMouseDown += Parent_PreviewMouseDown;
- parent.PreviewTouchDown += Parent_PreviewTouchDown;
+ //parent.PreviewTouchDown += Parent_PreviewTouchDown;
//parent.TouchMove += (_, __) => CancelRipple();
- //parent.PreviewMouseUp += Parent_PreviewMouseUp;
- parent.PreviewTouchUp += Parent_PreviewTouchUp;
+ parent.PreviewMouseUp += Parent_PreviewMouseUp;
+ //parent.PreviewTouchUp += Parent_PreviewTouchUp;
}
private void Parent_PreviewMouseUp(object sender, MouseButtonEventArgs e)
diff --git a/Software/Visual_Studio/Tango.Touch/Components/Ripple.xaml b/Software/Visual_Studio/Tango.Touch/Components/Ripple.xaml
index e2aaefd67..353f106cf 100644
--- a/Software/Visual_Studio/Tango.Touch/Components/Ripple.xaml
+++ b/Software/Visual_Studio/Tango.Touch/Components/Ripple.xaml
@@ -27,7 +27,7 @@
</Border.Clip>
<Grid x:Name="PART_grid">
<ContentPresenter Content="{TemplateBinding Content}" />
- <Canvas>
+ <Canvas IsHitTestVisible="False">
<Ellipse IsHitTestVisible="False" x:Name="PART_ellipse" RenderTransformOrigin="0.5,0.5" Fill="{TemplateBinding RippleBrush}" HorizontalAlignment="Center" VerticalAlignment="Center" Height="{TemplateBinding ActualHeight}" Width="{TemplateBinding ActualHeight}">
<Ellipse.RenderTransform>
<ScaleTransform x:Name="PART_scale" ScaleX="0" ScaleY="0"></ScaleTransform>
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.cs
index cf941f069..50d041b9d 100644
--- a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.cs
+++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.cs
@@ -12,6 +12,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using Tango.DragAndDrop;
namespace Tango.Touch.Controls
{
@@ -57,9 +58,35 @@ namespace Tango.Touch.Controls
public static readonly DependencyProperty ShadowColorProperty =
DependencyProperty.Register("ShadowColor", typeof(Color), typeof(TouchDataGrid), new PropertyMetadata(Colors.Gray));
+ public bool IsDraggable
+ {
+ get { return (bool)GetValue(IsDraggableProperty); }
+ set { SetValue(IsDraggableProperty, value); }
+ }
+ public static readonly DependencyProperty IsDraggableProperty =
+ DependencyProperty.Register("IsDraggable", typeof(bool), typeof(TouchDataGrid), new PropertyMetadata(true));
+
+ public DraggingSurface DraggingSurface
+ {
+ get { return (DraggingSurface)GetValue(DraggingSurfaceProperty); }
+ set { SetValue(DraggingSurfaceProperty, value); }
+ }
+ public static readonly DependencyProperty DraggingSurfaceProperty =
+ DependencyProperty.Register("DraggingSurface", typeof(DraggingSurface), typeof(TouchDataGrid), new PropertyMetadata(null));
+
static TouchDataGrid()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchDataGrid), new FrameworkPropertyMetadata(typeof(TouchDataGrid)));
}
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ DraggingSurface = GetTemplateChild("PART_DraggingSurface") as DraggingSurface;
+ ScrollViewer scrollViewer = GetTemplateChild("DG_ScrollViewer") as ScrollViewer;
+
+ scrollViewer.IsManipulationEnabled = false;
+ }
}
}
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml
index e793b094c..b4a822c7c 100644
--- a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml
+++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml
@@ -3,6 +3,7 @@
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:surface="http://schemas.microsoft.com/surface/2008"
xmlns:components="clr-namespace:Tango.Touch.Components"
+ xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop"
xmlns:local="clr-namespace:Tango.Touch.Controls">
<ResourceDictionary.MergedDictionaries>
@@ -83,23 +84,28 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
- <components:Ripple SynchedScrollViewer="{Binding RelativeSource={RelativeSource AncestorType=ScrollViewer}}" CornerRadius="{Binding RelativeSource={RelativeSource AncestorType=local:TouchDataGrid},Path=CornerRadius}" RippleBrush="{StaticResource RippleDarkBrush}">
- <Border x:Name="DGR_Border" Margin="5 2" Style="{StaticResource DropShadowBorder}" BorderBrush="{StaticResource TangoLightBorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
- <SelectiveScrollingGrid>
- <SelectiveScrollingGrid.ColumnDefinitions>
- <ColumnDefinition Width="Auto"/>
- <ColumnDefinition Width="*"/>
- </SelectiveScrollingGrid.ColumnDefinitions>
- <SelectiveScrollingGrid.RowDefinitions>
- <RowDefinition Height="*"/>
- <RowDefinition Height="Auto"/>
- </SelectiveScrollingGrid.RowDefinitions>
- <DataGridCellsPresenter Grid.Column="1" ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
- <DataGridDetailsPresenter Grid.Column="1" Grid.Row="1" SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Visibility="{TemplateBinding DetailsVisibility}"/>
- <DataGridRowHeader Grid.RowSpan="2" SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
- </SelectiveScrollingGrid>
- </Border>
- </components:Ripple>
+ <Grid
+ dragAndDrop:DragAndDropService.Draggable="{Binding RelativeSource={RelativeSource AncestorType=local:TouchDataGrid},Path=IsDraggable}"
+ dragAndDrop:DragAndDropService.Droppable="{Binding RelativeSource={RelativeSource AncestorType=local:TouchDataGrid},Path=IsDraggable}"
+ dragAndDrop:DragAndDropService.DraggingSurface="{Binding RelativeSource={RelativeSource AncestorType=local:TouchDataGrid},Path=DraggingSurface}">
+ <components:Ripple SynchedScrollViewer="{Binding RelativeSource={RelativeSource AncestorType=ScrollViewer}}" CornerRadius="{Binding RelativeSource={RelativeSource AncestorType=local:TouchDataGrid},Path=CornerRadius}" RippleBrush="{StaticResource RippleDarkBrush}">
+ <Border x:Name="DGR_Border" Margin="5 2" Style="{StaticResource DropShadowBorder}" BorderBrush="{StaticResource TangoLightBorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
+ <SelectiveScrollingGrid>
+ <SelectiveScrollingGrid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto"/>
+ <ColumnDefinition Width="*"/>
+ </SelectiveScrollingGrid.ColumnDefinitions>
+ <SelectiveScrollingGrid.RowDefinitions>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="Auto"/>
+ </SelectiveScrollingGrid.RowDefinitions>
+ <DataGridCellsPresenter Grid.Column="1" ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
+ <DataGridDetailsPresenter Grid.Column="1" Grid.Row="1" SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Visibility="{TemplateBinding DetailsVisibility}"/>
+ <DataGridRowHeader Grid.RowSpan="2" SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
+ </SelectiveScrollingGrid>
+ </Border>
+ </components:Ripple>
+ </Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
@@ -160,7 +166,7 @@
<ControlTemplate TargetType="{x:Type local:TouchDataGrid}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
<DockPanel>
- <ScrollViewer x:Name="DG_ScrollViewer" Focusable="false" Style="{StaticResource TouchScrollViewer}">
+ <ScrollViewer x:Name="DG_ScrollViewer" Focusable="false" Style="{StaticResource TouchScrollViewer}" IsManipulationEnabled="False">
<ScrollViewer.Template>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid>
@@ -168,7 +174,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
-
+
<DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Margin="{TemplateBinding Padding}" Grid.Row="1"/>
<ScrollBar Opacity="0" Grid.Row="1" x:Name="PART_VerticalScrollBar" Style="{StaticResource TouchScrollBar}" HorizontalAlignment="Right" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
@@ -193,6 +199,8 @@
</ScrollViewer.Template>
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
+
+ <dragAndDrop:DraggingSurface x:Name="PART_DraggingSurface" />
</DockPanel>
</Border>
</ControlTemplate>
diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj
index 547c90cc8..386ede511 100644
--- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj
+++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj
@@ -180,6 +180,10 @@
<Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project>
<Name>Tango.Core</Name>
</ProjectReference>
+ <ProjectReference Include="..\Tango.DragAndDrop\Tango.DragAndDrop.csproj">
+ <Project>{b112d89a-a106-41ae-a0c1-4abc84c477f5}</Project>
+ <Name>Tango.DragAndDrop</Name>
+ </ProjectReference>
<ProjectReference Include="..\Tango.SharedUI\Tango.SharedUI.csproj">
<Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project>
<Name>Tango.SharedUI</Name>