mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 06:55:04 +00:00
Version 5.0: Reworked MapBase and MapPath
This commit is contained in:
parent
06fd31c17b
commit
49e15ce424
41 changed files with 466 additions and 1068 deletions
70
MapControl/WPF/MapPath.WPF.cs
Normal file
70
MapControl/WPF/MapPath.WPF.cs
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2020 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public partial class MapPath : Shape, IWeakEventListener
|
||||
{
|
||||
public static readonly DependencyProperty DataProperty = Path.DataProperty.AddOwner(typeof(MapPath));
|
||||
|
||||
public Geometry Data
|
||||
{
|
||||
get { return (Geometry)GetValue(DataProperty); }
|
||||
set { SetValue(DataProperty, value); }
|
||||
}
|
||||
|
||||
protected override Geometry DefiningGeometry
|
||||
{
|
||||
get { return Data; }
|
||||
}
|
||||
|
||||
public bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
|
||||
{
|
||||
UpdateData();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void DataCollectionPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
INotifyCollectionChanged collection;
|
||||
|
||||
if ((collection = e.OldValue as INotifyCollectionChanged) != null)
|
||||
{
|
||||
CollectionChangedEventManager.RemoveListener(collection, this);
|
||||
}
|
||||
|
||||
if ((collection = e.NewValue as INotifyCollectionChanged) != null)
|
||||
{
|
||||
CollectionChangedEventManager.AddListener(collection, this);
|
||||
}
|
||||
|
||||
UpdateData();
|
||||
}
|
||||
|
||||
protected void AddPolylineLocations(PathFigureCollection figures, IEnumerable<Location> locations, bool closed)
|
||||
{
|
||||
if (locations != null && locations.Count() >= 2)
|
||||
{
|
||||
var points = locations.Select(loc => LocationToView(loc));
|
||||
var figure = new PathFigure
|
||||
{
|
||||
StartPoint = points.First(),
|
||||
IsClosed = closed,
|
||||
IsFilled = closed
|
||||
};
|
||||
|
||||
figure.Segments.Add(new PolyLineSegment(points.Skip(1), true));
|
||||
figures.Add(figure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue