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

158 lines
5.5 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
{
2024-05-26 14:15:02 +02:00
public class MapOverlay : MapPanel
{
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);
2024-05-26 14:15:02 +02:00
public FontFamily FontFamily
{
2024-05-26 14:15:02 +02:00
get => (FontFamily)GetValue(FontFamilyProperty);
set => SetValue(FontFamilyProperty, value);
}
2021-12-01 20:15:48 +01:00
2024-05-26 14:15:02 +02:00
public double FontSize
{
get => (double)GetValue(FontSizeProperty);
set => SetValue(FontSizeProperty, value);
}
public FontStyle FontStyle
{
get => (FontStyle)GetValue(FontStyleProperty);
set => SetValue(FontStyleProperty, value);
}
public FontStretch FontStretch
{
get => (FontStretch)GetValue(FontStretchProperty);
set => SetValue(FontStretchProperty, value);
}
public FontWeight FontWeight
{
get => (FontWeight)GetValue(FontWeightProperty);
set => SetValue(FontWeightProperty, value);
}
public Brush Foreground
{
get => (Brush)GetValue(ForegroundProperty);
set => SetValue(ForegroundProperty, value);
}
public Brush Stroke
{
get => (Brush)GetValue(StrokeProperty);
set => SetValue(StrokeProperty, value);
}
public double StrokeThickness
{
get => (double)GetValue(StrokeThicknessProperty);
set => SetValue(StrokeThicknessProperty, value);
}
public DoubleCollection StrokeDashArray
{
get => (DoubleCollection)GetValue(StrokeDashArrayProperty);
set => SetValue(StrokeDashArrayProperty, value);
}
public double StrokeDashOffset
{
get => (double)GetValue(StrokeDashOffsetProperty);
set => SetValue(StrokeDashOffsetProperty, value);
}
public PenLineCap StrokeLineCap
{
get => (PenLineCap)GetValue(StrokeLineCapProperty);
set => SetValue(StrokeLineCapProperty, value);
}
public PenLineJoin StrokeLineJoin
{
get => (PenLineJoin)GetValue(StrokeLineJoinProperty);
set => SetValue(StrokeLineJoinProperty, value);
}
public double StrokeMiterLimit
{
get => (double)GetValue(StrokeMiterLimitProperty);
set => SetValue(StrokeMiterLimitProperty, value);
}
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)
};
}
2024-05-26 14:15:02 +02:00
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
if (Stroke == null)
{
SetBinding(StrokeProperty, this.CreateBinding(nameof(Foreground)));
}
}
}
}