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

155 lines
5.4 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)
using Windows.UI.Text;
2024-05-22 11:25:32 +02:00
#if UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;
2024-05-22 11:25:32 +02:00
#else
using Microsoft.UI.Text;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
2021-06-14 21:41:37 +02:00
#endif
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 =
DependencyPropertyHelper.Register<MapOverlay, FontFamily>(nameof(FontFamily));
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty FontSizeProperty =
DependencyPropertyHelper.Register<MapOverlay, double>(nameof(FontSize), 12d);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty FontStyleProperty =
DependencyPropertyHelper.Register<MapOverlay, FontStyle>(nameof(FontStyle), FontStyle.Normal);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty FontStretchProperty =
DependencyPropertyHelper.Register<MapOverlay, FontStretch>(nameof(FontStretch), FontStretch.Normal);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty FontWeightProperty =
DependencyPropertyHelper.Register<MapOverlay, FontWeight>(nameof(FontWeight), FontWeights.Normal);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty ForegroundProperty =
DependencyPropertyHelper.Register<MapOverlay, Brush>(nameof(Foreground));
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeProperty =
DependencyPropertyHelper.Register<MapOverlay, Brush>(nameof(Stroke));
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeThicknessProperty =
DependencyPropertyHelper.Register<MapOverlay, double>(nameof(StrokeThickness), 1d);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeDashArrayProperty =
DependencyPropertyHelper.Register<MapOverlay, DoubleCollection>(nameof(StrokeDashArray));
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeDashOffsetProperty =
DependencyPropertyHelper.Register<MapOverlay, double>(nameof(StrokeDashOffset));
2024-05-24 18:24:44 +02:00
public static readonly DependencyProperty StrokeLineCapProperty =
DependencyPropertyHelper.Register<MapOverlay, PenLineCap>(nameof(StrokeLineCap), PenLineCap.Flat);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeLineJoinProperty =
DependencyPropertyHelper.Register<MapOverlay, PenLineJoin>(nameof(StrokeLineJoin), PenLineJoin.Miter);
2024-05-23 18:08:14 +02:00
public static readonly DependencyProperty StrokeMiterLimitProperty =
DependencyPropertyHelper.Register<MapOverlay, double>(nameof(StrokeMiterLimit), 1d);
2024-05-26 14:15:02 +02:00
public FontFamily FontFamily
{
get => (FontFamily)GetValue(FontFamilyProperty);
set => SetValue(FontFamilyProperty, value);
}
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);
}
protected override void SetParentMap(MapBase map)
{
if (map != null)
{
2024-05-24 18:24:44 +02:00
if (Foreground == null)
{
SetBinding(ForegroundProperty, map.CreateBinding(nameof(Foreground)));
}
if (Stroke == null)
{
SetBinding(StrokeProperty, this.CreateBinding(nameof(Foreground)));
}
}
base.SetParentMap(map);
}
}
}