// XAML Map Control - http://xamlmapcontrol.codeplex.com/
// Copyright © Clemens Fischer 2012-2013
// Licensed under the Microsoft Public License (Ms-PL)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace MapControl
{
public partial class MapItemsControl
{
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(
typeof(MapItemsControl), new FrameworkPropertyMetadata(typeof(MapItemsControl)));
}
public MapItemsControl()
{
Items.CurrentChanging += OnCurrentItemChanging;
Items.CurrentChanged += OnCurrentItemChanged;
}
///
/// 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.
///
public Geometry SelectionGeometry
{
get { return (Geometry)GetValue(SelectionGeometryProperty); }
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())
{
return null;
}
return Items.Cast