XAML-Map-Control/SampleApps/SilverlightApplication/MainPage.xaml.cs
ClemensF f6a881c674 Version 2.4.2.:
- added HyperlinkText.InlinesSource attached property
- simplified TileLayerCollection, removed it from MapBase
- simplified MapRectangle and MapImage
2014-12-17 21:38:28 +01:00

61 lines
1.8 KiB
C#

using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using MapControl;
namespace SilverlightApplication
{
public partial class MainPage : UserControl
{
public MainPage()
{
//BingMapsTileLayer.ApiKey = "...";
InitializeComponent();
}
private void MapMouseMove(object sender, MouseEventArgs e)
{
var location = map.ViewportPointToLocation(e.GetPosition(map));
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);
}
private void MapMouseLeave(object sender, MouseEventArgs e)
{
mouseLocation.Text = string.Empty;
}
private void SeamarksChecked(object sender, RoutedEventArgs e)
{
map.TileLayers.Add(((TileLayerCollection)Resources["TileLayers"])["Seamarks"]);
}
private void SeamarksUnchecked(object sender, RoutedEventArgs e)
{
map.TileLayers.Remove(((TileLayerCollection)Resources["TileLayers"])["Seamarks"]);
}
}
}