public RibbonDropDownRenderEventArgs(
     Graphics g, RibbonDropDown dropDown
     )
 {
     Graphics = g;
     DropDown = dropDown;
 }
        /// <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
        private void DropDown_Closed(object sender, EventArgs e)
        {
            _dropDownVisible = false;
            _dropdown        = null;

            RemoveHandlers();
        }
 public RibbonDropDownRenderEventArgs(
     Graphics g, RibbonDropDown dropDown
     )
 {
     Graphics = g;
     DropDown = dropDown;
 }
示例#5
0
        /// <summary>
        /// Closes the DropDown if opened
        /// </summary>
        public void CloseDropDown()
        {
            if (_dropDown != null)
            {
                RibbonDropDown.DismissTo(_dropDown);
            }

            SetDropDownVisible(false);
        }
示例#6
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);
            }
        }
示例#7
0
        /// <summary>
        /// Closes the DropDown if opened
        /// </summary>
        public void CloseDropDown()
        {
            if (DropDown != null)
            {
                RibbonPopupManager.Dismiss(DropDown, RibbonPopupManager.DismissReason.NewPopup);
                RemoveHandlers();
                _dropDown = null;
            }

            SetDropDownVisible(false);
        }
        /// <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)));
        }
示例#9
0
        public void HideDropDown()
        {
            if (_dropdown != null && !_dropdown.IsDisposed)
            {
                _dropdown.Close();
            }

            RemoveHandlers();

            _dropDownVisible = false;
            _dropdown        = null;
        }
示例#10
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)
            {
                WinApi.POINT pos;
                if (WinApi.GetCursorPos(out pos))
                {
                    foreach (RibbonItem item in dd.Items)
                    {
                        if (dd.RectangleToScreen(item.Bounds).Contains(pos.x, pos.y))
                        //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);
                            }
                        }
                    }
                }
            }
            //kevin carbis - added scrollbar support to dropdowns so we need to feed the mouse wheel to the
            //actual dropdown item if it was not intended for a child item.
            if (dd != null)
            {
                if (e.Delta < 0)
                {
                    dd.ScrollDown();
                }
                else
                {
                    dd.ScrollUp();
                }

                return(true);
            }
            return(false);
        }
示例#11
0
        /// <summary>
        /// Shows the DropDown
        /// </summary>
        public void ShowDropDown()
        {
            OnDropDownShowing(EventArgs.Empty);

            AssignHandlers();

            if (_dropdown == null || _dropdown.IsDisposed)
            {
                _dropdown = new RibbonDropDown(this, DropDownItems, Owner);
                _dropdown.ShowSizingGrip = DropDownResizable;
                _dropdown.Closed        += new EventHandler(DropDown_Closed);
            }

            _dropdown.Show(Owner.PointToScreen(new Point(TextBoxBounds.Left, Bounds.Bottom)));

            _dropDownVisible = true;
        }
示例#12
0
        /// <summary>
        /// Shows the DropDown
        /// </summary>
        public virtual void ShowDropDown()
        {
            if (!_DropDownVisible)
            {
                AssignHandlers();

                OnDropDownShowing(EventArgs.Empty);

                RibbonDropDown dd = new RibbonDropDown(this, DropDownItems, Owner);
                dd.DropDownMaxHeight = _dropDownMaxHeight;
                dd.ShowSizingGrip    = DropDownResizable;
                dd.DrawIconsBar      = _iconsBar;
                dd.Closed           += new EventHandler(DropDown_Closed);
                Point location = OnGetDropDownMenuLocation();
                dd.Show(location);
                _DropDownVisible = true;
            }
        }
示例#13
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);

            _dropDown                = new RibbonDropDown(this, DropDownItems, Owner);
            _dropDown.Closed        += new EventHandler(_dropDown_Closed);
            _dropDown.ShowSizingGrip = DropDownResizable;

            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);
        }
示例#14
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);
        }
示例#15
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();
                }
            }
        }
        /// <summary>
        /// Closes the DropDown if opened
        /// </summary>
        public void CloseDropDown()
        {
            if (DropDown != null)
            {
                RibbonPopupManager.Dismiss(DropDown, RibbonPopupManager.DismissReason.NewPopup);
                RemoveHandlers();
                _dropDown = null;
            }

            SetDropDownVisible(false);
        }
      /// <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);
      }
示例#18
0
 private static void RegisterDropDown(RibbonDropDown dropDown)
 {
     registeredDds.Add(dropDown);
 }
示例#19
0
 /// <summary>
 /// Creates the DropDown menu
 /// </summary>
 protected virtual void CreateDropDown()
 {
     _dropDown = new RibbonDropDown(this, DropDownItems, Owner);
 }
示例#20
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);

            _dropDown = new RibbonDropDown(this, DropDownItems, Owner);
            _dropDown.Closed += new EventHandler(_dropDown_Closed);
            _dropDown.ShowSizingGrip = DropDownResizable;

            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);
        }
示例#21
0
 /// <summary>
 /// Creates the DropDown menu
 /// </summary>
 protected virtual void CreateDropDown()
 {
     _dropDown = new RibbonDropDown(this, DropDownItems, Owner);
 }
示例#22
0
 private static void UnregisterDropDown(RibbonDropDown dropDown)
 {
     registeredDds.Remove(dropDown);
 }
        /// <summary>
        /// Shows the DropDown
        /// </summary>
        public virtual void ShowDropDown()
        {
            if (!_DropDownVisible)
             {
                AssignHandlers();

                OnDropDownShowing(EventArgs.Empty);

            RibbonDropDown dd = new RibbonDropDown(this, DropDownItems, Owner);
            dd.DropDownMaxHeight = _dropDownMaxHeight;
            dd.ShowSizingGrip = DropDownResizable;
            dd.DrawIconsBar = _iconsBar;
            dd.Closed += new EventHandler(DropDown_Closed);
                Point location = OnGetDropDownMenuLocation();
            dd.Show(location);
            _DropDownVisible = true;
             }
        }
示例#24
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();
                }
            }
        }
示例#25
0
 private static void RegisterDropDown(RibbonDropDown dropDown)
 {
     registeredDds.Add(dropDown);
 }
示例#26
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)));
        }
示例#27
0
 private static void UnregisterDropDown(RibbonDropDown dropDown)
 {
     registeredDds.Remove(dropDown);
 }
示例#28
0
 void AddDropDownItem(RibbonDropDown dd, string label)
 {
     var item = Factory.CreateRibbonDropDownItem();
     item.Label = label;
     dd.Items.Add(item);
 }
示例#29
0
        /// <summary>
        /// Shows the DropDown
        /// </summary>
        public virtual void ShowDropDown()
        {
            if (!_DropDownVisible)
             {
            //foreach (RibbonItem item in DropDownItems)
            //{
            //   if (item == _selectedItem)
            //      item.Checked = true;
            //   else
            //      item.Checked = false;
            //}

            OnDropDownShowing(EventArgs.Empty);

            AssignHandlers();

            RibbonDropDown dd = new RibbonDropDown(this, DropDownItems, Owner);
            dd.ShowSizingGrip = DropDownResizable;
            dd.DrawIconsBar = _iconsBar;
            dd.Closed += new EventHandler(DropDown_Closed);
            dd.Show(Owner.PointToScreen(new Point(TextBoxBounds.Left, Bounds.Bottom)));
            _DropDownVisible = true;
             }
        }