using System;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows.Media.Animation;
using System.Windows.Controls.Primitives;
namespace CustomUI
{
public class FloatingActionMenu : ItemsControl
{
#region const string
public const string PopupPartName = "PART_Popup";
#endregion
#region private fields
private Popup PART_Popup;
private ToggleButton PART_ToggleButton;
#endregion
#region DependencyProperty
#region IsDropdownOpen
public bool IsDropDownOpen
{
get { return (bool)GetValue(IsDropDownOpenProperty); }
set { SetValue(IsDropDownOpenProperty, value); }
}
public static readonly DependencyProperty IsDropDownOpenProperty =
DependencyProperty.Register("IsDropDownOpen", typeof(bool), typeof(FloatingActionMenu), new PropertyMetadata(false, IsDropDownOpenChangedCallback));
private static void IsDropDownOpenChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
FloatingActionMenu menu = d as FloatingActionMenu;
bool flag;
if(bool.TryParse(Convert.ToString(e.NewValue), out flag))
{
if(flag)
{
menu.AnimateChildOpen();
VisualStateManager.GoToState(menu, "PopupOpen", true);
}
else
{
menu.AnimateChildClose();
}
}
}
#endregion
#region DisplayTipContentMemberPath
///
/// 获取或者设置浮动按钮的提示内容的属性名称
///
public string DisplayTipContentMemberPath
{
get { return (string)GetValue(DisplayTipContentMemberPathProperty); }
set { SetValue(DisplayTipContentMemberPathProperty, value); }
}
public static readonly DependencyProperty DisplayTipContentMemberPathProperty =
DependencyProperty.Register("DisplayTipContentMemberPath", typeof(string), typeof(FloatingActionMenu));
#endregion
#region Trigger
///
/// 获取或者设置按钮组的弹出方式
///
public EnumTrigger Trigger
{
get { return (EnumTrigger)GetValue(TriggerProperty); }
set { SetValue(TriggerProperty, value); }
}
public static readonly DependencyProperty TriggerProperty =
DependencyProperty.Register("Trigger", typeof(EnumTrigger), typeof(FloatingActionMenu), new PropertyMetadata(EnumTrigger.Click));
#endregion
#region PlacementDirection
///
/// 获取或者设置按钮组的弹出位置(共有左、上、右、下四个方向)
///
public EnumPlacementDirection PlacementDirection
{
get { return (EnumPlacementDirection)GetValue(PlacementDirectionProperty); }
set { SetValue(PlacementDirectionProperty, value); }
}
public static readonly DependencyProperty PlacementDirectionProperty =
DependencyProperty.Register("PlacementDirection", typeof(EnumPlacementDirection), typeof(FloatingActionMenu), new PropertyMetadata(EnumPlacementDirection.Top));
#endregion
#region ItemOrientation
public Orientation ItemOrientation
{
get { return (Orientation)GetValue(ItemOrientationProperty); }
set { SetValue(ItemOrientationProperty, value); }
}
public static readonly DependencyProperty ItemOrientationProperty =
DependencyProperty.Register("ItemOrientation", typeof(Orientation), typeof(FloatingActionMenu), new PropertyMetadata(Orientation.Vertical));
#endregion
#endregion
#region Events
#region ItemClickEvent
public static readonly RoutedEvent ItemClickEvent = EventManager.RegisterRoutedEvent("ItemClick",
RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler