mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Removed LocationPath property from MapItem and PushPin.
This commit is contained in:
parent
b0ecd850a2
commit
d0d949c9be
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@
|
|||
<Compile Include="MapBase.Silverlight.WinRT.cs" />
|
||||
<Compile Include="MapGraticule.cs" />
|
||||
<Compile Include="MapGraticule.Silverlight.WinRT.cs" />
|
||||
<Compile Include="MapItem.cs" />
|
||||
<Compile Include="MapItem.Silverlight.WinRT.cs" />
|
||||
<Compile Include="MapItemsControl.cs" />
|
||||
<Compile Include="MapItemsControl.Silverlight.WinRT.cs" />
|
||||
|
|
@ -89,7 +88,6 @@
|
|||
<Compile Include="MatrixEx.cs" />
|
||||
<Compile Include="MercatorTransform.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Pushpin.cs" />
|
||||
<Compile Include="Pushpin.Silverlight.WinRT.cs" />
|
||||
<Compile Include="Tile.cs" />
|
||||
<Compile Include="Tile.Silverlight.WinRT.cs" />
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@
|
|||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MapBase.WPF.cs" />
|
||||
<Compile Include="MapItem.cs" />
|
||||
<Compile Include="MapItem.WPF.cs" />
|
||||
<Compile Include="MapItemsControl.cs" />
|
||||
<Compile Include="MapItemsControl.WPF.cs" />
|
||||
|
|
@ -68,7 +67,6 @@
|
|||
<Compile Include="MapTransform.cs" />
|
||||
<Compile Include="MercatorTransform.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Pushpin.cs" />
|
||||
<Compile Include="Pushpin.WPF.cs" />
|
||||
<Compile Include="Tile.cs" />
|
||||
<Compile Include="Tile.WPF.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
|
||||
/// <summary>
|
||||
/// Container class for an item in a MapItemsControl.
|
||||
/// </summary>
|
||||
public class MapItem : ListBoxItem
|
||||
{
|
||||
public MapItem()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,9 +7,12 @@ using System.Windows.Controls;
|
|||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Container class for an item in a MapItemsControl.
|
||||
/// </summary>
|
||||
[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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Container class for an item in a MapItemsControl.
|
||||
/// </summary>
|
||||
public partial class MapItem : ListBoxItem
|
||||
{
|
||||
public static readonly DependencyProperty LocationPathProperty = DependencyProperty.Register(
|
||||
"LocationPath", typeof(string), typeof(MapItem), new PropertyMetadata(null, LocationPathPropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the property path that is used to bind the MapPanel.Location attached property.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
/// <summary>
|
||||
/// Displays a pushpin at a geographic location provided by the MapPanel.Location attached property.
|
||||
/// </summary>
|
||||
public class Pushpin : ContentControl
|
||||
{
|
||||
public Pushpin()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/// <summary>
|
||||
/// Displays a pushpin at a geographic location provided by the MapPanel.Location attached property.
|
||||
/// </summary>
|
||||
public class Pushpin : ContentControl
|
||||
{
|
||||
static Pushpin()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Displays a pushpin at a geographic location provided by the MapPanel.Location attached property.
|
||||
/// </summary>
|
||||
public partial class Pushpin : ContentControl
|
||||
{
|
||||
public static readonly DependencyProperty LocationPathProperty = DependencyProperty.Register(
|
||||
"LocationPath", typeof(string), typeof(Pushpin), new PropertyMetadata(null, LocationPathPropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the property path that is used to bind the MapPanel.Location attached property.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -129,9 +129,6 @@
|
|||
<Compile Include="..\MapGraticule.Silverlight.WinRT.cs">
|
||||
<Link>MapGraticule.Silverlight.WinRT.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MapItem.cs">
|
||||
<Link>MapItem.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MapItem.Silverlight.WinRT.cs">
|
||||
<Link>MapItem.Silverlight.WinRT.cs</Link>
|
||||
</Compile>
|
||||
|
|
@ -168,9 +165,6 @@
|
|||
<Compile Include="..\MercatorTransform.cs">
|
||||
<Link>MercatorTransform.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Pushpin.cs">
|
||||
<Link>Pushpin.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Pushpin.Silverlight.WinRT.cs">
|
||||
<Link>Pushpin.Silverlight.WinRT.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="PointItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="LocationPath" Value="Location"/>
|
||||
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Template">
|
||||
|
|
@ -83,12 +83,12 @@
|
|||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="PushpinItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="LocationPath" Value="Location"/>
|
||||
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate>
|
||||
<ControlTemplate TargetType="map:MapItem">
|
||||
<map:Pushpin Content="{Binding Name}"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
|
|
|
|||
36
SampleApps/StoreApplication/BindingHelper.cs
Normal file
36
SampleApps/StoreApplication/BindingHelper.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using MapControl;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
namespace StoreApplication
|
||||
{
|
||||
public class BindingHelper
|
||||
{
|
||||
public static readonly DependencyProperty LocationPathProperty = DependencyProperty.RegisterAttached(
|
||||
"LocationPath", typeof(string), typeof(BindingHelper),
|
||||
new PropertyMetadata(null, LocationPathPropertyChanged));
|
||||
|
||||
public static string GetLocationPath(DependencyObject obj)
|
||||
{
|
||||
return (string)obj.GetValue(LocationPathProperty);
|
||||
}
|
||||
|
||||
public static void SetLocationPath(DependencyObject obj, string value)
|
||||
{
|
||||
obj.SetValue(LocationPathProperty, value);
|
||||
}
|
||||
|
||||
private static void LocationPathPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var propertyPath = e.NewValue as string;
|
||||
|
||||
if (propertyPath != null)
|
||||
{
|
||||
BindingOperations.SetBinding(
|
||||
obj,
|
||||
MapPanel.LocationProperty,
|
||||
new Binding { Path = new PropertyPath(propertyPath) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="PointItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="LocationPath" Value="Location"/>
|
||||
<Setter Property="local:BindingHelper.LocationPath" Value="Location"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
|
|
@ -82,13 +82,13 @@
|
|||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="PushpinItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="LocationPath" Value="Location"/>
|
||||
<Setter Property="local:BindingHelper.LocationPath" Value="Location"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate>
|
||||
<ControlTemplate TargetType="map:MapItem">
|
||||
<map:Pushpin Content="{Binding Name}"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
|
|
@ -122,7 +122,8 @@
|
|||
<map:MapItemsControl ItemsSource="{StaticResource Pushpins}"
|
||||
ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
|
||||
|
||||
<!--<map:Pushpin map:MapPanel.Location="53.5,8.2" Background="Yellow" Foreground="Blue" Content="N 53° 30' E 8° 12'"/>-->
|
||||
<!-- No TypeConverter (yet?) for string to Location
|
||||
<map:Pushpin map:MapPanel.Location="53.5,8.2" Background="Yellow" Foreground="Blue" Content="N 53° 30' E 8° 12'"/>-->
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="4" FontSize="10"
|
||||
Text="{Binding TileLayer.Description, ElementName=map}"/>
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@
|
|||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BindingHelper.cs" />
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@
|
|||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate>
|
||||
<ControlTemplate TargetType="map:MapItem">
|
||||
<map:Pushpin Content="{Binding Name}"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
|
|
|
|||
Loading…
Reference in a new issue