2013-05-07 18:12:25 +02:00
|
|
|
|
using System;
|
2013-04-12 19:59:16 +02:00
|
|
|
|
using System.Globalization;
|
2013-11-12 21:14:53 +01:00
|
|
|
|
using System.Runtime.Caching;
|
2012-05-04 12:52:20 +02:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
using System.Windows.Input;
|
2013-05-07 18:12:25 +02:00
|
|
|
|
using Caching;
|
|
|
|
|
|
using MapControl;
|
2012-05-04 12:52:20 +02:00
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
namespace WpfApplication
|
2012-05-04 12:52:20 +02:00
|
|
|
|
{
|
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
|
|
{
|
|
|
|
|
|
public MainWindow()
|
|
|
|
|
|
{
|
2012-08-15 21:31:10 +02:00
|
|
|
|
switch (Properties.Settings.Default.TileCache)
|
2012-07-03 18:03:56 +02:00
|
|
|
|
{
|
2013-11-12 21:14:53 +01:00
|
|
|
|
case "MemoryCache":
|
|
|
|
|
|
TileImageLoader.Cache = MemoryCache.Default;
|
|
|
|
|
|
break;
|
2012-08-15 21:31:10 +02:00
|
|
|
|
case "FileDbCache":
|
|
|
|
|
|
TileImageLoader.Cache = new FileDbCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheDirectory);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "ImageFileCache":
|
|
|
|
|
|
TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheDirectory);
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
2012-07-03 18:03:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-05-04 12:52:20 +02:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
private void MapMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
2012-05-04 12:52:20 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
if (e.ClickCount == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
map.ZoomMap(e.GetPosition(map), Math.Floor(map.ZoomLevel + 1.5));
|
|
|
|
|
|
//map.TargetCenter = map.ViewportPointToLocation(e.GetPosition(map));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void MapMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.ClickCount == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
map.ZoomMap(e.GetPosition(map), Math.Ceiling(map.ZoomLevel - 1.5));
|
|
|
|
|
|
}
|
2012-05-04 12:52:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void MapMouseLeave(object sender, MouseEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
mouseLocation.Text = string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void MapMouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
|
{
|
2013-04-12 19:59:16 +02:00
|
|
|
|
var location = map.ViewportPointToLocation(e.GetPosition(map));
|
|
|
|
|
|
var longitude = Location.NormalizeLongitude(location.Longitude);
|
|
|
|
|
|
var latString = location.Latitude < 0 ?
|
|
|
|
|
|
string.Format(CultureInfo.InvariantCulture, "S {0:00.00000}", -location.Latitude) :
|
|
|
|
|
|
string.Format(CultureInfo.InvariantCulture, "N {0:00.00000}", location.Latitude);
|
|
|
|
|
|
var lonString = longitude < 0 ?
|
|
|
|
|
|
string.Format(CultureInfo.InvariantCulture, "W {0:000.00000}", -longitude) :
|
|
|
|
|
|
string.Format(CultureInfo.InvariantCulture, "E {0:000.00000}", longitude);
|
|
|
|
|
|
mouseLocation.Text = latString + "\n" + lonString;
|
2012-05-04 12:52:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
private void MapManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
e.TranslationBehavior.DesiredDeceleration = 0.001;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-11-17 16:52:03 +01:00
|
|
|
|
private void MapItemTouchDown(object sender, TouchEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var mapItem = (MapItem)sender;
|
|
|
|
|
|
mapItem.IsSelected = !mapItem.IsSelected;
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-05-04 12:52:20 +02:00
|
|
|
|
private void SeamarksClick(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
var seamarks = (TileLayer)Resources["SeamarksTileLayer"];
|
|
|
|
|
|
var checkBox = (CheckBox)sender;
|
2012-05-04 12:52:20 +02:00
|
|
|
|
|
|
|
|
|
|
if ((bool)checkBox.IsChecked)
|
|
|
|
|
|
{
|
|
|
|
|
|
map.TileLayers.Add(seamarks);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
map.TileLayers.Remove(seamarks);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|