Default Pushpin Style

This commit is contained in:
ClemensFischer 2025-11-05 16:25:19 +01:00
parent 6f7b2ba611
commit 6542596fd5
5 changed files with 45 additions and 31 deletions

View file

@ -36,9 +36,11 @@
<ControlTheme TargetType="map:Pushpin" x:Key="{x:Type map:Pushpin}" BasedOn="{StaticResource ContentControlTheme}"> <ControlTheme TargetType="map:Pushpin" x:Key="{x:Type map:Pushpin}" BasedOn="{StaticResource ContentControlTheme}">
<Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Bottom"/> <Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="5"/> <Setter Property="CornerRadius" Value="0"/>
<Setter Property="Padding" Value="7,5"/> <Setter Property="Padding" Value="6,4"/>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="map:Pushpin"> <ControlTemplate TargetType="map:Pushpin">
<map:PushpinBorder <map:PushpinBorder

View file

@ -54,38 +54,38 @@ namespace MapControl
IsFilled = true IsFilled = true
}; };
figure.Segments.Add(ArcTo(x1 + r1, y1, r1)); figure.ArcTo(x1 + r1, y1, r1);
figure.Segments.Add(LineTo(x2 - r2, y1)); figure.LineTo(x2 - r2, y1);
figure.Segments.Add(ArcTo(x2, y1 + r2, r2)); figure.ArcTo(x2, y1 + r2, r2);
if (HorizontalAlignment == HorizontalAlignment.Right) if (HorizontalAlignment == HorizontalAlignment.Right)
{ {
figure.Segments.Add(LineTo(x2, y3)); figure.LineTo(x2, y3);
figure.Segments.Add(LineTo(x2 - aw, y2)); figure.LineTo(x2 - aw, y2);
} }
else else
{ {
figure.Segments.Add(LineTo(x2, y2 - r3)); figure.LineTo(x2, y2 - r3);
figure.Segments.Add(ArcTo(x2 - r3, y2, r3)); figure.ArcTo(x2 - r3, y2, r3);
} }
if (HorizontalAlignment == HorizontalAlignment.Center) if (HorizontalAlignment == HorizontalAlignment.Center)
{ {
var c = width / 2d; var c = width / 2d;
figure.Segments.Add(LineTo(c + aw / 2d, y2)); figure.LineTo(c + aw / 2d, y2);
figure.Segments.Add(LineTo(c, y3)); figure.LineTo(c, y3);
figure.Segments.Add(LineTo(c - aw / 2d, y2)); figure.LineTo(c - aw / 2d, y2);
} }
if (HorizontalAlignment == HorizontalAlignment.Left || HorizontalAlignment == HorizontalAlignment.Stretch) if (HorizontalAlignment == HorizontalAlignment.Left || HorizontalAlignment == HorizontalAlignment.Stretch)
{ {
figure.Segments.Add(LineTo(x1 + aw, y2)); figure.LineTo(x1 + aw, y2);
figure.Segments.Add(LineTo(x1, y3)); figure.LineTo(x1, y3);
} }
else else
{ {
figure.Segments.Add(LineTo(x1 + r4, y2)); figure.LineTo(x1 + r4, y2);
figure.Segments.Add(ArcTo(x1, y2 - r4, r4)); figure.ArcTo(x1, y2 - r4, r4);
} }
var geometry = new PathGeometry(); var geometry = new PathGeometry();
@ -93,23 +93,29 @@ namespace MapControl
return geometry; return geometry;
} }
private static LineSegment LineTo(double x, double y)
{
return new LineSegment
{
Point = new Point(x, y)
};
} }
private static ArcSegment ArcTo(double x, double y, double r) internal static class PathFigureExtensions
{ {
return new ArcSegment public static void LineTo(this PathFigure figure, double x, double y)
{
figure.Segments.Add(new LineSegment
{
Point = new Point(x, y)
});
}
public static void ArcTo(this PathFigure figure, double x, double y, double r)
{
if (r > 0d)
{
figure.Segments.Add(new ArcSegment
{ {
Point = new Point(x, y), Point = new Point(x, y),
Size = new Size(r, r), Size = new Size(r, r),
SweepDirection = SweepDirection.Clockwise SweepDirection = SweepDirection.Clockwise
}; });
}
} }
} }
} }

View file

@ -50,9 +50,11 @@
<Style TargetType="map:Pushpin" BasedOn="{StaticResource ContentControlStyle}"> <Style TargetType="map:Pushpin" BasedOn="{StaticResource ContentControlStyle}">
<Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Bottom"/> <Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="5"/> <Setter Property="CornerRadius" Value="0"/>
<Setter Property="Padding" Value="5,7"/> <Setter Property="Padding" Value="3,6,4,6"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="map:Pushpin"> <ControlTemplate TargetType="map:Pushpin">

View file

@ -49,9 +49,11 @@
<Style TargetType="map:Pushpin" BasedOn="{StaticResource ContentControlStyle}"> <Style TargetType="map:Pushpin" BasedOn="{StaticResource ContentControlStyle}">
<Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Bottom"/> <Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="5"/> <Setter Property="CornerRadius" Value="0"/>
<Setter Property="Padding" Value="7,5"/> <Setter Property="Padding" Value="6,3,6,4"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="map:Pushpin"> <ControlTemplate TargetType="map:Pushpin">

View file

@ -50,9 +50,11 @@
<Style TargetType="map:Pushpin" BasedOn="{StaticResource ContentControlStyle}"> <Style TargetType="map:Pushpin" BasedOn="{StaticResource ContentControlStyle}">
<Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Bottom"/> <Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="5"/> <Setter Property="CornerRadius" Value="0"/>
<Setter Property="Padding" Value="7,5"/> <Setter Property="Padding" Value="6,3,6,4"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="map:Pushpin"> <ControlTemplate TargetType="map:Pushpin">