Beispiel #1
0
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);
            this.inheritanceService = new InheritanceService();
            ISite                    provider  = component.Site;
            IContainer               container = null;
            IDesignerHost            host      = (IDesignerHost)this.GetService(typeof(IDesignerHost));
            IExtenderProviderService ex        = (IExtenderProviderService)this.GetService(typeof(IExtenderProviderService));

            if (ex != null)
            {
                this.designerExtenders = new DesignerExtenders(ex);
            }
            if (host != null)
            {
                this.eventHandlerService = new EventHandlerService(null);
                this.selectionUIService  = new SelectionUIService(host);
                host.AddService(typeof(IInheritanceService), this.inheritanceService);
                host.AddService(typeof(IEventHandlerService), this.eventHandlerService);
                host.AddService(typeof(ISelectionUIService), this.selectionUIService);
                this.compositionUI = new CompositionUI(this, provider);
                host.AddService(typeof(ComponentTray), this.compositionUI);
                IComponentChangeService service2 = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));
                if (service2 != null)
                {
                    service2.ComponentAdded   += new ComponentEventHandler(this.OnComponentAdded);
                    service2.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved);
                }
                ISelectionService service3 = (ISelectionService)this.GetService(typeof(ISelectionService));
                if (service3 != null)
                {
                    service3.SetSelectedComponents(new object[] { component }, SelectionTypes.Auto);
                }
            }
            if (provider != null)
            {
                this.commandSet = new CompositionCommandSet(this.compositionUI, provider);
                container       = provider.Container;
            }
            this.pbrsFwd = new PbrsForward(this.compositionUI, provider);
            this.inheritanceService.AddInheritedComponents(component, container);
            IServiceContainer service = (IServiceContainer)this.GetService(typeof(IServiceContainer));

            if (service != null)
            {
                this.delegateFilterService = (ITypeDescriptorFilterService)this.GetService(typeof(ITypeDescriptorFilterService));
                if (this.delegateFilterService != null)
                {
                    service.RemoveService(typeof(ITypeDescriptorFilterService));
                }
                service.AddService(typeof(ITypeDescriptorFilterService), this);
            }
        }
Beispiel #2
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));
         if (host != null)
         {
             host.RemoveService(typeof(IInheritanceService));
             host.RemoveService(typeof(IEventHandlerService));
             host.RemoveService(typeof(ISelectionUIService));
             host.RemoveService(typeof(ComponentTray));
             IComponentChangeService service = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));
             if (service != null)
             {
                 service.ComponentAdded   -= new ComponentEventHandler(this.OnComponentAdded);
                 service.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
             }
         }
         if (this.selectionUIService != null)
         {
             this.selectionUIService.Dispose();
             this.selectionUIService = null;
         }
         if (this.commandSet != null)
         {
             this.commandSet.Dispose();
             this.commandSet = null;
         }
         if (this.pbrsFwd != null)
         {
             this.pbrsFwd.Dispose();
             this.pbrsFwd = null;
         }
         if (this.compositionUI != null)
         {
             this.compositionUI.Dispose();
             this.compositionUI = null;
         }
         if (this.designerExtenders != null)
         {
             this.designerExtenders.Dispose();
             this.designerExtenders = null;
         }
         if (this.inheritanceService != null)
         {
             this.inheritanceService.Dispose();
             this.inheritanceService = null;
         }
     }
     base.Dispose(disposing);
 }
        /// <include file='doc\SelectionUIHandler.uex' path='docs/doc[@for="SelectionUIHandler.DragMoved"]/*' />
        /// <devdoc>
        ///     Called when the user has moved the mouse.  This will only be called on
        ///     the designer that returned true from beginDrag.  The designer
        ///     should update its UI feedback here.
        /// </devdoc>
        public virtual void DragMoved(object[] components, Rectangle offset)
        {
            dragOffset = offset;

            // Since we do full drag, begin a batch operation now so that
            // we don't fire ten thousand change events.  We also
            // call ComponentChanging so that any srcsafe stuff
            // can happen.
            //
            if (originalCoords == null && components.Length > 0)
            {
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
                Debug.Assert(host != null, "We really need a designer host here.");

                moveTrans = host.CreateTransaction(SelectionUIService.GetTransactionName(rules, components));
            }

            MoveControls(components, false, false);
            Debug.Assert(originalCoords != null, "We are keying off of originalCoords, but MoveControls didn't set it");
        }
Beispiel #4
0
        /// <include file='doc\CompositionDesigner.uex' path='docs/doc[@for="ComponentDocumentDesigner.Dispose"]/*' />
        /// <devdoc>
        ///    <para>Disposes of the resources (other than memory) used by
        ///       the <see cref='System.Windows.Forms.Design.ComponentDocumentDesigner'/>.</para>
        /// </devdoc>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
                Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found");

                if (host != null)
                {
                    host.RemoveService(typeof(IInheritanceService));
                    host.RemoveService(typeof(IEventHandlerService));
                    host.RemoveService(typeof(ISelectionUIService));
                    host.RemoveService(typeof(ComponentTray));

                    IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService));
                    Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || cs != null, "IComponentChangeService not found");
                    if (cs != null)
                    {
                        cs.ComponentAdded   -= new ComponentEventHandler(OnComponentAdded);
                        cs.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved);
                    }
                }

                if (selectionUIService != null)
                {
                    selectionUIService.Dispose();
                    selectionUIService = null;
                }

                if (commandSet != null)
                {
                    commandSet.Dispose();
                    commandSet = null;
                }

                if (this.pbrsFwd != null)
                {
                    pbrsFwd.Dispose();
                    pbrsFwd = null;
                }

                if (compositionUI != null)
                {
                    compositionUI.Dispose();
                    compositionUI = null;
                }

                if (designerExtenders != null)
                {
                    designerExtenders.Dispose();
                    designerExtenders = null;
                }

                if (inheritanceService != null)
                {
                    inheritanceService.Dispose();
                    inheritanceService = null;
                }
            }
            base.Dispose(disposing);
        }
Beispiel #5
0
        /// <include file='doc\CompositionDesigner.uex' path='docs/doc[@for="ComponentDocumentDesigner.Initialize"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Initializes the designer with the specified component.</para>
        /// </devdoc>
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);

            inheritanceService = new InheritanceService();

            ISite      site      = component.Site;
            IContainer container = null;

            IDesignerHost            host = (IDesignerHost)GetService(typeof(IDesignerHost));
            IExtenderProviderService exps = (IExtenderProviderService)GetService(typeof(IExtenderProviderService));

            if (exps != null)
            {
                designerExtenders = new DesignerExtenders(exps);
            }

            Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found");
            if (host != null)
            {
                eventHandlerService = new EventHandlerService(null);
                selectionUIService  = new SelectionUIService(host);

                host.AddService(typeof(IInheritanceService), inheritanceService);
                host.AddService(typeof(IEventHandlerService), eventHandlerService);
                host.AddService(typeof(ISelectionUIService), selectionUIService);

                compositionUI = new CompositionUI(this, site);

                host.AddService(typeof(ComponentTray), compositionUI);

                IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService));
                Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || cs != null, "IComponentChangeService not found");
                if (cs != null)
                {
                    cs.ComponentAdded   += new ComponentEventHandler(OnComponentAdded);
                    cs.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved);
                }

                // Select this component.
                //
                ISelectionService ss = (ISelectionService)GetService(typeof(ISelectionService));
                if (ss != null)
                {
                    ss.SetSelectedComponents(new object[] { component }, SelectionTypes.Normal);
                }
            }

            // Set up our menu command set
            //
            if (site != null)
            {
                commandSet = new CompositionCommandSet(compositionUI, site);
                container  = site.Container;
            }

            this.pbrsFwd = new PbrsForward(compositionUI, site);

            // Hook up our inheritance service and do a scan for inherited components.
            //
            inheritanceService.AddInheritedComponents(component, container);

            // Hook yourself up to the ITypeDescriptorFilterService so we can hide the
            // location property on all components being added to the designer.
            //
            IServiceContainer serviceContainer = (IServiceContainer)GetService(typeof(IServiceContainer));

            if (serviceContainer != null)
            {
                delegateFilterService = (ITypeDescriptorFilterService)GetService(typeof(ITypeDescriptorFilterService));
                if (delegateFilterService != null)
                {
                    serviceContainer.RemoveService(typeof(ITypeDescriptorFilterService));
                }

                serviceContainer.AddService(typeof(ITypeDescriptorFilterService), this);
            }
        }
 public SelectionUIItem(SelectionUIService selUIsvc, object component)
 {
     this.selUIsvc = selUIsvc;
     this.component = component;
     this.selectionStyle = SelectionStyles.Selected;
     this.handler = selUIsvc.GetHandler(component);
     this.sizes = inactiveSizeArray;
     this.cursors = inactiveCursorArray;
     IComponent component2 = component as IComponent;
     if (component2 != null)
     {
         ControlDesigner designer = selUIsvc.host.GetDesigner(component2) as ControlDesigner;
         if (designer != null)
         {
             this.control = designer.Control;
         }
     }
     this.UpdateRules();
     this.UpdateGrabSettings();
     this.UpdateSize();
 }
 public HitTestInfo(int hitTest, SelectionUIService.SelectionUIItem selectionUIHit, bool containerSelector)
 {
     this.hitTest = hitTest;
     this.selectionUIHit = selectionUIHit;
     this.containerSelector = containerSelector;
 }
 public HitTestInfo(int hitTest, SelectionUIService.SelectionUIItem selectionUIHit)
 {
     this.hitTest = hitTest;
     this.selectionUIHit = selectionUIHit;
     this.containerSelector = false;
 }
 public ContainerSelectionUIItem(SelectionUIService selUIsvc, object component) : base(selUIsvc, component)
 {
 }