2014-07-09 21:27:28 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Globalization;
|
2012-05-04 12:52:20 +02:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
2014-10-19 21:50:23 +02:00
|
|
|
|
using System.Windows.Documents;
|
2012-05-04 12:52:20 +02:00
|
|
|
|
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
|
|
|
|
{
|
2014-10-19 21:50:23 +02:00
|
|
|
|
private TileLayerCollection tileLayers;
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public MainPage()
|
2012-05-04 12:52:20 +02:00
|
|
|
|
{
|
2014-10-19 21:50:23 +02:00
|
|
|
|
//BingMapsTileLayer.ApiKey = ...
|
|
|
|
|
|
|
2012-05-04 12:52:20 +02:00
|
|
|
|
InitializeComponent();
|
2014-10-19 21:50:23 +02:00
|
|
|
|
|
|
|
|
|
|
tileLayers = (TileLayerCollection)Resources["TileLayers"];
|
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));
|
2014-07-09 21:27:28 +02:00
|
|
|
|
var latitude = (int)Math.Round(location.Latitude * 60000d);
|
|
|
|
|
|
var longitude = (int)Math.Round(Location.NormalizeLongitude(location.Longitude) * 60000d);
|
|
|
|
|
|
var latHemisphere = 'N';
|
|
|
|
|
|
var lonHemisphere = 'E';
|
|
|
|
|
|
|
|
|
|
|
|
if (latitude < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
latitude = -latitude;
|
|
|
|
|
|
latHemisphere = 'S';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (longitude < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
longitude = -longitude;
|
|
|
|
|
|
lonHemisphere = 'W';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mouseLocation.Text = string.Format(CultureInfo.InvariantCulture,
|
|
|
|
|
|
"{0} {1:00} {2:00.000}\n{3} {4:000} {5:00.000}",
|
|
|
|
|
|
latHemisphere, latitude / 60000, (double)(latitude % 60000) / 1000d,
|
|
|
|
|
|
lonHemisphere, longitude / 60000, (double)(longitude % 60000) / 1000d);
|
2012-05-04 12:52:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
private void TileLayerSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
|
{
|
2014-10-19 21:50:23 +02:00
|
|
|
|
var selectedItem = (ComboBoxItem)tileLayerComboBox.SelectedItem;
|
|
|
|
|
|
|
|
|
|
|
|
map.TileLayer = tileLayers[(string)selectedItem.Tag];
|
|
|
|
|
|
|
|
|
|
|
|
var paragraph = new Paragraph();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var inline in map.TileLayer.DescriptionInlines)
|
|
|
|
|
|
{
|
|
|
|
|
|
paragraph.Inlines.Add(inline);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mapLegend.Blocks.Clear();
|
|
|
|
|
|
mapLegend.Blocks.Add(paragraph);
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-06-11 23:03:13 +02:00
|
|
|
|
private void SeamarksChecked(object sender, RoutedEventArgs e)
|
2012-05-04 12:52:20 +02:00
|
|
|
|
{
|
2014-10-19 21:50:23 +02:00
|
|
|
|
map.TileLayers.Add(tileLayers["Seamarks"]);
|
2014-06-11 23:03:13 +02:00
|
|
|
|
}
|
2012-05-04 12:52:20 +02:00
|
|
|
|
|
2014-06-11 23:03:13 +02:00
|
|
|
|
private void SeamarksUnchecked(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2014-10-19 21:50:23 +02:00
|
|
|
|
map.TileLayers.Remove(tileLayers["Seamarks"]);
|
2012-05-04 12:52:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|