Esempio n. 1
0
        // this ctor doesn't load the surface
        //
        public DesignSurface(IServiceProvider parentProvider)
        {
            _serviceContainer = new DesignSurfaceServiceContainer(parentProvider);
            _serviceContainer.AddNonReplaceableService(typeof(IServiceContainer), _serviceContainer);

            _designerHost = new DesignerHost((IServiceProvider)_serviceContainer);
            _designerHost.DesignerLoaderHostLoaded    += new LoadedEventHandler(OnDesignerHost_Loaded);
            _designerHost.DesignerLoaderHostLoading   += new EventHandler(OnDesignerHost_Loading);
            _designerHost.DesignerLoaderHostUnloading += new EventHandler(OnDesignerHost_Unloading);
            _designerHost.DesignerLoaderHostUnloaded  += new EventHandler(OnDesignerHost_Unloaded);

            _designerHost.Activated += new EventHandler(OnDesignerHost_Activated);

            _serviceContainer.AddNonReplaceableService(typeof(IComponentChangeService), _designerHost);
            _serviceContainer.AddNonReplaceableService(typeof(IDesignerHost), _designerHost);
            _serviceContainer.AddNonReplaceableService(typeof(IContainer), _designerHost);
            _serviceContainer.AddService(typeof(ITypeDescriptorFilterService),
                                         (ITypeDescriptorFilterService) new TypeDescriptorFilterService(_serviceContainer));

            ExtenderService extenderService = new ExtenderService();

            _serviceContainer.AddService(typeof(IExtenderProviderService), (IExtenderProviderService)extenderService);
            _serviceContainer.AddService(typeof(IExtenderListService), (IExtenderListService)extenderService);
            _serviceContainer.AddService(typeof(DesignSurface), this);

            SelectionService selectionService = new SelectionService(_serviceContainer);

            _serviceContainer.AddService(typeof(ISelectionService), (ISelectionService)selectionService);
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.Disposed != null)
         {
             this.Disposed(this, EventArgs.Empty);
         }
         try
         {
             try
             {
                 if (this._host != null)
                 {
                     this._host.DisposeHost();
                 }
             }
             finally
             {
                 if (this._serviceContainer != null)
                 {
                     this._serviceContainer.RemoveService(typeof(DesignSurface));
                     this._serviceContainer.Dispose();
                 }
             }
         }
         finally
         {
             this._host             = null;
             this._serviceContainer = null;
         }
     }
 }
Esempio n. 3
0
        protected virtual void Dispose(bool disposing)
        {
            if (_designerLoader != null)
            {
                _designerLoader.Dispose();
                _designerLoader = null;
            }
            if (_designerHost != null)
            {
                _designerHost.Dispose();
                _designerHost.DesignerLoaderHostLoaded    -= new LoadedEventHandler(OnDesignerHost_Loaded);
                _designerHost.DesignerLoaderHostLoading   -= new EventHandler(OnDesignerHost_Loading);
                _designerHost.DesignerLoaderHostUnloading -= new EventHandler(OnDesignerHost_Unloading);
                _designerHost.DesignerLoaderHostUnloaded  -= new EventHandler(OnDesignerHost_Unloaded);
                _designerHost.Activated -= new EventHandler(OnDesignerHost_Activated);
                _designerHost            = null;
            }
            if (_serviceContainer != null)
            {
                _serviceContainer.Dispose();
                _serviceContainer = null;
            }

            if (Disposed != null)
            {
                Disposed(this, EventArgs.Empty);
            }
        }
Esempio n. 4
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // technically we should raise this after we've destroyed ourselves.  Unfortunately, too many things query us for services so they can detatch.
                Disposed?.Invoke(this, EventArgs.Empty);

                // Destroying the host also destroys all components. In most cases destroying the root component will destroy its designer which also kills the view. So, we destroy the view below last (remember, this view is a "view container" so we are destroying the innermost view first and then destroying our own view).
                try
                {
                    try
                    {
                        if (_host != null)
                        {
                            _host.DisposeHost();
                        }
                    }
                    finally
                    {
                        if (_serviceContainer != null)
                        {
                            _serviceContainer.RemoveService(typeof(DesignSurface));
                            _serviceContainer.Dispose();
                        }
                    }
                }
                finally
                {
                    _host             = null;
                    _serviceContainer = null;
                }
            }
        }
Esempio n. 5
0
 public override void Add(IComponent component, string name)
 {
     if (this.Owner.Site != null)
     {
         DesignerHost host = this.Owner.Site.GetService(typeof(IDesignerHost)) as DesignerHost;
         if (host != null)
         {
             host.AddPreProcess(component, name);
             base.Add(component, name);
             host.AddPostProcess(component, name);
         }
     }
 }
