Use expression bodies for properties

This commit is contained in:
Clemens 2022-08-06 10:40:59 +02:00
parent e8b37f03ff
commit 74ba508e26
33 changed files with 194 additions and 230 deletions

View file

@ -42,31 +42,31 @@ namespace MapControl
public double South public double South
{ {
get { return south; } get => south;
set { south = Math.Min(Math.Max(value, -90d), 90d); } set => south = Math.Min(Math.Max(value, -90d), 90d);
} }
public double North public double North
{ {
get { return north; } get => north;
set { north = Math.Min(Math.Max(value, -90d), 90d); } set => north = Math.Min(Math.Max(value, -90d), 90d);
} }
public virtual double Width public virtual double Width
{ {
get { return East - West; } get => East - West;
protected set { } protected set { }
} }
public virtual double Height public virtual double Height
{ {
get { return North - South; } get => North - South;
protected set { } protected set { }
} }
public virtual Location Center public virtual Location Center
{ {
get { return new Location((South + North) / 2d, (West + East) / 2d); } get => new Location((South + North) / 2d, (West + East) / 2d);
protected set { } protected set { }
} }

View file

@ -41,8 +41,8 @@ namespace MapControl
public string SourcePath public string SourcePath
{ {
get { return (string)GetValue(SourcePathProperty); } get => (string)GetValue(SourcePathProperty);
set { SetValue(SourcePathProperty, value); } set => SetValue(SourcePathProperty, value);
} }
public GeoImage() public GeoImage()

View file

@ -61,8 +61,8 @@ namespace MapControl
public string SourcePath public string SourcePath
{ {
get { return (string)GetValue(SourcePathProperty); } get => (string)GetValue(SourcePathProperty);
set { SetValue(SourcePathProperty, value); } set => SetValue(SourcePathProperty, value);
} }
private async Task SourcePathPropertyChanged(string sourcePath) private async Task SourcePathPropertyChanged(string sourcePath)

View file

@ -29,8 +29,8 @@ namespace MapControl
public double Latitude public double Latitude
{ {
get { return latitude; } get => latitude;
set { latitude = Math.Min(Math.Max(value, -90d), 90d); } set => latitude = Math.Min(Math.Max(value, -90d), 90d);
} }
public double Longitude { get; set; } public double Longitude { get; set; }

View file

