Exemplo n.º 1
0
        public void Load()
        {
            _modified = false;

            // Initialize code provider, loader and surface
            //
            _codeProvider = new CodeProvider(this.FileName, this.CodeBehindFileName);
            _loader       = new CodeProviderDesignerLoader(_codeProvider);
            _surface      = new DesignSurface(_workspace.Services);

            // Initialize and add the services
            //
            IServiceContainer container = (IServiceContainer)_surface.GetService(typeof(IServiceContainer));

            container.AddService(typeof(IEventBindingService), new CodeProviderEventBindingService(_codeProvider,
                                                                                                   (IServiceProvider)container));
            _surface.BeginLoad(_loader);

            // Mark as Modified on ComponentChanged
            //
            IComponentChangeService changeService = (IComponentChangeService)_surface.GetService(typeof(IComponentChangeService));

            changeService.ComponentChanged += delegate {
                _modified = true;
                if (Modified != null)
                {
                    Modified(this, EventArgs.Empty);
                }
            };
            if (Loaded != null)
            {
                Loaded(this, EventArgs.Empty);
            }
        }
Exemplo n.º 2
0
        public bool Load()
        {
            if (_loaded)
            {
                return(true);
            }
            _loaded   = false;
            _modified = false;

            // Initialize code provider, loader and surface
            //

            ITypeResolutionService resolutionSvc = _surface.GetService(typeof(ITypeResolutionService)) as ITypeResolutionService;

            _codeProvider = new CodeProvider(this.FileName, resolutionSvc);
            _loader       = new CodeProviderDesignerLoader(_codeProvider);

            // Initialize and add the services
            //
            IServiceContainer container = (IServiceContainer)_surface.GetService(typeof(IServiceContainer));

            container.AddService(typeof(IEventBindingService),
                                 new CodeProviderEventBindingService(_codeProvider, (IServiceProvider)container));
            _surface.BeginLoad(_loader);
            if (_surface.IsLoaded)
            {
                _loaded = true;
                // Mark as Modified on ComponentChanged
                //
                IComponentChangeService changeService = (IComponentChangeService)_surface.GetService(typeof(IComponentChangeService));
                changeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
                if (Loaded != null)
                {
                    Loaded(this, EventArgs.Empty);
                }
            }

            return(_loaded);
        }
        private void OnDesignSurfaceCreated(DesignSurface surface)
        {
            if (DesignSurfaceCreated != null)
            {
                DesignSurfaceCreated(this, new DesignSurfaceEventArgs(surface));
            }

            // monitor disposing
            surface.Disposed += new EventHandler(OnDesignSurfaceDisposed);

            DesignerEventService eventService = GetService(typeof(IDesignerEventService)) as DesignerEventService;

            if (eventService != null)
            {
                eventService.RaiseDesignerCreated(surface.GetService(typeof(IDesignerHost)) as IDesignerHost);
            }
        }
        private void OnDesignSurfaceDisposed(object sender, EventArgs args)
        {
            DesignSurface surface = (DesignSurface)sender;

            surface.Disposed -= new EventHandler(OnDesignSurfaceDisposed);

            if (DesignSurfaceDisposed != null)
            {
                DesignSurfaceDisposed(this, new DesignSurfaceEventArgs(surface));
            }

            DesignerEventService eventService = GetService(typeof(IDesignerEventService)) as DesignerEventService;

            if (eventService != null)
            {
                eventService.RaiseDesignerDisposed(surface.GetService(typeof(IDesignerHost)) as IDesignerHost);
            }
        }
Exemplo n.º 5
0
		public void Load ()
		{
			_modified = false;

			// Initialize code provider, loader and surface
			//
			_codeProvider = new CodeProvider (this.FileName, this.CodeBehindFileName);
			_loader = new CodeProviderDesignerLoader (_codeProvider);
			_surface = new DesignSurface (_workspace.Services);

			// Initialize and add the services
			//
			IServiceContainer container = (IServiceContainer)_surface.GetService (typeof (IServiceContainer));
			container.AddService (typeof (IEventBindingService),new CodeProviderEventBindingService (_codeProvider, 
																									 (IServiceProvider) container));
			_surface.BeginLoad (_loader);

			// Mark as Modified on ComponentChanged
			//
			IComponentChangeService changeService = (IComponentChangeService)_surface.GetService (typeof (IComponentChangeService));
			changeService.ComponentChanged += delegate {
				_modified = true;
				if (Modified != null)
					Modified (this, EventArgs.Empty);
			};
			if (Loaded != null)
				Loaded (this, EventArgs.Empty);
		}