/// <summary> /// Gets access to the view used to display the provided button definition. /// </summary> /// <param name="qatButton"></param> /// <returns>Element that matches button; otherwise null</returns> public ViewBase ViewForButton(IQuickAccessToolbarButton qatButton) { if (_qatButtonToView.ContainsKey(qatButton)) { return(_qatButtonToView[qatButton]); } else { return(null); } }
/// <summary> /// Gets access to the view used to display the provided button definition. /// </summary> /// <returns></returns> public ViewBase ViewForButton(IQuickAccessToolbarButton qatButton) { // Find the first qat button ViewBase view = _borderContents.ViewForButton(qatButton); // If defined then use the extra button if (view == null) { view = _extraButton; } return(view); }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonQATButton class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="qatButton">Reference to button definition.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewDrawRibbonQATButton(KryptonRibbon ribbon, IQuickAccessToolbarButton qatButton, NeedPaintHandler needPaint) { Debug.Assert(ribbon != null); Debug.Assert(qatButton != null); // Remember incoming references _ribbon = ribbon; QATButton = qatButton; _viewSize = new Size((int)(22 * FactorDpiX), (int)(22 * FactorDpiY)); // If the source interface comes from a component then allow it to // be selected at design time by clicking on the view instance Component = qatButton as Component; // Attach a controller to this element for the pressing of the button QATButtonController controller = new(ribbon, this, needPaint); controller.Click += OnClick; SourceController = controller; KeyController = controller; // Create controller for intercepting events to determine tool tip handling MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager.ToolTipManager, this, controller); // Use a class to convert from ribbon tab to content interface _contentProvider = new QATButtonToContent(qatButton); // Create and add the draw content for display inside the button _drawContent = new ViewDrawContent(_contentProvider, this, VisualOrientation.Top); Add(_drawContent); // Need to notice when the ribbon enable state changes _ribbon.EnabledChanged += OnRibbonEnableChanged; // Set the initial enabled state UpdateEnabled(); }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonQATButton class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="qatButton">Reference to button definition.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewDrawRibbonQATButton(KryptonRibbon ribbon, IQuickAccessToolbarButton qatButton, NeedPaintHandler needPaint) { Debug.Assert(ribbon != null); Debug.Assert(qatButton != null); // Remember incoming references _ribbon = ribbon; _qatButton = qatButton; // If the source interface comes from a component then allow it to // be selected at design time by clicking on the view instance Component = qatButton as System.ComponentModel.Component; // Attach a controller to this element for the pressing of the button QATButtonController controller = new QATButtonController(ribbon, this, needPaint); controller.Click += new MouseEventHandler(OnClick); SourceController = controller; KeyController = controller; // Create controller for intercepting events to determine tool tip handling MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager.ToolTipManager, this, controller); // Use a class to convert from ribbon tab to content interface _contentProvider = new QATButtonToContent(qatButton); // Create and add the draw content for display inside the button _drawContent = new ViewDrawContent(_contentProvider, this, VisualOrientation.Top); Add(_drawContent); // Need to notice when the ribbon enable state changes _ribbon.EnabledChanged += new EventHandler(OnRibbonEnableChanged); // Set the initial enabled state UpdateEnabled(); }
/// <summary> /// Initialize a new instance of the QATButtonToolTipToContent class. /// </summary> /// <param name="qatButton">Source quick access toolbar button.</param> public QATButtonToolTipToContent(IQuickAccessToolbarButton qatButton) { Debug.Assert(qatButton != null); _qatButton = qatButton; }
private void SyncChildren(bool layout) { // Remove all child elements Clear(); // Create a new lookup that reflects any changes in QAT buttons QATButtonToView regenerate = new QATButtonToView(); // Get an array with all the buttons to be considered for display IQuickAccessToolbarButton[] qatButtons = QATButtons; // Make sure we have a view element to match each QAT button definition foreach (IQuickAccessToolbarButton qatButton in qatButtons) { ViewDrawRibbonQATButton view = null; // Get the currently cached view for the button if (_qatButtonToView.ContainsKey(qatButton)) { view = _qatButtonToView[qatButton]; } // If a new button, create a view for it now if (view == null) { view = new ViewDrawRibbonQATButton(Ribbon, qatButton, _needPaint); } // Add to the lookup for future reference regenerate.Add(qatButton, view); } // Add child elements appropriate for each qat button for (int i = 0; i < qatButtons.Length; i++) { IQuickAccessToolbarButton qatButton = qatButtons[i]; // Does the layout processing require the view to be updated if (layout) { // Update the enabled/visible state of the button regenerate[qatButton].Enabled = Ribbon.InDesignHelperMode || qatButton.GetEnabled(); regenerate[qatButton].Visible = Ribbon.InDesignHelperMode || qatButton.GetVisible(); } // Always add the group view Add(regenerate[qatButton]); // Remove entries we are still using if (_qatButtonToView.ContainsKey(qatButton)) { _qatButtonToView.Remove(qatButton); } } // Dispose of views no longer required foreach (ViewDrawRibbonQATButton view in _qatButtonToView.Values) { view.Dispose(); } // No longer need the old lookup _qatButtonToView = regenerate; // Always add the customization/overflow button last if (_extraButton != null) { Add(_extraButton); } }
/// <summary> /// Gets access to the view used to display the provided button definition. /// </summary> /// <param name="qatButton"></param> /// <returns>Element that matches button; otherwise null</returns> public ViewBase ViewForButton(IQuickAccessToolbarButton qatButton) => _qatButtonToView.ContainsKey(qatButton) ? _qatButtonToView[qatButton] : null;