示例#1
0
        /// <summary>
        /// Applies the mouse down behavior.
        /// </summary>
        /// <param name="selectedIndex">The selected item index.</param>
        /// <param name="element">The element of concern.</param>
        public virtual void ApplyMouseDownBehavior(int selectedIndex, CoolMenuItem element)
        {
            if (!BounceEnabled)
            {
                return;
            }

            m_mouseCaptured = element.CaptureMouse();

            var da = new DoubleAnimationUsingKeyFrames();
            var k1 = new SplineDoubleKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100)),
                Value   = this.MaxItemHeight * 0.30
            };

            da.KeyFrames.Add(k1);

            Storyboard sb = new Storyboard();

            Storyboard.SetTarget(da, element);
            Storyboard.SetTargetProperty(da,
                                         new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)"));
            sb.Children.Add(da);
            sb.Begin();
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            m_rootElement = this.GetTemplateChild(ROOT_ELEMENT) as Panel;

            if (m_rootElement == null)
            {
                return;
            }

            m_rootElement.MouseLeave += new MouseEventHandler(m_rootElement_MouseLeave);

            for (int i = 0; i < this.Items.Count; ++i)
            {
                CoolMenuItem     cmi            = this.Items[i];
                FrameworkElement contentElement = cmi.Content;
                contentElement.Height               = this.MaxItemHeight * NORMAL_ICON_SIZE;
                contentElement.Width                = this.MaxItemWidth * NORMAL_ICON_SIZE;
                contentElement.Tag                  = i;
                contentElement.RenderTransform      = BuildTransformGroup();
                contentElement.VerticalAlignment    = VerticalAlignment.Bottom;
                contentElement.MouseEnter          += new MouseEventHandler(contentElement_MouseEnter);
                contentElement.MouseLeave          += new MouseEventHandler(contentElement_MouseLeave);
                contentElement.MouseLeftButtonDown += new MouseButtonEventHandler(contentElement_MouseLeftButtonDown);

                m_rootElement.Children.Add(contentElement);
            }
        }
示例#3
0
        /// <summary>
        /// Removes a CoolMenuItem from the control.
        /// </summary>
        /// <param name="element">The CoolMenuItem element of concern.</param>
        /// <param name="item">The item contained by the CoolMenuItem.</param>
        protected override void ClearContainerForItemOverride(DependencyObject element, object item)
        {
            CoolMenuItem menuItem = element as CoolMenuItem;

            if (menuItem != null)
            {
                menuItem.ParentItemsControl = null;
            }
            m_generator.ClearContainerForItemOverride(element, item);
            base.ClearContainerForItemOverride(element, item);
        }
示例#4
0
        /// <summary>
        /// Associates the element with a parent container and registers the item with the generator.
        /// </summary>
        /// <param name="element">The CoolMenuItem element of concern.</param>
        /// <param name="item">The item contained by the CoolMenuItem.</param>
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            CoolMenuItem menuItem = element as CoolMenuItem;

            if (menuItem != null)
            {
                // Associate the parent.
                menuItem.ParentItemsControl = this;
                this.Behavior.Initialize(this, menuItem);
            }

            base.PrepareContainerForItemOverride(element, item);
            m_generator.PrepareContainerForItemOverride(element, item, ItemContainerStyle);
        }
        /// <summary>
        /// Applies the mouse enter behavior.
        /// </summary>
        /// <param name="proximity">The proximity of the element which is selected.</param>
        /// <param name="element">The element of concern.</param>
        public virtual void ApplyMouseEnterBehavior(int proximity, CoolMenuItem element)
        {
            if (proximity >= m_sizes.Length || proximity < 0)
                proximity = m_sizes.Length - 1;

            TimeSpan speed = TimeSpan.FromMilliseconds(100);
            DoubleAnimation daWidth = new DoubleAnimation { To = m_sizes[proximity] * MaxItemWidth, Duration = new Duration(speed) };
            DoubleAnimation daHeight = new DoubleAnimation { To = m_sizes[proximity] * MaxItemHeight, Duration = new Duration(speed) };
            Storyboard sb = new Storyboard();
            Storyboard.SetTarget(daWidth, element);
            Storyboard.SetTarget(daHeight, element);
            Storyboard.SetTargetProperty(daHeight, new PropertyPath("(UIElement.Height)"));
            Storyboard.SetTargetProperty(daWidth, new PropertyPath("(UIElement.Width)"));
            sb.Children.Add(daWidth);
            sb.Children.Add(daHeight);
            sb.Begin();
            
        }
