/// <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 += new EventHandler(OnRibbonParentChanged); // Unhook from watching any top level window if (_formContainer != null) { _formContainer.Deactivate -= new EventHandler(OnRibbonFormDeactivate); _formContainer.Activated -= new EventHandler(OnRibbonFormActivated); _formContainer.SizeChanged -= new EventHandler(OnRibbonFormSizeChanged); _formContainer.MdiChildActivate -= new EventHandler(OnRibbonMdiChildActivate); _formContainer = null; } // Unhook from watching any mdi child window if (_activeMdiChild != null) { _activeMdiChild.SizeChanged -= new EventHandler(OnRibbonMdiChildSizeChanged); _activeMdiChild = null; } // Destruct the button manager resources if (_buttonManager != null) { _buttonManager.Destruct(); _buttonManager = null; } } base.Dispose(disposing); }
private void CreateViewElements(PaletteRedirect redirect) { // Layout for individual tabs inside the header _layoutRibbonTabs = new ViewLayoutRibbonTabs(_ribbon, NeedPaintDelegate); // Put inside a viewport so scrollers are used when tabs cannot be shrunk to fill space _tabsViewport = new ViewLayoutRibbonScrollPort(_ribbon, System.Windows.Forms.Orientation.Horizontal, _layoutRibbonTabs, true, SCROLL_SPEED, NeedPaintDelegate); _tabsViewport.TransparentBackground = true; _tabsViewport.PaintBackground += new PaintEventHandler(OnTabsPaintBackground); _layoutRibbonTabs.ParentControl = _tabsViewport.ViewLayoutControl.ChildControl; _layoutRibbonTabs.NeedPaintDelegate = _tabsViewport.ViewControlPaintDelegate; // We use a layout docker as a child to prevent buttons going to the left of the app button ViewLayoutDocker tabsDocker = new ViewLayoutDocker(); // Place the tabs viewport as the fill inside ourself, the button specs will be placed // to the left and right of this fill element automatically by the button manager below tabsDocker.Add(_tabsViewport, ViewDockStyle.Fill); // We need to draw the bottom half of the application button or a full app tab _layoutAppButton = new ViewLayoutRibbonAppButton(_ribbon, true); _layoutAppTab = new ViewLayoutRibbonAppTab(_ribbon); // Connect up the application button controller to the app button element _appButtonController.Target3 = _layoutAppButton.AppButton; _appButtonController.Click += new EventHandler(OnAppButtonClicked); _appButtonController.MouseReleased += new EventHandler(OnAppButtonReleased); _layoutAppButton.MouseController = _appButtonController; _layoutAppButton.SourceController = _appButtonController; _layoutAppButton.KeyController = _appButtonController; _appTabController.Target1 = _layoutAppTab.AppTab; _appTabController.Click += new EventHandler(OnAppButtonClicked); _appTabController.MouseReleased += new EventHandler(OnAppButtonReleased); _layoutAppTab.MouseController = _appTabController; _layoutAppTab.SourceController = _appTabController; _layoutAppTab.KeyController = _appTabController; // When the app button is not visible we need separator instead before start of first tab _layoutAppButtonSep = new ViewLayoutSeparator(5, 0); _layoutAppButtonSep.Visible = false; // Used separators around the tabs and the edge elements _rightSeparator = new ViewLayoutRibbonSeparator(FAR_TAB_GAP, true); _leftSeparator = new ViewLayoutRibbonSeparator(BUTTON_TAB_GAP_2007, true); // Place application button on left and tabs as the filler (with some separators for neatness) Add(_rightSeparator, ViewDockStyle.Left); Add(_leftSeparator, ViewDockStyle.Left); Add(_layoutAppButton, ViewDockStyle.Left); Add(_layoutAppButtonSep, ViewDockStyle.Left); Add(_layoutAppTab, ViewDockStyle.Left); Add(tabsDocker, ViewDockStyle.Fill); // Create button specification collection manager PaletteRedirect aeroOverrideText = new PaletteRedirectRibbonAeroOverride(_ribbon, redirect); _buttonManager = new ButtonSpecManagerLayoutRibbon(_ribbon, aeroOverrideText, _ribbon.ButtonSpecs, _buttonSpecsFixed, new ViewLayoutDocker[] { tabsDocker }, new IPaletteMetric[] { _ribbon.StateCommon }, new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetPrimary }, new PaletteMetricPadding[] { PaletteMetricPadding.RibbonButtonPadding }, new GetToolStripRenderer(_ribbon.CreateToolStripRenderer), NeedPaintDelegate); // Create the manager for handling tooltips _toolTipManager = new ToolTipManager(); _toolTipManager.ShowToolTip += new EventHandler <ToolTipEventArgs>(OnShowToolTip); _toolTipManager.CancelToolTip += new EventHandler(OnCancelToolTip); _buttonManager.ToolTipManager = _toolTipManager; }