@ -85,8 +85,8 @@ namespace MapControl
/// </summary> /// </summary>
public Brush Foreground public Brush Foreground
{ {
get { return (Brush)GetValue(ForegroundProperty); } get => (Brush)GetValue(ForegroundProperty);
set { SetValue(ForegroundProperty, value); } set => SetValue(ForegroundProperty, value);
} }
/// <summary> /// <summary>
@ -96,8 +96,8 @@ namespace MapControl
/// </summary> /// </summary>
public UIElement MapLayer public UIElement MapLayer
{ {
get { return (UIElement)GetValue(MapLayerProperty); } get => (UIElement)GetValue(MapLayerProperty);
set { SetValue(MapLayerProperty, value); } set => SetValue(MapLayerProperty, value);
} }
/// <summary> /// <summary>
@ -105,8 +105,8 @@ namespace MapControl
/// </summary> /// </summary>
public MapProjection MapProjection public MapProjection MapProjection
{ {
get { return (MapProjection)GetValue(MapProjectionProperty); } get => (MapProjection)GetValue(MapProjectionProperty);
set { SetValue(MapProjectionProperty, value); } set => SetValue(MapProjectionProperty, value);
} }
/// <summary> /// <summary>
@ -115,8 +115,8 @@ namespace MapControl
/// </summary> /// </summary>
public Location ProjectionCenter public Location ProjectionCenter
{ {
get { return (Location)GetValue(ProjectionCenterProperty); } get => (Location)GetValue(ProjectionCenterProperty);
set { SetValue(ProjectionCenterProperty, value); } set => SetValue(ProjectionCenterProperty, value);
} }
/// <summary> /// <summary>
@ -124,8 +124,8 @@ namespace MapControl
/// </summary> /// </summary>
public Location Center public Location Center
{ {
get { return (Location)GetValue(CenterProperty); } get => (Location)GetValue(CenterProperty);
set { SetValue(CenterProperty, value); } set => SetValue(CenterProperty, value);
} }
/// <summary> /// <summary>
@ -133,8 +133,8 @@ namespace MapControl
/// </summary> /// </summary>
public Location TargetCenter public Location TargetCenter
{ {
get { return (Location)GetValue(TargetCenterProperty); } get => (Location)GetValue(TargetCenterProperty);
set { SetValue(TargetCenterProperty, value); } set => SetValue(TargetCenterProperty, value);
} }
/// <summary> /// <summary>
@ -144,8 +144,8 @@ namespace MapControl
/// </summary> /// </summary>
public double MinZoomLevel public double MinZoomLevel
{ {
get { return (double)GetValue(MinZoomLevelProperty); } get => (double)GetValue(MinZoomLevelProperty);
set { SetValue(MinZoomLevelProperty, value); } set => SetValue(MinZoomLevelProperty, value);
} }
/// <summary> /// <summary>
@ -155,8 +155,8 @@ namespace MapControl
/// </summary> /// </summary>
public double MaxZoomLevel public double MaxZoomLevel
{ {
get { return (double)GetValue(MaxZoomLevelProperty); } get => (double)GetValue(MaxZoomLevelProperty);
set { SetValue(MaxZoomLevelProperty, value); } set => SetValue(MaxZoomLevelProperty, value);
} }
/// <summary> /// <summary>
@ -164,8 +164,8 @@ namespace MapControl
/// </summary> /// </summary>
public double ZoomLevel public double ZoomLevel
{ {
get { return (double)GetValue(ZoomLevelProperty); } get => (double)GetValue(ZoomLevelProperty);
set { SetValue(ZoomLevelProperty, value); } set => SetValue(ZoomLevelProperty, value);
} }
/// <summary> /// <summary>
@ -173,8 +173,8 @@ namespace MapControl
/// </summary> /// </summary>
public double TargetZoomLevel public double TargetZoomLevel
{ {
get { return (double)GetValue(TargetZoomLevelProperty); } get => (double)GetValue(TargetZoomLevelProperty);
set { SetValue(TargetZoomLevelProperty, value); } set => SetValue(TargetZoomLevelProperty, value);
} }
/// <summary> /// <summary>
@ -182,8 +182,8 @@ namespace MapControl
/// </summary> /// </summary>
public double Heading public double Heading
{ {
get { return (double)GetValue(HeadingProperty); } get => (double)GetValue(HeadingProperty);
set { SetValue(HeadingProperty, value); } set => SetValue(HeadingProperty, value);
} }
/// <summary> /// <summary>
@ -191,8 +191,8 @@ namespace MapControl
/// </summary> /// </summary>
public double TargetHeading public double TargetHeading
{ {
get { return (double)GetValue(TargetHeadingProperty); } get => (double)GetValue(TargetHeadingProperty);
set { SetValue(TargetHeadingProperty, value); } set => SetValue(TargetHeadingProperty, value);
} }
/// <summary> /// <summary>
@ -201,8 +201,8 @@ namespace MapControl
/// </summary> /// </summary>
public TimeSpan AnimationDuration public TimeSpan AnimationDuration
{ {
get { return (TimeSpan)GetValue(AnimationDurationProperty); } get => (TimeSpan)GetValue(AnimationDurationProperty);
set { SetValue(AnimationDurationProperty, value); } set => SetValue(AnimationDurationProperty, value);
} }
/// <summary> /// <summary>
@ -211,18 +211,15 @@ namespace MapControl
/// </summary> /// </summary>
public EasingFunctionBase AnimationEasingFunction public EasingFunctionBase AnimationEasingFunction
{ {
get { return (EasingFunctionBase)GetValue(AnimationEasingFunctionProperty); } get => (EasingFunctionBase)GetValue(AnimationEasingFunctionProperty);
set { SetValue(AnimationEasingFunctionProperty, value); } set => SetValue(AnimationEasingFunctionProperty, value);
} }
/// <summary> /// <summary>
/// Gets the scaling factor from cartesian map coordinates to view coordinates, /// Gets the scaling factor from cartesian map coordinates to view coordinates,
/// i.e. pixels per meter, as a read-only dependency property. /// i.e. pixels per meter, as a read-only dependency property.
/// </summary> /// </summary>
public double ViewScale public double ViewScale => (double)GetValue(ViewScaleProperty);
{
get { return (double)GetValue(ViewScaleProperty); }
}
/// <summary> /// <summary>
/// Gets the ViewTransform instance that is used to transform between cartesian map coordinates /// Gets the ViewTransform instance that is used to transform between cartesian map coordinates

View file

@ -57,8 +57,8 @@ namespace MapControl
/// </summary> /// </summary>
public double MinLineDistance public double MinLineDistance
{ {
get { return (double)GetValue(MinLineDistanceProperty); } get => (double)GetValue(MinLineDistanceProperty);
set { SetValue(MinLineDistanceProperty, value); } set => SetValue(MinLineDistanceProperty, value);
} }
private void SetLineDistance() private void SetLineDistance()

View file