示例#6
0
        /// <summary>
        /// Applies the mouse enter behavior.
        /// </summary>
        /// <param name="proximity">The proximity of the element which is selected.</param>
        /// <param name="element">The element of concern.</param>
        public virtual void ApplyMouseEnterBehavior(int proximity, CoolMenuItem element)
        {
            if (proximity >= m_sizes.Length || proximity < 0)
            {
                proximity = m_sizes.Length - 1;
            }

            TimeSpan        speed   = TimeSpan.FromMilliseconds(100);
            DoubleAnimation daWidth = new DoubleAnimation {
                To = m_sizes[proximity] * MaxItemWidth, Duration = new Duration(speed)
            };
            DoubleAnimation daHeight = new DoubleAnimation {
                To = m_sizes[proximity] * MaxItemHeight, Duration = new Duration(speed)
            };
            Storyboard sb = new Storyboard();

            Storyboard.SetTarget(daWidth, element);
            Storyboard.SetTarget(daHeight, element);
            Storyboard.SetTargetProperty(daHeight, new PropertyPath("(UIElement.Height)"));
            Storyboard.SetTargetProperty(daWidth, new PropertyPath("(UIElement.Width)"));
            sb.Children.Add(daWidth);
            sb.Children.Add(daHeight);
            sb.Begin();
        }
 public SelectedMenuItemArgs(CoolMenuItem menuItem, int menuIndex)
 {
     m_cmi = menuItem;
     m_index = menuIndex;
 }
        /// <summary>
        /// Applies the mouse down behavior.
        /// </summary>
        /// <param name="selectedIndex">The selected item index.</param>
        /// <param name="element">The element of concern.</param>
        public virtual void ApplyMouseDownBehavior(int selectedIndex, CoolMenuItem element)
        {
            if(!BounceEnabled)
                return;

            m_mouseCaptured = element.CaptureMouse();

            var da = new DoubleAnimationUsingKeyFrames();
            var k1 = new SplineDoubleKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100)),
                Value = this.MaxItemHeight * 0.30
            };
            da.KeyFrames.Add(k1);

            Storyboard sb = new Storyboard();
            Storyboard.SetTarget(da, element);
            Storyboard.SetTargetProperty(da,
                new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)"));
            sb.Children.Add(da);
            sb.Begin();
        }
 /// <summary>
 /// Does nothing in this implementation.
 /// </summary>
 /// <param name="element">The element of concern.</param>
 public virtual void ApplyMouseLeaveBehavior(CoolMenuItem element)
 {
     // Do nothing.
 }
 /// <summary>
 /// Initializes each element in the cool menu.
 /// </summary>
 /// <param name="parent">The parent CoolMenu.</param>
 /// <param name="element">The element of concern.</param>
 public virtual void Initialize(CoolMenu parent, CoolMenuItem element)
 {
     element.Height = MaxItemHeight * m_sizes[m_sizes.Length -1];
     element.Width = MaxItemWidth * m_sizes[m_sizes.Length - 1];
 }
示例#11
0
 /// <summary>
 /// Does nothing in this implementation.
 /// </summary>
 /// <param name="element">The element of concern.</param>
 public virtual void ApplyMouseLeaveBehavior(CoolMenuItem element)
 {
     // Do nothing.
 }
示例#12
0
 /// <summary>
 /// Initializes each element in the cool menu.
 /// </summary>
 /// <param name="parent">The parent CoolMenu.</param>
 /// <param name="element">The element of concern.</param>
 public virtual void Initialize(CoolMenu parent, CoolMenuItem element)
 {
     element.Height = MaxItemHeight * m_sizes[m_sizes.Length - 1];
     element.Width  = MaxItemWidth * m_sizes[m_sizes.Length - 1];
 }
 /// <summary>
 /// Creates a new instance of the SelectedMenuItemArgs class.
 /// </summary>
 /// <param name="menuItem">The currently selected menu item</param>
 /// <param name="menuIndex">The index of the currently selected menu item.</param>
 public SelectedMenuItemArgs(CoolMenuItem menuItem, int menuIndex)
 {
     m_cmi   = menuItem;
     m_index = menuIndex;
 }
 public override void Initialize(CoolMenu parent, CoolMenuItem element)
 {
     base.Initialize(parent, element);
     element.Background = new SolidColorBrush(Colors.Yellow);
 }