/// <summary> /// Release unmanaged and optionally managed resources. /// </summary> /// <param name="disposing">Called from Dispose method.</param> protected override void Dispose(bool disposing) { if (ButtonSpecManager != null) { ButtonSpecManager.Destruct(); ButtonSpecManager = null; } // Must call base class to finish disposing base.Dispose(disposing); }
private void OnRibbonMdiChildActivate(object sender, EventArgs e) { // Cast to correct type Form topForm = sender as Form; // Unhook from watching any previous mdi child if (_activeMdiChild != null) { _activeMdiChild.SizeChanged -= OnRibbonMdiChildSizeChanged; } _activeMdiChild = topForm.ActiveMdiChild; // Start watching any new mdi child if (_activeMdiChild != null) { _activeMdiChild.SizeChanged += OnRibbonMdiChildSizeChanged; } // Update the pendant buttons with reference to new child _buttonSpecClose.MdiChild = _activeMdiChild; _buttonSpecRestore.MdiChild = _activeMdiChild; _buttonSpecMin.MdiChild = _activeMdiChild; ButtonSpecManager.RecreateButtons(); PerformNeedPaint(true); // We never want the mdi child window to have a system menu, we provide the // pendant buttons as part of the ribbon and so replace the need for it. PI.SetMenu(new HandleRef(_ribbon, topForm.Handle), NullHandleRef); if (_activeMdiChild != null) { uint windowStyle = PI.GetWindowLong(_activeMdiChild.Handle, PI.GWL_.STYLE); windowStyle |= PI.WS_.SYSMENU; PI.SetWindowLong(_activeMdiChild.Handle, PI.GWL_.STYLE, windowStyle); } }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { // Remove any showing tooltip OnCancelToolTip(this, EventArgs.Empty); // Unhook from the parent control _ribbon.ParentChanged += OnRibbonParentChanged; // Unhook from watching any top level window if (_formContainer != null) { _formContainer.Deactivate -= OnRibbonFormDeactivate; _formContainer.Activated -= OnRibbonFormActivated; _formContainer.SizeChanged -= OnRibbonFormSizeChanged; _formContainer.MdiChildActivate -= OnRibbonMdiChildActivate; _formContainer = null; } // Unhook from watching any mdi child window if (_activeMdiChild != null) { _activeMdiChild.SizeChanged -= OnRibbonMdiChildSizeChanged; _activeMdiChild = null; } // Destruct the button manager resources if (ButtonSpecManager != null) { ButtonSpecManager.Destruct(); ButtonSpecManager = null; } } base.Dispose(disposing); }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { if (_mementos != null) { // Dispose of all the mementos in the array foreach (IDisposable memento in _mementos) { memento?.Dispose(); } _mementos = null; } if (ButtonSpecManager != null) { ButtonSpecManager.Destruct(); ButtonSpecManager = null; } } base.Dispose(disposing); }
/// <summary> /// Update the button spec manager mapping to reflect current settings. /// </summary> public override void UpdateButtonSpecMapping() { // Define a default mapping for text color and recreate to use that new setting ButtonSpecManager.SetRemapTarget(Navigator.Outlook.CheckButtonStyle); ButtonSpecManager.RecreateButtons(); }
private void OnShowToolTip(object sender, ToolTipEventArgs e) { if (!_ribbon.IsDisposed) { // Do not show tooltips when the form we are in does not have focus Form topForm = _ribbon.FindForm(); if ((topForm != null) && !topForm.ContainsFocus) { return; } // Never show tooltips are design time if (!_ribbon.InDesignMode) { IContentValues sourceContent = null; LabelStyle toolTipStyle = LabelStyle.SuperTip; Rectangle screenRect = new Rectangle(e.ControlMousePosition, new Size(1, 1)); // If the target is the application button switch (e.Target) { case ViewLayoutRibbonAppButton _: case ViewLayoutRibbonAppTab _: // Create a content that recovers values from a the ribbon for the app button/tab AppButtonToolTipToContent appButtonContent = new AppButtonToolTipToContent(_ribbon); // Is there actually anything to show for the tooltip if (appButtonContent.HasContent) { sourceContent = appButtonContent; // Grab the style from the app button settings toolTipStyle = _ribbon.RibbonAppButton.AppButtonToolTipStyle; // Display below the mouse cursor screenRect.Height += (SystemInformation.CursorSize.Height / 3) * 2; } break; case ViewDrawRibbonQATButton viewElement1: // If the target is a QAT button // Cast to correct type // Create a content that recovers values from a IQuickAccessToolbarButton QATButtonToolTipToContent qatButtonContent = new QATButtonToolTipToContent(viewElement1.QATButton); // Is there actually anything to show for the tooltip if (qatButtonContent.HasContent) { sourceContent = qatButtonContent; // Grab the style from the QAT button settings toolTipStyle = viewElement1.QATButton.GetToolTipStyle(); // Display below the mouse cursor screenRect.Height += (SystemInformation.CursorSize.Height / 3) * 2; } break; default: if (e.Target.Parent is ViewDrawRibbonGroupLabel viewElement2) { // Cast to correct type // Create a content that recovers values from a KryptonRibbonGroupItem GroupItemToolTipToContent groupItemContent = new GroupItemToolTipToContent(viewElement2.GroupLabel); // Is there actually anything to show for the tooltip if (groupItemContent.HasContent) { sourceContent = groupItemContent; // Grab the style from the group label settings toolTipStyle = viewElement2.GroupLabel.ToolTipStyle; // Display below the bottom of the ribbon control Rectangle ribbonScreenRect = _ribbon.ToolTipScreenRectangle; screenRect.Y = ribbonScreenRect.Y; screenRect.Height = ribbonScreenRect.Height; screenRect.X = ribbonScreenRect.X + viewElement2.ClientLocation.X; screenRect.Width = viewElement2.ClientWidth; } } else { switch (e.Target) { case ViewDrawRibbonGroupButtonBackBorder viewElement3: { // Is the target is a button or cluster button // Cast to correct type // Create a content that recovers values from a KryptonRibbonGroupItem GroupItemToolTipToContent groupItemContent = new GroupItemToolTipToContent(viewElement3.GroupItem); // Is there actually anything to show for the tooltip if (groupItemContent.HasContent) { sourceContent = groupItemContent; // Grab the style from the group button/group cluster button settings toolTipStyle = viewElement3.GroupItem.InternalToolTipStyle; // Display below the bottom of the ribbon control Rectangle ribbonScreenRect = _ribbon.ToolTipScreenRectangle; screenRect.Y = ribbonScreenRect.Y; screenRect.Height = ribbonScreenRect.Height; screenRect.X = ribbonScreenRect.X + viewElement3.ClientLocation.X; screenRect.Width = viewElement3.ClientWidth; } break; } case ViewLayoutRibbonCheckBox _: { // Cast to correct type ViewDrawRibbonGroupCheckBox viewElement = (ViewDrawRibbonGroupCheckBox)e.Target.Parent; // Create a content that recovers values from a KryptonRibbonGroupItem GroupItemToolTipToContent groupItemContent = new GroupItemToolTipToContent(viewElement.GroupCheckBox); // Is there actually anything to show for the tooltip if (groupItemContent.HasContent) { sourceContent = groupItemContent; // Grab the style from the group check box cluster button settings toolTipStyle = viewElement.GroupCheckBox.InternalToolTipStyle; // Display below the bottom of the ribbon control Rectangle ribbonScreenRect = _ribbon.ToolTipScreenRectangle; screenRect.Y = ribbonScreenRect.Y; screenRect.Height = ribbonScreenRect.Height; screenRect.X = ribbonScreenRect.X + viewElement.ClientLocation.X; screenRect.Width = viewElement.ClientWidth; } break; } case ViewLayoutRibbonRadioButton _: { // Cast to correct type ViewDrawRibbonGroupRadioButton viewElement = (ViewDrawRibbonGroupRadioButton)e.Target.Parent; // Create a content that recovers values from a KryptonRibbonGroupItem GroupItemToolTipToContent groupItemContent = new GroupItemToolTipToContent(viewElement.GroupRadioButton); // Is there actually anything to show for the tooltip if (groupItemContent.HasContent) { sourceContent = groupItemContent; // Grab the style from the group radio button button settings toolTipStyle = viewElement.GroupRadioButton.InternalToolTipStyle; // Display below the bottom of the ribbon control Rectangle ribbonScreenRect = _ribbon.ToolTipScreenRectangle; screenRect.Y = ribbonScreenRect.Y; screenRect.Height = ribbonScreenRect.Height; screenRect.X = ribbonScreenRect.X + viewElement.ClientLocation.X; screenRect.Width = viewElement.ClientWidth; } break; } default: // Find the button spec associated with the tooltip request ButtonSpec buttonSpec = ButtonSpecManager.ButtonSpecFromView(e.Target); // If the tooltip is for a button spec if (buttonSpec != null) { // Are we allowed to show page related tooltips if (_ribbon.AllowButtonSpecToolTips) { // Create a helper object to provide tooltip values ButtonSpecToContent buttonSpecMapping = new ButtonSpecToContent(_ribbon.GetRedirector(), buttonSpec); // Is there actually anything to show for the tooltip if (buttonSpecMapping.HasContent) { sourceContent = buttonSpecMapping; // Grab the style from the button spec settings toolTipStyle = buttonSpec.ToolTipStyle; // Display below the mouse cursor screenRect.Height += (SystemInformation.CursorSize.Height / 3) * 2; } } } break; } } break; } if (sourceContent != null) { // Remove any currently showing tooltip _visualPopupToolTip?.Dispose(); // Create the actual tooltip popup object _visualPopupToolTip = new VisualPopupToolTip(_ribbon.GetRedirector(), sourceContent, _ribbon.Renderer, PaletteBackStyle.ControlToolTip, PaletteBorderStyle.ControlToolTip, CommonHelper.ContentStyleFromLabelStyle(toolTipStyle)); _visualPopupToolTip.Disposed += OnVisualPopupToolTipDisposed; // The popup tooltip control always adds on a border above/below so we negate that here. screenRect.Height -= 20; _visualPopupToolTip.ShowRelativeTo(e.Target, screenRect.Location); } } } }
private void OnRibbonMdiChildSizeChanged(object sender, EventArgs e) { // Update pendant buttons to reflect new child state ButtonSpecManager.RecreateButtons(); PerformNeedPaint(true); }
/// <summary> /// Recreate the button specifications. /// </summary> public void RecreateButtons() { ButtonSpecManager?.RecreateButtons(); }
/// <summary> /// Update the button spec manager mapping to reflect current settings. /// </summary> public override void UpdateButtonSpecMapping() { // Update the button spec manager for this tab to use a tab style for remapping ButtonSpecManager.SetRemapTarget(Navigator.Bar.TabStyle); ButtonSpecManager.RecreateButtons(); }