private void InitializePanelControls() { this._selectLabel.Text = System.Design.SR.GetString("CreateDataSource_SelectType"); this._idLabel.Text = System.Design.SR.GetString("CreateDataSource_ID"); base.OKButton.Enabled = false; this.Text = System.Design.SR.GetString("CreateDataSource_Title"); this._descriptionBox.Text = System.Design.SR.GetString("CreateDataSource_SelectTypeDesc"); base.AccessibleDescription = System.Design.SR.GetString("CreateDataSource_Description"); base.CaptionLabel.Text = System.Design.SR.GetString("CreateDataSource_Caption"); this.UpdateFonts(); ISite site = this.GetSite(); if (site != null) { IComponentDiscoveryService service = (IComponentDiscoveryService)site.GetService(typeof(IComponentDiscoveryService)); IDesignerHost designerHost = (IDesignerHost)site.GetService(typeof(IDesignerHost)); if (service != null) { ICollection componentTypes = service.GetComponentTypes(designerHost, this._dataSourceType); if (componentTypes != null) { ImageList list = new ImageList { ColorDepth = ColorDepth.Depth32Bit }; System.Type[] array = new System.Type[componentTypes.Count]; componentTypes.CopyTo(array, 0); foreach (System.Type type in array) { System.ComponentModel.AttributeCollection attributes = TypeDescriptor.GetAttributes(type); Bitmap image = null; if (attributes != null) { ToolboxBitmapAttribute attribute = attributes[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; if ((attribute != null) && !attribute.Equals(ToolboxBitmapAttribute.Default)) { image = attribute.GetImage(type, true) as Bitmap; } } if (image == null) { image = new Bitmap(base.GetType(), "CustomDataSource.bmp"); } list.ImageSize = new Size(0x20, 0x20); list.Images.Add(type.FullName, image); this._dataSourceTypesListView.Items.Add(new DataSourceListViewItem(type)); } this._dataSourceTypesListView.Sort(); this._dataSourceTypesListView.LargeImageList = list; } } } }
// This utility method connects the designer to various // services it will use. private void InitializeServices() { // Acquire a reference to DesignerActionService. this.actionService = GetService(typeof(DesignerActionService)) as DesignerActionService; // Acquire a reference to DesignerActionUIService. this.actionUiService = GetService(typeof(DesignerActionUIService)) as DesignerActionUIService; // Acquire a reference to IComponentChangeService. this.changeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService; // Acquire a reference to IDesignerHost. this.host = GetService(typeof(IDesignerHost)) as IDesignerHost; // Acquire a reference to IDesignerOptionService. this.optionService = GetService(typeof(IDesignerOptionService)) as IDesignerOptionService; // Acquire a reference to IEventBindingService. this.eventBindingService = GetService(typeof(IEventBindingService)) as IEventBindingService; // Acquire a reference to IExtenderListService. this.listService = GetService(typeof(IExtenderListService)) as IExtenderListService; // Acquire a reference to IReferenceService. this.referenceService = GetService(typeof(IReferenceService)) as IReferenceService; // Acquire a reference to ITypeResolutionService. this.typeResService = GetService(typeof(ITypeResolutionService)) as ITypeResolutionService; // Acquire a reference to IComponentDiscoveryService. this.componentDiscoveryService = GetService(typeof(IComponentDiscoveryService)) as IComponentDiscoveryService; // Acquire a reference to IToolboxService. this.toolboxService = GetService(typeof(IToolboxService)) as IToolboxService; // Acquire a reference to UndoEngine. this.undoEng = GetService(typeof(UndoEngine)) as UndoEngine; if (this.undoEng != null) { //MessageBox.Show("UndoEngine"); } }
// </snippet6> // <snippet7> // This utility method connects the designer to various // services it will use. private void InitializeServices() { // Acquire a reference to DesignerActionService. this.actionService = GetService(typeof(DesignerActionService)) as DesignerActionService; // Acquire a reference to DesignerActionUIService. this.actionUiService = GetService(typeof(DesignerActionUIService)) as DesignerActionUIService; // Acquire a reference to IComponentChangeService. this.changeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService; // <snippet14> // Hook the IComponentChangeService events. if (this.changeService != null) { this.changeService.ComponentChanged += new ComponentChangedEventHandler( ChangeService_ComponentChanged); this.changeService.ComponentAdded += new ComponentEventHandler( ChangeService_ComponentAdded); this.changeService.ComponentRemoved += new ComponentEventHandler( changeService_ComponentRemoved); } // </snippet14> // Acquire a reference to ISelectionService. this.selectionService = GetService(typeof(ISelectionService)) as ISelectionService; // Hook the SelectionChanged event. if (this.selectionService != null) { this.selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged); } // Acquire a reference to IDesignerEventService. this.eventService = GetService(typeof(IDesignerEventService)) as IDesignerEventService; if (this.eventService != null) { this.eventService.ActiveDesignerChanged += new ActiveDesignerEventHandler( eventService_ActiveDesignerChanged); } // Acquire a reference to IDesignerHost. this.host = GetService(typeof(IDesignerHost)) as IDesignerHost; // Acquire a reference to IDesignerOptionService. this.optionService = GetService(typeof(IDesignerOptionService)) as IDesignerOptionService; // Acquire a reference to IEventBindingService. this.eventBindingService = GetService(typeof(IEventBindingService)) as IEventBindingService; // Acquire a reference to IExtenderListService. this.listService = GetService(typeof(IExtenderListService)) as IExtenderListService; // Acquire a reference to IReferenceService. this.referenceService = GetService(typeof(IReferenceService)) as IReferenceService; // Acquire a reference to ITypeResolutionService. this.typeResService = GetService(typeof(ITypeResolutionService)) as ITypeResolutionService; // Acquire a reference to IComponentDiscoveryService. this.componentDiscoveryService = GetService(typeof(IComponentDiscoveryService)) as IComponentDiscoveryService; // Acquire a reference to IToolboxService. this.toolboxService = GetService(typeof(IToolboxService)) as IToolboxService; // Acquire a reference to UndoEngine. this.undoEng = GetService(typeof(UndoEngine)) as UndoEngine; if (this.undoEng != null) { MessageBox.Show("UndoEngine"); } }