mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Default Pushpin Style
This commit is contained in:
parent
6f7b2ba611
commit
6542596fd5
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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)
|
internal static class PathFigureExtensions
|
||||||
|
{
|
||||||
|
public static void LineTo(this PathFigure figure, double x, double y)
|
||||||
{
|
{
|
||||||
return new LineSegment
|
figure.Segments.Add(new LineSegment
|
||||||
{
|
{
|
||||||
Point = new Point(x, y)
|
Point = new Point(x, y)
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArcSegment ArcTo(double x, double y, double r)
|
public static void ArcTo(this PathFigure figure, double x, double y, double r)
|
||||||
{
|
{
|
||||||
return new ArcSegment
|
if (r > 0d)
|
||||||
{
|
{
|
||||||
Point = new Point(x, y),
|
figure.Segments.Add(new ArcSegment
|
||||||
Size = new Size(r, r),
|
{
|
||||||
SweepDirection = SweepDirection.Clockwise
|
Point = new Point(x, y),
|
||||||
};
|
Size = new Size(r, r),
|
||||||
|
SweepDirection = SweepDirection.Clockwise
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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">
|
||||||
|
|
|
||||||
|
|
@ -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">
|
||||||
|
|
|
||||||
|
|
@ -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">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue