Beispiel #1
0
        /// <summary>
        /// Shows the drop down items of the button, as if the dropdown part has been clicked
        /// </summary>
        public void ShowDropDown()
        {
            if (Style == RibbonButtonStyle.Normal || DropDownItems.Count == 0)
            {
                CloseDropDown();
                return;
            }

            if (Style == RibbonButtonStyle.DropDown)
            {
                SetPressed(true);
            }
            else
            {
                _dropDownPressed = true;
            }

            OnDropDownShowing(EventArgs.Empty);

            CreateDropDown();
            DropDown.Closed        += new EventHandler(_dropDown_Closed);
            DropDown.ShowSizingGrip = DropDownResizable;

            RibbonPopup canvasdd = Canvas as RibbonPopup;
            Point       location = OnGetDropDownMenuLocation();
            Size        minsize  = OnGetDropDownMenuSize();

            if (canvasdd != null)
            {
                canvasdd.NextPopup     = DropDown;
                DropDown.PreviousPopup = canvasdd;
            }

            if (!minsize.IsEmpty)
            {
                DropDown.MinimumSize = minsize;
            }

            SetDropDownVisible(true);
            DropDown.SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
            DropDown.Show(location);
        }
Beispiel #2
0
        /// <summary>
        /// Raises the MouseDown event
        /// </summary>
        /// <param name="e">Event data</param>
        public virtual void OnMouseDown(MouseEventArgs e)
        {
            if (!Enabled)
            {
                return;
            }

            RibbonPopup pop = Canvas as RibbonPopup;

            if (pop != null)
            {
                if (ClosesDropDownAt(e.Location))
                {
                    pop.CloseAll();
                }
            }

            if (MouseDown != null)
            {
                MouseDown(this, e);
            }

            SetPressed(true);
        }