2012-07-07 17:19:10 +02:00
|
|
|
|
// WPF MapControl - http://wpfmapcontrol.codeplex.com/
|
|
|
|
|
|
// Copyright © 2012 Clemens Fischer
|
|
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2012-05-04 12:52:20 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A collection of geographic locations.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[TypeConverter(typeof(LocationCollectionConverter))]
|
|
|
|
|
|
public class LocationCollection : ObservableCollection<Location>
|
|
|
|
|
|
{
|
|
|
|
|
|
public LocationCollection()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public LocationCollection(IEnumerable<Location> locations)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (Location location in locations)
|
|
|
|
|
|
{
|
|
|
|
|
|
Add(location);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static LocationCollection Parse(string source)
|
|
|
|
|
|
{
|
|
|
|
|
|
LocationCollection locations = new LocationCollection();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string locString in source.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
|
|
|
|
|
|
{
|
|
|
|
|
|
locations.Add(Location.Parse(locString));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return locations;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class LocationCollectionConverter : TypeConverter
|
|
|
|
|
|
{
|
|
|
|
|
|
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
|
|
|
|
|
{
|
|
|
|
|
|
return sourceType == typeof(string);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
return LocationCollection.Parse((string)value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|