From f6a881c674536066fe34cd95760221661515fa25 Mon Sep 17 00:00:00 2001 From: ClemensF Date: Wed, 17 Dec 2014 21:38:28 +0100 Subject: [PATCH] Version 2.4.2.: - added HyperlinkText.InlinesSource attached property - simplified TileLayerCollection, removed it from MapBase - simplified MapRectangle and MapImage --- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../ImageFileCache.WinRT/ImageFileCache.cs | 2 +- .../Properties/AssemblyInfo.cs | 4 +- MapControl/HyperlinkText.cs | 52 +++++- MapControl/MapBase.cs | 27 ++- MapControl/MapControl.PhoneSilverlight.csproj | 1 - MapControl/MapControl.Silverlight.csproj | 1 - MapControl/MapImage.cs | 22 ++- MapControl/MapPolyline.cs | 11 +- MapControl/MapRectangle.Silverlight.WinRT.cs | 24 --- MapControl/MapRectangle.WPF.cs | 27 +-- MapControl/MapRectangle.cs | 21 +-- MapControl/Properties/AssemblyInfo.cs | 4 +- MapControl/TileImageLoader.WPF.cs | 4 +- MapControl/TileLayer.cs | 12 -- MapControl/TileLayerCollection.cs | 15 +- MapControl/WinRT/MapControl.WinRT.csproj | 3 - MapControl/WinRT/Properties/AssemblyInfo.cs | 4 +- SampleApps/Common/ViewModel.cs | 46 ++--- SampleApps/PhoneApplication/MainPage.xaml | 4 +- SampleApps/PhoneApplication/MainPage.xaml.cs | 45 ++--- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../SilverlightApplication/MainPage.xaml | 37 ++-- .../SilverlightApplication/MainPage.xaml.cs | 27 +-- .../Properties/AssemblyInfo.cs | 4 +- SampleApps/StoreApplication/MainPage.xaml | 37 ++-- SampleApps/StoreApplication/MainPage.xaml.cs | 23 +-- .../Properties/AssemblyInfo.cs | 4 +- SampleApps/WpfApplication/MainWindow.xaml | 172 +++++++++--------- SampleApps/WpfApplication/MainWindow.xaml.cs | 25 +-- SampleApps/WpfApplication/OutlinedText.cs | 145 +++++++++++++++ .../WpfApplication/Properties/AssemblyInfo.cs | 4 +- .../WpfApplication/WpfApplication.csproj | 1 + 36 files changed, 456 insertions(+), 372 deletions(-) delete mode 100644 MapControl/MapRectangle.Silverlight.WinRT.cs create mode 100644 SampleApps/WpfApplication/OutlinedText.cs diff --git a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs index e701f87f..5c79b760 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("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.1")] -[assembly: AssemblyFileVersion("2.4.1")] +[assembly: AssemblyVersion("2.4.2")] +[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs index 02ce4e59..0476ecf8 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("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.1")] -[assembly: AssemblyFileVersion("2.4.1")] +[assembly: AssemblyVersion("2.4.2")] +[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs index 590e88c8..c78cc7c1 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("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.1")] -[assembly: AssemblyFileVersion("2.4.1")] +[assembly: AssemblyVersion("2.4.2")] +[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache.WinRT/ImageFileCache.cs b/Caching/ImageFileCache.WinRT/ImageFileCache.cs index 113b0ba2..97296348 100644 --- a/Caching/ImageFileCache.WinRT/ImageFileCache.cs +++ b/Caching/ImageFileCache.WinRT/ImageFileCache.cs @@ -49,7 +49,7 @@ namespace MapControl.Caching var cacheItem = new ImageCacheItem { - Buffer = await FileIO.ReadBufferAsync(file), + Buffer = await FileIO.ReadBufferAsync(file) }; try diff --git a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs index cf492161..b5437bad 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("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.1")] -[assembly: AssemblyFileVersion("2.4.1")] +[assembly: AssemblyVersion("2.4.2")] +[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/HyperlinkText.cs b/MapControl/HyperlinkText.cs index 29198ba7..6ffbb646 100644 --- a/MapControl/HyperlinkText.cs +++ b/MapControl/HyperlinkText.cs @@ -6,8 +6,12 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; #if WINDOWS_RUNTIME +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Documents; #else +using System.Windows; +using System.Windows.Controls; using System.Windows.Documents; #endif @@ -21,7 +25,7 @@ namespace MapControl /// Converts text containing hyperlinks in markdown syntax [text](url) /// to a collection of Run and Hyperlink inlines. /// - public static List ToInlines(this string text) + public static IEnumerable TextToInlines(this string text) { var inlines = new List(); @@ -56,5 +60,51 @@ namespace MapControl return inlines; } + + public static readonly DependencyProperty InlinesSourceProperty = DependencyProperty.RegisterAttached( + "InlinesSource", typeof(string), typeof(HyperlinkText), new PropertyMetadata(null, InlinesSourcePropertyChanged)); + + public static string GetInlinesSource(UIElement element) + { + return (string)element.GetValue(InlinesSourceProperty); + } + + public static void SetInlinesSource(UIElement element, string value) + { + element.SetValue(InlinesSourceProperty, value); + } + + private static void InlinesSourcePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) + { + InlineCollection inlines = null; + + if (obj is TextBlock) + { + inlines = ((TextBlock)obj).Inlines; + } + else if (obj is Paragraph) + { + inlines = ((Paragraph)obj).Inlines; + } +#if WINDOWS_RUNTIME || SILVERLIGHT + else if (obj is RichTextBlock) + { + var paragraph = new Paragraph(); + inlines = paragraph.Inlines; + var richTextBlock = (RichTextBlock)obj; + richTextBlock.Blocks.Clear(); + richTextBlock.Blocks.Add(paragraph); + } +#endif + if (inlines != null) + { + inlines.Clear(); + + foreach (var inline in TextToInlines((string)e.NewValue)) + { + inlines.Add(inline); + } + } + } } } diff --git a/MapControl/MapBase.cs b/MapControl/MapBase.cs index afc8b342..96322b79 100644 --- a/MapControl/MapBase.cs +++ b/MapControl/MapBase.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; #if WINDOWS_RUNTIME @@ -39,8 +40,8 @@ namespace MapControl (o, e) => ((MapBase)o).TileLayerPropertyChanged((TileLayer)e.NewValue))); public static readonly DependencyProperty TileLayersProperty = DependencyProperty.Register( - "TileLayers", typeof(TileLayerCollection), typeof(MapBase), new PropertyMetadata(null, - (o, e) => ((MapBase)o).TileLayersPropertyChanged((TileLayerCollection)e.OldValue, (TileLayerCollection)e.NewValue))); + "TileLayers", typeof(IList), typeof(MapBase), new PropertyMetadata(null, + (o, e) => ((MapBase)o).TileLayersPropertyChanged((IList)e.OldValue, (IList)e.NewValue))); public static readonly DependencyProperty MinZoomLevelProperty = DependencyProperty.Register( "MinZoomLevel", typeof(double), typeof(MapBase), new PropertyMetadata(1d, @@ -74,7 +75,7 @@ namespace MapControl public MapBase() { Children.Add(tileLayerPanel); - TileLayers = new TileLayerCollection(); + TileLayers = new ObservableCollection(); tileUpdateTimer.Tick += UpdateTiles; Loaded += OnLoaded; @@ -119,9 +120,9 @@ namespace MapControl /// The additional TileLayers usually have transparent backgrounds and their IsOverlay /// property is set to true. /// - public TileLayerCollection TileLayers + public IList TileLayers { - get { return (TileLayerCollection)GetValue(TileLayersProperty); } + get { return (IList)GetValue(TileLayersProperty); } set { SetValue(TileLayersProperty, value); } } @@ -416,7 +417,7 @@ namespace MapControl { if (TileLayers == null) { - TileLayers = new TileLayerCollection(tileLayer); + TileLayers = new ObservableCollection(new TileLayer[] { tileLayer }); } else if (TileLayers.Count == 0) { @@ -429,11 +430,15 @@ namespace MapControl } } - private void TileLayersPropertyChanged(TileLayerCollection oldTileLayers, TileLayerCollection newTileLayers) + private void TileLayersPropertyChanged(IList oldTileLayers, IList newTileLayers) { if (oldTileLayers != null) { - oldTileLayers.CollectionChanged -= TileLayerCollectionChanged; + var oldCollection = oldTileLayers as INotifyCollectionChanged; + if (oldCollection != null) + { + oldCollection.CollectionChanged -= TileLayerCollectionChanged; + } TileLayer = null; RemoveTileLayers(0, oldTileLayers.Count); @@ -444,7 +449,11 @@ namespace MapControl TileLayer = newTileLayers.FirstOrDefault(); AddTileLayers(0, newTileLayers); - newTileLayers.CollectionChanged += TileLayerCollectionChanged; + var newCollection = newTileLayers as INotifyCollectionChanged; + if (newCollection != null) + { + newCollection.CollectionChanged += TileLayerCollectionChanged; + } } } diff --git a/MapControl/MapControl.PhoneSilverlight.csproj b/MapControl/MapControl.PhoneSilverlight.csproj index 82a855b8..5a3d2486 100644 --- a/MapControl/MapControl.PhoneSilverlight.csproj +++ b/MapControl/MapControl.PhoneSilverlight.csproj @@ -72,7 +72,6 @@ - diff --git a/MapControl/MapControl.Silverlight.csproj b/MapControl/MapControl.Silverlight.csproj index 5b4043e2..dccb6836 100644 --- a/MapControl/MapControl.Silverlight.csproj +++ b/MapControl/MapControl.Silverlight.csproj @@ -99,7 +99,6 @@ - diff --git a/MapControl/MapImage.cs b/MapControl/MapImage.cs index b04a6d4e..75e991cb 100644 --- a/MapControl/MapImage.cs +++ b/MapControl/MapImage.cs @@ -19,21 +19,23 @@ namespace MapControl { public static readonly DependencyProperty SourceProperty = DependencyProperty.Register( "Source", typeof(ImageSource), typeof(MapImage), - new PropertyMetadata(null, (o, e) => ((MapImage)o).SourcePropertyChanged((ImageSource)e.NewValue))); + new PropertyMetadata(null, (o, e) => ((ImageBrush)((MapImage)o).Fill).ImageSource = (ImageSource)e.NewValue)); + + public MapImage() + { + Fill = new ImageBrush + { + RelativeTransform = new MatrixTransform + { + Matrix = new Matrix(1d, 0d, 0d, -1d, 0d, 1d) + } + }; + } public ImageSource Source { get { return (ImageSource)GetValue(SourceProperty); } set { SetValue(SourceProperty, value); } } - - private void SourcePropertyChanged(ImageSource image) - { - Fill = new ImageBrush - { - ImageSource = image, - RelativeTransform = FillTransform - }; - } } } diff --git a/MapControl/MapPolyline.cs b/MapControl/MapPolyline.cs index a8fb4dc1..e2c91594 100644 --- a/MapControl/MapPolyline.cs +++ b/MapControl/MapPolyline.cs @@ -2,11 +2,9 @@ // Copyright © 2014 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) -using System; using System.Collections.Generic; using System.Collections.Specialized; #if WINDOWS_RUNTIME -using Windows.Foundation; using Windows.UI.Xaml; #else using System.Windows; @@ -20,15 +18,8 @@ namespace MapControl /// public partial class MapPolyline : MapPath { -#if WINDOWS_RUNTIME - // For Windows Runtime, the Locations dependency property type is declared as object - // instead of IEnumerable. See http://stackoverflow.com/q/10544084/1136211 - private static readonly Type LocationsPropertyType = typeof(object); -#else - private static readonly Type LocationsPropertyType = typeof(IEnumerable); -#endif public static readonly DependencyProperty LocationsProperty = DependencyProperty.Register( - "Locations", LocationsPropertyType, typeof(MapPolyline), + "Locations", typeof(IEnumerable), typeof(MapPolyline), new PropertyMetadata(null, LocationsPropertyChanged)); public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register( diff --git a/MapControl/MapRectangle.Silverlight.WinRT.cs b/MapControl/MapRectangle.Silverlight.WinRT.cs deleted file mode 100644 index 8737e1bf..00000000 --- a/MapControl/MapRectangle.Silverlight.WinRT.cs +++ /dev/null @@ -1,24 +0,0 @@ -// XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2014 Clemens Fischer -// Licensed under the Microsoft Public License (Ms-PL) - -#if WINDOWS_RUNTIME -using Windows.Foundation; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Media; -#else -using System.Windows; -using System.Windows.Media; -#endif - -namespace MapControl -{ - public partial class MapRectangle - { - private void SetRect(Rect rect) - { - ((RectangleGeometry)Data).Rect = rect; - RenderTransform = ParentMap.ViewportTransform; - } - } -} diff --git a/MapControl/MapRectangle.WPF.cs b/MapControl/MapRectangle.WPF.cs index 1b77cf88..8f567505 100644 --- a/MapControl/MapRectangle.WPF.cs +++ b/MapControl/MapRectangle.WPF.cs @@ -2,7 +2,6 @@ // Copyright © 2014 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) -using System; using System.Windows; using System.Windows.Media; @@ -10,31 +9,21 @@ namespace MapControl { public partial class MapRectangle { - static MapRectangle() + static partial void ScaleRect(ref Rect rect, ref Transform transform) { - FillTransform.Freeze(); - } - - private void SetRect(Rect rect) - { - // Apply scaling to the RectangleGeometry to compensate for inaccurate hit testing in WPF. + // Scales the RectangleGeometry to compensate inaccurate hit testing in WPF. // See http://stackoverflow.com/a/19335624/1136211 - var scale = 1e6 / Math.Min(rect.Width, rect.Height); - rect.X *= scale; - rect.Y *= scale; - rect.Width *= scale; - rect.Height *= scale; + rect.Scale(1e6, 1e6); - var scaleTransform = new ScaleTransform(1d / scale, 1d / scale); + var scaleTransform = new ScaleTransform(1e-6, 1e-6); // reverts rect scaling scaleTransform.Freeze(); - var transform = new TransformGroup(); - transform.Children.Add(scaleTransform); // revert scaling - transform.Children.Add(ParentMap.ViewportTransform); + var transformGroup = new TransformGroup(); + transformGroup.Children.Add(scaleTransform); + transformGroup.Children.Add(transform); - ((RectangleGeometry)Data).Rect = rect; - RenderTransform = transform; + transform = transformGroup; } } } \ No newline at end of file diff --git a/MapControl/MapRectangle.cs b/MapControl/MapRectangle.cs index 39e21eff..9a5099af 100644 --- a/MapControl/MapRectangle.cs +++ b/MapControl/MapRectangle.cs @@ -18,14 +18,6 @@ namespace MapControl /// public partial class MapRectangle : MapPath { - /// - /// Used in derived classes like MapImage. - /// - protected static readonly MatrixTransform FillTransform = new MatrixTransform - { - Matrix = new Matrix(1d, 0d, 0d, -1d, 0d, 1d) - }; - public static readonly DependencyProperty WestProperty = DependencyProperty.Register( "West", typeof(double), typeof(MapRectangle), new PropertyMetadata(double.NaN, (o, e) => ((MapRectangle)o).UpdateData())); @@ -81,9 +73,14 @@ namespace MapControl !double.IsNaN(West) && !double.IsNaN(East) && South < North && West < East) { - SetRect(new Rect( - ParentMap.MapTransform.Transform(new Location(South, West)), - ParentMap.MapTransform.Transform(new Location(North, East)))); + var rect = new Rect(ParentMap.MapTransform.Transform(new Location(South, West)), + ParentMap.MapTransform.Transform(new Location(North, East))); + var transform = ParentMap.ViewportTransform; + + ScaleRect(ref rect, ref transform); + + geometry.Rect = rect; + RenderTransform = transform; } else { @@ -91,5 +88,7 @@ namespace MapControl ClearValue(RenderTransformProperty); } } + + static partial void ScaleRect(ref Rect rect, ref Transform transform); } } diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index 4012d169..70d0caf6 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -17,8 +17,8 @@ using System.Windows; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.1")] -[assembly: AssemblyFileVersion("2.4.1")] +[assembly: AssemblyVersion("2.4.2")] +[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/TileImageLoader.WPF.cs b/MapControl/TileImageLoader.WPF.cs index 3c1d1946..b5d5b937 100644 --- a/MapControl/TileImageLoader.WPF.cs +++ b/MapControl/TileImageLoader.WPF.cs @@ -85,7 +85,7 @@ namespace MapControl } else { - var tileList = tiles.ToList(); + var tileList = tiles.ToList(); // force immediate evaluation var sourceName = tileLayer.SourceName; var maxDownloads = tileLayer.MaxParallelDownloads; @@ -101,7 +101,7 @@ namespace MapControl while (pendingTiles.TryDequeue(out pendingTile)) ; // no Clear method } - private void GetTiles(List tiles, Dispatcher dispatcher, TileSource tileSource, string sourceName, int maxDownloads) + private void GetTiles(IEnumerable tiles, Dispatcher dispatcher, TileSource tileSource, string sourceName, int maxDownloads) { if (Cache != null && !string.IsNullOrWhiteSpace(sourceName) && diff --git a/MapControl/TileLayer.cs b/MapControl/TileLayer.cs index 80d9d839..17cedf76 100644 --- a/MapControl/TileLayer.cs +++ b/MapControl/TileLayer.cs @@ -8,12 +8,10 @@ using System.Linq; #if WINDOWS_RUNTIME using Windows.Foundation; using Windows.UI.Xaml; -using Windows.UI.Xaml.Documents; using Windows.UI.Xaml.Markup; using Windows.UI.Xaml.Media; #else using System.Windows; -using System.Windows.Documents; using System.Windows.Markup; using System.Windows.Media; #endif @@ -158,16 +156,6 @@ namespace MapControl set { SetValue(BackgroundProperty, value); } } - /// - /// In case the Description text contains copyright links in markdown syntax [text](url), - /// the DescriptionInlines property may be used to create a collection of Run and Hyperlink - /// inlines to be displayed in e.g. a TextBlock or a Silverlight RichTextBlock. - /// - public List DescriptionInlines - { - get { return Description.ToInlines(); } - } - public MapBase ParentMap { get { return parentMap; } diff --git a/MapControl/TileLayerCollection.cs b/MapControl/TileLayerCollection.cs index f638dd2e..b86bcb93 100644 --- a/MapControl/TileLayerCollection.cs +++ b/MapControl/TileLayerCollection.cs @@ -7,17 +7,12 @@ using System.Linq; namespace MapControl { - public class TileLayerCollection : ObservableCollection + /// + /// A collection of TileLayers with a string indexer that allows + /// to retrieve individual TileLayers by their SourceName property. + /// + public class TileLayerCollection : Collection { - internal TileLayerCollection(TileLayer tileLayer) - { - Add(tileLayer); - } - - public TileLayerCollection() - { - } - public TileLayer this[string sourceName] { get { return this.FirstOrDefault(t => t.SourceName == sourceName); } diff --git a/MapControl/WinRT/MapControl.WinRT.csproj b/MapControl/WinRT/MapControl.WinRT.csproj index 9714c135..0981cb7d 100644 --- a/MapControl/WinRT/MapControl.WinRT.csproj +++ b/MapControl/WinRT/MapControl.WinRT.csproj @@ -126,9 +126,6 @@ MapRectangle.cs - - MapRectangle.Silverlight.WinRT.cs - MapTransform.cs diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs index 522f590e..d3f996b6 100644 --- a/MapControl/WinRT/Properties/AssemblyInfo.cs +++ b/MapControl/WinRT/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.1")] -[assembly: AssemblyFileVersion("2.4.1")] +[assembly: AssemblyVersion("2.4.2")] +[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/Common/ViewModel.cs b/SampleApps/Common/ViewModel.cs index 0e5648ab..7c14754f 100644 --- a/SampleApps/Common/ViewModel.cs +++ b/SampleApps/Common/ViewModel.cs @@ -11,7 +11,7 @@ using MapControl; namespace ViewModel { - public class VmBase : INotifyPropertyChanged + public class Base : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; @@ -25,7 +25,7 @@ namespace ViewModel } } - public class VmPoint : VmBase + public class Point : Base { private string name; public string Name @@ -50,16 +50,16 @@ namespace ViewModel } } - public class VmPolyline + public class Polyline { public LocationCollection Locations { get; set; } } - public class ViewModel : VmBase + public class ViewModel : Base { - public ObservableCollection Points { get; set; } - public ObservableCollection Pushpins { get; set; } - public ObservableCollection Polylines { get; set; } + public ObservableCollection Points { get; set; } + public ObservableCollection Pushpins { get; set; } + public ObservableCollection Polylines { get; set; } private Location mapCenter; public Location MapCenter @@ -76,71 +76,71 @@ namespace ViewModel { MapCenter = new Location(53.5, 8.2); - Points = new ObservableCollection(); + Points = new ObservableCollection(); Points.Add( - new VmPoint + new Point { Name = "Steinbake Leitdamm", Location = new Location(53.51217, 8.16603) }); Points.Add( - new VmPoint + new Point { Name = "Buhne 2", Location = new Location(53.50926, 8.15815) }); Points.Add( - new VmPoint + new Point { Name = "Buhne 4", Location = new Location(53.50468, 8.15343) }); Points.Add( - new VmPoint + new Point { Name = "Buhne 6", Location = new Location(53.50092, 8.15267) }); Points.Add( - new VmPoint + new Point { Name = "Buhne 8", Location = new Location(53.49871, 8.15321) }); Points.Add( - new VmPoint + new Point { Name = "Buhne 10", Location = new Location(53.49350, 8.15563) }); Points.Add( - new VmPoint + new Point { Name = "Moving", Location = new Location(53.5, 8.25) }); - Pushpins = new ObservableCollection(); + Pushpins = new ObservableCollection(); Pushpins.Add( - new VmPoint + new Point { Name = "WHV - Eckwarderhörne", Location = new Location(53.5495, 8.1877) }); Pushpins.Add( - new VmPoint + new Point { Name = "JadeWeserPort", Location = new Location(53.5914, 8.14) }); Pushpins.Add( - new VmPoint + new Point { Name = "Kurhaus Dangast", Location = new Location(53.447, 8.1114) }); Pushpins.Add( - new VmPoint + new Point { Name = "Eckwarderhörne", Location = new Location(53.5207, 8.2323) @@ -157,14 +157,14 @@ namespace ViewModel // }); //} - Polylines = new ObservableCollection(); + Polylines = new ObservableCollection(); Polylines.Add( - new VmPolyline + new Polyline { Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387") }); Polylines.Add( - new VmPolyline + new Polyline { Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212") }); diff --git a/SampleApps/PhoneApplication/MainPage.xaml b/SampleApps/PhoneApplication/MainPage.xaml index f39ea5a2..13b63d87 100644 --- a/SampleApps/PhoneApplication/MainPage.xaml +++ b/SampleApps/PhoneApplication/MainPage.xaml @@ -65,9 +65,9 @@ @@ -97,7 +97,7 @@ - + diff --git a/SampleApps/PhoneApplication/MainPage.xaml.cs b/SampleApps/PhoneApplication/MainPage.xaml.cs index 2e37b7cc..4b9fde7d 100644 --- a/SampleApps/PhoneApplication/MainPage.xaml.cs +++ b/SampleApps/PhoneApplication/MainPage.xaml.cs @@ -10,8 +10,7 @@ namespace PhoneApplication { public sealed partial class MainPage : Page { - private TileLayerCollection tileLayers; - private bool manipulationActive; + private bool mapCentered; public MainPage() { @@ -19,66 +18,48 @@ namespace PhoneApplication InitializeComponent(); - tileLayers = (TileLayerCollection)Resources["TileLayers"]; - SetTileLayer(tileLayers[0].SourceName); - DataContext = new ViewModel(Dispatcher); NavigationCacheMode = NavigationCacheMode.Required; } - private void SetTileLayer(string tileLayer) + private void MapMenuItemClick(object sender, RoutedEventArgs e) { - map.TileLayer = tileLayers[tileLayer]; - - mapLegend.Inlines.Clear(); - - foreach (var inline in map.TileLayer.DescriptionInlines) - { - mapLegend.Inlines.Add(inline); - } + var tileLayers = (TileLayerCollection)Resources["TileLayers"]; + map.TileLayer = tileLayers[(string)((FrameworkElement)sender).Tag]; } private void SeamarksChecked(object sender, RoutedEventArgs e) { - map.TileLayers.Add((TileLayer)tileLayers["Seamarks"]); + var tileLayers = (TileLayerCollection)Resources["TileLayers"]; + map.TileLayers.Add(tileLayers["Seamarks"]); } private void SeamarksUnchecked(object sender, RoutedEventArgs e) { - map.TileLayers.Remove((TileLayer)tileLayers["Seamarks"]); - } - - private void MapMenuItemClick(object sender, RoutedEventArgs e) - { - var selectedItem = (MenuFlyoutItem)sender; - SetTileLayer((string)selectedItem.Tag); + var tileLayers = (TileLayerCollection)Resources["TileLayers"]; + map.TileLayers.Remove(tileLayers["Seamarks"]); } private void CenterButtonClick(object sender, RoutedEventArgs e) { - manipulationActive = false; map.TargetCenter = ((ViewModel)DataContext).Location; + mapCentered = true; } private void MapManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e) { - manipulationActive = true; - } - - private void MapManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) - { - manipulationActive = false; + mapCentered = false; } private void MapManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) { - if (manipulationActive) + if (mapCentered) { - map.TransformMap(e.Position, e.Delta.Translation, e.Delta.Rotation, e.Delta.Scale); + e.Complete(); } else { - e.Complete(); + map.TransformMap(e.Position, e.Delta.Translation, e.Delta.Rotation, e.Delta.Scale); } } } diff --git a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs index 912f9044..2e8e6a1b 100644 --- a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.1")] -[assembly: AssemblyFileVersion("2.4.1")] +[assembly: AssemblyVersion("2.4.2")] +[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs index 353eee48..c2ceff4a 100644 --- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.1")] -[assembly: AssemblyFileVersion("2.4.1")] +[assembly: AssemblyVersion("2.4.2")] +[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/MainPage.xaml b/SampleApps/SilverlightApplication/MainPage.xaml index 54470139..23e9f6af 100644 --- a/SampleApps/SilverlightApplication/MainPage.xaml +++ b/SampleApps/SilverlightApplication/MainPage.xaml @@ -57,9 +57,11 @@ Description="© [Microsoft Corporation](http://www.bing.com/maps/)" Mode="AerialWithLabels" MaxZoomLevel="19" Foreground="White" Background="Black"/> + + + + + + - + + @@ -162,7 +171,7 @@ - + @@ -191,18 +200,18 @@ - - OpenStreetMap - OpenCycleMap - Landscape - Outdoors - Transport - Transport Dark - MapQuest Open - + + OpenStreetMap + OpenCycleMap + Landscape + Outdoors + Transport + Transport Dark + MapQuest Open + diff --git a/SampleApps/SilverlightApplication/MainPage.xaml.cs b/SampleApps/SilverlightApplication/MainPage.xaml.cs index 996ec3f6..bd4f2ae1 100644 --- a/SampleApps/SilverlightApplication/MainPage.xaml.cs +++ b/SampleApps/SilverlightApplication/MainPage.xaml.cs @@ -2,7 +2,6 @@ using System.Globalization; using System.Windows; using System.Windows.Controls; -using System.Windows.Documents; using System.Windows.Input; using MapControl; @@ -10,16 +9,11 @@ namespace SilverlightApplication { public partial class MainPage : UserControl { - private TileLayerCollection tileLayers; - public MainPage() { //BingMapsTileLayer.ApiKey = "..."; InitializeComponent(); - - tileLayers = (TileLayerCollection)Resources["TileLayers"]; - tileLayerComboBox.SelectedIndex = 0; } private void MapMouseMove(object sender, MouseEventArgs e) @@ -53,31 +47,14 @@ namespace SilverlightApplication mouseLocation.Text = string.Empty; } - private void TileLayerSelectionChanged(object sender, SelectionChangedEventArgs e) - { - var selectedItem = (ComboBoxItem)tileLayerComboBox.SelectedItem; - - map.TileLayer = tileLayers[(string)selectedItem.Tag]; - - var paragraph = new Paragraph(); - - foreach (var inline in map.TileLayer.DescriptionInlines) - { - paragraph.Inlines.Add(inline); - } - - mapLegend.Blocks.Clear(); - mapLegend.Blocks.Add(paragraph); - } - private void SeamarksChecked(object sender, RoutedEventArgs e) { - map.TileLayers.Add(tileLayers["Seamarks"]); + map.TileLayers.Add(((TileLayerCollection)Resources["TileLayers"])["Seamarks"]); } private void SeamarksUnchecked(object sender, RoutedEventArgs e) { - map.TileLayers.Remove(tileLayers["Seamarks"]); + map.TileLayers.Remove(((TileLayerCollection)Resources["TileLayers"])["Seamarks"]); } } } diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs index bddcb0a5..6a584bd3 100644 --- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.1")] -[assembly: AssemblyFileVersion("2.4.1")] +[assembly: AssemblyVersion("2.4.2")] +[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/StoreApplication/MainPage.xaml b/SampleApps/StoreApplication/MainPage.xaml index de40ee88..097d323d 100644 --- a/SampleApps/StoreApplication/MainPage.xaml +++ b/SampleApps/StoreApplication/MainPage.xaml @@ -61,9 +61,11 @@ Description="Bing Maps - © Microsoft Corporation" Mode="AerialWithLabels" MaxZoomLevel="19" Foreground="White" Background="Black"/> + + + + + + - + @@ -194,7 +200,8 @@ - + @@ -220,18 +227,18 @@ - - OpenStreetMap - OpenCycleMap - Landscape - Outdoors - Transport - Transport Dark - MapQuest Open - + + OpenStreetMap + OpenCycleMap + Landscape + Outdoors + Transport + Transport Dark + MapQuest Open + diff --git a/SampleApps/StoreApplication/MainPage.xaml.cs b/SampleApps/StoreApplication/MainPage.xaml.cs index 69c6228d..dccccc5b 100644 --- a/SampleApps/StoreApplication/MainPage.xaml.cs +++ b/SampleApps/StoreApplication/MainPage.xaml.cs @@ -7,8 +7,6 @@ namespace StoreApplication { public sealed partial class MainPage : Page { - private TileLayerCollection tileLayers; - public MainPage() { //TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(); @@ -16,9 +14,6 @@ namespace StoreApplication //BingMapsTileLayer.ApiKey = "..."; this.InitializeComponent(); - - tileLayers = (TileLayerCollection)Resources["TileLayers"]; - tileLayerComboBox.SelectedIndex = 0; } private void ImageOpacitySliderValueChanged(object sender, RangeBaseValueChangedEventArgs e) @@ -29,28 +24,14 @@ namespace StoreApplication } } - private void TileLayerSelectionChanged(object sender, SelectionChangedEventArgs e) - { - var selectedItem = (ComboBoxItem)tileLayerComboBox.SelectedItem; - - map.TileLayer = tileLayers[(string)selectedItem.Tag]; - - mapLegend.Inlines.Clear(); - - foreach (var inline in map.TileLayer.DescriptionInlines) - { - mapLegend.Inlines.Add(inline); - } - } - private void SeamarksChecked(object sender, RoutedEventArgs e) { - map.TileLayers.Add(tileLayers["Seamarks"]); + map.TileLayers.Add(((TileLayerCollection)Resources["TileLayers"])["Seamarks"]); } private void SeamarksUnchecked(object sender, RoutedEventArgs e) { - map.TileLayers.Remove(tileLayers["Seamarks"]); + map.TileLayers.Remove(((TileLayerCollection)Resources["TileLayers"])["Seamarks"]); } } } diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs index e9f23182..ee828a0a 100644 --- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.1")] -[assembly: AssemblyFileVersion("2.4.1")] +[assembly: AssemblyVersion("2.4.2")] +[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/WpfApplication/MainWindow.xaml b/SampleApps/WpfApplication/MainWindow.xaml index 29b90cea..852297f0 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml +++ b/SampleApps/WpfApplication/MainWindow.xaml @@ -8,80 +8,81 @@ Title="XAML MapControl - WPF Test Application" Height="600" Width="800" Stylus.IsPressAndHoldEnabled="False"> - - - - - - - - - - + + + + + + + + + - - - - + + + + - - + + - - + + + + + - - - + + + + + + - @@ -223,7 +229,7 @@ - + @@ -252,18 +258,18 @@ - - OpenStreetMap - OpenCycleMap - Landscape - Outdoors - Transport - Transport Dark - MapQuest Open - + + OpenStreetMap + OpenCycleMap + Landscape + Outdoors + Transport + Transport Dark + MapQuest Open + diff --git a/SampleApps/WpfApplication/MainWindow.xaml.cs b/SampleApps/WpfApplication/MainWindow.xaml.cs index 91d45d8f..5410ffb9 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml.cs +++ b/SampleApps/WpfApplication/MainWindow.xaml.cs @@ -1,28 +1,21 @@ using System; using System.Globalization; using System.Windows; -using System.Windows.Controls; using System.Windows.Input; using MapControl; -using MapControl.Caching; namespace WpfApplication { public partial class MainWindow : Window { - private TileLayerCollection tileLayers; - public MainWindow() { - //TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheFolder); - //TileImageLoader.Cache = new FileDbCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheFolder); + //TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheFolder); + //TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheFolder); //TileImageLoader.HttpUserAgent = "..."; //BingMapsTileLayer.ApiKey = "..."; InitializeComponent(); - - tileLayers = (TileLayerCollection)Resources["TileLayers"]; - tileLayerComboBox.SelectedIndex = 0; } private void MapMouseLeftButtonDown(object sender, MouseButtonEventArgs e) @@ -85,24 +78,14 @@ namespace WpfApplication e.Handled = true; } - private void TileLayerSelectionChanged(object sender, SelectionChangedEventArgs e) - { - var selectedItem = (ComboBoxItem)tileLayerComboBox.SelectedItem; - - map.TileLayer = tileLayers[(string)selectedItem.Tag]; - - mapLegend.Inlines.Clear(); - mapLegend.Inlines.AddRange(map.TileLayer.DescriptionInlines); - } - private void SeamarksChecked(object sender, RoutedEventArgs e) { - map.TileLayers.Add(tileLayers["Seamarks"]); + map.TileLayers.Add((TileLayer)Resources["Seamarks"]); } private void SeamarksUnchecked(object sender, RoutedEventArgs e) { - map.TileLayers.Remove(tileLayers["Seamarks"]); + map.TileLayers.Remove((TileLayer)Resources["Seamarks"]); } } } diff --git a/SampleApps/WpfApplication/OutlinedText.cs b/SampleApps/WpfApplication/OutlinedText.cs new file mode 100644 index 00000000..16d6023f --- /dev/null +++ b/SampleApps/WpfApplication/OutlinedText.cs @@ -0,0 +1,145 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; + +namespace WpfApplication +{ + public class OutlinedText : FrameworkElement + { + private GlyphRun glyphRun; + private Geometry outline; + + public static readonly DependencyProperty TextProperty = TextBlock.TextProperty.AddOwner( + typeof(OutlinedText), new FrameworkPropertyMetadata((o, e) => ((OutlinedText)o).glyphRun = null)); + + public static readonly DependencyProperty FontSizeProperty = TextBlock.FontSizeProperty.AddOwner( + typeof(OutlinedText), new FrameworkPropertyMetadata((o, e) => ((OutlinedText)o).glyphRun = null)); + + public static readonly DependencyProperty FontFamilyProperty = TextBlock.FontFamilyProperty.AddOwner( + typeof(OutlinedText), new FrameworkPropertyMetadata((o, e) => ((OutlinedText)o).glyphRun = null)); + + public static readonly DependencyProperty FontStyleProperty = TextBlock.FontStyleProperty.AddOwner( + typeof(OutlinedText), new FrameworkPropertyMetadata((o, e) => ((OutlinedText)o).glyphRun = null)); + + public static readonly DependencyProperty FontWeightProperty = TextBlock.FontWeightProperty.AddOwner( + typeof(OutlinedText), new FrameworkPropertyMetadata((o, e) => ((OutlinedText)o).glyphRun = null)); + + public static readonly DependencyProperty FontStretchProperty = TextBlock.FontStretchProperty.AddOwner( + typeof(OutlinedText), new FrameworkPropertyMetadata((o, e) => ((OutlinedText)o).glyphRun = null)); + + public static readonly DependencyProperty ForegroundProperty = TextBlock.ForegroundProperty.AddOwner( + typeof(OutlinedText), new FrameworkPropertyMetadata((o, e) => ((OutlinedText)o).glyphRun = null)); + + public static readonly DependencyProperty BackgroundProperty = TextBlock.BackgroundProperty.AddOwner( + typeof(OutlinedText), new FrameworkPropertyMetadata(Brushes.White, (o, e) => ((OutlinedText)o).glyphRun = null)); + + public static readonly DependencyProperty OutlineThicknessProperty = DependencyProperty.Register( + "OutlineThickness", typeof(double), typeof(OutlinedText), + new FrameworkPropertyMetadata(1d, FrameworkPropertyMetadataOptions.AffectsMeasure, (o, e) => ((OutlinedText)o).glyphRun = null)); + + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + public double FontSize + { + get { return (double)GetValue(FontSizeProperty); } + set { SetValue(FontSizeProperty, value); } + } + + public FontFamily FontFamily + { + get { return (FontFamily)GetValue(FontFamilyProperty); } + set { SetValue(FontFamilyProperty, value); } + } + + public FontStyle FontStyle + { + get { return (FontStyle)GetValue(FontStyleProperty); } + set { SetValue(FontStyleProperty, value); } + } + + public FontWeight FontWeight + { + get { return (FontWeight)GetValue(FontWeightProperty); } + set { SetValue(FontWeightProperty, value); } + } + + public FontStretch FontStretch + { + get { return (FontStretch)GetValue(FontStretchProperty); } + set { SetValue(FontStretchProperty, value); } + } + + public Brush Foreground + { + get { return (Brush)GetValue(ForegroundProperty); } + set { SetValue(ForegroundProperty, value); } + } + + public Brush Background + { + get { return (Brush)GetValue(BackgroundProperty); } + set { SetValue(BackgroundProperty, value); } + } + + public double OutlineThickness + { + get { return (double)GetValue(OutlineThicknessProperty); } + set { SetValue(OutlineThicknessProperty, value); } + } + + protected override Size MeasureOverride(Size availableSize) + { + return CheckGlyphRun() ? outline.Bounds.Size : new Size(); + } + + protected override void OnRender(DrawingContext drawingContext) + { + if (CheckGlyphRun()) + { + var location = outline.Bounds.Location; + drawingContext.PushTransform(new TranslateTransform(-location.X, -location.Y)); + drawingContext.DrawGeometry(Background, null, outline); + drawingContext.DrawGlyphRun(Foreground, glyphRun); + } + } + + private bool CheckGlyphRun() + { + if (glyphRun == null) + { + if (string.IsNullOrWhiteSpace(Text)) + { + return false; + } + + var typeface = new Typeface(FontFamily, FontStyle, FontWeight, FontStretch); + GlyphTypeface glyphTypeface; + + if (!typeface.TryGetGlyphTypeface(out glyphTypeface)) + { + return false; + } + + 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] * FontSize; + } + + glyphRun = new GlyphRun(glyphTypeface, 0, false, FontSize, glyphIndices, new Point(), advanceWidths, null, null, null, null, null, null); + + outline = glyphRun.BuildGeometry().GetWidenedPathGeometry(new Pen(null, OutlineThickness * 2d)); + } + + return true; + } + } +} diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs index 2e17b6d8..542597ff 100644 --- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.1")] -[assembly: AssemblyFileVersion("2.4.1")] +[assembly: AssemblyVersion("2.4.2")] +[assembly: AssemblyFileVersion("2.4.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/WpfApplication/WpfApplication.csproj b/SampleApps/WpfApplication/WpfApplication.csproj index bc99a8d3..132e1dff 100644 --- a/SampleApps/WpfApplication/WpfApplication.csproj +++ b/SampleApps/WpfApplication/WpfApplication.csproj @@ -69,6 +69,7 @@ + Code