@ -74,8 +74,8 @@ namespace MapControl
/// </summary> /// </summary>
public string Description public string Description
{ {
get { return (string)GetValue(DescriptionProperty); } get => (string)GetValue(DescriptionProperty);
set { SetValue(DescriptionProperty, value); } set => SetValue(DescriptionProperty, value);
} }
/// <summary> /// <summary>
@ -85,8 +85,8 @@ namespace MapControl
/// </summary> /// </summary>
public double RelativeImageSize public double RelativeImageSize
{ {
get { return (double)GetValue(RelativeImageSizeProperty); } get => (double)GetValue(RelativeImageSizeProperty);
set { SetValue(RelativeImageSizeProperty, value); } set => SetValue(RelativeImageSizeProperty, value);
} }
/// <summary> /// <summary>
@ -94,8 +94,8 @@ namespace MapControl
/// </summary> /// </summary>
public TimeSpan UpdateInterval public TimeSpan UpdateInterval
{ {
get { return (TimeSpan)GetValue(UpdateIntervalProperty); } get => (TimeSpan)GetValue(UpdateIntervalProperty);
set { SetValue(UpdateIntervalProperty, value); } set => SetValue(UpdateIntervalProperty, value);
} }
/// <summary> /// <summary>
@ -103,8 +103,8 @@ namespace MapControl
/// </summary> /// </summary>
public bool UpdateWhileViewportChanging public bool UpdateWhileViewportChanging
{ {
get { return (bool)GetValue(UpdateWhileViewportChangingProperty); } get => (bool)GetValue(UpdateWhileViewportChangingProperty);
set { SetValue(UpdateWhileViewportChangingProperty, value); } set => SetValue(UpdateWhileViewportChangingProperty, value);
} }
/// <summary> /// <summary>
@ -112,8 +112,8 @@ namespace MapControl
/// </summary> /// </summary>
public Brush MapBackground public Brush MapBackground
{ {
get { return (Brush)GetValue(MapBackgroundProperty); } get => (Brush)GetValue(MapBackgroundProperty);
set { SetValue(MapBackgroundProperty, value); } set => SetValue(MapBackgroundProperty, value);
} }
/// <summary> /// <summary>
@ -121,8 +121,8 @@ namespace MapControl
/// </summary> /// </summary>
public Brush MapForeground public Brush MapForeground
{ {
get { return (Brush)GetValue(MapForegroundProperty); } get => (Brush)GetValue(MapForegroundProperty);
set { SetValue(MapForegroundProperty, value); } set => SetValue(MapForegroundProperty, value);
} }
/// <summary> /// <summary>
@ -130,8 +130,8 @@ namespace MapControl
/// </summary> /// </summary>
public double LoadingProgress public double LoadingProgress
{ {
get { return (double)GetValue(LoadingProgressProperty); } get => (double)GetValue(LoadingProgressProperty);
private set { SetValue(LoadingProgressProperty, value); } private set => SetValue(LoadingProgressProperty, value);
} }
/// <summary> /// <summary>

View file

@ -36,8 +36,8 @@ namespace MapControl
/// </summary> /// </summary>
public bool AutoCollapse public bool AutoCollapse
{ {
get { return (bool)GetValue(AutoCollapseProperty); } get => (bool)GetValue(AutoCollapseProperty);
set { SetValue(AutoCollapseProperty, value); } set => SetValue(AutoCollapseProperty, value);
} }
/// <summary> /// <summary>
@ -45,8 +45,8 @@ namespace MapControl
/// </summary> /// </summary>
public Location Location public Location Location
{ {
get { return (Location)GetValue(LocationProperty); } get => (Location)GetValue(LocationProperty);
set { SetValue(LocationProperty, value); } set => SetValue(LocationProperty, value);
} }
/// <summary> /// <summary>
@ -54,8 +54,8 @@ namespace MapControl
/// </summary> /// </summary>
public string LocationMemberPath public string LocationMemberPath
{ {
get { return (string)GetValue(LocationMemberPathProperty); } get => (string)GetValue(LocationMemberPathProperty);
set { SetValue(LocationMemberPathProperty, value); } set => SetValue(LocationMemberPathProperty, value);
} }
} }

View file

