Ejemplo n.º 1
0
        // this ctor doesn't load the surface
        //
        public DesignSurface(IServiceProvider parentProvider)
        {
            _serviceContainer = new DesignSurfaceServiceContainer(parentProvider);
            _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.AddNonReplaceableService(typeof(IServiceContainer), _serviceContainer);
            _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.º 2
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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }