示例#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;
            }

            IgnoreDeactivation();

            _dropDown = new RibbonDropDown(this, DropDownItems, Owner);
            _dropDown.VisibleChanged += new EventHandler(_dropDown_VisibleChanged);
            //_dropDown.StartPosition = FormStartPosition.Manual;

            RibbonDropDown canvasdd = Canvas as RibbonDropDown;
            Point          location = Point.Empty;

            if (canvasdd != null)
            {
                location = Canvas.PointToScreen(new Point(Bounds.Right, Bounds.Top));
                _dropDown.PreviousDropDown = Canvas as RibbonDropDown;
                canvasdd.NextDropDown      = _dropDown;
            }
            else
            {
                location = Canvas.PointToScreen(new Point(Bounds.Left, Bounds.Bottom));
            }

            SetDropDownVisible(true);
            _dropDown.SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
            _dropDown.Show(location);
        }
示例#2
0
        /// <summary>
        /// Feeds mouse Wheel. If applied on a IScrollableItem it's sended to it
        /// </summary>
        /// <param name="e"></param>
        /// <returns>True if handled. False otherwise</returns>
        internal static bool FeedMouseWheel(MouseEventArgs e)
        {
            RibbonDropDown dd = LastPopup as RibbonDropDown;

            if (dd != null)
            {
                foreach (RibbonItem item in dd.Items)
                {
                    if (dd.RectangleToScreen(item.Bounds).Contains(e.Location))
                    {
                        IScrollableRibbonItem sc = item as IScrollableRibbonItem;

                        if (sc != null)
                        {
                            if (e.Delta < 0)
                            {
                                sc.ScrollDown();
                            }
                            else
                            {
                                sc.ScrollUp();
                            }

                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
示例#3
0
        /// <summary>
        /// Closes the DropDown if opened
        /// </summary>
        public void CloseDropDown()
        {
            if (_dropDown != null)
            {
                RibbonDropDown.DismissTo(_dropDown);
            }

            SetDropDownVisible(false);
        }
示例#4
0
        /// <summary>
        /// Selects the item when in a dropdown, in design mode
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RibbonItem_Click(object sender, EventArgs e)
        {
            RibbonDropDown dd = Canvas as RibbonDropDown;

            if (dd != null && dd.SelectionService != null)
            {
                dd.SelectionService.SetSelectedComponents(
                    new Component[] { this }, System.ComponentModel.Design.SelectionTypes.Primary);
            }
        }
示例#5
0
        /// <summary>
        /// Shows the DropDown
        /// </summary>
        public void ShowDropDown()
        {
            OnDropDownShowing(EventArgs.Empty);

            AssignHandlers();

            RibbonDropDown dd = new RibbonDropDown(this, DropDownItems, Owner);

            dd.ShowSizingGrip = DropDownResizable;
            dd.Closed        += new EventHandler(DropDown_Closed);
            dd.Show(Owner.PointToScreen(new Point(TextBoxBounds.Left, Bounds.Bottom)));
        }
示例#6
0
        /// <summary>
        /// Shows the drop down items of the button, as if the dropdown part has been clicked
        /// </summary>
        public void ShowDropDown()
        {
            if (DropDownItems.Count == 0)
            {
                SetPressed(false);
                return;
            }

            IgnoreDeactivation();

            _dropDown = new RibbonDropDown(this, DropDownItems, Owner);
            //_dropDown.FormClosed += new FormClosedEventHandler(dropDown_FormClosed);
            //_dropDown.StartPosition = FormStartPosition.Manual;
            _dropDown.ShowSizingGrip = true;
            Point location = Canvas.PointToScreen(new Point(Bounds.Left, Bounds.Top));


            SetDropDownVisible(true);
            _dropDown.Show(location);
        }
示例#7
0
        /// <summary>
        /// Closes all the dropdowns before the specified dropDown
        /// </summary>
        /// <param name="dropDown"></param>
        internal static void DismissTo(RibbonDropDown dropDown)
        {
            if (dropDown == null)
            {
                throw new ArgumentNullException("dropDown");
            }

            for (int i = registeredDds.Count - 1; i >= 0; i--)
            {
                if (i >= registeredDds.Count)
                {
                    break;
                }

                if (registeredDds[i].Equals(dropDown))
                {
                    break;
                }
                else
                {
                    registeredDds[i].Close();
                }
            }
        }
示例#8
0
 /// <summary>
 /// Creates the DropDown menu
 /// </summary>
 protected virtual void CreateDropDown()
 {
     _dropDown = new RibbonDropDown(this, DropDownItems, Owner);
 }
示例#9
0
 private static void UnregisterDropDown(RibbonDropDown dropDown)
 {
     registeredDds.Remove(dropDown);
 }
示例#10
0
 private static void RegisterDropDown(RibbonDropDown dropDown)
 {
     registeredDds.Add(dropDown);
 }