Esempio n. 6
0
 public override void Remove(IComponent component)
 {
     if (this.Owner.Site != null)
     {
         DesignerHost host = this.Owner.Site.GetService(typeof(IDesignerHost)) as DesignerHost;
         if (host != null)
         {
             host.RemovePreProcess(component);
             base.Remove(component);
             host.RemovePostProcess(component);
         }
     }
 }
 public DesignSurface(IServiceProvider parentProvider)
 {
     this._parentProvider = parentProvider;
     this._serviceContainer = new DesignSurfaceServiceContainer(this._parentProvider);
     ServiceCreatorCallback callback = new ServiceCreatorCallback(this.OnCreateService);
     this.ServiceContainer.AddService(typeof(ISelectionService), callback);
     this.ServiceContainer.AddService(typeof(IExtenderProviderService), callback);
     this.ServiceContainer.AddService(typeof(IExtenderListService), callback);
     this.ServiceContainer.AddService(typeof(ITypeDescriptorFilterService), callback);
     this.ServiceContainer.AddService(typeof(IReferenceService), callback);
     this.ServiceContainer.AddService(typeof(DesignSurface), this);
     this._host = new DesignerHost(this);
 }
        public DesignSurface(IServiceProvider parentProvider)
        {
            this._parentProvider   = parentProvider;
            this._serviceContainer = new DesignSurfaceServiceContainer(this._parentProvider);
            ServiceCreatorCallback callback = new ServiceCreatorCallback(this.OnCreateService);

            this.ServiceContainer.AddService(typeof(ISelectionService), callback);
            this.ServiceContainer.AddService(typeof(IExtenderProviderService), callback);
            this.ServiceContainer.AddService(typeof(IExtenderListService), callback);
            this.ServiceContainer.AddService(typeof(ITypeDescriptorFilterService), callback);
            this.ServiceContainer.AddService(typeof(IReferenceService), callback);
            this.ServiceContainer.AddService(typeof(DesignSurface), this);
            this._host = new DesignerHost(this);
        }
Esempio n. 9
0
        /// <summary>
        /// Creates a new DesignSurface given a parent service provider.
        /// </summary>
        /// <param name="parentProvider"> The parent service provider. If there is no parent used to resolve services this can be null. </param>
        public DesignSurface(IServiceProvider parentProvider)
        {
            _parentProvider = parentProvider;
            _serviceContainer = new DesignSurfaceServiceContainer(_parentProvider);

            // Configure our default services
            ServiceCreatorCallback callback = new ServiceCreatorCallback(OnCreateService);
            ServiceContainer.AddService(typeof(ISelectionService), callback);
            ServiceContainer.AddService(typeof(IExtenderProviderService), callback);
            ServiceContainer.AddService(typeof(IExtenderListService), callback);
            ServiceContainer.AddService(typeof(ITypeDescriptorFilterService), callback);
            ServiceContainer.AddService(typeof(IReferenceService), callback);

            ServiceContainer.AddService(typeof(DesignSurface), this);
            _host = new DesignerHost(this);
        }
Esempio n. 10
0
			public DesignerHostTransaction (DesignerHost host, string description) : base (description)
			{
				_designerHost = host;
			}
 protected override void OnCommit()
 {
     if (this._host != null)
     {
         if (this._host._transactions.Peek() != this)
         {
             string description = ((DesignerTransaction) this._host._transactions.Peek()).Description;
             throw new InvalidOperationException(System.Design.SR.GetString("DesignerHostNestedTransaction", new object[] { base.Description, description }));
         }
         this._host.IsClosingTransaction = true;
         try
         {
             this._host._transactions.Pop();
             DesignerTransactionCloseEventArgs e = new DesignerTransactionCloseEventArgs(true, this._host._transactions.Count == 0);
             this._host.OnTransactionClosing(e);
             this._host.OnTransactionClosed(e);
         }
         finally
         {
             this._host.IsClosingTransaction = false;
             this._host = null;
         }
     }
 }
 internal Site(IComponent component, DesignerHost host, string name, Container container)
 {
     this._component = component;
     this._host = host;
     this._name = name;
     this._container = container;
 }
 public DesignerHostTransaction(DesignerHost host, string description) : base(description)
 {
     this._host = host;
     if (this._host._transactions == null)
     {
         this._host._transactions = new Stack();
     }
     this._host._transactions.Push(this);
     this._host.OnTransactionOpening(EventArgs.Empty);
     this._host.OnTransactionOpened(EventArgs.Empty);
 }
