2013-05-07 18:12:25 +02:00
|
|
|
|
using System;
|
2012-08-09 23:41:47 +02:00
|
|
|
|
using System.Collections.Generic;
|
2013-04-12 19:59:16 +02:00
|
|
|
|
using System.Globalization;
|
2012-05-04 12:52:20 +02:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
using System.Windows.Input;
|
2012-08-09 23:41:47 +02:00
|
|
|
|
using System.Windows.Threading;
|
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-08-09 23:41:47 +02:00
|
|
|
|
private SamplePoint movingPoint = new SamplePoint
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Moving",
|
|
|
|
|
|
Location = new Location(53.5, 8.25)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public MainPage()
|
2012-05-04 12:52:20 +02:00
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
2013-04-12 19:59:16 +02:00
|
|
|
|
var polylines = (ICollection<object>)Resources["Polylines"];
|
2012-06-14 10:43:27 +02:00
|
|
|
|
polylines.Add(
|
2012-05-04 12:52:20 +02:00
|
|
|
|
new SamplePolyline
|
|
|
|
|
|
{
|
|
|
|
|
|
Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387")
|
|
|
|
|
|
});
|
2012-06-14 10:43:27 +02:00
|
|
|
|
polylines.Add(
|
|
|
|
|
|
new SamplePolyline
|
2012-05-04 12:52:20 +02:00
|
|
|
|
{
|
2012-06-14 10:43:27 +02:00
|
|
|
|
Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212")
|
2012-05-04 12:52:20 +02:00
|
|
|
|
});
|
2012-06-14 10:43:27 +02:00
|
|
|
|
|
2013-04-12 19:59:16 +02:00
|
|
|
|
var points = (ICollection<object>)Resources["Points"];
|
2012-06-14 10:43:27 +02:00
|
|
|
|
points.Add(
|
2012-05-04 12:52:20 +02:00
|
|
|
|
new SamplePoint
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Steinbake Leitdamm",
|
|
|
|
|
|
Location = new Location(53.51217, 8.16603)
|
|
|
|
|
|
});
|
2012-06-14 10:43:27 +02:00
|
|
|
|
points.Add(
|
2012-05-04 12:52:20 +02:00
|
|
|
|
new SamplePoint
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Buhne 2",
|
|
|
|
|
|
Location = new Location(53.50926, 8.15815)
|
|
|
|
|
|
});
|
2012-06-14 10:43:27 +02:00
|
|
|
|
points.Add(
|
2012-05-04 12:52:20 +02:00
|
|
|
|
new SamplePoint
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Buhne 4",
|
|
|
|
|
|
Location = new Location(53.50468, 8.15343)
|
|
|
|
|
|
});
|
2012-06-14 10:43:27 +02:00
|
|
|
|
points.Add(
|
2012-05-04 12:52:20 +02:00
|
|
|
|
new SamplePoint
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Buhne 6",
|
|
|
|
|
|
Location = new Location(53.50092, 8.15267)
|
|
|
|
|
|
});
|
2012-06-14 10:43:27 +02:00
|
|
|
|
points.Add(
|
2012-05-04 12:52:20 +02:00
|
|
|
|
new SamplePoint
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Buhne 8",
|
|
|
|
|
|
Location = new Location(53.49871, 8.15321)
|
|
|
|
|
|
});
|
2012-06-14 10:43:27 +02:00
|
|
|
|
points.Add(
|
2012-05-04 12:52:20 +02:00
|
|
|
|
new SamplePoint
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Buhne 10",
|
|
|
|
|
|
Location = new Location(53.49350, 8.15563)
|
|
|
|
|
|
});
|
2012-08-09 23:41:47 +02:00
|
|
|
|
points.Add(movingPoint);
|
2012-06-14 10:43:27 +02:00
|
|
|
|
|
2013-04-12 19:59:16 +02:00
|
|
|
|
var pushpins = (ICollection<object>)Resources["Pushpins"];
|
2012-06-14 10:43:27 +02:00
|
|
|
|
pushpins.Add(
|
|
|
|
|
|
new SamplePoint
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "WHV - Eckwarderhörne",
|
|
|
|
|
|
Location = new Location(53.5495, 8.1877)
|
|
|
|
|
|
});
|
|
|
|
|
|
pushpins.Add(
|
|
|
|
|
|
new SamplePoint
|
2012-05-04 12:52:20 +02:00
|
|
|
|
{
|
2012-06-14 10:43:27 +02:00
|
|
|
|
Name = "JadeWeserPort",
|
|
|
|
|
|
Location = new Location(53.5914, 8.14)
|
|
|
|
|
|
});
|
|
|
|
|
|
pushpins.Add(
|
|
|
|
|
|
new SamplePoint
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Kurhaus Dangast",
|
|
|
|
|
|
Location = new Location(53.447, 8.1114)
|
|
|
|
|
|
});
|
|
|
|
|
|
pushpins.Add(
|
|
|
|
|
|
new SamplePoint
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Eckwarderhörne",
|
|
|
|
|
|
Location = new Location(53.5207, 8.2323)
|
2012-05-04 12:52:20 +02:00
|
|
|
|
});
|
2012-08-09 23:41:47 +02:00
|
|
|
|
|
2013-04-12 19:59:16 +02:00
|
|
|
|
var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.1) };
|
2012-08-09 23:41:47 +02:00
|
|
|
|
timer.Tick += MovePoint;
|
|
|
|
|
|
timer.Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void MovePoint(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2012-08-13 19:16:59 +02:00
|
|
|
|
movingPoint.Location = new Location(movingPoint.Location.Latitude + 0.001, movingPoint.Location.Longitude + 0.002);
|
2012-08-09 23:41:47 +02:00
|
|
|
|
|
|
|
|
|
|
if (movingPoint.Location.Latitude > 54d)
|
|
|
|
|
|
{
|
|
|
|
|
|
movingPoint.Name = "Stopped";
|
|
|
|
|
|
((DispatcherTimer)sender).Stop();
|
|
|
|
|
|
}
|
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)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (map != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var comboBox = (ComboBox)sender;
|
|
|
|
|
|
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
|
|
|
|
|
|
map.TileLayer = tileLayers[(string)comboBox.SelectedItem];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|