protected override void Dispose(bool disposing) { if (disposing && (this.controls != null)) { IExtenderProviderService service = (IExtenderProviderService) this.GetService(typeof(IExtenderProviderService)); bool enabled = System.ComponentModel.CompModSwitches.CommonDesignerServices.Enabled; if (service != null) { service.RemoveExtenderProvider(this); } IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost)); if ((this.eventHandlerService != null) && (host != null)) { host.RemoveService(typeof(IEventHandlerService)); this.eventHandlerService = null; } IComponentChangeService service2 = (IComponentChangeService) this.GetService(typeof(IComponentChangeService)); if (service2 != null) { service2.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved); } TypeDescriptor.Refreshed -= new RefreshEventHandler(this.OnComponentRefresh); SystemEvents.DisplaySettingsChanged -= new EventHandler(this.OnSystemSettingChanged); SystemEvents.InstalledFontsChanged -= new EventHandler(this.OnSystemSettingChanged); SystemEvents.UserPreferenceChanged -= new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged); IMenuCommandService menuService = this.MenuService; if (menuService != null) { menuService.RemoveCommand(this.menucmdArrangeIcons); menuService.RemoveCommand(this.menucmdLineupIcons); menuService.RemoveCommand(this.menucmdLargeIcons); } if (this.privateCommandSet != null) { this.privateCommandSet.Dispose(); if (host != null) { host.RemoveService(typeof(ISelectionUIService)); } } this.selectionUISvc = null; if (this.inheritanceUI != null) { this.inheritanceUI.Dispose(); this.inheritanceUI = null; } this.serviceProvider = null; this.controls.Clear(); this.controls = null; if (this.glyphManager != null) { this.glyphManager.Dispose(); this.glyphManager = null; } } base.Dispose(disposing); }
public ComponentTray(IDesigner mainDesigner, IServiceProvider serviceProvider) { this.AutoScroll = true; this.mainDesigner = mainDesigner; this.serviceProvider = serviceProvider; this.AllowDrop = true; this.Text = "ComponentTray"; base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); this.controls = new ArrayList(); IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost)); IExtenderProviderService service = (IExtenderProviderService) this.GetService(typeof(IExtenderProviderService)); if (service != null) { service.AddExtenderProvider(this); } if ((this.GetService(typeof(IEventHandlerService)) == null) && (host != null)) { this.eventHandlerService = new EventHandlerService(this); host.AddService(typeof(IEventHandlerService), this.eventHandlerService); } IMenuCommandService menuService = this.MenuService; if (menuService != null) { this.menucmdArrangeIcons = new MenuCommand(new EventHandler(this.OnMenuArrangeIcons), StandardCommands.ArrangeIcons); this.menucmdLineupIcons = new MenuCommand(new EventHandler(this.OnMenuLineupIcons), StandardCommands.LineupIcons); this.menucmdLargeIcons = new MenuCommand(new EventHandler(this.OnMenuShowLargeIcons), StandardCommands.ShowLargeIcons); this.menucmdArrangeIcons.Checked = this.AutoArrange; this.menucmdLargeIcons.Checked = this.ShowLargeIcons; menuService.AddCommand(this.menucmdArrangeIcons); menuService.AddCommand(this.menucmdLineupIcons); menuService.AddCommand(this.menucmdLargeIcons); } IComponentChangeService service3 = (IComponentChangeService) this.GetService(typeof(IComponentChangeService)); if (service3 != null) { service3.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved); } IUIService service4 = this.GetService(typeof(IUIService)) as IUIService; if (service4 != null) { System.Drawing.Color info; if (service4.Styles["ArtboardBackground"] is System.Drawing.Color) { info = (System.Drawing.Color) service4.Styles["ArtboardBackground"]; } else if (service4.Styles["VsColorDesignerTray"] is System.Drawing.Color) { info = (System.Drawing.Color) service4.Styles["VsColorDesignerTray"]; } else if (service4.Styles["HighlightColor"] is System.Drawing.Color) { info = (System.Drawing.Color) service4.Styles["HighlightColor"]; } else { info = SystemColors.Info; } if (service4.Styles["VsColorPanelText"] is System.Drawing.Color) { this.ForeColor = (System.Drawing.Color) service4.Styles["VsColorPanelText"]; } this.BackColor = info; this.Font = (Font) service4.Styles["DialogFont"]; } ISelectionService selSvc = (ISelectionService) this.GetService(typeof(ISelectionService)); if (selSvc != null) { selSvc.SelectionChanged += new EventHandler(this.OnSelectionChanged); } SystemEvents.DisplaySettingsChanged += new EventHandler(this.OnSystemSettingChanged); SystemEvents.InstalledFontsChanged += new EventHandler(this.OnSystemSettingChanged); SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged); TypeDescriptor.Refreshed += new RefreshEventHandler(this.OnComponentRefresh); BehaviorService behaviorSvc = this.GetService(typeof(BehaviorService)) as BehaviorService; if (behaviorSvc != null) { this.glyphManager = new ComponentTrayGlyphManager(selSvc, behaviorSvc); } }