diff --git a/Caching/FileDbCache/Properties/AssemblyInfo.cs b/Caching/FileDbCache/Properties/AssemblyInfo.cs index 1ccc79f5..2794ffbc 100644 --- a/Caching/FileDbCache/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.8")] -[assembly: AssemblyFileVersion("1.3.8")] +[assembly: AssemblyVersion("1.3.9")] +[assembly: AssemblyFileVersion("1.3.9")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache/Properties/AssemblyInfo.cs b/Caching/ImageFileCache/Properties/AssemblyInfo.cs index 0374992d..8edbc738 100644 --- a/Caching/ImageFileCache/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.8")] -[assembly: AssemblyFileVersion("1.3.8")] +[assembly: AssemblyVersion("1.3.9")] +[assembly: AssemblyFileVersion("1.3.9")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/MapControl.Silverlight.csproj b/MapControl/MapControl.Silverlight.csproj index 866f943a..72dcdfb1 100644 --- a/MapControl/MapControl.Silverlight.csproj +++ b/MapControl/MapControl.Silverlight.csproj @@ -76,7 +76,6 @@ - diff --git a/MapControl/MapControl.WPF.csproj b/MapControl/MapControl.WPF.csproj index 7b9844b7..4bffa4a8 100644 --- a/MapControl/MapControl.WPF.csproj +++ b/MapControl/MapControl.WPF.csproj @@ -57,7 +57,6 @@ - diff --git a/MapControl/MapItem.WPF.cs b/MapControl/MapItem.WPF.cs index a4be3eea..56f9a237 100644 --- a/MapControl/MapItem.WPF.cs +++ b/MapControl/MapItem.WPF.cs @@ -10,41 +10,12 @@ namespace MapControl /// /// Container class for an item in a MapItemsControl. /// - [TemplateVisualState(Name = "NotCurrent", GroupName = "CurrentStates")] - [TemplateVisualState(Name = "Current", GroupName = "CurrentStates")] public class MapItem : ListBoxItem { - public static readonly DependencyProperty IsCurrentProperty = MapItemsControl.IsCurrentProperty.AddOwner( - typeof(MapItem), new PropertyMetadata((o, e) => ((MapItem)o).IsCurrentPropertyChanged((bool)e.NewValue))); - static MapItem() { - FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata( + DefaultStyleKeyProperty.OverrideMetadata( typeof(MapItem), new FrameworkPropertyMetadata(typeof(MapItem))); } - - /// - /// Gets a value that indicates if the MapItem is the CurrentItem of the containing items collection. - /// - public bool IsCurrent - { - get { return (bool)GetValue(IsCurrentProperty); } - } - - private void IsCurrentPropertyChanged(bool isCurrent) - { - var zIndex = Panel.GetZIndex(this); - - if (isCurrent) - { - Panel.SetZIndex(this, zIndex | 0x40000000); - VisualStateManager.GoToState(this, "Current", true); - } - else - { - Panel.SetZIndex(this, zIndex & ~0x40000000); - VisualStateManager.GoToState(this, "NotCurrent", true); - } - } } } diff --git a/MapControl/MapItemsControl.Silverlight.WinRT.cs b/MapControl/MapItemsControl.Silverlight.WinRT.cs index 206ac8e7..ba329316 100644 --- a/MapControl/MapItemsControl.Silverlight.WinRT.cs +++ b/MapControl/MapItemsControl.Silverlight.WinRT.cs @@ -2,14 +2,30 @@ // Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) +#if NETFX_CORE +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +#else +using System.Windows; +using System.Windows.Controls; +#endif + namespace MapControl { - public partial class MapItemsControl + /// + /// Manages a collection of selectable items on a Map. Uses MapItem as item container class. + /// + public class MapItemsControl : ListBox { public MapItemsControl() { DefaultStyleKey = typeof(MapItemsControl); MapPanel.AddParentMapHandlers(this); } + + protected override DependencyObject GetContainerForItemOverride() + { + return new MapItem(); + } } -} \ No newline at end of file +} diff --git a/MapControl/MapItemsControl.WPF.cs b/MapControl/MapItemsControl.WPF.cs index 25620a06..48cd5d42 100644 --- a/MapControl/MapItemsControl.WPF.cs +++ b/MapControl/MapItemsControl.WPF.cs @@ -12,30 +12,35 @@ using System.Windows.Media; namespace MapControl { - public partial class MapItemsControl + /// + /// Manages a collection of selectable items on a Map. Uses MapItem as item container class. + /// + public class MapItemsControl : ListBox { public static readonly DependencyProperty SelectionGeometryProperty = DependencyProperty.Register( "SelectionGeometry", typeof(Geometry), typeof(MapItemsControl), new PropertyMetadata((o, e) => ((MapItemsControl)o).SelectionGeometryPropertyChanged((Geometry)e.NewValue))); - public static readonly DependencyProperty IsCurrentProperty = DependencyProperty.RegisterAttached( - "IsCurrent", typeof(bool), typeof(MapItemsControl), null); - static MapItemsControl() { - FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata( + DefaultStyleKeyProperty.OverrideMetadata( typeof(MapItemsControl), new FrameworkPropertyMetadata(typeof(MapItemsControl))); } public MapItemsControl() { - Items.CurrentChanging += OnCurrentItemChanging; - Items.CurrentChanged += OnCurrentItemChanged; + Items.CurrentChanging += CurrentItemChanging; + Items.CurrentChanged += CurrentItemChanged; + } + + protected override DependencyObject GetContainerForItemOverride() + { + return new MapItem(); } /// - /// Gets or sets a Geometry that selects all items that lie inside its fill area, - /// i.e. where Geometry.FillContains returns true for the item's viewport position. + /// Gets or sets a Geometry that selects all items inside its fill area, i.e. + /// where Geometry.FillContains returns true for the item's viewport position. /// public Geometry SelectionGeometry { @@ -43,11 +48,6 @@ namespace MapControl set { SetValue(SelectionGeometryProperty, value); } } - public static bool GetIsCurrent(UIElement element) - { - return (bool)element.GetValue(IsCurrentProperty); - } - public object GetFirstItemInGeometry(Geometry geometry) { if (geometry == null || geometry.IsEmpty()) @@ -62,30 +62,20 @@ namespace MapControl { if (geometry == null || geometry.IsEmpty()) { - return new List(); + return null; } - return new List(Items.Cast().Where(i => IsItemInGeometry(i, geometry))); + return Items.Cast().Where(i => IsItemInGeometry(i, geometry)).ToList(); } - private void OnCurrentItemChanging(object sender, CurrentChangingEventArgs e) + private bool IsItemInGeometry(object item, Geometry geometry) { - var container = ContainerFromItem(Items.CurrentItem); + var container = ItemContainerGenerator.ContainerFromItem(item) as UIElement; + Point? viewportPosition; - if (container != null) - { - container.SetValue(IsCurrentProperty, false); - } - } - - private void OnCurrentItemChanged(object sender, EventArgs e) - { - var container = ContainerFromItem(Items.CurrentItem); - - if (container != null) - { - container.SetValue(IsCurrentProperty, true); - } + return container != null && + (viewportPosition = MapPanel.GetViewportPosition(container)).HasValue && + geometry.FillContains(viewportPosition.Value); } private void SelectionGeometryPropertyChanged(Geometry geometry) @@ -100,14 +90,26 @@ namespace MapControl } } - private bool IsItemInGeometry(object item, Geometry geometry) + private void CurrentItemChanging(object sender, CurrentChangingEventArgs e) { - var container = ContainerFromItem(item); - Point? viewportPosition; + var container = ItemContainerGenerator.ContainerFromItem(Items.CurrentItem) as UIElement; - return container != null && - (viewportPosition = MapPanel.GetViewportPosition(container)).HasValue && - geometry.FillContains(viewportPosition.Value); + if (container != null) + { + var zIndex = Panel.GetZIndex(container); + Panel.SetZIndex(container, zIndex & ~0x40000000); + } + } + + private void CurrentItemChanged(object sender, EventArgs e) + { + var container = ItemContainerGenerator.ContainerFromItem(Items.CurrentItem) as UIElement; + + if (container != null) + { + var zIndex = Panel.GetZIndex(container); + Panel.SetZIndex(container, zIndex | 0x40000000); + } } } -} \ No newline at end of file +} diff --git a/MapControl/MapItemsControl.cs b/MapControl/MapItemsControl.cs deleted file mode 100644 index e31cd4e3..00000000 --- a/MapControl/MapItemsControl.cs +++ /dev/null @@ -1,37 +0,0 @@ -// XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © Clemens Fischer 2012-2013 -// Licensed under the Microsoft Public License (Ms-PL) - -#if NETFX_CORE -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -#else -using System.Windows; -using System.Windows.Controls; -#endif - -namespace MapControl -{ - /// - /// Manages a collection of selectable items on a Map. Uses MapItem as container for items - /// and (for WPF only) updates the IsCurrent attached property on each MapItem when the - /// Items.CurrentItem property changes. - /// - public partial class MapItemsControl : ListBox - { - public UIElement ContainerFromItem(object item) - { - return item != null ? ItemContainerGenerator.ContainerFromItem(item) as UIElement : null; - } - - public object ItemFromContainer(DependencyObject container) - { - return container != null ? ItemContainerGenerator.ItemFromContainer(container) : null; - } - - protected override DependencyObject GetContainerForItemOverride() - { - return new MapItem(); - } - } -} diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index 5a98f0f5..7d886deb 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -15,8 +15,8 @@ using System.Windows; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.3.8")] -[assembly: AssemblyFileVersion("1.3.8")] +[assembly: AssemblyVersion("1.3.9")] +[assembly: AssemblyFileVersion("1.3.9")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/Pushpin.WPF.cs b/MapControl/Pushpin.WPF.cs index 90e62d17..c0f3378f 100644 --- a/MapControl/Pushpin.WPF.cs +++ b/MapControl/Pushpin.WPF.cs @@ -14,7 +14,7 @@ namespace MapControl { static Pushpin() { - FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata( + DefaultStyleKeyProperty.OverrideMetadata( typeof(Pushpin), new FrameworkPropertyMetadata(typeof(Pushpin))); } } diff --git a/MapControl/Themes/Generic.xaml b/MapControl/Themes/Generic.xaml index d419143c..ad67eb4d 100644 --- a/MapControl/Themes/Generic.xaml +++ b/MapControl/Themes/Generic.xaml @@ -1,5 +1,5 @@ -