Exemplo n.º 1
0
        void BaseItem_MouseEnter(object sender, MouseEventArgs e)
        {
            MenuItemButton item = sender as MenuItemButton;

            if (item.IsSelected && CurrentState != _STATE_EXPAND)
            {
                item.Focus();
                CurrentState = _STATE_EXPAND;
                VisualStateManager.GoToState(this, _STATE_EXPAND, true);
            }
        }
        protected static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MenuItemButton me       = d as MenuItemButton;
            bool           selected = (bool)e.NewValue;

            if (me.MenuButtonShape != null)
            {
                if (selected)
                {
                    if (me.MouseOverBackground != null)
                    {
                        me.MenuButtonShape.Fill = me.SelectedBackground;
                    }

                    if (me.SelectedEffect != null)
                    {
                        if (me.IsImageOnly)
                        {
                            me.MenuButtonImage.Effect = me.SelectedEffect;
                        }
                        else
                        {
                            me.MenuButtonShape.Effect = me.SelectedEffect;
                        }

                        if (me.SelectedEffect is DropShadowEffect)
                        {
                            (me.MenuTextBlock.Effect as DropShadowEffect).Color = (me.SelectedEffect as DropShadowEffect).Color;
                        }
                    }
                }
                else
                {
                    if (me.MouseOverBackground != null)
                    {
                        me.MenuButtonShape.Fill = me.Background;
                    }

                    if (me.SelectedEffect != null)
                    {
                        if (me.IsImageOnly)
                        {
                            me.MenuButtonImage.Effect = me.DefaultEffect;
                        }
                        else
                        {
                            me.MenuButtonShape.Effect = me.DefaultEffect;
                        }

                        (me.MenuTextBlock.Effect as DropShadowEffect).Color = Colors.White;
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void SetSelectedMenuItem()
        {
            if (this.SelectedButton != null)
            {
                this.SelectedButton.TextPosition = this.ContentPosition;
                return;
            }

            MenuItemButton selectedItem = null;

            if (Items != null && Items.Count > 0)
            {
                foreach (MenuItemButton item in Items)
                {
                    if (item.IsSelected)
                    {
                        if (selectedItem == null)
                        {
                            selectedItem = item;
                        }
                        else
                        {
                            item.IsSelected = false;
                        }
                    }
                }

                if (selectedItem == null)
                {
                    Items[0].IsSelected = true;
                    selectedItem        = Items[0];
                }
            }

            if (selectedItem != null)
            {
                if (double.IsNaN(selectedItem.Width))
                {
                    selectedItem.Width = 50;
                }
                if (double.IsNaN(selectedItem.Height))
                {
                    selectedItem.Height = 50;
                }
                selectedItem.Click       += new MenuItemClickEventHandler(BaseItem_Clicked);
                selectedItem.LostFocus   += new RoutedEventHandler(BaseItem_LostFocus);
                selectedItem.TextPosition = this.ContentPosition;
                BaseMenuItemPanel.Children.Add(selectedItem);
                this.SelectedButton = selectedItem;
            }
        }
        void BaseItem_Clicked(object sender, MenuItemClickEventArgs e)
        {
            MenuItemButton item = sender as MenuItemButton;

            if (CurrentState != _STATE_EXPAND)
            {
                CurrentState = _STATE_EXPAND;
                VisualStateManager.GoToState(this, _STATE_EXPAND, true);
            }

            if (this.MenuOpenMode == MenuOpenAction.MouseHover)
            {
                this.BaseButton.MouseEnter += new MouseEventHandler(BaseItem_MouseEnter);
                this.BaseButton.Click      -= BaseItem_Clicked;
            }
        }
Exemplo n.º 5
0
        void MenuItem_Clicked(object sender, MenuItemClickEventArgs e)
        {
            MenuItemButton item = sender as MenuItemButton;

            if (!item.IsSelected)
            {
                ClickedItem = item;
                double x0 = (this.ContentPosition == ContentOrientation.RIGHT) ? 0 : ((this.ContentPosition == ContentOrientation.LEFT) ? ChildPanelWidth : (ChildPanelWidth / 2.0));
                double y0 = (this.ContentPosition == ContentOrientation.DOWN) ? 0 : ((this.ContentPosition == ContentOrientation.UP) ? ChildPanelHeight : (ChildPanelHeight / 2.0));
                double dx = x0 - (item.Margin.Left + item.Width / 2.0);
                double dy = y0 - (item.Margin.Top + item.Height / 2.0);

                DoubleAnimationUsingKeyFrames animationX = new DoubleAnimationUsingKeyFrames();
                animationX.KeyFrames.Add(new SplineDoubleKeyFrame()
                {
                    KeyTime = TimeSpan.FromMilliseconds(0), Value = 0
                });
                animationX.KeyFrames.Add(new SplineDoubleKeyFrame()
                {
                    KeyTime = TimeSpan.FromMilliseconds(300), Value = dx
                });

                DoubleAnimationUsingKeyFrames animationY = new DoubleAnimationUsingKeyFrames();
                animationY.KeyFrames.Add(new SplineDoubleKeyFrame()
                {
                    KeyTime = TimeSpan.FromMilliseconds(0), Value = 0
                });
                animationY.KeyFrames.Add(new SplineDoubleKeyFrame()
                {
                    KeyTime = TimeSpan.FromMilliseconds(300), Value = dy
                });

                Storyboard sbExchange = new Storyboard();
                sbExchange.Completed += new EventHandler(StoryboardExchange_Completed);
                Storyboard.SetTargetProperty(animationX, new PropertyPath("X"));
                Storyboard.SetTarget(animationX, item.RenderTransform);
                Storyboard.SetTargetProperty(animationY, new PropertyPath("Y"));
                Storyboard.SetTarget(animationY, item.RenderTransform);
                sbExchange.Children.Add(animationX);
                sbExchange.Children.Add(animationY);
                sbExchange.Begin();
            }
        }
Exemplo n.º 6
0
        void BaseItem_Clicked(object sender, MenuItemClickEventArgs e)
        {
            MenuItemButton item = sender as MenuItemButton;

            if (item.IsSelected && CurrentState != _STATE_EXPAND)
            {
                CurrentState = _STATE_EXPAND;
                VisualStateManager.GoToState(this, _STATE_EXPAND, true);
            }

            if (this.MenuOpenMode == MenuOpenAction.MouseHover && !isHoverModeSet)
            {
                this.SelectedButton.MouseEnter += new MouseEventHandler(BaseItem_MouseEnter);
                isHoverModeSet = true;
            }

            // Added to meet ViewPoint-GIS's need
            OnBaseButtonClicked(new MenuItemClickEventArgs(item.Tag));
        }
        private void InitializeBaseButton()
        {
            if (this.ImageSource != null)
            {
                if (this.ButtonShape == MenuButtonShape.Square)
                {
                    BaseButton = new SquareMenuButton();
                }
                else
                {
                    BaseButton = new CircleMenuButton();
                }

                BaseButton.Text                = this.Text;
                BaseButton.Width               = this.Width;
                BaseButton.Height              = this.Height;
                BaseButton.IsImageOnly         = this.IsImageOnly;
                BaseButton.ImageSource         = this.ImageSource;
                BaseButton.ImageMargin         = this.ImageMargin;
                BaseButton.TextPosition        = this.ContentPosition;
                BaseButton.TextVisibility      = this.TextVisibility;
                BaseButton.DefaultEffect       = this.DefaultEffect;
                BaseButton.MouseOverEffect     = this.MouseOverEffect;
                BaseButton.MouseOverBackground = this.MouseOverBackground;

                if (double.IsNaN(BaseButton.Width))
                {
                    BaseButton.Width = 50;
                }
                if (double.IsNaN(BaseButton.Height))
                {
                    BaseButton.Height = 50;
                }
                BaseButton.Click     += new MenuItemClickEventHandler(BaseItem_Clicked);
                BaseButton.LostFocus += new RoutedEventHandler(BaseItem_LostFocus);
                BaseMenuItemPanel.Children.Add(BaseButton);
            }
        }
 public MenuButtonChangeEventArgs(MenuItemButton oldButton, MenuItemButton newButton)
 {
     this._OldButton = oldButton;
     this._NewButton = newButton;
 }