mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-23 00:50:16 +01:00
MapPanel implementation
This commit is contained in:
parent
6d2ba9ede7
commit
7637210211
|
|
@ -17,6 +17,8 @@ namespace MapControl
|
|||
public static readonly AttachedProperty<BoundingBox> BoundingBoxProperty =
|
||||
DependencyPropertyHelper.RegisterAttached<MapPanel, BoundingBox>("BoundingBox");
|
||||
|
||||
protected IEnumerable<Control> ChildElements => Children;
|
||||
|
||||
static MapPanel()
|
||||
{
|
||||
AffectsParentArrange<MapPanel>(LocationProperty, BoundingBoxProperty);
|
||||
|
|
@ -41,8 +43,6 @@ namespace MapControl
|
|||
element.RenderTransformOrigin = new RelativePoint(originX, originY, RelativeUnit.Relative);
|
||||
}
|
||||
|
||||
protected IEnumerable<Control> ChildElements => Children;
|
||||
|
||||
private static void SetVisible(Control element, bool visible)
|
||||
{
|
||||
element.IsVisible = visible;
|
||||
|
|
|
|||
|
|
@ -192,8 +192,7 @@ namespace MapControl
|
|||
var position = parentMap.LocationToView(location);
|
||||
|
||||
if (parentMap.MapProjection.Type <= MapProjectionType.NormalCylindrical &&
|
||||
position.HasValue &&
|
||||
IsOutsideViewport(position.Value))
|
||||
IsOutsideViewport(position))
|
||||
{
|
||||
position = parentMap.LocationToView(
|
||||
new Location(location.Latitude, parentMap.CoerceLongitude(location.Longitude)));
|
||||
|
|
@ -220,7 +219,8 @@ namespace MapControl
|
|||
var position = parentMap.ViewTransform.MapToView(rectCenter);
|
||||
var projection = parentMap.MapProjection;
|
||||
|
||||
if (projection.Type <= MapProjectionType.NormalCylindrical && IsOutsideViewport(position))
|
||||
if (projection.Type <= MapProjectionType.NormalCylindrical &&
|
||||
IsOutsideViewport(position))
|
||||
{
|
||||
var location = projection.MapToLocation(rectCenter);
|
||||
|
||||
|
|
@ -250,6 +250,11 @@ namespace MapControl
|
|||
|| point.Y < 0d || point.Y > parentMap.ActualHeight;
|
||||
}
|
||||
|
||||
private bool IsOutsideViewport(Point? point)
|
||||
{
|
||||
return point.HasValue && IsOutsideViewport(point.Value);
|
||||
}
|
||||
|
||||
private void ArrangeChildElement(FrameworkElement element, Size panelSize)
|
||||
{
|
||||
var location = GetLocation(element);
|
||||
|
|
@ -259,7 +264,7 @@ namespace MapControl
|
|||
|
||||
if (GetAutoCollapse(element))
|
||||
{
|
||||
SetVisible(element, !(position.HasValue && IsOutsideViewport(position.Value)));
|
||||
SetVisible(element, !IsOutsideViewport(position));
|
||||
}
|
||||
|
||||
if (position.HasValue)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ namespace MapControl
|
|||
DependencyPropertyHelper.RegisterAttached<MapPanel, BoundingBox>("BoundingBox", null,
|
||||
FrameworkPropertyMetadataOptions.AffectsParentArrange);
|
||||
|
||||
protected IEnumerable<FrameworkElement> ChildElements => InternalChildren.OfType<FrameworkElement>();
|
||||
|
||||
public MapPanel()
|
||||
{
|
||||
if (this is MapBase)
|
||||
|
|
@ -41,8 +43,6 @@ namespace MapControl
|
|||
element.RenderTransformOrigin = new Point(originX, originY);
|
||||
}
|
||||
|
||||
protected IEnumerable<FrameworkElement> ChildElements => InternalChildren.OfType<FrameworkElement>();
|
||||
|
||||
private static void SetVisible(FrameworkElement element, bool visible)
|
||||
{
|
||||
element.Visibility = visible ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ namespace MapControl
|
|||
DependencyPropertyHelper.RegisterAttached<MapPanel, BoundingBox>("BoundingBox", null,
|
||||
(element, oldValue, newValue) => (element.Parent as MapPanel)?.InvalidateArrange());
|
||||
|
||||
protected IEnumerable<FrameworkElement> ChildElements => Children.OfType<FrameworkElement>();
|
||||
|
||||
public MapPanel()
|
||||
{
|
||||
InitMapElement(this);
|
||||
|
|
@ -74,8 +76,6 @@ namespace MapControl
|
|||
element.RenderTransformOrigin = new Point(originX, originY);
|
||||
}
|
||||
|
||||
protected IEnumerable<FrameworkElement> ChildElements => Children.OfType<FrameworkElement>();
|
||||
|
||||
private static void SetVisible(FrameworkElement element, bool visible)
|
||||
{
|
||||
element.Visibility = visible ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
|
|
|||
Loading…
Reference in a new issue