XAML-Map-Control/SampleApps/AvaloniaApp/MainWindow.axaml.cs

48 lines
1.3 KiB
C#
Raw Normal View History

2024-05-24 15:28:28 +02:00
using Avalonia.Controls;
using Avalonia.Input;
using MapControl;
using System.Diagnostics;
using System.Linq;
2024-05-24 15:28:28 +02:00
2024-05-27 11:10:10 +02:00
namespace SampleApplication
2024-05-24 15:28:28 +02:00
{
public partial class MainWindow : Window
{
static MainWindow()
{
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder);
}
public MainWindow()
{
InitializeComponent();
AddBingMapsLayers();
2024-05-29 17:19:03 +02:00
AddTestLayers();
2024-05-28 18:56:28 +02:00
}
partial void AddBingMapsLayers();
2024-05-29 17:19:03 +02:00
partial void AddTestLayers();
2024-05-28 18:56:28 +02:00
2024-05-31 22:45:50 +02:00
private void MapItemsControlSelectionChanged(object sender, SelectionChangedEventArgs e)
{
Debug.WriteLine("SelectedItems: " + string.Join(", ", ((MapItemsControl)sender).SelectedItems.OfType<PointItem>().Select(item => item.Name)));
}
private void MapItemsControlDoubleTapped(object sender, TappedEventArgs e)
2024-05-29 20:29:45 +02:00
{
e.Handled = true; // prevent MapDoubleTapped
2024-05-29 20:29:45 +02:00
}
private void MapDoubleTapped(object sender, TappedEventArgs e)
2024-05-28 18:56:28 +02:00
{
2024-05-29 17:19:03 +02:00
map.TargetCenter = map.ViewToLocation(e.GetPosition(map));
2024-05-28 18:56:28 +02:00
}
2024-05-29 17:19:03 +02:00
private void ResetHeadingButtonClick(object sender, Avalonia.Interactivity.RoutedEventArgs e)
2024-05-28 18:56:28 +02:00
{
2024-05-29 17:19:03 +02:00
map.TargetHeading = 0d;
2024-05-24 15:28:28 +02:00
}
}
}