Пример #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);
        }
Пример #2
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);
            }
        }