mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
CsWinRT1028, C# LangVersion 12
This commit is contained in:
parent
e1a4ba3fd6
commit
c0783efb4a
|
|
@ -2,17 +2,10 @@
|
|||
|
||||
namespace MapControl
|
||||
{
|
||||
public class CenteredBoundingBox : BoundingBox
|
||||
public class CenteredBoundingBox(Location center, double width, double height) : BoundingBox
|
||||
{
|
||||
public CenteredBoundingBox(Location center, double width, double height)
|
||||
{
|
||||
Center = center;
|
||||
Width = Math.Max(width, 0d);
|
||||
Height = Math.Max(height, 0d);
|
||||
}
|
||||
|
||||
public override Location Center { get; }
|
||||
public override double Width { get; }
|
||||
public override double Height { get; }
|
||||
public override Location Center { get; } = center;
|
||||
public override double Width { get; } = Math.Max(width, 0d);
|
||||
public override double Height { get; } = Math.Max(height, 0d);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ namespace MapControl
|
|||
{
|
||||
public static string GetFullPath(string path)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return Path.GetFullPath(path, System.AppDomain.CurrentDomain.BaseDirectory);
|
||||
#else
|
||||
#if NETFRAMEWORK
|
||||
return Path.GetFullPath(path);
|
||||
#else
|
||||
return Path.GetFullPath(path, System.AppDomain.CurrentDomain.BaseDirectory);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ using Avalonia.Media;
|
|||
|
||||
namespace MapControl
|
||||
{
|
||||
public class GroundOverlay : MapPanel
|
||||
public partial class GroundOverlay : MapPanel
|
||||
{
|
||||
private class ImageOverlay
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace MapControl.Caching
|
|||
/// IDistributedCache implementation that creates a single file per cache entry.
|
||||
/// The cache expiration time is stored in the file's CreationTime property.
|
||||
/// </summary>
|
||||
public sealed class ImageFileCache : IDistributedCache, IDisposable
|
||||
public sealed partial class ImageFileCache : IDistributedCache, IDisposable
|
||||
{
|
||||
private readonly MemoryDistributedCache memoryCache;
|
||||
private readonly DirectoryInfo rootDirectory;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace MapControl
|
|||
#else
|
||||
[System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))]
|
||||
#endif
|
||||
public class LocationCollection : List<Location>
|
||||
public partial class LocationCollection : List<Location>
|
||||
{
|
||||
public LocationCollection()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace MapControl
|
|||
/// Such elements are arranged at a distance of BorderWidth/2 from the edges of the
|
||||
/// MapBorderPanel in direction of their original azimuth from the map center.
|
||||
/// </summary>
|
||||
public class MapBorderPanel : MapPanel
|
||||
public partial class MapBorderPanel : MapPanel
|
||||
{
|
||||
public static readonly DependencyProperty BorderWidthProperty =
|
||||
DependencyPropertyHelper.Register<MapBorderPanel, double>(nameof(BorderWidth));
|
||||
|
|
|
|||
|
|
@ -24,22 +24,13 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public partial class MapGraticule
|
||||
{
|
||||
private class Label
|
||||
private class Label(string latText, string lonText, double x, double y, double rotation)
|
||||
{
|
||||
public Label(string latText, string lonText, double x, double y, double rotation)
|
||||
{
|
||||
LatitudeText = latText;
|
||||
LongitudeText = lonText;
|
||||
X = x;
|
||||
Y = y;
|
||||
Rotation = rotation;
|
||||
}
|
||||
|
||||
public string LatitudeText { get; }
|
||||
public string LongitudeText { get; }
|
||||
public double X { get; }
|
||||
public double Y { get; }
|
||||
public double Rotation { get; }
|
||||
public string LatitudeText { get; } = latText;
|
||||
public string LongitudeText { get; } = lonText;
|
||||
public double X { get; } = x;
|
||||
public double Y { get; } = y;
|
||||
public double Rotation { get; } = rotation;
|
||||
}
|
||||
|
||||
private const double LineInterpolationResolution = 2d;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace MapControl
|
|||
/// for the Polygons property if collection changes of the property itself and its
|
||||
/// elements are both supposed to trigger UI updates.
|
||||
/// </summary>
|
||||
public class MapMultiPolygon : MapPolypoint
|
||||
public partial class MapMultiPolygon : MapPolypoint
|
||||
{
|
||||
public static readonly DependencyProperty PolygonsProperty =
|
||||
DependencyPropertyHelper.Register<MapMultiPolygon, IEnumerable<IEnumerable<Location>>>(nameof(Polygons), null,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// A MapPanel with a collection of GroundOverlay or GeoImage children.
|
||||
/// </summary>
|
||||
public class MapOverlaysPanel : MapPanel
|
||||
public partial class MapOverlaysPanel : MapPanel
|
||||
{
|
||||
public static readonly DependencyProperty SourcePathsProperty =
|
||||
DependencyPropertyHelper.Register<MapOverlaysPanel, IEnumerable<string>>(nameof(SourcePaths), null,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// A polygon defined by a collection of Locations.
|
||||
/// </summary>
|
||||
public class MapPolygon : MapPolypoint
|
||||
public partial class MapPolygon : MapPolypoint
|
||||
{
|
||||
public static readonly DependencyProperty LocationsProperty =
|
||||
DependencyPropertyHelper.Register<MapPolygon, IEnumerable<Location>>(nameof(Locations), null,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// A polyline defined by a collection of Locations.
|
||||
/// </summary>
|
||||
public class MapPolyline : MapPolypoint
|
||||
public partial class MapPolyline : MapPolypoint
|
||||
{
|
||||
public static readonly DependencyProperty LocationsProperty =
|
||||
DependencyPropertyHelper.Register<MapPolyline, IEnumerable<Location>>(nameof(Locations), null,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Draws a map scale overlay.
|
||||
/// </summary>
|
||||
public class MapScale : MapPanel
|
||||
public partial class MapScale : MapPanel
|
||||
{
|
||||
public static readonly DependencyProperty PaddingProperty =
|
||||
DependencyPropertyHelper.Register<MapScale, Thickness>(nameof(Padding), new Thickness(4));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Displays a standard Web Mercator map tile grid, e.g. an OpenStreetMap tile grid.
|
||||
/// </summary>
|
||||
public class MapTileLayer : MapTileLayerBase
|
||||
public partial class MapTileLayer : MapTileLayerBase
|
||||
{
|
||||
public static readonly DependencyProperty MinZoomLevelProperty =
|
||||
DependencyPropertyHelper.Register<MapTileLayer, int>(nameof(MinZoomLevel), 0);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace MapControl
|
|||
/// listener to each element that implements INotifyCollectionChanged and, when such an element changes,
|
||||
/// fires its own CollectionChanged event with NotifyCollectionChangedAction.Replace for that element.
|
||||
/// </summary>
|
||||
public class PolygonCollection : ObservableCollection<IEnumerable<Location>>
|
||||
public partial class PolygonCollection : ObservableCollection<IEnumerable<Location>>
|
||||
{
|
||||
private void PolygonChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,22 +14,15 @@ using Avalonia.Media;
|
|||
|
||||
namespace MapControl
|
||||
{
|
||||
public partial class Tile
|
||||
public partial class Tile(int zoomLevel, int x, int y, int columnCount)
|
||||
{
|
||||
public Tile(int zoomLevel, int x, int y, int columnCount)
|
||||
{
|
||||
ZoomLevel = zoomLevel;
|
||||
X = x;
|
||||
Y = y;
|
||||
Column = ((x % columnCount) + columnCount) % columnCount;
|
||||
}
|
||||
public int ZoomLevel { get; } = zoomLevel;
|
||||
public int X { get; } = x;
|
||||
public int Y { get; } = y;
|
||||
public int Column { get; } = ((x % columnCount) + columnCount) % columnCount;
|
||||
public int Row => Y;
|
||||
|
||||
public Image Image { get; } = new Image { Stretch = Stretch.Fill };
|
||||
public int ZoomLevel { get; }
|
||||
public int X { get; }
|
||||
public int Y { get; }
|
||||
public int Column { get; }
|
||||
public int Row => Y;
|
||||
public bool IsPending { get; set; } = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using System.Linq;
|
|||
|
||||
namespace MapControl
|
||||
{
|
||||
public class TileCollection : List<Tile>
|
||||
public partial class TileCollection : List<Tile>
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds existing Tiles from the source collection or newly created Tiles to fill the specified tile matrix.
|
||||
|
|
|
|||
|
|
@ -1,20 +1,11 @@
|
|||
namespace MapControl
|
||||
{
|
||||
public class TileMatrix
|
||||
public class TileMatrix(int zoomLevel, int xMin, int yMin, int xMax, int yMax)
|
||||
{
|
||||
public TileMatrix(int zoomLevel, int xMin, int yMin, int xMax, int yMax)
|
||||
{
|
||||
ZoomLevel = zoomLevel;
|
||||
XMin = xMin;
|
||||
YMin = yMin;
|
||||
XMax = xMax;
|
||||
YMax = yMax;
|
||||
}
|
||||
|
||||
public int ZoomLevel { get; }
|
||||
public int XMin { get; }
|
||||
public int YMin { get; }
|
||||
public int XMax { get; }
|
||||
public int YMax { get; }
|
||||
public int ZoomLevel { get; } = zoomLevel;
|
||||
public int XMin { get; } = xMin;
|
||||
public int YMin { get; } = yMin;
|
||||
public int XMax { get; } = xMax;
|
||||
public int YMax { get; } = yMax;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ using ConverterCulture = System.Globalization.CultureInfo;
|
|||
|
||||
namespace MapControl
|
||||
{
|
||||
public class LocationConverter : TypeConverter, IValueConverter
|
||||
public partial class LocationConverter : TypeConverter, IValueConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
|
|
@ -41,7 +41,7 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
public class LocationCollectionConverter : TypeConverter, IValueConverter
|
||||
public partial class LocationCollectionConverter : TypeConverter, IValueConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
|
|
@ -64,7 +64,7 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
public class BoundingBoxConverter : TypeConverter, IValueConverter
|
||||
public partial class BoundingBoxConverter : TypeConverter, IValueConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
|
|
@ -87,7 +87,7 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
public class TileSourceConverter : TypeConverter, IValueConverter
|
||||
public partial class TileSourceConverter : TypeConverter, IValueConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,25 +2,19 @@
|
|||
|
||||
namespace MapControl
|
||||
{
|
||||
public class ViewportChangedEventArgs : EventArgs
|
||||
public class ViewportChangedEventArgs(bool projectionChanged = false, bool transformCenterChanged = false) : EventArgs
|
||||
{
|
||||
public ViewportChangedEventArgs(bool projectionChanged = false, bool transformCenterChanged = false)
|
||||
{
|
||||
ProjectionChanged = projectionChanged;
|
||||
TransformCenterChanged = transformCenterChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the map projection has changed. Used to control when
|
||||
/// a MapTileLayer or a MapImageLayer should be updated immediately,
|
||||
/// or MapPath Data in projected map coordinates should be recalculated.
|
||||
/// </summary>
|
||||
public bool ProjectionChanged { get; }
|
||||
public bool ProjectionChanged { get; } = projectionChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the view transform center has moved across 180° longitude.
|
||||
/// Used to control when a MapTileLayer should be updated immediately.
|
||||
/// </summary>
|
||||
public bool TransformCenterChanged { get; }
|
||||
public bool TransformCenterChanged { get; } = transformCenterChanged;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Displays a single map image from a Web Map Service (WMS).
|
||||
/// </summary>
|
||||
public class WmsImageLayer : MapImageLayer
|
||||
public partial class WmsImageLayer : MapImageLayer
|
||||
{
|
||||
private static ILogger logger;
|
||||
private static ILogger Logger => logger ??= ImageLoader.LoggerFactory?.CreateLogger<GroundOverlay>();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Displays map tiles from a Web Map Tile Service (WMTS).
|
||||
/// </summary>
|
||||
public class WmtsTileLayer : MapTileLayerBase
|
||||
public partial class WmtsTileLayer : MapTileLayerBase
|
||||
{
|
||||
private static ILogger logger;
|
||||
private static ILogger Logger => logger ??= ImageLoader.LoggerFactory?.CreateLogger<GroundOverlay>();
|
||||
|
|
@ -70,7 +70,7 @@ namespace MapControl
|
|||
|
||||
public IEnumerable<WmtsTileMatrixLayer> ChildLayers => Children.Cast<WmtsTileMatrixLayer>();
|
||||
|
||||
public Dictionary<string, WmtsTileMatrixSet> TileMatrixSets { get; } = new Dictionary<string, WmtsTileMatrixSet>();
|
||||
public Dictionary<string, WmtsTileMatrixSet> TileMatrixSets { get; } = [];
|
||||
|
||||
protected virtual WmtsTileSource CreateTileSource(string uriTemplate) => new WmtsTileSource { UriTemplate = uriTemplate };
|
||||
|
||||
|
|
|
|||
|
|
@ -6,29 +6,19 @@ using Avalonia;
|
|||
|
||||
namespace MapControl
|
||||
{
|
||||
public class WmtsTileMatrix
|
||||
// See 07-057r7_Web_Map_Tile_Service_Standard.pdf, section 6.1.a, page 8:
|
||||
// "standardized rendering pixel size" is 0.28 mm
|
||||
//
|
||||
public class WmtsTileMatrix(
|
||||
string identifier, double scaleDenominator, Point topLeft,
|
||||
int tileWidth, int tileHeight, int matrixWidth, int matrixHeight)
|
||||
{
|
||||
// See 07-057r7_Web_Map_Tile_Service_Standard.pdf, section 6.1.a, page 8:
|
||||
// "standardized rendering pixel size" is 0.28 mm
|
||||
|
||||
public WmtsTileMatrix(string identifier, double scaleDenominator, Point topLeft,
|
||||
int tileWidth, int tileHeight, int matrixWidth, int matrixHeight)
|
||||
{
|
||||
Identifier = identifier;
|
||||
Scale = 1 / (scaleDenominator * 0.00028); // 0.28 mm
|
||||
TopLeft = topLeft;
|
||||
TileWidth = tileWidth;
|
||||
TileHeight = tileHeight;
|
||||
MatrixWidth = matrixWidth;
|
||||
MatrixHeight = matrixHeight;
|
||||
}
|
||||
|
||||
public string Identifier { get; }
|
||||
public double Scale { get; }
|
||||
public Point TopLeft { get; }
|
||||
public int TileWidth { get; }
|
||||
public int TileHeight { get; }
|
||||
public int MatrixWidth { get; }
|
||||
public int MatrixHeight { get; }
|
||||
public string Identifier { get; } = identifier;
|
||||
public double Scale { get; } = 1 / (scaleDenominator * 0.00028); // 0.28 mm
|
||||
public Point TopLeft { get; } = topLeft;
|
||||
public int TileWidth { get; } = tileWidth;
|
||||
public int TileHeight { get; } = tileHeight;
|
||||
public int MatrixWidth { get; } = matrixWidth;
|
||||
public int MatrixHeight { get; } = matrixHeight;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ using Avalonia.Media;
|
|||
|
||||
namespace MapControl
|
||||
{
|
||||
public class WmtsTileMatrixLayer : Panel
|
||||
public partial class WmtsTileMatrixLayer : Panel
|
||||
{
|
||||
// zoomLevel is index of tileMatrix in a WmtsTileMatrixSet.TileMatrixes list.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net9.0-windows;net462</TargetFrameworks>
|
||||
<LangVersion Condition="'$(TargetFramework)'=='net462'">8.0</LangVersion>
|
||||
<LangVersion Condition="'$(TargetFramework)'=='net462'">12.0</LangVersion>
|
||||
<UseWPF>true</UseWPF>
|
||||
<DefineConstants>WPF</DefineConstants>
|
||||
<RootNamespace>MapControl</RootNamespace>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// ContentControl placed on a MapPanel at a geographic location specified by the Location property.
|
||||
/// </summary>
|
||||
public class MapContentControl : ContentControl
|
||||
public partial class MapContentControl : ContentControl
|
||||
{
|
||||
public static readonly DependencyProperty AutoCollapseProperty =
|
||||
DependencyPropertyHelper.Register<MapContentControl, bool>(nameof(AutoCollapse), false,
|
||||
|
|
@ -79,7 +79,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// MapContentControl with a Pushpin Style.
|
||||
/// </summary>
|
||||
public class Pushpin : MapContentControl
|
||||
public partial class Pushpin : MapContentControl
|
||||
{
|
||||
public Pushpin()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Base class of MapPolyline and MapPolygon.
|
||||
/// </summary>
|
||||
public class MapPolypoint : MapPath
|
||||
public partial class MapPolypoint : MapPath
|
||||
{
|
||||
public static readonly DependencyProperty FillRuleProperty =
|
||||
DependencyPropertyHelper.Register<MapPolygon, FillRule>(nameof(FillRule), FillRule.EvenOdd,
|
||||
|
|
|
|||
|
|
@ -25,15 +25,11 @@
|
|||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)'=='net48'">
|
||||
<Reference Include="System.Net.Http" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MapUiTools\WPF\MapUiTools.WPF.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MapUiTools\WPF\MapUiTools.WPF.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
Loading…
Reference in a new issue