Beispiel #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);
            }
        }
Beispiel #2
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);
		}
 public CodeProviderEventBindingService(CodeProvider codeProvider, IServiceProvider provider)
     : base(provider)
 {
     if (codeProvider == null)
         throw new ArgumentNullException ("codeProvider");
     _codeProvider = codeProvider;
 }
Beispiel #4
0
 public CodeProviderDesignerLoader(CodeProvider provider)
 {
     if (provider == null)
     {
         throw new ArgumentNullException("provider");
     }
     _provider = provider;
 }
 public CodeProviderEventBindingService(CodeProvider codeProvider, IServiceProvider provider) : base(provider)
 {
     if (codeProvider == null)
     {
         throw new ArgumentNullException("codeProvider");
     }
     _codeProvider = codeProvider;
 }
Beispiel #6
0
 public void Dispose()
 {
     if (_surface.IsLoaded)
     {
         IComponentChangeService changeService = (IComponentChangeService)_surface.GetService(typeof(IComponentChangeService));
         changeService.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged);
         _surface.Dispose();
         _codeProvider = null;
     }
 }
Beispiel #7
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewFileDialog dialog = new NewFileDialog(TemplateManager.AvailableTemplates);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                TemplateManager.WriteCode(dialog.Template, dialog.File, CodeProvider.GetCodeBehindFileName(dialog.File),
                                          dialog.Namespace, dialog.Class);
                this.LoadDocument(dialog.File, _workspace);
            }
        }
Beispiel #8
0
 private void LoadFile(string f)
 {
     System.Console.WriteLine("LoadFile: {0}", f);
     if (surfaceTabs.TabPages.ContainsKey(f))               // tab page for file already existing
     {
         surfaceTabs.SelectedTab = surfaceTabs.TabPages[f];
     }
     else
     {
         if (CodeProvider.IsValidFile(f))
         {
             LoadDocument(f, _workspace);
         }
         else
         {
             MessageBox.Show("No corresponding .Designer file found for " + f);
         }
     }
 }
Beispiel #9
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);
        }
 public CodeProviderDesignerLoader(CodeProvider provider)
 {
     if (provider == null)
         throw new ArgumentNullException ("provider");
     _provider = provider;
 }
Beispiel #11
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;
        }
Beispiel #12
0
 public void Dispose()
 {
     if (_surface.IsLoaded) {
         IComponentChangeService changeService = (IComponentChangeService)_surface.GetService (typeof (IComponentChangeService));
         changeService.ComponentChanged -= new ComponentChangedEventHandler (OnComponentChanged);
         _surface.Dispose ();
         _codeProvider = null;
     }
 }
Beispiel #13
0
 public CodeProviderDesignerLoader(CodeProvider provider)
 {
     _provider = provider ?? throw new ArgumentNullException(nameof(provider));
 }