mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Updated MapGraticule
This commit is contained in:
parent
0696441a4e
commit
5a681d3580
|
|
@ -1,47 +1,15 @@
|
||||||
using Avalonia.Controls.Shapes;
|
using Avalonia.Controls.Primitives;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace MapControl
|
namespace MapControl
|
||||||
{
|
{
|
||||||
public partial class MapGraticule : Control, IMapElement
|
public partial class MapGraticule : TemplatedControl, IMapElement
|
||||||
{
|
{
|
||||||
public static readonly StyledProperty<Brush> ForegroundProperty =
|
static MapGraticule()
|
||||||
DependencyPropertyHelper.AddOwner<MapGraticule, Brush>(TextElement.ForegroundProperty, null,
|
|
||||||
(graticule, oldValue, newValue) => graticule.InvalidateVisual());
|
|
||||||
|
|
||||||
public static readonly StyledProperty<FontFamily> FontFamilyProperty =
|
|
||||||
DependencyPropertyHelper.AddOwner<MapGraticule, FontFamily>(TextElement.FontFamilyProperty);
|
|
||||||
|
|
||||||
public static readonly StyledProperty<double> FontSizeProperty =
|
|
||||||
DependencyPropertyHelper.AddOwner<MapGraticule, double>(TextElement.FontSizeProperty);
|
|
||||||
|
|
||||||
public static readonly StyledProperty<double> StrokeThicknessProperty =
|
|
||||||
DependencyPropertyHelper.AddOwner<MapGraticule, double>(Shape.StrokeThicknessProperty, 0.5);
|
|
||||||
|
|
||||||
public Brush Foreground
|
|
||||||
{
|
{
|
||||||
get => GetValue(ForegroundProperty);
|
ForegroundProperty.Changed.AddClassHandler<MapGraticule, IBrush>((graticule, e) => graticule.InvalidateVisual());
|
||||||
set => SetValue(ForegroundProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FontFamily FontFamily
|
|
||||||
{
|
|
||||||
get => GetValue(FontFamilyProperty);
|
|
||||||
set => SetValue(FontFamilyProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double FontSize
|
|
||||||
{
|
|
||||||
get => GetValue(FontSizeProperty);
|
|
||||||
set => SetValue(FontSizeProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double StrokeThickness
|
|
||||||
{
|
|
||||||
get => GetValue(StrokeThicknessProperty);
|
|
||||||
set => SetValue(StrokeThicknessProperty, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MapBase parentMap;
|
private MapBase parentMap;
|
||||||
|
|
@ -91,7 +59,7 @@ namespace MapControl
|
||||||
|
|
||||||
if (labels.Count > 0)
|
if (labels.Count > 0)
|
||||||
{
|
{
|
||||||
var typeface = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Normal, FontStretch.Normal);
|
var typeface = new Typeface(FontFamily, FontStyle, FontWeight, FontStretch);
|
||||||
|
|
||||||
foreach (var label in labels)
|
foreach (var label in labels)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,17 @@ namespace MapControl
|
||||||
|
|
||||||
private const double LineInterpolationResolution = 2d;
|
private const double LineInterpolationResolution = 2d;
|
||||||
|
|
||||||
|
public static readonly DependencyProperty StrokeThicknessProperty =
|
||||||
|
DependencyPropertyHelper.Register<MapGraticule, double>(nameof(StrokeThickness), 0.5);
|
||||||
|
|
||||||
public static readonly DependencyProperty MinLineDistanceProperty =
|
public static readonly DependencyProperty MinLineDistanceProperty =
|
||||||
DependencyPropertyHelper.Register<MapGraticule, double>(nameof(MinLineDistance), 150d);
|
DependencyPropertyHelper.Register<MapGraticule, double>(nameof(MinLineDistance), 150d);
|
||||||
|
|
||||||
private double lineDistance;
|
public double StrokeThickness
|
||||||
private string labelFormat;
|
{
|
||||||
|
get => (double)GetValue(StrokeThicknessProperty);
|
||||||
|
set => SetValue(StrokeThicknessProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Minimum graticule line distance in pixels. The default value is 150.
|
/// Minimum graticule line distance in pixels. The default value is 150.
|
||||||
|
|
@ -55,6 +61,9 @@ namespace MapControl
|
||||||
set => SetValue(MinLineDistanceProperty, value);
|
set => SetValue(MinLineDistanceProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double lineDistance;
|
||||||
|
private string labelFormat;
|
||||||
|
|
||||||
private void SetLineDistance()
|
private void SetLineDistance()
|
||||||
{
|
{
|
||||||
var minDistance = MinLineDistance / PixelPerLongitudeDegree(ParentMap.Center);
|
var minDistance = MinLineDistance / PixelPerLongitudeDegree(ParentMap.Center);
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,6 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public partial class MapGraticule : Control, IMapElement
|
public partial class MapGraticule : Control, IMapElement
|
||||||
{
|
{
|
||||||
public static readonly DependencyProperty StrokeThicknessProperty =
|
|
||||||
DependencyPropertyHelper.Register<MapGraticule, double>(nameof(StrokeThickness), 0.5);
|
|
||||||
|
|
||||||
public double StrokeThickness
|
|
||||||
{
|
|
||||||
get => (double)GetValue(StrokeThicknessProperty);
|
|
||||||
set => SetValue(StrokeThicknessProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private MapBase parentMap;
|
private MapBase parentMap;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@ namespace MapControl
|
||||||
public static readonly DependencyProperty FontSizeProperty =
|
public static readonly DependencyProperty FontSizeProperty =
|
||||||
DependencyPropertyHelper.Register<MapGraticule, double>(nameof(FontSize), 12d);
|
DependencyPropertyHelper.Register<MapGraticule, double>(nameof(FontSize), 12d);
|
||||||
|
|
||||||
public static readonly DependencyProperty StrokeThicknessProperty =
|
|
||||||
DependencyPropertyHelper.Register<MapGraticule, double>(nameof(StrokeThickness), 0.5);
|
|
||||||
|
|
||||||
private readonly Path path = new Path { Data = new PathGeometry() };
|
private readonly Path path = new Path { Data = new PathGeometry() };
|
||||||
|
|
||||||
public Brush Foreground
|
public Brush Foreground
|
||||||
|
|
@ -51,12 +48,6 @@ namespace MapControl
|
||||||
set => SetValue(FontSizeProperty, value);
|
set => SetValue(FontSizeProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double StrokeThickness
|
|
||||||
{
|
|
||||||
get => (double)GetValue(StrokeThicknessProperty);
|
|
||||||
set => SetValue(StrokeThicknessProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SetParentMap(MapBase map)
|
protected override void SetParentMap(MapBase map)
|
||||||
{
|
{
|
||||||
if (map != null && Foreground == null)
|
if (map != null && Foreground == null)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue