コード例 #1
0
        /// <include file='doc\GroupBoxDesigner.uex' path='docs/doc[@for="GroupBoxDesigner.OnPaintAdornments"]/*' />
        /// <devdoc>
        ///      We override this because even though we still want to
        ///      offset our grid for our display rectangle, we still want
        ///      to align to our parent's grid - so we don't look funny
        /// </devdoc>
        protected override void OnPaintAdornments(PaintEventArgs pe)
        {
            if (DrawGrid)
            {
                Control   control   = (Control)Control;
                Rectangle rectangle = Control.DisplayRectangle;

                rectangle.Width++; // gpr: FillRectangle with a TextureBrush comes up one pixel short
                rectangle.Height++;
                ControlPaint.DrawGrid(pe.Graphics, rectangle, GridSize, control.BackColor);
            }

            // If this control is being inherited, paint it
            //
            if (Inherited)
            {
                if (inheritanceUI == null)
                {
                    inheritanceUI = (InheritanceUI)GetService(typeof(InheritanceUI));
                }

                if (inheritanceUI != null)
                {
                    pe.Graphics.DrawImage(inheritanceUI.InheritanceGlyph, 0, 0);
                }
            }
        }
コード例 #2
0
 protected override void OnPaintAdornments(PaintEventArgs pe)
 {
     if (this.DrawGrid)
     {
         Control   control          = this.Control;
         Rectangle displayRectangle = this.Control.DisplayRectangle;
         displayRectangle.Width++;
         displayRectangle.Height++;
         ControlPaint.DrawGrid(pe.Graphics, displayRectangle, base.GridSize, control.BackColor);
     }
     if (base.Inherited)
     {
         if (this.inheritanceUI == null)
         {
             this.inheritanceUI = (InheritanceUI)this.GetService(typeof(InheritanceUI));
         }
         if (this.inheritanceUI != null)
         {
             pe.Graphics.DrawImage(this.inheritanceUI.InheritanceGlyph, 0, 0);
         }
     }
 }
 protected override void OnPaintAdornments(PaintEventArgs pe)
 {
     if (this.DrawGrid)
     {
         Control control = this.Control;
         Rectangle displayRectangle = this.Control.DisplayRectangle;
         displayRectangle.Width++;
         displayRectangle.Height++;
         ControlPaint.DrawGrid(pe.Graphics, displayRectangle, base.GridSize, control.BackColor);
     }
     if (base.Inherited)
     {
         if (this.inheritanceUI == null)
         {
             this.inheritanceUI = (InheritanceUI) this.GetService(typeof(InheritanceUI));
         }
         if (this.inheritanceUI != null)
         {
             pe.Graphics.DrawImage(this.inheritanceUI.InheritanceGlyph, 0, 0);
         }
     }
 }
コード例 #4
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
         if (host != null)
         {
             ToolStripAdornerWindowService service = (ToolStripAdornerWindowService) this.GetService(typeof(ToolStripAdornerWindowService));
             if (service != null)
             {
                 service.Dispose();
                 host.RemoveService(typeof(ToolStripAdornerWindowService));
             }
             host.Activated -= new EventHandler(this.OnDesignerActivate);
             host.Deactivated -= new EventHandler(this.OnDesignerDeactivate);
             if (this.componentTray != null)
             {
                 ISplitWindowService service2 = (ISplitWindowService) this.GetService(typeof(ISplitWindowService));
                 if (service2 != null)
                 {
                     service2.RemoveSplitWindow(this.componentTray);
                     this.componentTray.Dispose();
                     this.componentTray = null;
                 }
                 host.RemoveService(typeof(ComponentTray));
             }
             IComponentChangeService service3 = (IComponentChangeService) this.GetService(typeof(IComponentChangeService));
             if (service3 != null)
             {
                 service3.ComponentAdded -= new ComponentEventHandler(this.OnComponentAdded);
                 service3.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
                 service3.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
             }
             if (this.undoEngine != null)
             {
                 this.undoEngine.Undoing -= new EventHandler(this.OnUndoing);
                 this.undoEngine.Undone -= new EventHandler(this.OnUndone);
             }
             if (this.toolboxCreator != null)
             {
                 IToolboxService service4 = (IToolboxService) this.GetService(typeof(IToolboxService));
                 if (service4 != null)
                 {
                     service4.RemoveCreator(axClipFormat, host);
                     service4.RemoveCreator(OleDragDropHandler.DataFormat, host);
                     service4.RemoveCreator(OleDragDropHandler.NestedToolboxItemFormat, host);
                 }
                 this.toolboxCreator = null;
             }
         }
         if (this.menuEditorService != null)
         {
             host.RemoveService(typeof(IMenuEditorService));
             this.menuEditorService = null;
         }
         ISelectionService service5 = (ISelectionService) this.GetService(typeof(ISelectionService));
         if (service5 != null)
         {
             service5.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
         }
         if (this.behaviorService != null)
         {
             this.behaviorService.Dispose();
             this.behaviorService = null;
         }
         if (this.selectionManager != null)
         {
             this.selectionManager.Dispose();
             this.selectionManager = null;
         }
         if (this.componentTray != null)
         {
             if (host != null)
             {
                 ISplitWindowService service6 = (ISplitWindowService) this.GetService(typeof(ISplitWindowService));
                 if (service6 != null)
                 {
                     service6.RemoveSplitWindow(this.componentTray);
                 }
             }
             this.componentTray.Dispose();
             this.componentTray = null;
         }
         if (this.pbrsFwd != null)
         {
             this.pbrsFwd.Dispose();
             this.pbrsFwd = null;
         }
         if (this.frame != null)
         {
             this.frame.Dispose();
             this.frame = null;
         }
         if (this.commandSet != null)
         {
             this.commandSet.Dispose();
             this.commandSet = null;
         }
         if (this.inheritanceService != null)
         {
             this.inheritanceService.Dispose();
             this.inheritanceService = null;
         }
         if (this.inheritanceUI != null)
         {
             this.inheritanceUI.Dispose();
             this.inheritanceUI = null;
         }
         if (this.designBindingValueUIHandler != null)
         {
             IPropertyValueUIService service7 = (IPropertyValueUIService) this.GetService(typeof(IPropertyValueUIService));
             if (service7 != null)
             {
                 service7.RemovePropertyValueUIHandler(new PropertyValueUIHandler(this.designBindingValueUIHandler.OnGetUIValueItem));
                 service7 = null;
             }
             this.designBindingValueUIHandler.Dispose();
             this.designBindingValueUIHandler = null;
         }
         if (this.designerExtenders != null)
         {
             this.designerExtenders.Dispose();
             this.designerExtenders = null;
         }
         if (this.axTools != null)
         {
             this.axTools.Clear();
         }
         if (host != null)
         {
             host.RemoveService(typeof(BehaviorService));
             host.RemoveService(typeof(ToolStripAdornerWindowService));
             host.RemoveService(typeof(SelectionManager));
             host.RemoveService(typeof(IInheritanceService));
             host.RemoveService(typeof(IEventHandlerService));
             host.RemoveService(typeof(IOverlayService));
             host.RemoveService(typeof(ISplitWindowService));
             host.RemoveService(typeof(InheritanceUI));
         }
     }
     base.Dispose(disposing);
 }
コード例 #5
0
 public override void Initialize(IComponent component)
 {
     this.initializing = true;
     base.Initialize(component);
     this.initializing = false;
     PropertyDescriptor descriptor = TypeDescriptor.GetProperties(base.Component.GetType())["BackColor"];
     if (((descriptor != null) && (descriptor.PropertyType == typeof(System.Drawing.Color))) && !descriptor.ShouldSerializeValue(base.Component))
     {
         this.Control.BackColor = SystemColors.Control;
     }
     IDesignerHost serviceProvider = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     IExtenderProviderService ex = (IExtenderProviderService) this.GetService(typeof(IExtenderProviderService));
     if (ex != null)
     {
         this.designerExtenders = new DesignerExtenders(ex);
     }
     if (serviceProvider != null)
     {
         serviceProvider.Activated += new EventHandler(this.OnDesignerActivate);
         serviceProvider.Deactivated += new EventHandler(this.OnDesignerDeactivate);
         ServiceCreatorCallback callback = new ServiceCreatorCallback(this.OnCreateService);
         serviceProvider.AddService(typeof(IEventHandlerService), callback);
         this.frame = new DesignerFrame(component.Site);
         IOverlayService frame = this.frame;
         serviceProvider.AddService(typeof(IOverlayService), frame);
         serviceProvider.AddService(typeof(ISplitWindowService), this.frame);
         this.behaviorService = new BehaviorService(base.Component.Site, this.frame);
         serviceProvider.AddService(typeof(BehaviorService), this.behaviorService);
         this.selectionManager = new SelectionManager(serviceProvider, this.behaviorService);
         serviceProvider.AddService(typeof(SelectionManager), this.selectionManager);
         serviceProvider.AddService(typeof(ToolStripAdornerWindowService), callback);
         IComponentChangeService service = (IComponentChangeService) this.GetService(typeof(IComponentChangeService));
         if (service != null)
         {
             service.ComponentAdded += new ComponentEventHandler(this.OnComponentAdded);
             service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
             service.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved);
         }
         this.inheritanceUI = new InheritanceUI();
         serviceProvider.AddService(typeof(InheritanceUI), this.inheritanceUI);
         InheritanceService serviceInstance = new DocumentInheritanceService(this);
         serviceProvider.AddService(typeof(IInheritanceService), serviceInstance);
         manager = serviceProvider.GetService(typeof(IDesignerSerializationManager)) as IDesignerSerializationManager;
         serviceInstance.AddInheritedComponents(component, component.Site.Container);
         manager = null;
         this.inheritanceService = serviceInstance;
         if (this.Control.IsHandleCreated)
         {
             this.OnCreateHandle();
         }
         IPropertyValueUIService service5 = (IPropertyValueUIService) component.Site.GetService(typeof(IPropertyValueUIService));
         if (service5 != null)
         {
             this.designBindingValueUIHandler = new DesignBindingValueUIHandler();
             service5.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.designBindingValueUIHandler.OnGetUIValueItem));
         }
         IToolboxService service6 = (IToolboxService) serviceProvider.GetService(typeof(IToolboxService));
         if (service6 != null)
         {
             this.toolboxCreator = new ToolboxItemCreatorCallback(this.OnCreateToolboxItem);
             service6.AddCreator(this.toolboxCreator, axClipFormat, serviceProvider);
             service6.AddCreator(this.toolboxCreator, OleDragDropHandler.DataFormat, serviceProvider);
             service6.AddCreator(this.toolboxCreator, OleDragDropHandler.NestedToolboxItemFormat, serviceProvider);
         }
         serviceProvider.LoadComplete += new EventHandler(this.OnLoadComplete);
     }
     this.commandSet = new ControlCommandSet(component.Site);
     this.frame.Initialize(this.Control);
     this.pbrsFwd = new PbrsForward(this.frame, component.Site);
     this.Location = new Point(0, 0);
 }
コード例 #6
0
 public override void Initialize(IComponent component)
 {
     PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(component.GetType());
     PropertyDescriptor descriptor = properties["Visible"];
     if (((descriptor == null) || (descriptor.PropertyType != typeof(bool))) || !descriptor.ShouldSerializeValue(component))
     {
         this.Visible = true;
     }
     else
     {
         this.Visible = (bool) descriptor.GetValue(component);
     }
     PropertyDescriptor descriptor2 = properties["Enabled"];
     if (((descriptor2 == null) || (descriptor2.PropertyType != typeof(bool))) || !descriptor2.ShouldSerializeValue(component))
     {
         this.Enabled = true;
     }
     else
     {
         this.Enabled = (bool) descriptor2.GetValue(component);
     }
     this.initializing = true;
     base.Initialize(component);
     this.initializing = false;
     this.host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     DockingAttribute attribute = (DockingAttribute) TypeDescriptor.GetAttributes(base.Component)[typeof(DockingAttribute)];
     if ((attribute != null) && (attribute.DockingBehavior != DockingBehavior.Never))
     {
         this.dockingAction = new DockingActionList(this);
         DesignerActionService service = this.GetService(typeof(DesignerActionService)) as DesignerActionService;
         if (service != null)
         {
             service.Add(base.Component, this.dockingAction);
         }
     }
     this.dataBindingsCollectionChanged = new CollectionChangeEventHandler(this.DataBindingsCollectionChanged);
     this.Control.DataBindings.CollectionChanged += this.dataBindingsCollectionChanged;
     this.Control.ControlAdded += new ControlEventHandler(this.OnControlAdded);
     this.Control.ControlRemoved += new ControlEventHandler(this.OnControlRemoved);
     this.Control.ParentChanged += new EventHandler(this.OnParentChanged);
     this.Control.SizeChanged += new EventHandler(this.OnSizeChanged);
     this.Control.LocationChanged += new EventHandler(this.OnLocationChanged);
     this.DesignerTarget = new DesignerWindowTarget(this);
     if (this.Control.IsHandleCreated)
     {
         this.OnCreateHandle();
     }
     if ((base.Inherited && (this.host != null)) && (this.host.RootComponent != component))
     {
         this.inheritanceUI = (InheritanceUI) this.GetService(typeof(InheritanceUI));
         if (this.inheritanceUI != null)
         {
             this.inheritanceUI.AddInheritedControl(this.Control, this.InheritanceAttribute.InheritanceLevel);
         }
     }
     if (((this.host == null) || (this.host.RootComponent != component)) && this.ForceVisible)
     {
         this.Control.Visible = true;
     }
     this.Control.Enabled = true;
     this.Control.EnabledChanged += new EventHandler(this.OnEnabledChanged);
     this.AllowDrop = this.Control.AllowDrop;
     this.statusCommandUI = new StatusCommandUI(component.Site);
 }