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

85 lines
3.7 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;
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-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeDashCapProperty =
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 StrokeStartLineCapProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, PenLineCap>(Shape.StrokeStartLineCapProperty);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeEndLineCapProperty =
2024-05-24 15:14:05 +02:00
DependencyPropertyHelper.AddOwner<MapOverlay, PenLineCap>(Shape.StrokeEndLineCapProperty);
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
2022-11-30 22:18:45 +01:00
// If this.Stroke is not explicitly set, bind it to this.Foreground.
//
2021-12-01 20:15:48 +01:00
this.SetBindingOnUnsetProperty(StrokeProperty, this, ForegroundProperty, nameof(Foreground));
}
public Pen CreatePen()
{
return new Pen
{
Brush = Stroke,
Thickness = StrokeThickness,
LineJoin = StrokeLineJoin,
MiterLimit = StrokeMiterLimit,
StartLineCap = StrokeStartLineCap,
EndLineCap = StrokeEndLineCap,
DashCap = StrokeDashCap,
DashStyle = new DashStyle(StrokeDashArray, StrokeDashOffset)
};
}
}
}