@ -22,92 +22,92 @@ namespace MapControl
{ {
public FontFamily FontFamily public FontFamily FontFamily
{ {
get { return (FontFamily)GetValue(FontFamilyProperty); } get => (FontFamily)GetValue(FontFamilyProperty);
set { SetValue(FontFamilyProperty, value); } set => SetValue(FontFamilyProperty, value);
} }
public double FontSize public double FontSize
{ {
get { return (double)GetValue(FontSizeProperty); } get => (double)GetValue(FontSizeProperty);
set { SetValue(FontSizeProperty, value); } set => SetValue(FontSizeProperty, value);
} }
public FontStyle FontStyle public FontStyle FontStyle
{ {
get { return (FontStyle)GetValue(FontStyleProperty); } get => (FontStyle)GetValue(FontStyleProperty);
set { SetValue(FontStyleProperty, value); } set => SetValue(FontStyleProperty, value);
} }
public FontStretch FontStretch public FontStretch FontStretch
{ {
get { return (FontStretch)GetValue(FontStretchProperty); } get => (FontStretch)GetValue(FontStretchProperty);
set { SetValue(FontStretchProperty, value); } set => SetValue(FontStretchProperty, value);
} }
public FontWeight FontWeight public FontWeight FontWeight
{ {
get { return (FontWeight)GetValue(FontWeightProperty); } get => (FontWeight)GetValue(FontWeightProperty);
set { SetValue(FontWeightProperty, value); } set => SetValue(FontWeightProperty, value);
} }
public Brush Foreground public Brush Foreground
{ {
get { return (Brush)GetValue(ForegroundProperty); } get => (Brush)GetValue(ForegroundProperty);
set { SetValue(ForegroundProperty, value); } set => SetValue(ForegroundProperty, value);
} }
public Brush Stroke public Brush Stroke
{ {
get { return (Brush)GetValue(StrokeProperty); } get => (Brush)GetValue(StrokeProperty);
set { SetValue(StrokeProperty, value); } set => SetValue(StrokeProperty, value);
} }
public double StrokeThickness public double StrokeThickness
{ {
get { return (double)GetValue(StrokeThicknessProperty); } get => (double)GetValue(StrokeThicknessProperty);
set { SetValue(StrokeThicknessProperty, value); } set => SetValue(StrokeThicknessProperty, value);
} }
public DoubleCollection StrokeDashArray public DoubleCollection StrokeDashArray
{ {
get { return (DoubleCollection)GetValue(StrokeDashArrayProperty); } get => (DoubleCollection)GetValue(StrokeDashArrayProperty);
set { SetValue(StrokeDashArrayProperty, value); } set => SetValue(StrokeDashArrayProperty, value);
} }
public double StrokeDashOffset public double StrokeDashOffset
{ {
get { return (double)GetValue(StrokeDashOffsetProperty); } get => (double)GetValue(StrokeDashOffsetProperty);
set { SetValue(StrokeDashOffsetProperty, value); } set => SetValue(StrokeDashOffsetProperty, value);
} }
public PenLineCap StrokeDashCap public PenLineCap StrokeDashCap
{ {
get { return (PenLineCap)GetValue(StrokeDashCapProperty); } get => (PenLineCap)GetValue(StrokeDashCapProperty);
set { SetValue(StrokeDashCapProperty, value); } set => SetValue(StrokeDashCapProperty, value);
} }
public PenLineCap StrokeStartLineCap public PenLineCap StrokeStartLineCap
{ {
get { return (PenLineCap)GetValue(StrokeStartLineCapProperty); } get => (PenLineCap)GetValue(StrokeStartLineCapProperty);
set { SetValue(StrokeStartLineCapProperty, value); } set => SetValue(StrokeStartLineCapProperty, value);
} }
public PenLineCap StrokeEndLineCap public PenLineCap StrokeEndLineCap
{ {
get { return (PenLineCap)GetValue(StrokeEndLineCapProperty); } get => (PenLineCap)GetValue(StrokeEndLineCapProperty);
set { SetValue(StrokeEndLineCapProperty, value); } set => SetValue(StrokeEndLineCapProperty, value);
} }
public PenLineJoin StrokeLineJoin public PenLineJoin StrokeLineJoin
{ {
get { return (PenLineJoin)GetValue(StrokeLineJoinProperty); } get => (PenLineJoin)GetValue(StrokeLineJoinProperty);
set { SetValue(StrokeLineJoinProperty, value); } set => SetValue(StrokeLineJoinProperty, value);
} }
public double StrokeMiterLimit public double StrokeMiterLimit
{ {
get { return (double)GetValue(StrokeMiterLimitProperty); } get => (double)GetValue(StrokeMiterLimitProperty);
set { SetValue(StrokeMiterLimitProperty, value); } set => SetValue(StrokeMiterLimitProperty, value);
} }
} }
} }

View file

@ -45,8 +45,8 @@ namespace MapControl
public MapBase ParentMap public MapBase ParentMap
{ {
get { return parentMap; } get => parentMap;
set { SetParentMap(value); } set => SetParentMap(value);
} }
/// <summary> /// <summary>

View file

