XAML-Map-Control/MapControl/WPF/MapOverlay.WPF.cs

81 lines
3.3 KiB
C#
Raw Normal View History

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2024-02-03 21:01:53 +01:00
// Copyright © 2024 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
2021-01-17 21:39:42 +01:00
using System;
using System.Windows;
2024-05-24 18:24:44 +02:00
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Shapes;
namespace MapControl
{
public partial class MapOverlay
{
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty FontFamilyProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, FontFamily>(TextElement.FontFamilyProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty FontSizeProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, double>(TextElement.FontSizeProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty FontStyleProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, FontStyle>(TextElement.FontStyleProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty FontStretchProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, FontStretch>(TextElement.FontStretchProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty FontWeightProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, FontWeight>(TextElement.FontWeightProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty ForegroundProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, Brush>(TextElement.ForegroundProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, Brush>(Shape.StrokeProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeThicknessProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, double>(Shape.StrokeThicknessProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeDashArrayProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, DoubleCollection>(Shape.StrokeDashArrayProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeDashOffsetProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, double>(Shape.StrokeDashOffsetProperty);
2024-05-24 18:24:44 +02:00
public static readonly DependencyProperty StrokeLineCapProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, PenLineCap>(Shape.StrokeDashCapProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeLineJoinProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, PenLineJoin>(Shape.StrokeLineJoinProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeMiterLimitProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, double>(Shape.StrokeMiterLimitProperty);
2021-01-17 21:39:42 +01:00
protected override void OnInitialized(EventArgs e)
{
2021-01-17 21:39:42 +01:00
base.OnInitialized(e);
2021-12-01 20:15:48 +01:00
2024-05-24 18:24:44 +02:00
if (Stroke == null)
{
SetBinding(StrokeProperty, this.CreateBinding(nameof(Foreground)));
}
}
public Pen CreatePen()
{
return new Pen
{
Brush = Stroke,
Thickness = StrokeThickness,
LineJoin = StrokeLineJoin,
MiterLimit = StrokeMiterLimit,
2024-05-24 18:24:44 +02:00
StartLineCap = StrokeLineCap,
EndLineCap = StrokeLineCap,
DashCap = StrokeLineCap,
DashStyle = new DashStyle(StrokeDashArray, StrokeDashOffset)
};
}
}
}