override cursor within image preview pane.

This commit is contained in:
morkt 2016-06-03 18:16:40 +04:00
parent 07eb5c07f0
commit f7e395b76b
3 changed files with 30 additions and 3 deletions

View File

@ -25,14 +25,32 @@ 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
{
get { return (bool)GetValue(IsEnabledProperty); }
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<object, MouseCapture> _captures = new Dictionary<object, MouseCapture>();
@ -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);

View File

@ -271,6 +271,12 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Cursors\grab.cur" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Cursors\grabbing.cur" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>perl "$(SolutionDir)inc-revision.pl" "$(ProjectPath)" $(ConfigurationName) "$(SolutionDir)\"

View File

@ -343,7 +343,8 @@
<Grid Grid.Column="2" Name="PreviewPane" SnapsToDevicePixels="True">
<ScrollViewer Name="ImageView" Background="LightGray" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<Image Name="ImageCanvas" Stretch="None" UseLayoutRounding="True" SnapsToDevicePixels="True"
local:TouchScrolling.IsEnabled="True" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
local:TouchScrolling.IsEnabled="True" RenderOptions.BitmapScalingMode="NearestNeighbor"
Cursor="Images/Cursors/grab.cur" local:TouchScrolling.DraggingCursor="Images/Cursors/grabbing.cur" />
</ScrollViewer>
<jv:TextViewer x:Name="TextView" Visibility="Collapsed" BorderThickness="1,0,0,0" BorderBrush="Black"/>
</Grid>