mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 2.5.1: Fixed Clip in Silverlight/WinRT. Replaced WPF GlyphRunText by FormattedText.
This commit is contained in:
parent
9c31163c2f
commit
43e87f26ba
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
|
||||||
// © 2015 Clemens Fischer
|
|
||||||
// Licensed under the Microsoft Public License (Ms-PL)
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace MapControl
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Contains helper methods for creating GlyphRun objects.
|
|
||||||
/// </summary>
|
|
||||||
public static class GlyphRunText
|
|
||||||
{
|
|
||||||
public static GlyphRun Create(string text, Typeface typeface, double emSize, Point baselineOrigin = new Point())
|
|
||||||
{
|
|
||||||
GlyphTypeface glyphTypeface;
|
|
||||||
|
|
||||||
if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
|
|
||||||
{
|
|
||||||
throw new ArgumentException(string.Format("{0}: No GlyphTypeface found", typeface.FontFamily));
|
|
||||||
}
|
|
||||||
|
|
||||||
var glyphIndices = new ushort[text.Length];
|
|
||||||
var advanceWidths = new double[text.Length];
|
|
||||||
|
|
||||||
for (int i = 0; i < text.Length; i++)
|
|
||||||
{
|
|
||||||
var glyphIndex = glyphTypeface.CharacterToGlyphMap[text[i]];
|
|
||||||
glyphIndices[i] = glyphIndex;
|
|
||||||
advanceWidths[i] = glyphTypeface.AdvanceWidths[glyphIndex] * emSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new GlyphRun(glyphTypeface, 0, false, emSize, glyphIndices, baselineOrigin, advanceWidths, null, null, null, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DrawGlyphRun(this DrawingContext drawingContext, Brush foreground, GlyphRun glyphRun,
|
|
||||||
Point position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
|
|
||||||
{
|
|
||||||
var boundingBox = glyphRun.ComputeInkBoundingBox();
|
|
||||||
|
|
||||||
switch (horizontalAlignment)
|
|
||||||
{
|
|
||||||
case HorizontalAlignment.Center:
|
|
||||||
position.X -= boundingBox.Width / 2d;
|
|
||||||
break;
|
|
||||||
case HorizontalAlignment.Right:
|
|
||||||
position.X -= boundingBox.Width;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (verticalAlignment)
|
|
||||||
{
|
|
||||||
case VerticalAlignment.Center:
|
|
||||||
position.Y -= boundingBox.Height / 2d;
|
|
||||||
break;
|
|
||||||
case VerticalAlignment.Bottom:
|
|
||||||
position.Y -= boundingBox.Height;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawingContext.PushTransform(new TranslateTransform(position.X - boundingBox.X, position.Y - boundingBox.Y));
|
|
||||||
drawingContext.DrawGlyphRun(foreground, glyphRun);
|
|
||||||
drawingContext.Pop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -53,17 +53,15 @@ namespace MapControl
|
||||||
style.Setters.Add(new Setter(Panel.BackgroundProperty, new SolidColorBrush(Colors.Transparent)));
|
style.Setters.Add(new Setter(Panel.BackgroundProperty, new SolidColorBrush(Colors.Transparent)));
|
||||||
Style = style;
|
Style = style;
|
||||||
|
|
||||||
Clip = new RectangleGeometry();
|
var clip = new RectangleGeometry();
|
||||||
|
Clip = clip;
|
||||||
|
|
||||||
SizeChanged += OnRenderSizeChanged;
|
SizeChanged += (s, e) =>
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRenderSizeChanged(object sender, SizeChangedEventArgs e)
|
|
||||||
{
|
{
|
||||||
((RectangleGeometry)Clip).Rect = new Rect(new Point(), e.NewSize);
|
clip.Rect = new Rect(new Point(), e.NewSize);
|
||||||
|
|
||||||
ResetTransformOrigin();
|
ResetTransformOrigin();
|
||||||
UpdateTransform();
|
UpdateTransform();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetViewportTransform(Location origin)
|
private void SetViewportTransform(Location origin)
|
||||||
|
|
|
||||||
|
|
@ -1,106 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProductVersion>10.0.20506</ProductVersion>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
<ProjectGuid>{3499D618-2846-4FCE-A418-7D211FDBDCB3}</ProjectGuid>
|
|
||||||
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>MapControl</RootNamespace>
|
|
||||||
<AssemblyName>MapControl.PhoneSilverlight</AssemblyName>
|
|
||||||
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
|
|
||||||
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
|
|
||||||
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
|
||||||
<SilverlightApplication>false</SilverlightApplication>
|
|
||||||
<ValidateXaml>true</ValidateXaml>
|
|
||||||
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
|
|
||||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
|
||||||
<NoStdLib>true</NoStdLib>
|
|
||||||
<NoConfig>true</NoConfig>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>none</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
|
||||||
<NoStdLib>true</NoStdLib>
|
|
||||||
<NoConfig>true</NoConfig>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="BingMapsTileLayer.cs" />
|
|
||||||
<Compile Include="BingMapsTileSource.cs" />
|
|
||||||
<Compile Include="Extensions.Silverlight.cs" />
|
|
||||||
<Compile Include="HyperlinkText.cs" />
|
|
||||||
<Compile Include="ImageTileSource.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="IMapElement.cs" />
|
|
||||||
<Compile Include="Int32Rect.cs" />
|
|
||||||
<Compile Include="ITileImageLoader.cs" />
|
|
||||||
<Compile Include="Location.cs" />
|
|
||||||
<Compile Include="LocationCollection.cs" />
|
|
||||||
<Compile Include="LocationCollectionConverter.cs" />
|
|
||||||
<Compile Include="LocationConverter.cs" />
|
|
||||||
<Compile Include="Map.Silverlight.cs" />
|
|
||||||
<Compile Include="MapBase.cs" />
|
|
||||||
<Compile Include="MapBase.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="MapGraticule.cs" />
|
|
||||||
<Compile Include="MapGraticule.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="MapImage.cs" />
|
|
||||||
<Compile Include="MapImageLayer.cs" />
|
|
||||||
<Compile Include="MapImageLayer.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="MapItem.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="MapItemsControl.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="MapOverlay.cs" />
|
|
||||||
<Compile Include="MapOverlay.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="MapPanel.cs" />
|
|
||||||
<Compile Include="MapPanel.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="MapPath.cs" />
|
|
||||||
<Compile Include="MapPath.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="MapPolyline.cs" />
|
|
||||||
<Compile Include="MapPolyline.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="MapRectangle.cs" />
|
|
||||||
<Compile Include="MapTransform.cs" />
|
|
||||||
<Compile Include="MatrixEx.cs" />
|
|
||||||
<Compile Include="MercatorTransform.cs" />
|
|
||||||
<Compile Include="PanelBase.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
<Compile Include="Pushpin.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="Tile.cs" />
|
|
||||||
<Compile Include="Tile.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="TileImageLoader.Silverlight.cs" />
|
|
||||||
<Compile Include="TileLayer.cs" />
|
|
||||||
<Compile Include="TileLayer.Silverlight.WinRT.cs" />
|
|
||||||
<Compile Include="TileLayerCollection.cs" />
|
|
||||||
<Compile Include="TileSource.cs" />
|
|
||||||
<Compile Include="TileSourceConverter.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Page Include="Themes\Generic.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
|
||||||
<ProjectExtensions />
|
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
|
||||||
<Target Name="BeforeBuild">
|
|
||||||
</Target>
|
|
||||||
<Target Name="AfterBuild">
|
|
||||||
</Target>
|
|
||||||
-->
|
|
||||||
</Project>
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ProjectExtensions>
|
|
||||||
<VisualStudio>
|
|
||||||
<FlavorProperties GUID="{C089C8C0-30E0-4E22-80C0-CE093F111A43}">
|
|
||||||
<SilverlightMobileCSProjectFlavor>
|
|
||||||
<FullDeploy>True</FullDeploy>
|
|
||||||
<DebuggerType>Managed</DebuggerType>
|
|
||||||
<DebuggerAgentType>Managed</DebuggerAgentType>
|
|
||||||
<Tombstone>False</Tombstone>
|
|
||||||
</SilverlightMobileCSProjectFlavor>
|
|
||||||
</FlavorProperties>
|
|
||||||
</VisualStudio>
|
|
||||||
</ProjectExtensions>
|
|
||||||
</Project>
|
|
||||||
|
|
@ -54,7 +54,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BingMapsTileLayer.cs" />
|
<Compile Include="BingMapsTileLayer.cs" />
|
||||||
<Compile Include="BingMapsTileSource.cs" />
|
<Compile Include="BingMapsTileSource.cs" />
|
||||||
<Compile Include="GlyphRunText.cs" />
|
|
||||||
<Compile Include="HyperlinkText.cs" />
|
<Compile Include="HyperlinkText.cs" />
|
||||||
<Compile Include="ImageTileSource.WPF.cs" />
|
<Compile Include="ImageTileSource.WPF.cs" />
|
||||||
<Compile Include="IMapElement.cs" />
|
<Compile Include="IMapElement.cs" />
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
@ -15,24 +16,22 @@ namespace MapControl
|
||||||
private class Label
|
private class Label
|
||||||
{
|
{
|
||||||
public readonly double Position;
|
public readonly double Position;
|
||||||
public readonly string Text;
|
public readonly FormattedText Text;
|
||||||
|
|
||||||
public Label(double position, string text)
|
public Label(double position, FormattedText text)
|
||||||
{
|
{
|
||||||
Position = position;
|
Position = position;
|
||||||
Text = text;
|
Text = text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, GlyphRun> glyphRuns = new Dictionary<string, GlyphRun>();
|
|
||||||
|
|
||||||
static MapGraticule()
|
static MapGraticule()
|
||||||
{
|
{
|
||||||
UIElement.IsHitTestVisibleProperty.OverrideMetadata(
|
UIElement.IsHitTestVisibleProperty.OverrideMetadata(
|
||||||
typeof(MapGraticule), new FrameworkPropertyMetadata(false));
|
typeof(MapGraticule), new FrameworkPropertyMetadata(false));
|
||||||
|
|
||||||
MapOverlay.StrokeThicknessProperty.OverrideMetadata(
|
MapOverlay.StrokeThicknessProperty.OverrideMetadata(
|
||||||
typeof(MapGraticule), new FrameworkPropertyMetadata(0.5, (o, e) => ((MapGraticule)o).glyphRuns.Clear()));
|
typeof(MapGraticule), new FrameworkPropertyMetadata(0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnViewportChanged()
|
protected override void OnViewportChanged()
|
||||||
|
|
@ -55,80 +54,48 @@ namespace MapControl
|
||||||
spacing = LineSpacings.FirstOrDefault(s => s >= minSpacing);
|
spacing = LineSpacings.FirstOrDefault(s => s >= minSpacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var latLabelStart = Math.Ceiling(start.Latitude / spacing) * spacing;
|
||||||
|
var lonLabelStart = Math.Ceiling(start.Longitude / spacing) * spacing;
|
||||||
|
var latLabels = new List<Label>((int)((end.Latitude - latLabelStart) / spacing) + 1);
|
||||||
|
var lonLabels = new List<Label>((int)((end.Longitude - lonLabelStart) / spacing) + 1);
|
||||||
var labelFormat = spacing < 1d ? "{0} {1}°{2:00}'" : "{0} {1}°";
|
var labelFormat = spacing < 1d ? "{0} {1}°{2:00}'" : "{0} {1}°";
|
||||||
var labelStart = new Location(
|
|
||||||
Math.Ceiling(start.Latitude / spacing) * spacing,
|
|
||||||
Math.Ceiling(start.Longitude / spacing) * spacing);
|
|
||||||
|
|
||||||
var latLabels = new List<Label>((int)((end.Latitude - labelStart.Latitude) / spacing) + 1);
|
for (var lat = latLabelStart; lat <= end.Latitude; lat += spacing)
|
||||||
var lonLabels = new List<Label>((int)((end.Longitude - labelStart.Longitude) / spacing) + 1);
|
|
||||||
|
|
||||||
for (var lat = labelStart.Latitude; lat <= end.Latitude; lat += spacing)
|
|
||||||
{
|
{
|
||||||
latLabels.Add(new Label(lat, CoordinateString(lat, labelFormat, "NS")));
|
latLabels.Add(new Label(lat, new FormattedText(
|
||||||
|
CoordinateString(lat, labelFormat, "NS"),
|
||||||
|
CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Typeface, FontSize, Foreground)));
|
||||||
|
|
||||||
drawingContext.DrawLine(Pen,
|
drawingContext.DrawLine(Pen,
|
||||||
ParentMap.LocationToViewportPoint(new Location(lat, start.Longitude)),
|
ParentMap.LocationToViewportPoint(new Location(lat, start.Longitude)),
|
||||||
ParentMap.LocationToViewportPoint(new Location(lat, end.Longitude)));
|
ParentMap.LocationToViewportPoint(new Location(lat, end.Longitude)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var lon = labelStart.Longitude; lon <= end.Longitude; lon += spacing)
|
for (var lon = lonLabelStart; lon <= end.Longitude; lon += spacing)
|
||||||
{
|
{
|
||||||
lonLabels.Add(new Label(lon, CoordinateString(Location.NormalizeLongitude(lon), labelFormat, "EW")));
|
lonLabels.Add(new Label(lon, new FormattedText(
|
||||||
|
CoordinateString(Location.NormalizeLongitude(lon), labelFormat, "EW"),
|
||||||
|
CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Typeface, FontSize, Foreground)));
|
||||||
|
|
||||||
drawingContext.DrawLine(Pen,
|
drawingContext.DrawLine(Pen,
|
||||||
ParentMap.LocationToViewportPoint(new Location(start.Latitude, lon)),
|
ParentMap.LocationToViewportPoint(new Location(start.Latitude, lon)),
|
||||||
ParentMap.LocationToViewportPoint(new Location(end.Latitude, lon)));
|
ParentMap.LocationToViewportPoint(new Location(end.Latitude, lon)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Foreground != null && Foreground != Brushes.Transparent && latLabels.Count > 0 && lonLabels.Count > 0)
|
|
||||||
{
|
|
||||||
var latLabelOrigin = new Point(StrokeThickness / 2d + 2d, -StrokeThickness / 2d - FontSize / 4d);
|
|
||||||
var lonLabelOrigin = new Point(StrokeThickness / 2d + 2d, StrokeThickness / 2d + FontSize);
|
|
||||||
var transform = Matrix.Identity;
|
|
||||||
transform.Rotate(ParentMap.Heading);
|
|
||||||
|
|
||||||
foreach (var latLabel in latLabels)
|
foreach (var latLabel in latLabels)
|
||||||
{
|
{
|
||||||
foreach (var lonLabel in lonLabels)
|
foreach (var lonLabel in lonLabels)
|
||||||
{
|
{
|
||||||
GlyphRun latGlyphRun;
|
|
||||||
GlyphRun lonGlyphRun;
|
|
||||||
|
|
||||||
if (!glyphRuns.TryGetValue(latLabel.Text, out latGlyphRun))
|
|
||||||
{
|
|
||||||
latGlyphRun = GlyphRunText.Create(latLabel.Text, Typeface, FontSize, latLabelOrigin);
|
|
||||||
glyphRuns.Add(latLabel.Text, latGlyphRun);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!glyphRuns.TryGetValue(lonLabel.Text, out lonGlyphRun))
|
|
||||||
{
|
|
||||||
lonGlyphRun = GlyphRunText.Create(lonLabel.Text, Typeface, FontSize, lonLabelOrigin);
|
|
||||||
glyphRuns.Add(lonLabel.Text, lonGlyphRun);
|
|
||||||
}
|
|
||||||
|
|
||||||
var position = ParentMap.LocationToViewportPoint(new Location(latLabel.Position, lonLabel.Position));
|
var position = ParentMap.LocationToViewportPoint(new Location(latLabel.Position, lonLabel.Position));
|
||||||
|
|
||||||
drawingContext.PushTransform(new MatrixTransform(
|
drawingContext.PushTransform(new RotateTransform(ParentMap.Heading, position.X, position.Y));
|
||||||
transform.M11, transform.M12, transform.M21, transform.M22, position.X, position.Y));
|
drawingContext.DrawText(latLabel.Text,
|
||||||
|
new Point(position.X + StrokeThickness / 2d + 2d, position.Y - StrokeThickness / 2d - latLabel.Text.Height));
|
||||||
drawingContext.DrawGlyphRun(Foreground, latGlyphRun);
|
drawingContext.DrawText(lonLabel.Text,
|
||||||
drawingContext.DrawGlyphRun(Foreground, lonGlyphRun);
|
new Point(position.X + StrokeThickness / 2d + 2d, position.Y + StrokeThickness / 2d));
|
||||||
drawingContext.Pop();
|
drawingContext.Pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var removeKeys = glyphRuns.Keys.Where(k => !latLabels.Any(l => l.Text == k) && !lonLabels.Any(l => l.Text == k));
|
|
||||||
|
|
||||||
foreach (var key in removeKeys.ToList())
|
|
||||||
{
|
|
||||||
glyphRuns.Remove(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glyphRuns.Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// Licensed under the Microsoft Public License (Ms-PL)
|
// Licensed under the Microsoft Public License (Ms-PL)
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
@ -68,7 +69,7 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
|
|
||||||
size.Width = length * ParentMap.CenterScale + StrokeThickness + Padding.Left + Padding.Right;
|
size.Width = length * ParentMap.CenterScale + StrokeThickness + Padding.Left + Padding.Right;
|
||||||
size.Height = FontSize + 2d * StrokeThickness + Padding.Top + Padding.Bottom;
|
size.Height = FontSize * FontFamily.LineSpacing + StrokeThickness + Padding.Top + Padding.Bottom;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -86,16 +87,15 @@ namespace MapControl
|
||||||
var x2 = size.Width - Padding.Right - StrokeThickness / 2d;
|
var x2 = size.Width - Padding.Right - StrokeThickness / 2d;
|
||||||
var y1 = size.Height / 2d;
|
var y1 = size.Height / 2d;
|
||||||
var y2 = size.Height - Padding.Bottom - StrokeThickness / 2d;
|
var y2 = size.Height - Padding.Bottom - StrokeThickness / 2d;
|
||||||
var text = length >= 1000d ? string.Format("{0:0} km", length / 1000d) : string.Format("{0:0} m", length);
|
var text = new FormattedText(
|
||||||
|
length >= 1000d ? string.Format("{0:0} km", length / 1000d) : string.Format("{0:0} m", length),
|
||||||
|
CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Typeface, FontSize, Foreground);
|
||||||
|
|
||||||
drawingContext.DrawRectangle(Background ?? ParentMap.Background, null, new Rect(size));
|
drawingContext.DrawRectangle(Background ?? ParentMap.Background, null, new Rect(size));
|
||||||
drawingContext.DrawLine(Pen, new Point(x1, y1), new Point(x1, y2));
|
drawingContext.DrawLine(Pen, new Point(x1, y1), new Point(x1, y2));
|
||||||
drawingContext.DrawLine(Pen, new Point(x2, y1), new Point(x2, y2));
|
drawingContext.DrawLine(Pen, new Point(x2, y1), new Point(x2, y2));
|
||||||
drawingContext.DrawLine(Pen, new Point(x1, y2), new Point(x2, y2));
|
drawingContext.DrawLine(Pen, new Point(x1, y2), new Point(x2, y2));
|
||||||
drawingContext.DrawGlyphRun(Foreground,
|
drawingContext.DrawText(text, new Point((size.Width - text.Width) / 2d, 0d));
|
||||||
GlyphRunText.Create(text, Typeface, FontSize),
|
|
||||||
new Point(size.Width / 2d, y1 - StrokeThickness - 1d),
|
|
||||||
HorizontalAlignment.Center, VerticalAlignment.Center);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,7 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
#if WINDOWS_PHONE
|
#if SILVERLIGHT
|
||||||
[assembly: AssemblyTitle("XAML Map Control (Windows Phone Silverlight)")]
|
|
||||||
[assembly: AssemblyDescription("XAML Map Control Library for Windows Phone Silverlight")]
|
|
||||||
#elif SILVERLIGHT
|
|
||||||
[assembly: AssemblyTitle("XAML Map Control (Silverlight)")]
|
[assembly: AssemblyTitle("XAML Map Control (Silverlight)")]
|
||||||
[assembly: AssemblyDescription("XAML Map Control Library for Silverlight")]
|
[assembly: AssemblyDescription("XAML Map Control Library for Silverlight")]
|
||||||
#else
|
#else
|
||||||
|
|
@ -17,8 +14,8 @@ using System.Windows;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public partial class Tile
|
public partial class Tile
|
||||||
{
|
{
|
||||||
public static TimeSpan OpacityAnimationDuration = TimeSpan.FromSeconds(0.3);
|
public static TimeSpan OpacityAnimationDuration = TimeSpan.FromSeconds(0.1);
|
||||||
|
|
||||||
public readonly int ZoomLevel;
|
public readonly int ZoomLevel;
|
||||||
public readonly int X;
|
public readonly int X;
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.5.0")]
|
[assembly: AssemblyVersion("2.5.1")]
|
||||||
[assembly: AssemblyFileVersion("2.5.0")]
|
[assembly: AssemblyFileVersion("2.5.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue