From d0d949c9bed636f4ac7444935a4ed3959b2f9b6f Mon Sep 17 00:00:00 2001 From: ClemensF Date: Thu, 6 Dec 2012 23:28:12 +0100 Subject: [PATCH] Removed LocationPath property from MapItem and PushPin. --- Caching/FileDbCache/FileDbCache.cs | 12 ++--- Caching/ImageFileCache/ImageFileCache.cs | 10 ++-- MapControl/MapControl.Silverlight.csproj | 2 - MapControl/MapControl.WPF.csproj | 2 - MapControl/MapItem.Silverlight.WinRT.cs | 11 ++++- MapControl/MapItem.WPF.cs | 5 +- MapControl/MapItem.cs | 49 ------------------- MapControl/Pushpin.Silverlight.WinRT.cs | 11 ++++- MapControl/Pushpin.WPF.cs | 6 ++- MapControl/Pushpin.cs | 49 ------------------- MapControl/TileImageLoader.WPF.cs | 4 +- MapControl/WinRT/MapControl.WinRT.csproj | 6 --- .../SilverlightApplication/MainPage.xaml | 6 +-- SampleApps/StoreApplication/BindingHelper.cs | 36 ++++++++++++++ SampleApps/StoreApplication/MainPage.xaml | 9 ++-- .../StoreApplication/StoreApplication.csproj | 1 + SampleApps/WpfApplication/MainWindow.xaml | 2 +- 17 files changed, 88 insertions(+), 133 deletions(-) delete mode 100644 MapControl/MapItem.cs delete mode 100644 MapControl/Pushpin.cs create mode 100644 SampleApps/StoreApplication/BindingHelper.cs diff --git a/Caching/FileDbCache/FileDbCache.cs b/Caching/FileDbCache/FileDbCache.cs index e7f1d87d..a4e82fba 100644 --- a/Caching/FileDbCache/FileDbCache.cs +++ b/Caching/FileDbCache/FileDbCache.cs @@ -30,8 +30,8 @@ namespace Caching public FileDbCache(string name, NameValueCollection config) : this(name, config["directory"]) { - string autoFlush = config["autoFlush"]; - string autoCleanThreshold = config["autoCleanThreshold"]; + var autoFlush = config["autoFlush"]; + var autoCleanThreshold = config["autoCleanThreshold"]; if (autoFlush != null) { @@ -221,13 +221,13 @@ namespace Caching } object value = null; - Record record = GetRecord(key); + var record = GetRecord(key); if (record != null) { try { - using (MemoryStream stream = new MemoryStream((byte[])record[0])) + using (var stream = new MemoryStream((byte[])record[0])) { value = formatter.Deserialize(stream); } @@ -296,7 +296,7 @@ namespace Caching try { - using (MemoryStream stream = new MemoryStream()) + using (var stream = new MemoryStream()) { formatter.Serialize(stream, value); valueBuffer = stream.ToArray(); @@ -309,7 +309,7 @@ namespace Caching if (valueBuffer != null) { - DateTime expires = DateTime.MaxValue; + var expires = DateTime.MaxValue; if (policy.AbsoluteExpiration != InfiniteAbsoluteExpiration) { diff --git a/Caching/ImageFileCache/ImageFileCache.cs b/Caching/ImageFileCache/ImageFileCache.cs index f69507c0..f6f422d5 100644 --- a/Caching/ImageFileCache/ImageFileCache.cs +++ b/Caching/ImageFileCache/ImageFileCache.cs @@ -112,10 +112,10 @@ namespace Caching if (path != null) { - long creationTime = File.GetLastWriteTimeUtc(path).ToBinary(); + var creationTime = File.GetLastWriteTimeUtc(path).ToBinary(); - using (FileStream fileStream = new FileStream(path, FileMode.Open)) - using (MemoryStream memoryStream = new MemoryStream((int)(fileStream.Length + 8))) + using (var fileStream = new FileStream(path, FileMode.Open)) + using (var memoryStream = new MemoryStream((int)(fileStream.Length + 8))) { memoryStream.Write(BitConverter.GetBytes(creationTime), 0, 8); fileStream.CopyTo(memoryStream); @@ -180,7 +180,7 @@ namespace Caching { Directory.CreateDirectory(Path.GetDirectoryName(path)); - using (FileStream fileStream = new FileStream(path, FileMode.Create)) + using (var fileStream = new FileStream(path, FileMode.Create)) { fileStream.Write(buffer, 8, buffer.Length - 8); } @@ -278,7 +278,7 @@ namespace Caching private static string GetFileExtension(byte[] buffer) { string extension = null; - DateTime creationTime = DateTime.FromBinary(BitConverter.ToInt64(buffer, 0)); + var creationTime = DateTime.FromBinary(BitConverter.ToInt64(buffer, 0)); if (creationTime.Kind == DateTimeKind.Utc && creationTime <= DateTime.UtcNow) { diff --git a/MapControl/MapControl.Silverlight.csproj b/MapControl/MapControl.Silverlight.csproj index 0863860f..0c4864a5 100644 --- a/MapControl/MapControl.Silverlight.csproj +++ b/MapControl/MapControl.Silverlight.csproj @@ -75,7 +75,6 @@ - @@ -89,7 +88,6 @@ - diff --git a/MapControl/MapControl.WPF.csproj b/MapControl/MapControl.WPF.csproj index ff119bf9..5a9ce143 100644 --- a/MapControl/MapControl.WPF.csproj +++ b/MapControl/MapControl.WPF.csproj @@ -57,7 +57,6 @@ Code - @@ -68,7 +67,6 @@ - diff --git a/MapControl/MapItem.Silverlight.WinRT.cs b/MapControl/MapItem.Silverlight.WinRT.cs index 64945cb2..507df33b 100644 --- a/MapControl/MapItem.Silverlight.WinRT.cs +++ b/MapControl/MapItem.Silverlight.WinRT.cs @@ -2,9 +2,18 @@ // Copyright © 2012 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) +#if WINRT +using Windows.UI.Xaml.Controls; +#else +using System.Windows.Controls; +#endif + namespace MapControl { - public partial class MapItem + /// + /// Container class for an item in a MapItemsControl. + /// + public class MapItem : ListBoxItem { public MapItem() { diff --git a/MapControl/MapItem.WPF.cs b/MapControl/MapItem.WPF.cs index 441f822e..d58739c1 100644 --- a/MapControl/MapItem.WPF.cs +++ b/MapControl/MapItem.WPF.cs @@ -7,9 +7,12 @@ using System.Windows.Controls; namespace MapControl { + /// + /// Container class for an item in a MapItemsControl. + /// [TemplateVisualState(Name = "NotCurrent", GroupName = "CurrentStates")] [TemplateVisualState(Name = "Current", GroupName = "CurrentStates")] - public partial class MapItem + public class MapItem : ListBoxItem { public static readonly DependencyProperty IsCurrentProperty = MapItemsControl.IsCurrentProperty.AddOwner( typeof(MapItem), diff --git a/MapControl/MapItem.cs b/MapControl/MapItem.cs deleted file mode 100644 index 92a77e2d..00000000 --- a/MapControl/MapItem.cs +++ /dev/null @@ -1,49 +0,0 @@ -// XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2012 Clemens Fischer -// Licensed under the Microsoft Public License (Ms-PL) - -#if WINRT -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Data; -#else -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -#endif - -namespace MapControl -{ - /// - /// Container class for an item in a MapItemsControl. - /// - public partial class MapItem : ListBoxItem - { - public static readonly DependencyProperty LocationPathProperty = DependencyProperty.Register( - "LocationPath", typeof(string), typeof(MapItem), new PropertyMetadata(null, LocationPathPropertyChanged)); - - /// - /// Gets or sets the property path that is used to bind the MapPanel.Location attached property. - /// - public string LocationPath - { - get { return (string)GetValue(LocationPathProperty); } - set { SetValue(LocationPathProperty, value); } - } - - private static void LocationPathPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) - { - string path = e.NewValue as string; - - if (!string.IsNullOrWhiteSpace(path)) - { - var binding = new Binding - { - Path = new PropertyPath(path) - }; - - BindingOperations.SetBinding(obj, MapPanel.LocationProperty, binding); - } - } - } -} diff --git a/MapControl/Pushpin.Silverlight.WinRT.cs b/MapControl/Pushpin.Silverlight.WinRT.cs index 883ead5a..c05a5939 100644 --- a/MapControl/Pushpin.Silverlight.WinRT.cs +++ b/MapControl/Pushpin.Silverlight.WinRT.cs @@ -2,9 +2,18 @@ // Copyright © 2012 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) +#if WINRT +using Windows.UI.Xaml.Controls; +#else +using System.Windows.Controls; +#endif + namespace MapControl { - public partial class Pushpin + /// + /// Displays a pushpin at a geographic location provided by the MapPanel.Location attached property. + /// + public class Pushpin : ContentControl { public Pushpin() { diff --git a/MapControl/Pushpin.WPF.cs b/MapControl/Pushpin.WPF.cs index 9b627af3..d15967f2 100644 --- a/MapControl/Pushpin.WPF.cs +++ b/MapControl/Pushpin.WPF.cs @@ -3,10 +3,14 @@ // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; +using System.Windows.Controls; namespace MapControl { - public partial class Pushpin + /// + /// Displays a pushpin at a geographic location provided by the MapPanel.Location attached property. + /// + public class Pushpin : ContentControl { static Pushpin() { diff --git a/MapControl/Pushpin.cs b/MapControl/Pushpin.cs deleted file mode 100644 index c64948bb..00000000 --- a/MapControl/Pushpin.cs +++ /dev/null @@ -1,49 +0,0 @@ -// XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2012 Clemens Fischer -// Licensed under the Microsoft Public License (Ms-PL) - -#if WINRT -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Data; -#else -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -#endif - -namespace MapControl -{ - /// - /// Displays a pushpin at a geographic location provided by the MapPanel.Location attached property. - /// - public partial class Pushpin : ContentControl - { - public static readonly DependencyProperty LocationPathProperty = DependencyProperty.Register( - "LocationPath", typeof(string), typeof(Pushpin), new PropertyMetadata(null, LocationPathPropertyChanged)); - - /// - /// Gets or sets the property path that is used to bind the MapPanel.Location attached property. - /// - public string LocationPath - { - get { return (string)GetValue(LocationPathProperty); } - set { SetValue(LocationPathProperty, value); } - } - - private static void LocationPathPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) - { - string path = e.NewValue as string; - - if (!string.IsNullOrWhiteSpace(path)) - { - var binding = new Binding - { - Path = new PropertyPath(path) - }; - - BindingOperations.SetBinding(obj, MapPanel.LocationProperty, binding); - } - } - } -} diff --git a/MapControl/TileImageLoader.WPF.cs b/MapControl/TileImageLoader.WPF.cs index 2eee7b35..1c806d4a 100644 --- a/MapControl/TileImageLoader.WPF.cs +++ b/MapControl/TileImageLoader.WPF.cs @@ -217,8 +217,8 @@ namespace MapControl var request = (HttpWebRequest)WebRequest.Create(uri); request.UserAgent = typeof(TileImageLoader).ToString(); - using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) - using (Stream responseStream = response.GetResponseStream()) + using (var response = (HttpWebResponse)request.GetResponse()) + using (var responseStream = response.GetResponseStream()) { var length = response.ContentLength; var creationTime = DateTime.UtcNow.ToBinary(); diff --git a/MapControl/WinRT/MapControl.WinRT.csproj b/MapControl/WinRT/MapControl.WinRT.csproj index 5525621b..e26e5a98 100644 --- a/MapControl/WinRT/MapControl.WinRT.csproj +++ b/MapControl/WinRT/MapControl.WinRT.csproj @@ -129,9 +129,6 @@ MapGraticule.Silverlight.WinRT.cs - - MapItem.cs - MapItem.Silverlight.WinRT.cs @@ -168,9 +165,6 @@ MercatorTransform.cs - - Pushpin.cs - Pushpin.Silverlight.WinRT.cs diff --git a/SampleApps/SilverlightApplication/MainPage.xaml b/SampleApps/SilverlightApplication/MainPage.xaml index b0223373..70cdedb0 100644 --- a/SampleApps/SilverlightApplication/MainPage.xaml +++ b/SampleApps/SilverlightApplication/MainPage.xaml @@ -37,7 +37,7 @@