mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Remove CanvasPanel
This commit is contained in:
parent
22d5aadb9d
commit
3a9050676c
|
|
@ -71,8 +71,6 @@ namespace MapControl
|
||||||
|
|
||||||
protected virtual void UpdateData()
|
protected virtual void UpdateData()
|
||||||
{
|
{
|
||||||
MapPanel.SetLocation(this, Location);
|
|
||||||
|
|
||||||
if (parentMap != null && Location != null && Data != null)
|
if (parentMap != null && Location != null && Data != null)
|
||||||
{
|
{
|
||||||
var matrix = parentMap.GetMapTransform(Location);
|
var matrix = parentMap.GetMapTransform(Location);
|
||||||
|
|
@ -86,6 +84,8 @@ namespace MapControl
|
||||||
Data.Transform = new MatrixTransform { Matrix = matrix };
|
Data.Transform = new MatrixTransform { Matrix = matrix };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MapPanel.SetLocation(this, Location);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Methods used only by derived classes MapPolyline, MapPolygon and MapMultiPolygon
|
#region Methods used only by derived classes MapPolyline, MapPolygon and MapMultiPolygon
|
||||||
|
|
|
||||||
|
|
@ -230,9 +230,6 @@
|
||||||
<Compile Include="..\WinUI\Animatable.WinUI.cs">
|
<Compile Include="..\WinUI\Animatable.WinUI.cs">
|
||||||
<Link>Animatable.WinUI.cs</Link>
|
<Link>Animatable.WinUI.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\WinUI\CanvasPanel.cs">
|
|
||||||
<Link>CanvasPanel.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\WinUI\GeoImage.WinUI.cs">
|
<Compile Include="..\WinUI\GeoImage.WinUI.cs">
|
||||||
<Link>GeoImage.WinUI.cs</Link>
|
<Link>GeoImage.WinUI.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|
||||||
// Copyright © 2023 Clemens Fischer
|
|
||||||
// Licensed under the Microsoft Public License (Ms-PL)
|
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using Windows.Foundation;
|
|
||||||
#if WINUI
|
|
||||||
using Microsoft.UI.Xaml;
|
|
||||||
using Microsoft.UI.Xaml.Controls;
|
|
||||||
#elif UWP
|
|
||||||
using Windows.UI.Xaml;
|
|
||||||
using Windows.UI.Xaml.Controls;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace MapControl
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Replacement for WinUI and UWP Canvas, which clips MapPath child elements.
|
|
||||||
/// </summary>
|
|
||||||
public class CanvasPanel : Panel
|
|
||||||
{
|
|
||||||
protected override Size MeasureOverride(Size availableSize)
|
|
||||||
{
|
|
||||||
availableSize = new Size(double.PositiveInfinity, double.PositiveInfinity);
|
|
||||||
|
|
||||||
foreach (var element in Children.OfType<UIElement>())
|
|
||||||
{
|
|
||||||
element.Measure(availableSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Size();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Size ArrangeOverride(Size finalSize)
|
|
||||||
{
|
|
||||||
foreach (var element in Children.OfType<UIElement>())
|
|
||||||
{
|
|
||||||
var x = Canvas.GetLeft(element);
|
|
||||||
var y = Canvas.GetTop(element);
|
|
||||||
var size = MapPanel.GetDesiredSize(element);
|
|
||||||
|
|
||||||
element.Arrange(new Rect(x, y, size.Width, size.Height));
|
|
||||||
}
|
|
||||||
|
|
||||||
return finalSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="map:MapItem">
|
<ControlTemplate TargetType="map:MapItem">
|
||||||
<map:CanvasPanel>
|
<Canvas>
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
<VisualStateGroup x:Name="CommonStates">
|
<VisualStateGroup x:Name="CommonStates">
|
||||||
<VisualState x:Name="Normal"/>
|
<VisualState x:Name="Normal"/>
|
||||||
|
|
@ -54,20 +54,12 @@
|
||||||
</VisualState>
|
</VisualState>
|
||||||
</VisualStateGroup>
|
</VisualStateGroup>
|
||||||
</VisualStateManager.VisualStateGroups>
|
</VisualStateManager.VisualStateGroups>
|
||||||
<!-- Path with transformed Geometry -->
|
|
||||||
<Path Fill="Red" Opacity="0.4" IsHitTestVisible="False">
|
<Path Fill="Red" Opacity="0.4" IsHitTestVisible="False">
|
||||||
<Path.Data>
|
<Path.Data>
|
||||||
<EllipseGeometry RadiusX="20" RadiusY="20"
|
<EllipseGeometry RadiusX="20" RadiusY="20"
|
||||||
Transform="{Binding MapTransform, RelativeSource={RelativeSource TemplatedParent}}"/>
|
Transform="{Binding MapTransform, RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||||
</Path.Data>
|
</Path.Data>
|
||||||
</Path>
|
</Path>
|
||||||
<!-- MapPath with Location, requires CanvasPanel parent to avoid clipping -->
|
|
||||||
<map:MapPath Stroke="Green" StrokeThickness="2" IsHitTestVisible="False"
|
|
||||||
Location="{TemplateBinding Location}">
|
|
||||||
<map:MapPath.Data>
|
|
||||||
<EllipseGeometry RadiusX="20" RadiusY="20"/>
|
|
||||||
</map:MapPath.Data>
|
|
||||||
</map:MapPath>
|
|
||||||
<Path x:Name="selectedPath" Fill="White" Opacity="0">
|
<Path x:Name="selectedPath" Fill="White" Opacity="0">
|
||||||
<Path.Data>
|
<Path.Data>
|
||||||
<EllipseGeometry RadiusX="12" RadiusY="12"/>
|
<EllipseGeometry RadiusX="12" RadiusY="12"/>
|
||||||
|
|
@ -78,10 +70,8 @@
|
||||||
<EllipseGeometry RadiusX="8" RadiusY="8"/>
|
<EllipseGeometry RadiusX="8" RadiusY="8"/>
|
||||||
</Path.Data>
|
</Path.Data>
|
||||||
</Path>
|
</Path>
|
||||||
<Grid Canvas.Left="15" Canvas.Top="-8">
|
<TextBlock Margin="16,-9,0,0" Text="{Binding Name}"/>
|
||||||
<TextBlock Margin="2,0,2,0" Text="{Binding Name}"/>
|
</Canvas>
|
||||||
</Grid>
|
|
||||||
</map:CanvasPanel>
|
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="map:MapItem">
|
<ControlTemplate TargetType="map:MapItem">
|
||||||
<map:CanvasPanel>
|
<Grid>
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
<VisualStateGroup x:Name="CommonStates">
|
<VisualStateGroup x:Name="CommonStates">
|
||||||
<VisualState x:Name="Normal"/>
|
<VisualState x:Name="Normal"/>
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
Transform="{Binding MapTransform, RelativeSource={RelativeSource TemplatedParent}}"/>
|
Transform="{Binding MapTransform, RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||||
</Path.Data>
|
</Path.Data>
|
||||||
</Path>
|
</Path>
|
||||||
<!-- MapPath with Location, requires CanvasPanel parent to avoid clipping -->
|
<!-- MapPath with Location -->
|
||||||
<map:MapPath Stroke="Green" StrokeThickness="2" IsHitTestVisible="False"
|
<map:MapPath Stroke="Green" StrokeThickness="2" IsHitTestVisible="False"
|
||||||
Location="{TemplateBinding Location}">
|
Location="{TemplateBinding Location}">
|
||||||
<map:MapPath.Data>
|
<map:MapPath.Data>
|
||||||
|
|
@ -85,10 +85,8 @@
|
||||||
<EllipseGeometry RadiusX="8" RadiusY="8"/>
|
<EllipseGeometry RadiusX="8" RadiusY="8"/>
|
||||||
</Path.Data>
|
</Path.Data>
|
||||||
</Path>
|
</Path>
|
||||||
<Grid Canvas.Left="15" Canvas.Top="-8">
|
<TextBlock Margin="16,-9,0,0" Text="{Binding Name}"/>
|
||||||
<TextBlock Margin="2,0,2,0" Text="{Binding Name}"/>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</map:CanvasPanel>
|
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
|
|
|
||||||
|
|
@ -77,9 +77,7 @@
|
||||||
<EllipseGeometry RadiusX="8" RadiusY="8"/>
|
<EllipseGeometry RadiusX="8" RadiusY="8"/>
|
||||||
</Path.Data>
|
</Path.Data>
|
||||||
</Path>
|
</Path>
|
||||||
<Grid Canvas.Left="15" Canvas.Top="-8">
|
<TextBlock Margin="16,-9,0,0" Text="{Binding Name}"/>
|
||||||
<TextBlock Margin="2,0" Text="{Binding Name}"/>
|
|
||||||
</Grid>
|
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue