protected virtual void Initialize()
        {
            _serializationMananger = new DesignerSerializationManager(_host);

            DesignSurfaceServiceContainer serviceContainer = _host.GetService(typeof(IServiceContainer)) as DesignSurfaceServiceContainer;

            if (serviceContainer != null)
            {
                serviceContainer.AddService(typeof(IDesignerLoaderService), (IDesignerLoaderService)this);
                serviceContainer.AddNonReplaceableService(typeof(IDesignerSerializationManager), _serializationMananger);
            }
        }
Ejemplo n.º 2
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);
			UISelectionService selection = new UISelectionService ((IServiceProvider) _serviceContainer);
			_serviceContainer.AddService (typeof (ISelectionService), (ISelectionService) selection);
			_serviceContainer.AddService (typeof (IUISelectionService), (IUISelectionService)selection);
			_serviceContainer.AddService (typeof (DesignSurface), this);
		}
Ejemplo n.º 3
0
		protected void Dispose (bool disposing)
		{
			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);
		}
Ejemplo n.º 4
0
        public override void BeginLoad(IDesignerLoaderHost host)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (this._state[StateLoaded])
            {
                Exception exception = new InvalidOperationException(System.Design.SR.GetString("BasicDesignerLoaderAlreadyLoaded"))
                {
                    HelpLink = "BasicDesignerLoaderAlreadyLoaded"
                };
                throw exception;
            }
            if ((this._host != null) && (this._host != host))
            {
                Exception exception2 = new InvalidOperationException(System.Design.SR.GetString("BasicDesignerLoaderDifferentHost"))
                {
                    HelpLink = "BasicDesignerLoaderDifferentHost"
                };
                throw exception2;
            }
            this._state[StateLoaded | StateLoadFailed] = false;
            this._loadDependencyCount = 0;
            if (this._host == null)
            {
                this._host                 = host;
                this._hostInitialized      = true;
                this._serializationManager = new DesignerSerializationManager(this._host);
                DesignSurfaceServiceContainer container = this.GetService(typeof(DesignSurfaceServiceContainer)) as DesignSurfaceServiceContainer;
                if (container != null)
                {
                    container.AddFixedService(typeof(IDesignerSerializationManager), this._serializationManager);
                }
                else
                {
                    IServiceContainer container2 = this.GetService(typeof(IServiceContainer)) as IServiceContainer;
                    if (container2 == null)
                    {
                        this.ThrowMissingService(typeof(IServiceContainer));
                    }
                    container2.AddService(typeof(IDesignerSerializationManager), this._serializationManager);
                }
                this.Initialize();
                host.Activated   += new EventHandler(this.OnDesignerActivate);
                host.Deactivated += new EventHandler(this.OnDesignerDeactivate);
            }
            bool      successful           = true;
            ArrayList errorCollection      = null;
            IDesignerLoaderService service = this.GetService(typeof(IDesignerLoaderService)) as IDesignerLoaderService;

            try
            {
                if (service != null)
                {
                    service.AddLoadDependency();
                }
                else
                {
                    this._loading = true;
                    this.OnBeginLoad();
                }
                this.PerformLoad(this._serializationManager);
            }
            catch (Exception innerException)
            {
                while (innerException is TargetInvocationException)
                {
                    innerException = innerException.InnerException;
                }
                errorCollection = new ArrayList();
                errorCollection.Add(innerException);
                successful = false;
            }
            if (service != null)
            {
                service.DependentLoadComplete(successful, errorCollection);
            }
            else
            {
                this.OnEndLoad(successful, errorCollection);
                this._loading = false;
            }
        }