mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Version 1.3.9: Removed IsCurrent property and Current/NotCurrent visual states from MapItem. Fixed visual states in sample Store Application.
This commit is contained in:
parent
c427345896
commit
09eeb11269
21 changed files with 115 additions and 156 deletions
|
|
@ -76,7 +76,6 @@
|
|||
<Compile Include="MapGraticule.Silverlight.WinRT.cs" />
|
||||
<Compile Include="MapImage.cs" />
|
||||
<Compile Include="MapItem.Silverlight.WinRT.cs" />
|
||||
<Compile Include="MapItemsControl.cs" />
|
||||
<Compile Include="MapItemsControl.Silverlight.WinRT.cs" />
|
||||
<Compile Include="MapPanel.cs" />
|
||||
<Compile Include="MapPanel.Silverlight.WinRT.cs" />
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@
|
|||
<Compile Include="MapBase.WPF.cs" />
|
||||
<Compile Include="MapImageLayer.cs" />
|
||||
<Compile Include="MapItem.WPF.cs" />
|
||||
<Compile Include="MapItemsControl.cs" />
|
||||
<Compile Include="MapItemsControl.WPF.cs" />
|
||||
<Compile Include="MapImage.cs" />
|
||||
<Compile Include="MapPanel.cs" />
|
||||
|
|
|
|||
|
|
@ -10,41 +10,12 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Container class for an item in a MapItemsControl.
|
||||
/// </summary>
|
||||
[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)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value that indicates if the MapItem is the CurrentItem of the containing items collection.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/// <summary>
|
||||
/// Manages a collection of selectable items on a Map. Uses MapItem as item container class.
|
||||
/// </summary>
|
||||
public class MapItemsControl : ListBox
|
||||
{
|
||||
public MapItemsControl()
|
||||
{
|
||||
DefaultStyleKey = typeof(MapItemsControl);
|
||||
MapPanel.AddParentMapHandlers(this);
|
||||
}
|
||||
|
||||
protected override DependencyObject GetContainerForItemOverride()
|
||||
{
|
||||
return new MapItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,30 +12,35 @@ using System.Windows.Media;
|
|||
|
||||
namespace MapControl
|
||||
{
|
||||
public partial class MapItemsControl
|
||||
/// <summary>
|
||||
/// Manages a collection of selectable items on a Map. Uses MapItem as item container class.
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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<object>();
|
||||
return null;
|
||||
}
|
||||
|
||||
return new List<object>(Items.Cast<object>().Where(i => IsItemInGeometry(i, geometry)));
|
||||
return Items.Cast<object>().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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace MapControl
|
|||
{
|
||||
static Pushpin()
|
||||
{
|
||||
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(
|
||||
DefaultStyleKeyProperty.OverrideMetadata(
|
||||
typeof(Pushpin), new FrameworkPropertyMetadata(typeof(Pushpin)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:map="clr-namespace:MapControl">
|
||||
<Style TargetType="map:MapItemsControl">
|
||||
<Setter Property="Template">
|
||||
|
|
|
|||
|
|
@ -66,9 +66,6 @@
|
|||
<Compile Include="..\MapItem.Silverlight.WinRT.cs">
|
||||
<Link>MapItem.Silverlight.WinRT.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MapItemsControl.cs">
|
||||
<Link>MapItemsControl.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MapItemsControl.Silverlight.WinRT.cs">
|
||||
<Link>MapItemsControl.Silverlight.WinRT.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue