mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 23:15:14 +00:00
Updated MapContentControl, MapItem, MapPath
This commit is contained in:
parent
2dc7431c25
commit
7cfb80520b
18 changed files with 216 additions and 133 deletions
|
|
@ -56,6 +56,29 @@ namespace MapControl
|
|||
return property;
|
||||
}
|
||||
|
||||
public static StyledProperty<TValue> AddOwner<TOwner, TValue>(
|
||||
StyledProperty<TValue> source) where TOwner : AvaloniaObject
|
||||
{
|
||||
return source.AddOwner<TOwner>();
|
||||
}
|
||||
|
||||
public static StyledProperty<TValue> AddOwner<TOwner, TValue>(
|
||||
StyledProperty<TValue> source,
|
||||
TValue defaultValue) where TOwner : AvaloniaObject
|
||||
{
|
||||
return source.AddOwner<TOwner>(new StyledPropertyMetadata<TValue>(new Optional<TValue>(defaultValue)));
|
||||
}
|
||||
|
||||
public static StyledProperty<TValue> AddOwner<TOwner, TValue>(
|
||||
StyledProperty<TValue> source,
|
||||
Action<TOwner, TValue, TValue> changed) where TOwner : AvaloniaObject
|
||||
{
|
||||
var property = source.AddOwner<TOwner>();
|
||||
property.Changed.AddClassHandler<TOwner, TValue>((o, e) => changed(o, e.OldValue.Value, e.NewValue.Value));
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
public static void SetBinding(this AvaloniaObject target, AvaloniaProperty property, Binding binding)
|
||||
{
|
||||
target.Bind(property, binding);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace MapControl
|
|||
public partial class MapBase
|
||||
{
|
||||
public static readonly StyledProperty<Brush> ForegroundProperty =
|
||||
TextElement.ForegroundProperty.AddOwner<MapBase>(new StyledPropertyMetadata<Brush>(new Optional<Brush>(Brushes.Black)));
|
||||
DependencyPropertyHelper.AddOwner<MapBase, Brush>(TextElement.ForegroundProperty, Brushes.Black);
|
||||
|
||||
public static readonly StyledProperty<Easing> AnimationEasingProperty =
|
||||
DependencyPropertyHelper.Register<MapBase, Easing>(nameof(AnimationEasing), new QuadraticEaseOut());
|
||||
|
|
|
|||
42
MapControl/Avalonia/MapContentControl.Avalonia.cs
Normal file
42
MapControl/Avalonia/MapContentControl.Avalonia.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// ContentControl placed on a MapPanel at a geographic location specified by the Location property.
|
||||
/// </summary>
|
||||
public class MapContentControl : ContentControl
|
||||
{
|
||||
public static readonly StyledProperty<Location> LocationProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapContentControl, Location>(MapPanel.LocationProperty);
|
||||
|
||||
public static readonly StyledProperty<bool> AutoCollapseProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapContentControl, bool>(MapPanel.AutoCollapseProperty);
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets MapPanel.Location.
|
||||
/// </summary>
|
||||
public Location Location
|
||||
{
|
||||
get => GetValue(LocationProperty);
|
||||
set => SetValue(LocationProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets MapPanel.AutoCollapse.
|
||||
/// </summary>
|
||||
public bool AutoCollapse
|
||||
{
|
||||
get => GetValue(AutoCollapseProperty);
|
||||
set => SetValue(AutoCollapseProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MapContentControl with a Pushpin Style.
|
||||
/// </summary>
|
||||
public class Pushpin : MapContentControl
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -15,13 +15,13 @@ namespace MapControl
|
|||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> ForegroundProperty =
|
||||
TextElement.ForegroundProperty.AddOwner<MapGraticule>();
|
||||
DependencyPropertyHelper.AddOwner<MapGraticule, IBrush>(TextElement.ForegroundProperty);
|
||||
|
||||
public static readonly StyledProperty<FontFamily> FontFamilyProperty =
|
||||
TextElement.FontFamilyProperty.AddOwner<MapGraticule>();
|
||||
DependencyPropertyHelper.AddOwner<MapGraticule, FontFamily>(TextElement.FontFamilyProperty);
|
||||
|
||||
public static readonly StyledProperty<double> FontSizeProperty =
|
||||
TextElement.FontSizeProperty.AddOwner<MapGraticule>(new StyledPropertyMetadata<double>(12d));
|
||||
DependencyPropertyHelper.AddOwner<MapGraticule, double>(TextElement.FontSizeProperty, 12d);
|
||||
|
||||
/// <summary>
|
||||
/// Implements IMapElement.ParentMap.
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public partial class MapItem
|
||||
{
|
||||
public static readonly StyledProperty<Location> LocationProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapItem, Location>(MapPanel.LocationProperty,
|
||||
(item, oldValue, newValue) => item.UpdateMapTransform());
|
||||
|
||||
public static readonly StyledProperty<bool> AutoCollapseProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapItem, bool>(MapPanel.AutoCollapseProperty);
|
||||
|
||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||
{
|
||||
if (e.Pointer.Type != PointerType.Mouse &&
|
||||
|
|
|
|||
|
|
@ -6,12 +6,9 @@ namespace MapControl
|
|||
{
|
||||
public partial class MapPath : Shape
|
||||
{
|
||||
public static readonly StyledProperty<Geometry> DataProperty = Path.DataProperty.AddOwner<MapPath>();
|
||||
|
||||
static MapPath()
|
||||
{
|
||||
DataProperty.Changed.AddClassHandler<MapPath, Geometry>((path, e) => path.UpdateData());
|
||||
}
|
||||
public static readonly StyledProperty<Geometry> DataProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapPath, Geometry>(Path.DataProperty,
|
||||
(path, oldValue, newValue) => path.UpdateData());
|
||||
|
||||
public Geometry Data
|
||||
{
|
||||
|
|
@ -20,17 +17,5 @@ namespace MapControl
|
|||
}
|
||||
|
||||
protected override Geometry CreateDefiningGeometry() => Data;
|
||||
|
||||
private void SetDataTransform(Matrix matrix)
|
||||
{
|
||||
if (Data.Transform is MatrixTransform transform)
|
||||
{
|
||||
transform.Matrix = matrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.Transform = new MatrixTransform(matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue