From f7e395b76baffb654b0527cb5aa96de8defbd577 Mon Sep 17 00:00:00 2001 From: morkt Date: Fri, 3 Jun 2016 18:16:40 +0400 Subject: [PATCH] override cursor within image preview pane. --- GUI/DragScroll.cs | 24 ++++++++++++++++++++++-- GUI/GARbro.GUI.csproj | 6 ++++++ GUI/MainWindow.xaml | 3 ++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/GUI/DragScroll.cs b/GUI/DragScroll.cs index 252045ca..ce13fefe 100644 --- a/GUI/DragScroll.cs +++ b/GUI/DragScroll.cs @@ -24,6 +24,16 @@ namespace GARbro.GUI { obj.SetValue(IsEnabledProperty, value); } + + public static Cursor GetDraggingCursor (UIElement e) + { + return (Cursor)e.GetValue (DraggingCursorProperty); + } + + public static void SetDraggingCursor (UIElement e, Cursor value) + { + e.SetValue (DraggingCursorProperty, value); + } public bool IsEnabled { @@ -31,8 +41,16 @@ namespace GARbro.GUI set { SetValue(IsEnabledProperty, value); } } + public Cursor DraggingCursor + { + get { return (Cursor)GetValue (DraggingCursorProperty); } + set { SetValue (DraggingCursorProperty, value); } + } + public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached("IsEnabled", typeof(bool), typeof(TouchScrolling), new UIPropertyMetadata(false, IsEnabledChanged)); + public static readonly DependencyProperty DraggingCursorProperty = + DependencyProperty.RegisterAttached("DraggingCursor", typeof(Cursor), typeof(TouchScrolling)); static Dictionary _captures = new Dictionary(); @@ -109,7 +127,7 @@ namespace GARbro.GUI if (target == null) return; target.ReleaseMouseCapture(); - target.Cursor = Cursors.Arrow; + Mouse.OverrideCursor = null; } static void target_PreviewMouseMove(object sender, MouseEventArgs e) @@ -138,7 +156,9 @@ namespace GARbro.GUI if (System.Math.Abs(dy) > 5 || System.Math.Abs(dx) > 5) { target.CaptureMouse(); - target.Cursor = Cursors.SizeAll; + var cursor = target.GetValue (DraggingCursorProperty) as Cursor; + if (cursor != null) + Mouse.OverrideCursor = cursor; } scroller.ScrollToHorizontalOffset(capture.HorizontalOffset - dx); scroller.ScrollToVerticalOffset(capture.VerticalOffset - dy); diff --git a/GUI/GARbro.GUI.csproj b/GUI/GARbro.GUI.csproj index 8b8e189f..2ffb9129 100644 --- a/GUI/GARbro.GUI.csproj +++ b/GUI/GARbro.GUI.csproj @@ -271,6 +271,12 @@ false + + + + + + perl "$(SolutionDir)inc-revision.pl" "$(ProjectPath)" $(ConfigurationName) "$(SolutionDir)\" diff --git a/GUI/MainWindow.xaml b/GUI/MainWindow.xaml index 64850936..0db0295e 100644 --- a/GUI/MainWindow.xaml +++ b/GUI/MainWindow.xaml @@ -343,7 +343,8 @@ + local:TouchScrolling.IsEnabled="True" RenderOptions.BitmapScalingMode="NearestNeighbor" + Cursor="Images/Cursors/grab.cur" local:TouchScrolling.DraggingCursor="Images/Cursors/grabbing.cur" />