From 43e87f26ba37617df95021652ed4391be1e810fb Mon Sep 17 00:00:00 2001 From: ClemensF Date: Tue, 25 Aug 2015 20:04:33 +0200 Subject: [PATCH] Version 2.5.1: Fixed Clip in Silverlight/WinRT. Replaced WPF GlyphRunText by FormattedText. --- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- MapControl/GlyphRunText.cs | 72 ------------ MapControl/MapBase.Silverlight.WinRT.cs | 18 ++- MapControl/MapControl.PhoneSilverlight.csproj | 106 ------------------ .../MapControl.PhoneSilverlight.csproj.user | 15 --- MapControl/MapControl.WPF.csproj | 1 - MapControl/MapGraticule.WPF.cs | 83 +++++--------- MapControl/MapScale.cs | 12 +- MapControl/Properties/AssemblyInfo.cs | 9 +- MapControl/Tile.cs | 2 +- MapControl/WinRT/Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../UniversalApp/Properties/AssemblyInfo.cs | 4 +- .../WpfApplication/Properties/AssemblyInfo.cs | 4 +- 20 files changed, 65 insertions(+), 297 deletions(-) delete mode 100644 MapControl/GlyphRunText.cs delete mode 100644 MapControl/MapControl.PhoneSilverlight.csproj delete mode 100644 MapControl/MapControl.PhoneSilverlight.csproj.user diff --git a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs index d4200840..a76f61b5 100644 --- a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.5.0")] -[assembly: AssemblyFileVersion("2.5.0")] +[assembly: AssemblyVersion("2.5.1")] +[assembly: AssemblyFileVersion("2.5.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs index 0aa39497..3f56882d 100644 --- a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.5.0")] -[assembly: AssemblyFileVersion("2.5.0")] +[assembly: AssemblyVersion("2.5.1")] +[assembly: AssemblyFileVersion("2.5.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs index 4a109317..f90aaa72 100644 --- a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.5.0")] -[assembly: AssemblyFileVersion("2.5.0")] +[assembly: AssemblyVersion("2.5.1")] +[assembly: AssemblyFileVersion("2.5.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs index 2daece9d..200cd12f 100644 --- a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.5.0")] -[assembly: AssemblyFileVersion("2.5.0")] +[assembly: AssemblyVersion("2.5.1")] +[assembly: AssemblyFileVersion("2.5.1")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/GlyphRunText.cs b/MapControl/GlyphRunText.cs deleted file mode 100644 index 6e199a41..00000000 --- a/MapControl/GlyphRunText.cs +++ /dev/null @@ -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 -{ - /// - /// Contains helper methods for creating GlyphRun objects. - /// - 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(); - } - } -} diff --git a/MapControl/MapBase.Silverlight.WinRT.cs b/MapControl/MapBase.Silverlight.WinRT.cs index 3cb3052c..c33cbc17 100644 --- a/MapControl/MapBase.Silverlight.WinRT.cs +++ b/MapControl/MapBase.Silverlight.WinRT.cs @@ -53,17 +53,15 @@ namespace MapControl style.Setters.Add(new Setter(Panel.BackgroundProperty, new SolidColorBrush(Colors.Transparent))); Style = style; - Clip = new RectangleGeometry(); + var clip = new RectangleGeometry(); + Clip = clip; - SizeChanged += OnRenderSizeChanged; - } - - private void OnRenderSizeChanged(object sender, SizeChangedEventArgs e) - { - ((RectangleGeometry)Clip).Rect = new Rect(new Point(), e.NewSize); - - ResetTransformOrigin(); - UpdateTransform(); + SizeChanged += (s, e) => + { + clip.Rect = new Rect(new Point(), e.NewSize); + ResetTransformOrigin(); + UpdateTransform(); + }; } private void SetViewportTransform(Location origin) diff --git a/MapControl/MapControl.PhoneSilverlight.csproj b/MapControl/MapControl.PhoneSilverlight.csproj deleted file mode 100644 index 5a3d2486..00000000 --- a/MapControl/MapControl.PhoneSilverlight.csproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - Debug - AnyCPU - 10.0.20506 - 2.0 - {3499D618-2846-4FCE-A418-7D211FDBDCB3} - {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - MapControl - MapControl.PhoneSilverlight - WindowsPhone - v8.1 - $(TargetFrameworkVersion) - false - true - 12.0 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE - true - true - prompt - 4 - - - none - true - bin\Release\ - TRACE;SILVERLIGHT;WINDOWS_PHONE - true - true - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MSBuild:Compile - Designer - - - - - - - \ No newline at end of file diff --git a/MapControl/MapControl.PhoneSilverlight.csproj.user b/MapControl/MapControl.PhoneSilverlight.csproj.user deleted file mode 100644 index d3122c8a..00000000 --- a/MapControl/MapControl.PhoneSilverlight.csproj.user +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - True - Managed - Managed - False - - - - - \ No newline at end of file diff --git a/MapControl/MapControl.WPF.csproj b/MapControl/MapControl.WPF.csproj index bf8e298c..a4e0eeec 100644 --- a/MapControl/MapControl.WPF.csproj +++ b/MapControl/MapControl.WPF.csproj @@ -54,7 +54,6 @@ - diff --git a/MapControl/MapGraticule.WPF.cs b/MapControl/MapGraticule.WPF.cs index b16c2330..70408edf 100644 --- a/MapControl/MapGraticule.WPF.cs +++ b/MapControl/MapGraticule.WPF.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Windows; using System.Windows.Media; @@ -15,24 +16,22 @@ namespace MapControl private class Label { 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; Text = text; } } - private Dictionary glyphRuns = new Dictionary(); - static MapGraticule() { UIElement.IsHitTestVisibleProperty.OverrideMetadata( typeof(MapGraticule), new FrameworkPropertyMetadata(false)); 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() @@ -55,79 +54,47 @@ namespace MapControl 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