/// <summary> /// Closes the DropDown if opened /// </summary> public void CloseDropDown() { if (DropDown != null) { RibbonPopupManager.Dismiss(DropDown, RibbonPopupManager.DismissReason.NewPopup); } SetDropDownVisible(false); }
/// <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))) { DeactivateToolTip(_TT); 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; //} }
/// <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; } AssignHandlers(); CreateDropDown(); DropDown.MouseEnter += DropDown_MouseEnter; DropDown.Closed += DropDown_Closed; DropDown.ShowSizingGrip = DropDownResizable; DropDown.DrawIconsBar = _iconsBar; var canvasdd = Canvas as RibbonPopup; var location = OnGetDropDownMenuLocation(); var minsize = OnGetDropDownMenuSize(); if (!minsize.IsEmpty) { DropDown.MinimumSize = minsize; } OnDropDownShowing(EventArgs.Empty); SetDropDownVisible(true); DropDown.SelectionService = GetService(typeof(ISelectionService)) as ISelectionService; DropDown.Show(location); }
/// <summary> /// Shows this Popup on the specified location of the screen /// </summary> /// <param name="screenLocation"></param> public void Show(Point screenLocation) { if (WrappedDropDown == null) { var 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 += ToolStripDropDown_Opening; WrappedDropDown.Closing += ToolStripDropDown_Closing; WrappedDropDown.Closed += ToolStripDropDown_Closed; WrappedDropDown.Size = Size; } WrappedDropDown.Show(screenLocation); RibbonPopupManager.Register(this); OnShowed(EventArgs.Empty); }