Sample Application Cursors

This commit is contained in:
ClemensFischer 2024-08-24 23:12:35 +02:00
parent dae7893642
commit 97b5288e29
3 changed files with 23 additions and 5 deletions

View file

@ -52,13 +52,18 @@ namespace SampleApplication
{
var point = e.GetCurrentPoint(map);
if (point.Properties.IsRightButtonPressed)
if (point.Properties.IsLeftButtonPressed)
{
map.Cursor = new Cursor(StandardCursorType.Hand);
}
else if (point.Properties.IsRightButtonPressed)
{
e.Pointer.Capture(map);
var location = map.ViewToLocation(point.Position);
if (location != null)
{
map.Cursor = new Cursor(StandardCursorType.Cross);
measurementLine.IsVisible = true;
measurementLine.Locations = new LocationCollection(location);
}
@ -74,6 +79,8 @@ namespace SampleApplication
measurementLine.IsVisible = false;
measurementLine.Locations = null;
}
map.Cursor = null;
}
private void MapPointerMoved(object sender, PointerEventArgs e)
@ -131,7 +138,7 @@ namespace SampleApplication
lonHemisphere, longitude / 60000, (longitude % 60000) / 1000d);
}
private string GetDistanceText(double distance)
private static string GetDistanceText(double distance)
{
var unit = "m";

View file

@ -118,6 +118,7 @@
MinZoomLevel="2" MaxZoomLevel="21" ZoomLevel="11"
Center="53.5,8.2" ManipulationMode="All"
MouseLeftButtonDown="MapMouseLeftButtonDown"
MouseLeftButtonUp="MapMouseLeftButtonUp"
MouseRightButtonDown="MapMouseRightButtonDown"
MouseRightButtonUp="MapMouseRightButtonUp"
MouseMove="MapMouseMove"

View file

@ -5,7 +5,6 @@ using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
namespace SampleApplication
@ -19,7 +18,7 @@ namespace SampleApplication
//TileImageLoader.Cache = new MapControl.Caching.SQLiteCache(TileImageLoader.DefaultCacheFolder);
//TileImageLoader.Cache = new RedisCache(Options.Create(new RedisCacheOptions
//{
// Configuration = "T400:6379",
// Configuration = "yoga:6379",
// InstanceName = "MapTileCache/"
//}));
}
@ -56,6 +55,15 @@ namespace SampleApplication
{
Debug.WriteLine(await wmsLayer.GetFeatureInfoAsync(e.GetPosition(map)));
}
else
{
map.Cursor = Cursors.ScrollAll;
}
}
private void MapMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
map.Cursor = null;
}
private void MapMouseRightButtonDown(object sender, MouseButtonEventArgs e)
@ -64,6 +72,7 @@ namespace SampleApplication
if (location != null && map.CaptureMouse())
{
map.Cursor = Cursors.Cross;
measurementLine.Visibility = Visibility.Visible;
measurementLine.Locations = new LocationCollection(location);
}
@ -72,6 +81,7 @@ namespace SampleApplication
private void MapMouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
map.ReleaseMouseCapture();
map.Cursor = null;
measurementLine.Visibility = Visibility.Collapsed;
measurementLine.Locations = null;
}
@ -143,7 +153,7 @@ namespace SampleApplication
lonHemisphere, longitude / 60000, (longitude % 60000) / 1000d);
}
private string GetDistanceText(double distance)
private static string GetDistanceText(double distance)
{
var unit = "m";