Example #1
0
        /// <summary>
        /// Raises the Click event
        /// </summary>
        /// <param name="e">Event data</param>
        public virtual void OnClick(EventArgs e)
        {
            try
            {
                if (!Enabled)
                {
                    return;
                }

                if (ClosesDropDownAt(Canvas.PointToClient(Cursor.Position)))
                {
                    DeactivateToolTip(_TT);
                    RibbonPopupManager.Dismiss(RibbonPopupManager.DismissReason.ItemClicked);
                }

                SetSelected(false);

                if (Click != null)
                {
                    Click(this, e);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Shows this Popup on the specified location of the screen
        /// </summary>
        /// <param name="screenLocation"></param>
        public void Show(Point screenLocation)
        {
            if (WrappedDropDown == null)
            {
                ToolStripControlHost host = new ToolStripControlHost(this);
                WrappedDropDown = new RibbonWrappedDropDown
                {
                    AutoClose = RibbonDesigner.Current != null
                };
                WrappedDropDown.Items.Add(host);

                WrappedDropDown.Padding = Padding.Empty;
                WrappedDropDown.Margin  = Padding.Empty;
                host.Padding            = Padding.Empty;
                host.Margin             = Padding.Empty;

                WrappedDropDown.Opening += ToolStripDropDown_Opening;
                WrappedDropDown.Closing += ToolStripDropDown_Closing;
                WrappedDropDown.Closed  += ToolStripDropDown_Closed;
                WrappedDropDown.Size     = Size;
            }
            WrappedDropDown.Show(screenLocation);
            RibbonPopupManager.Register(this);

            OnShowed(EventArgs.Empty);
        }
Example #3
0
 private void _keyboardHook_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         RibbonPopupManager.Dismiss(RibbonPopupManager.DismissReason.EscapePressed);
     }
 }
Example #4
0
        /// <summary>
        /// Raises the MouseDown event
        /// </summary>
        /// <param name="e">Event data</param>
        public virtual void OnMouseDown(MouseEventArgs e)
        {
            if (!Enabled)
            {
                return;
            }

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

            RibbonPopup pop = Canvas as RibbonPopup;

            if (pop != null)
            {
                if (ClosesDropDownAt(e.Location))
                {
                    RibbonPopupManager.Dismiss(RibbonPopupManager.DismissReason.ItemClicked);
                }

                OnClick(EventArgs.Empty);
            }

            SetPressed(true);
        }
Example #5
0
 /// <summary>
 /// Resends the mousedown to PopupManager
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void _mouseHook_MouseDown(object sender, MouseEventArgs e)
 {
     if (!RectangleToScreen(OrbBounds).Contains(e.Location))
     {
         RibbonPopupManager.FeedHookClick(e);
     }
 }
Example #6
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         RibbonPopupManager.Dismiss(RibbonPopupManager.DismissReason.EscapePressed);
     }
     base.OnKeyDown(e);
 }
Example #7
0
        /// <summary>
        /// Closes the DropDown if opened
        /// </summary>
        public void CloseDropDown()
        {
            if (DropDown != null)
            {
                RibbonPopupManager.Dismiss(DropDown, RibbonPopupManager.DismissReason.NewPopup);
            }

            SetDropDownVisible(false);
        }
Example #8
0
 /// <summary>
 /// Checks if MouseWheel should be raised
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void _mouseHook_MouseWheel(object sender, MouseEventArgs e)
 {
     if (!RibbonPopupManager.FeedMouseWheel(e))
     {
         if (RectangleToScreen(
                 new Rectangle(Point.Empty, Size)
                 ).Contains(e.Location))
         {
             OnMouseWheel(e);
         }
     }
 }
Example #9
0
        /// <summary>
        /// Removes all helper controls placed by any reason.
        /// Contol's visibility is set to false before removed.
        /// </summary>
        private void RemoveHelperControls()
        {
            RibbonPopupManager.Dismiss(RibbonPopupManager.DismissReason.AppClicked);

            while (Controls.Count > 0)
            {
                Control ctl = Controls[0];

                ctl.Visible = false;

                Controls.Remove(ctl);
            }
        }
Example #10
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)
            {
                if (DropDown != null)
                {
                    RibbonPopupManager.DismissChildren(DropDown, RibbonPopupManager.DismissReason.NewPopup);
                }
                return;
            }

            if (Style == RibbonButtonStyle.DropDown)
            {
                SetPressed(true);
            }
            else
            {
                _dropDownPressed = true;
            }
            OnDropDownShowing(EventArgs.Empty);
            if (DropDownItems.Count == 0)
            {
                if (DropDown != null)
                {
                    RibbonPopupManager.DismissChildren(DropDown, RibbonPopupManager.DismissReason.NewPopup);
                }
                return;
            }
            AssignHandlers();

            CreateDropDown();
            DropDown.MouseEnter    += new EventHandler(DropDown_MouseEnter);
            DropDown.Closed        += new EventHandler(DropDown_Closed);
            DropDown.ShowSizingGrip = DropDownResizable;
            DropDown.DrawIconsBar   = DrawDropDownIconsBar;

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

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

            SetDropDownVisible(true);
            DropDown.SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
            DropDown.Show(location);
        }
Example #11
0
        /// <summary>
        /// Raises the Click event
        /// </summary>
        /// <param name="e">Event data</param>
        public virtual void OnClick(EventArgs e)
        {
            if (!Enabled)
            {
                return;
            }

            if (ClosesDropDownAt(Canvas.PointToClient(Cursor.Position)))
            {
                RibbonPopupManager.Dismiss(RibbonPopupManager.DismissReason.ItemClicked);
            }

            SetSelected(false);

            if (Click != null)
            {
                Click(this, e);
            }
        }
        /// <summary>
        /// Raises the <see cref="Closed"/> event.
        /// <remarks>If you override this event don't forget to call base! Otherwise the popup will not be unregistered and hook will not work!</remarks>
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnClosed(EventArgs e)
        {
            RibbonPopupManager.Unregister(this);

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

            //if (NextPopup != null)
            //{
            //    NextPopup.CloseForward();
            //    NextPopup = null;
            //}

            //if (PreviousPopup != null && PreviousPopup.NextPopup.Equals(this))
            //{
            //    PreviousPopup.NextPopup = null;
            //}
        }
Example #13
0
        /// <summary>
        /// Raises the Click event
        /// </summary>
        /// <param name="e">Event data</param>
        public virtual void OnClick(EventArgs e)
        {
            if (!Enabled)
            {
                return;
            }

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

            RibbonPopup pop = Canvas as RibbonPopup;

            if (pop != null)
            {
                if (ClosesDropDownAt(Cursor.Position))
                {
                    RibbonPopupManager.Dismiss(RibbonPopupManager.DismissReason.ItemClicked);
                }
            }
        }