Beispiel #1
0
 private void _keyboardHook_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         RibbonPopupManager.Dismiss(RibbonPopupManager.DismissReason.EscapePressed);
     }
 }
Beispiel #2
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);
     }
 }
Beispiel #3
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);
        }
Beispiel #4
0
        /// <summary>
        /// Closes the DropDown if opened
        /// </summary>
        public void CloseDropDown()
        {
            if (DropDown != null)
            {
                RibbonPopupManager.Dismiss(DropDown, RibbonPopupManager.DismissReason.NewPopup);
            }

            SetDropDownVisible(false);
        }
Beispiel #5
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);
         }
     }
 }
Beispiel #6
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);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Raises the <see cref="Closed"/> event
        /// </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;
            //}
        }
Beispiel #8
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)
            {
                if (DropDown != null)
                {
                    RibbonPopupManager.DismissChildren(DropDown, RibbonPopupManager.DismissReason.NewPopup);
                }
                return;
            }

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



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

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

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

            OnDropDownShowing(EventArgs.Empty);
            SetDropDownVisible(true);
            DropDown.SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
            DropDown.Show(location);
        }
Beispiel #9
0
        /// <summary>
        /// Shows this Popup on the specified location of the screen
        /// </summary>
        /// <param name="screenLocation"></param>
        public void Show(Point screenLocation)
        {
            ToolStripControlHost host = new ToolStripControlHost(this);

            WrappedDropDown           = new RibbonWrappedDropDown();
            WrappedDropDown.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 += new CancelEventHandler(ToolStripDropDown_Opening);
            WrappedDropDown.Closing += new ToolStripDropDownClosingEventHandler(ToolStripDropDown_Closing);
            WrappedDropDown.Closed  += new ToolStripDropDownClosedEventHandler(ToolStripDropDown_Closed);
            WrappedDropDown.Size     = Size;
            WrappedDropDown.Show(screenLocation);
            RibbonPopupManager.Register(this);

            OnShowed(EventArgs.Empty);
        }