@ -36,13 +36,13 @@ namespace MapControl
/// </summary> /// </summary>
public Location Location public Location Location
{ {
get { return (Location)GetValue(LocationProperty); } get => (Location)GetValue(LocationProperty);
set { SetValue(LocationProperty, value); } set => SetValue(LocationProperty, value);
} }
public MapBase ParentMap public MapBase ParentMap
{ {
get { return parentMap; } get => parentMap;
set set
{ {
if (parentMap != null) if (parentMap != null)

View file

@ -34,8 +34,8 @@ namespace MapControl
#endif #endif
public IEnumerable<Location> Locations public IEnumerable<Location> Locations
{ {
get { return (IEnumerable<Location>)GetValue(LocationsProperty); } get => (IEnumerable<Location>)GetValue(LocationsProperty);
set { SetValue(LocationsProperty, value); } set => SetValue(LocationsProperty, value);
} }
public MapPolygon() public MapPolygon()

View file

@ -34,8 +34,8 @@ namespace MapControl
#endif #endif
public IEnumerable<Location> Locations public IEnumerable<Location> Locations
{ {
get { return (IEnumerable<Location>)GetValue(LocationsProperty); } get => (IEnumerable<Location>)GetValue(LocationsProperty);
set { SetValue(LocationsProperty, value); } set => SetValue(LocationsProperty, value);
} }
public MapPolyline() public MapPolyline()

View file

@ -63,8 +63,8 @@ namespace MapControl
public Thickness Padding public Thickness Padding
{ {
get { return (Thickness)GetValue(PaddingProperty); } get => (Thickness)GetValue(PaddingProperty);
set { SetValue(PaddingProperty, value); } set => SetValue(PaddingProperty, value);
} }
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)

View file

@ -34,18 +34,12 @@ namespace MapControl
/// <summary> /// <summary>
/// A default MapTileLayer using OpenStreetMap data. /// A default MapTileLayer using OpenStreetMap data.
/// </summary> /// </summary>
public static MapTileLayer OpenStreetMapTileLayer public static MapTileLayer OpenStreetMapTileLayer => new MapTileLayer
{ {
get TileSource = new TileSource { UriFormat = "https://tile.openstreetmap.org/{z}/{x}/{y}.png" },
{ SourceName = "OpenStreetMap",
return new MapTileLayer Description = "© [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)"
{ };
TileSource = new TileSource { UriFormat = "https://tile.openstreetmap.org/{z}/{x}/{y}.png" },
SourceName = "OpenStreetMap",
Description = "© [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)"
};
}
}
public static readonly DependencyProperty MinZoomLevelProperty = DependencyProperty.Register( public static readonly DependencyProperty MinZoomLevelProperty = DependencyProperty.Register(
nameof(MinZoomLevel), typeof(int), typeof(MapTileLayer), new PropertyMetadata(0)); nameof(MinZoomLevel), typeof(int), typeof(MapTileLayer), new PropertyMetadata(0));
@ -75,8 +69,8 @@ namespace MapControl
/// </summary> /// </summary>
public int MinZoomLevel public int MinZoomLevel
{ {
get { return (int)GetValue(MinZoomLevelProperty); } get => (int)GetValue(MinZoomLevelProperty);
set { SetValue(MinZoomLevelProperty, value); } set => SetValue(MinZoomLevelProperty, value);
} }
/// <summary> /// <summary>
@ -84,8 +78,8 @@ namespace MapControl
/// </summary> /// </summary>
public int MaxZoomLevel public int MaxZoomLevel
{ {
get { return (int)GetValue(MaxZoomLevelProperty); } get => (int)GetValue(MaxZoomLevelProperty);
set { SetValue(MaxZoomLevelProperty, value); } set => SetValue(MaxZoomLevelProperty, value);
} }
/// <summary> /// <summary>
@ -94,8 +88,8 @@ namespace MapControl
/// </summary> /// </summary>
public double ZoomLevelOffset public double ZoomLevelOffset
{ {
get { return (double)GetValue(ZoomLevelOffsetProperty); } get => (double)GetValue(ZoomLevelOffsetProperty);
set { SetValue(ZoomLevelOffsetProperty, value); } set => SetValue(ZoomLevelOffsetProperty, value);
} }
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)

View file

@ -88,8 +88,8 @@ namespace MapControl
/// </summary> /// </summary>
public TileSource TileSource public TileSource TileSource
{ {
get { return (TileSource)GetValue(TileSourceProperty); } get => (TileSource)GetValue(TileSourceProperty);
set { SetValue(TileSourceProperty, value); } set => SetValue(TileSourceProperty, value);
} }
/// <summary> /// <summary>
@ -97,8 +97,8 @@ namespace MapControl
/// </summary> /// </summary>
public string SourceName public string SourceName
{ {
get { return (string)GetValue(SourceNameProperty); } get => (string)GetValue(SourceNameProperty);
set { SetValue(SourceNameProperty, value); } set => SetValue(SourceNameProperty, value);
} }
/// <summary> /// <summary>
@ -106,8 +106,8 @@ namespace MapControl
/// </summary> /// </summary>
public string Description public string Description
{ {
get { return (string)GetValue(DescriptionProperty); } get => (string)GetValue(DescriptionProperty);
set { SetValue(DescriptionProperty, value); } set => SetValue(DescriptionProperty, value);
} }
/// <summary> /// <summary>
@ -116,8 +116,8 @@ namespace MapControl
/// </summary> /// </summary>
public int MaxBackgroundLevels public int MaxBackgroundLevels
{ {
get { return (int)GetValue(MaxBackgroundLevelsProperty); } get => (int)GetValue(MaxBackgroundLevelsProperty);
set { SetValue(MaxBackgroundLevelsProperty, value); } set => SetValue(MaxBackgroundLevelsProperty, value);
} }
/// <summary> /// <summary>
@ -125,8 +125,8 @@ namespace MapControl
/// </summary> /// </summary>
public TimeSpan UpdateInterval public TimeSpan UpdateInterval
{ {
get { return (TimeSpan)GetValue(UpdateIntervalProperty); } get => (TimeSpan)GetValue(UpdateIntervalProperty);
set { SetValue(UpdateIntervalProperty, value); } set => SetValue(UpdateIntervalProperty, value);
} }
/// <summary> /// <summary>
@ -134,8 +134,8 @@ namespace MapControl
/// </summary> /// </summary>
public bool UpdateWhileViewportChanging public bool UpdateWhileViewportChanging
{ {
get { return (bool)GetValue(UpdateWhileViewportChangingProperty); } get => (bool)GetValue(UpdateWhileViewportChangingProperty);
set { SetValue(UpdateWhileViewportChangingProperty, value); } set => SetValue(UpdateWhileViewportChangingProperty, value);
} }
/// <summary> /// <summary>
@ -143,8 +143,8 @@ namespace MapControl
/// </summary> /// </summary>
public Brush MapBackground public Brush MapBackground
{ {
get { return (Brush)GetValue(MapBackgroundProperty); } get => (Brush)GetValue(MapBackgroundProperty);
set { SetValue(MapBackgroundProperty, value); } set => SetValue(MapBackgroundProperty, value);
} }
/// <summary> /// <summary>
@ -152,8 +152,8 @@ namespace MapControl
/// </summary> /// </summary>
public Brush MapForeground public Brush MapForeground
{ {
get { return (Brush)GetValue(MapForegroundProperty); } get => (Brush)GetValue(MapForegroundProperty);
set { SetValue(MapForegroundProperty, value); } set => SetValue(MapForegroundProperty, value);
} }
/// <summary> /// <summary>
@ -161,13 +161,13 @@ namespace MapControl
/// </summary> /// </summary>
public double LoadingProgress public double LoadingProgress
{ {
get { return (double)GetValue(LoadingProgressProperty); } get => (double)GetValue(LoadingProgressProperty);
private set { SetValue(LoadingProgressProperty, value); } private set => SetValue(LoadingProgressProperty, value);
} }
public MapBase ParentMap public MapBase ParentMap
{ {
get { return parentMap; } get => parentMap;
set set
{ {
if (parentMap != null) if (parentMap != null)
@ -186,15 +186,7 @@ namespace MapControl
} }
} }
protected bool IsBaseMapLayer protected bool IsBaseMapLayer => parentMap != null && parentMap.Children.Count > 0 && parentMap.Children[0] == this;
{
get
{
return parentMap != null
&& parentMap.Children.Count > 0
&& parentMap.Children[0] == this;
}
}
protected abstract void SetRenderTransform(); protected abstract void SetRenderTransform();

View file

@ -22,14 +22,14 @@ namespace MapControl
{ {
public Size ArrowSize public Size ArrowSize
{ {
get { return (Size)GetValue(ArrowSizeProperty); } get => (Size)GetValue(ArrowSizeProperty);
set { SetValue(ArrowSizeProperty, value); } set => SetValue(ArrowSizeProperty, value);
} }
public double BorderWidth public double BorderWidth
{ {
get { return (double)GetValue(BorderWidthProperty); } get => (double)GetValue(BorderWidthProperty);
set { SetValue(BorderWidthProperty, value); } set => SetValue(BorderWidthProperty, value);
} }
protected virtual Geometry BuildGeometry() protected virtual Geometry BuildGeometry()

View file

@ -29,7 +29,7 @@ namespace MapControl
/// </summary> /// </summary>
public string UriFormat public string UriFormat
{ {
get { return uriFormat; } get => uriFormat;
set set
{ {
uriFormat = value?.Replace("{c}", "{s}"); // for backwards compatibility since 5.4.0 uriFormat = value?.Replace("{c}", "{s}"); // for backwards compatibility since 5.4.0

View file

@ -60,8 +60,8 @@ namespace MapControl
/// </summary> /// </summary>
public Uri ServiceUri public Uri ServiceUri
{ {
get { return (Uri)GetValue(ServiceUriProperty); } get => (Uri)GetValue(ServiceUriProperty);
set { SetValue(ServiceUriProperty, value); } set => SetValue(ServiceUriProperty, value);
} }
/// <summary> /// <summary>
@ -69,8 +69,8 @@ namespace MapControl
/// </summary> /// </summary>
public string Layers public string Layers
{ {
get { return (string)GetValue(LayersProperty); } get => (string)GetValue(LayersProperty);
set { SetValue(LayersProperty, value); } set => SetValue(LayersProperty, value);
} }
/// <summary> /// <summary>
@ -78,8 +78,8 @@ namespace MapControl
/// </summary> /// </summary>
public string Styles public string Styles
{ {
get { return (string)GetValue(StylesProperty); } get => (string)GetValue(StylesProperty);
set { SetValue(StylesProperty, value); } set => SetValue(StylesProperty, value);
} }
/// <summary> /// <summary>

View file

@ -47,8 +47,8 @@ namespace MapControl
/// </summary> /// </summary>
public Uri CapabilitiesUri public Uri CapabilitiesUri
{ {
get { return (Uri)GetValue(CapabilitiesUriProperty); } get => (Uri)GetValue(CapabilitiesUriProperty);
set { SetValue(CapabilitiesUriProperty, value); } set => SetValue(CapabilitiesUriProperty, value);
} }
/// <summary> /// <summary>
@ -56,14 +56,11 @@ namespace MapControl
/// </summary> /// </summary>
public string LayerIdentifier public string LayerIdentifier
{ {
get { return (string)GetValue(LayerIdentifierProperty); } get => (string)GetValue(LayerIdentifierProperty);
set { SetValue(LayerIdentifierProperty, value); } set => SetValue(LayerIdentifierProperty, value);
} }
public IEnumerable<WmtsTileMatrixLayer> ChildLayers public IEnumerable<WmtsTileMatrixLayer> ChildLayers => Children.Cast<WmtsTileMatrixLayer>();
{
get { return Children.Cast<WmtsTileMatrixLayer>(); }
}
public Dictionary<string, WmtsTileMatrixSet> TileMatrixSets { get; } = new Dictionary<string, WmtsTileMatrixSet>(); public Dictionary<string, WmtsTileMatrixSet> TileMatrixSets { get; } = new Dictionary<string, WmtsTileMatrixSet>();

View file

@ -25,10 +25,7 @@ namespace MapControl
/// Default folder path where an IImageCache instance may save cached data, /// Default folder path where an IImageCache instance may save cached data,
/// i.e. Windows.Storage.ApplicationData.Current.TemporaryFolder.Path. /// i.e. Windows.Storage.ApplicationData.Current.TemporaryFolder.Path.
/// </summary> /// </summary>
public static string DefaultCacheFolder public static string DefaultCacheFolder => Windows.Storage.ApplicationData.Current.TemporaryFolder.Path;
{
get { return Windows.Storage.ApplicationData.Current.TemporaryFolder.Path; }
}
/// <summary> /// <summary>
/// An IImageCache implementation used to cache tile images. /// An IImageCache implementation used to cache tile images.

View file

@ -21,20 +21,14 @@ namespace MapControl.Caching
private readonly MemoryCache memoryCache = MemoryCache.Default; private readonly MemoryCache memoryCache = MemoryCache.Default;
public override string Name public override string Name => string.Empty;
{
get { return string.Empty; }
}
public override DefaultCacheCapabilities DefaultCacheCapabilities public override DefaultCacheCapabilities DefaultCacheCapabilities => DefaultCacheCapabilities.None;
{
get { return DefaultCacheCapabilities.None; }
}
public override object this[string key] public override object this[string key]
{ {
get { return Get(key); } get => Get(key);
set { Set(key, value, null); } set => Set(key, value, null);
} }
protected override IEnumerator<KeyValuePair<string, object>> GetEnumerator() protected override IEnumerator<KeyValuePair<string, object>> GetEnumerator()

View file

@ -42,8 +42,8 @@ namespace MapControl
/// </summary> /// </summary>
public double MouseWheelZoomDelta public double MouseWheelZoomDelta
{ {
get { return (double)GetValue(MouseWheelZoomDeltaProperty); } get => (double)GetValue(MouseWheelZoomDeltaProperty);
set { SetValue(MouseWheelZoomDeltaProperty, value); } set => SetValue(MouseWheelZoomDeltaProperty, value);
} }
/// <summary> /// <summary>
@ -51,8 +51,8 @@ namespace MapControl
/// </summary> /// </summary>
public ManipulationModes ManipulationMode public ManipulationModes ManipulationMode
{ {
get { return (ManipulationModes)GetValue(ManipulationModeProperty); } get => (ManipulationModes)GetValue(ManipulationModeProperty);
set { SetValue(ManipulationModeProperty, value); } set => SetValue(ManipulationModeProperty, value);
} }
private void OnManipulationStarted(object sender, ManipulationStartedEventArgs e) private void OnManipulationStarted(object sender, ManipulationStartedEventArgs e)

View file

@ -26,8 +26,8 @@ namespace MapControl
/// </summary> /// </summary>
public bool AutoCollapse public bool AutoCollapse
{ {
get { return (bool)GetValue(AutoCollapseProperty); } get => (bool)GetValue(AutoCollapseProperty);
set { SetValue(AutoCollapseProperty, value); } set => SetValue(AutoCollapseProperty, value);
} }
/// <summary> /// <summary>
@ -35,8 +35,8 @@ namespace MapControl
/// </summary> /// </summary>
public Location Location public Location Location
{ {
get { return (Location)GetValue(LocationProperty); } get => (Location)GetValue(LocationProperty);
set { SetValue(LocationProperty, value); } set => SetValue(LocationProperty, value);
} }
} }
@ -55,8 +55,8 @@ namespace MapControl
public CornerRadius CornerRadius public CornerRadius CornerRadius
{ {
get { return (CornerRadius)GetValue(CornerRadiusProperty); } get => (CornerRadius)GetValue(CornerRadiusProperty);
set { SetValue(CornerRadiusProperty, value); } set => SetValue(CornerRadiusProperty, value);
} }
} }
} }

View file

@ -25,8 +25,8 @@ namespace MapControl
public IEnumerable<IMapDrawingItem> ItemsSource public IEnumerable<IMapDrawingItem> ItemsSource
{ {
get { return (IEnumerable<IMapDrawingItem>)GetValue(ItemsSourceProperty); } get => (IEnumerable<IMapDrawingItem>)GetValue(ItemsSourceProperty);
set { SetValue(ItemsSourceProperty, value); } set => SetValue(ItemsSourceProperty, value);
} }
protected override async Task<ImageSource> GetImageAsync(IProgress<double> progress) protected override async Task<ImageSource> GetImageAsync(IProgress<double> progress)

View file

@ -27,8 +27,8 @@ namespace MapControl
/// </summary> /// </summary>
public IEnumerable<IEnumerable<Location>> Polygons public IEnumerable<IEnumerable<Location>> Polygons
{ {
get { return (IEnumerable<IEnumerable<Location>>)GetValue(PolygonsProperty); } get => (IEnumerable<IEnumerable<Location>>)GetValue(PolygonsProperty);
set { SetValue(PolygonsProperty, value); } set => SetValue(PolygonsProperty, value);
} }
public MapMultiPolygon() public MapMultiPolygon()

View file

@ -18,14 +18,11 @@ namespace MapControl
public Geometry Data public Geometry Data
{ {
get { return (Geometry)GetValue(DataProperty); } get => (Geometry)GetValue(DataProperty);
set { SetValue(DataProperty, value); } set => SetValue(DataProperty, value);
} }
protected override Geometry DefiningGeometry protected override Geometry DefiningGeometry => Data;
{
get { return Data; }
}
#region Methods used only by derived classes MapPolyline, MapPolygon and MapMultiPolygon #region Methods used only by derived classes MapPolyline, MapPolygon and MapMultiPolygon

View file

@ -43,26 +43,26 @@ namespace MapControl
public Brush Background public Brush Background
{ {
get { return (Brush)GetValue(BackgroundProperty); } get => (Brush)GetValue(BackgroundProperty);
set { SetValue(BackgroundProperty, value); } set => SetValue(BackgroundProperty, value);
} }
public Brush BorderBrush public Brush BorderBrush
{ {
get { return (Brush)GetValue(BorderBrushProperty); } get => (Brush)GetValue(BorderBrushProperty);
set { SetValue(BorderBrushProperty, value); } set => SetValue(BorderBrushProperty, value);
} }
public CornerRadius CornerRadius public CornerRadius CornerRadius
{ {
get { return (CornerRadius)GetValue(CornerRadiusProperty); } get => (CornerRadius)GetValue(CornerRadiusProperty);
set { SetValue(CornerRadiusProperty, value); } set => SetValue(CornerRadiusProperty, value);
} }
public Thickness Padding public Thickness Padding
{ {
get { return (Thickness)GetValue(PaddingProperty); } get => (Thickness)GetValue(PaddingProperty);
set { SetValue(PaddingProperty, value); } set => SetValue(PaddingProperty, value);
} }
protected override Size MeasureOverride(Size constraint) protected override Size MeasureOverride(Size constraint)

View file

@ -14,10 +14,8 @@ namespace MapControl
/// <summary> /// <summary>
/// Default folder path where an ObjectCache instance may save cached data, i.e. C:\ProgramData\MapControl\TileCache /// Default folder path where an ObjectCache instance may save cached data, i.e. C:\ProgramData\MapControl\TileCache
/// </summary> /// </summary>
public static string DefaultCacheFolder public static string DefaultCacheFolder =>
{ Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "TileCache");
get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "TileCache"); }
}
/// <summary> /// <summary>
/// An ObjectCache instance used to cache tile image data. The default value is MemoryCache.Default. /// An ObjectCache instance used to cache tile image data. The default value is MemoryCache.Default.

