2013-11-17 16:52:03 +01:00
|
|
|
|
using System.Globalization;
|
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 MapControl;
|
2012-05-04 12:52:20 +02:00
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
namespace SilverlightApplication
|
2012-05-04 12:52:20 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public partial class MainPage : UserControl
|
2012-05-04 12:52:20 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public MainPage()
|
2012-05-04 12:52:20 +02:00
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
2013-08-29 15:49:48 +02:00
|
|
|
|
tileLayerComboBox.SelectedIndex = 0;
|
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 TileLayerSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
|
{
|
2013-08-29 15:49:48 +02:00
|
|
|
|
var comboBox = (ComboBox)sender;
|
|
|
|
|
|
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
|
|
|
|
|
|
map.TileLayer = tileLayers[(string)comboBox.SelectedItem];
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-05-04 12:52:20 +02:00
|
|
|
|
private void SeamarksClick(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
var checkBox = (CheckBox)sender;
|
|
|
|
|
|
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
|
|
|
|
|
|
var tileLayer = tileLayers["Seamarks"];
|
2012-05-04 12:52:20 +02:00
|
|
|
|
|
|
|
|
|
|
if ((bool)checkBox.IsChecked)
|
|
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
map.TileLayers.Add(tileLayer);
|
2012-05-04 12:52:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
map.TileLayers.Remove(tileLayer);
|
2012-05-04 12:52:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|