Esempio n. 14
0
		protected virtual void Dispose (bool disposing)
		{
			if (_designerLoader != null) {
				_designerLoader.Dispose ();
				_designerLoader = null;
			}
			if (_designerHost != null) {
				_designerHost.Dispose ();
				_designerHost.DesignerLoaderHostLoaded -= new LoadedEventHandler (OnDesignerHost_Loaded);
				_designerHost.DesignerLoaderHostLoading -= new EventHandler (OnDesignerHost_Loading);
				_designerHost.DesignerLoaderHostUnloading -= new EventHandler (OnDesignerHost_Unloading);
				_designerHost.DesignerLoaderHostUnloaded -= new EventHandler (OnDesignerHost_Unloaded);
				_designerHost.Activated -= new EventHandler (OnDesignerHost_Activated);
				_designerHost = null;	
			}
			if (_serviceContainer != null) {
				_serviceContainer.Dispose ();
				_serviceContainer = null;
			}
			
			if (Disposed != null)
				Disposed (this, EventArgs.Empty);
		}
 public DesignerHostTransaction(DesignerHost host, string description) : base(description)
 {
     _designerHost = host;
 }
Esempio n. 16
0
 internal NestedSite(IComponent component, DesignerHost host, string name, Container container) : base(component, host, name, container)
 {
     _container = container as SiteNestedContainer;
     _name      = name;
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.Disposed != null)
         {
             this.Disposed(this, EventArgs.Empty);
         }
         try
         {
             try
             {
                 if (this._host != null)
                 {
                     this._host.DisposeHost();
                 }
             }
             finally
             {
                 if (this._serviceContainer != null)
                 {
                     this._serviceContainer.RemoveService(typeof(DesignSurface));
                     this._serviceContainer.Dispose();
                 }
             }
         }
         finally
         {
             this._host = null;
             this._serviceContainer = null;
         }
     }
 }
Esempio n. 18
0
 internal SiteNestedContainer(IComponent owner, string containerName, DesignerHost host) : base(owner)
 {
     _containerName   = containerName;
     _host            = host;
     _safeToCallOwner = true;
 }
 internal NestedSite(IComponent component, DesignerHost host, string name, Container container) : base(component, host, name, container)
 {
     this._container = container as SiteNestedContainer;
     this._name = name;
 }
 internal SiteNestedContainer(IComponent owner, string containerName, DesignerHost host) : base(owner)
 {
     this._containerName = containerName;
     this._host = host;
     this._safeToCallOwner = true;
 }
Esempio n. 21
0
		// this ctor doesn't load the surface
		//
		public DesignSurface (IServiceProvider parentProvider)
		{
			
			_serviceContainer = new DesignSurfaceServiceContainer (parentProvider);
			_serviceContainer.AddNonReplaceableService (typeof (IServiceContainer), _serviceContainer);

			_designerHost = new DesignerHost ((IServiceProvider) _serviceContainer);
			_designerHost.DesignerLoaderHostLoaded += new LoadedEventHandler (OnDesignerHost_Loaded);
			_designerHost.DesignerLoaderHostLoading += new EventHandler (OnDesignerHost_Loading);
			_designerHost.DesignerLoaderHostUnloading += new EventHandler (OnDesignerHost_Unloading);
			_designerHost.DesignerLoaderHostUnloaded += new EventHandler (OnDesignerHost_Unloaded);

			_designerHost.Activated += new EventHandler (OnDesignerHost_Activated);

			_serviceContainer.AddNonReplaceableService (typeof (IComponentChangeService), _designerHost);
			_serviceContainer.AddNonReplaceableService (typeof (IDesignerHost), _designerHost);
			_serviceContainer.AddNonReplaceableService (typeof (IContainer), _designerHost);
			_serviceContainer.AddService (typeof (ITypeDescriptorFilterService),
							  (ITypeDescriptorFilterService) new TypeDescriptorFilterService (_serviceContainer));

			ExtenderService extenderService = new ExtenderService ();
			_serviceContainer.AddService (typeof (IExtenderProviderService), (IExtenderProviderService) extenderService);
			_serviceContainer.AddService (typeof (IExtenderListService), (IExtenderListService) extenderService);
			_serviceContainer.AddService (typeof (DesignSurface), this);

			SelectionService selectionService = new SelectionService (_serviceContainer);
			_serviceContainer.AddService (typeof (ISelectionService), (ISelectionService) selectionService);
		}