View file

@ -45,8 +45,8 @@ namespace MapControl
/// </summary> /// </summary>
public double MouseWheelZoomDelta public double MouseWheelZoomDelta
{ {
get { return (double)GetValue(MouseWheelZoomDeltaProperty); } get => (double)GetValue(MouseWheelZoomDeltaProperty);
set { SetValue(MouseWheelZoomDeltaProperty, value); } set => SetValue(MouseWheelZoomDeltaProperty, value);
} }
private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e) private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)

View file

@ -36,8 +36,8 @@ namespace MapControl
/// </summary> /// </summary>
public bool AutoCollapse public bool AutoCollapse
{ {
get { return (bool)GetValue(AutoCollapseProperty); } get => (bool)GetValue(AutoCollapseProperty);
set { SetValue(AutoCollapseProperty, value); } set => SetValue(AutoCollapseProperty, value);
} }
/// <summary> /// <summary>
@ -45,8 +45,8 @@ namespace MapControl
/// </summary> /// </summary>
public Location Location public Location Location
{ {
get { return (Location)GetValue(LocationProperty); } get => (Location)GetValue(LocationProperty);
set { SetValue(LocationProperty, value); } set => SetValue(LocationProperty, value);
} }
protected override void OnApplyTemplate() protected override void OnApplyTemplate()

View file

@ -80,8 +80,8 @@ namespace MapControl
public UIElement Child public UIElement Child
{ {
get { return border.Child; } get => border.Child;
set { border.Child = value; } set => border.Child = value;
} }
private void SetBorderMargin() private void SetBorderMargin()

View file

@ -25,10 +25,8 @@ namespace MapControl
/// <summary> /// <summary>
/// Default folder path where an IImageCache instance may save cached data, i.e. C:\ProgramData\MapControl\TileCache /// Default folder path where an IImageCache instance may save cached data, i.e. C:\ProgramData\MapControl\TileCache
/// </summary> /// </summary>
public static string DefaultCacheFolder public static string DefaultCacheFolder =>
{ Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "TileCache");
get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "TileCache"); }
}
/// <summary> /// <summary>
/// An IImageCache implementation used to cache tile images. /// An IImageCache implementation used to cache tile images.