Example #1
0
 private void OnIdle(object sender, EventArgs e)
 {
     Application.Idle -= new EventHandler(this.OnIdle);
     if (this._state[StateReloadAtIdle])
     {
         this._state[StateReloadAtIdle] = false;
         DesignSurfaceManager service = (DesignSurfaceManager)this.GetService(typeof(DesignSurfaceManager));
         DesignSurface        objB    = (DesignSurface)this.GetService(typeof(DesignSurface));
         if (((service != null) && (objB != null)) && !object.ReferenceEquals(service.ActiveDesignSurface, objB))
         {
             this._state[StateActiveDocument] = false;
             this._state[StateDeferredReload] = true;
         }
         else
         {
             IDesignerLoaderHost loaderHost = this.LoaderHost;
             if ((loaderHost != null) && (this._state[StateForceReload] || this.IsReloadNeeded()))
             {
                 try
                 {
                     if (this._state[StateFlushReload])
                     {
                         this.Flush();
                     }
                     this.UnloadDocument();
                     loaderHost.Reload();
                 }
                 finally
                 {
                     this._state[(StateForceReload | StateModifyIfErrors) | StateFlushReload] = false;
                 }
             }
         }
     }
 }
Example #2
0
        /// <summary>
        /// Initialize the workflow designer loader
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            //add any necessary services
            IDesignerLoaderHost host = LoaderHost;

            if (host != null)
            {
                //add the custom MenuCommandService
                host.AddService(
                    typeof(IMenuCommandService),
                    new WorkflowMenuService(host));

                //add the TypeProvider
                host.AddService(
                    typeof(ITypeProvider), _typeProvider, true);

                //add the toolbox service
                _toolboxService = new WorkflowToolboxService(host);
                host.AddService(
                    typeof(IToolboxService), _toolboxService);

                //add the property value UI service
                host.AddService(
                    typeof(IPropertyValueUIService),
                    new WorkflowPropertyValueService());

                //add the event binding service
                host.AddService(
                    typeof(IEventBindingService),
                    new WorkflowEventBindingService(host));
            }
        }
Example #3
0
        public override void Dispose()
        {
            if (this._state[StateReloadAtIdle])
            {
                Application.Idle -= new EventHandler(this.OnIdle);
            }
            this.UnloadDocument();
            IComponentChangeService service = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));

            if (service != null)
            {
                service.ComponentAdded    -= new ComponentEventHandler(this.OnComponentAdded);
                service.ComponentAdding   -= new ComponentEventHandler(this.OnComponentAdding);
                service.ComponentRemoving -= new ComponentEventHandler(this.OnComponentRemoving);
                service.ComponentRemoved  -= new ComponentEventHandler(this.OnComponentRemoved);
                service.ComponentChanged  -= new ComponentChangedEventHandler(this.OnComponentChanged);
                service.ComponentChanging -= new ComponentChangingEventHandler(this.OnComponentChanging);
                service.ComponentRename   -= new ComponentRenameEventHandler(this.OnComponentRename);
            }
            if (this._host != null)
            {
                this._host.RemoveService(typeof(IDesignerLoaderService));
                this._host.Activated   -= new EventHandler(this.OnDesignerActivate);
                this._host.Deactivated -= new EventHandler(this.OnDesignerDeactivate);
                this._host              = null;
            }
        }
 public override void BeginLoad(IDesignerLoaderHost host)
 {
     string baseClassName;
     if (host == null)
     {
         throw new ArgumentNullException("SampleDesignerLoader.BeginLoad: Invalid designerLoaderHost.");
     }
     this.host = host;
     ArrayList errors = new ArrayList();
     bool successful = true;
     host.AddService(typeof(IDesignerSerializationManager), new SampleDesignerSerializationManager(this));
     host.AddService(typeof(IEventBindingService), new SampleEventBindingService(host));
     host.AddService(typeof(ITypeResolutionService), new SampleTypeResolutionService());
     host.AddService(typeof(CodeDomProvider), new CSharpCodeProvider());
     host.AddService(typeof(IResourceService), new SampleResourceService(host));
     if (this.fileName == null)
     {
         baseClassName = host.CreateComponent(typeof(Form)).Site.Name;
     }
     else
     {
         baseClassName = this.ReadFile(this.fileName, errors, out this.xmlDocument);
     }
     IComponentChangeService cs = host.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
     if (cs != null)
     {
         cs.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
         cs.ComponentAdded += new ComponentEventHandler(this.OnComponentAddedRemoved);
         cs.ComponentRemoved += new ComponentEventHandler(this.OnComponentAddedRemoved);
     }
     host.EndLoad(baseClassName, successful, errors);
     this.dirty = true;
     this.unsaved = false;
 }
Example #5
0
        /// <summary>
        /// 载入页面的时候调用,负责从xml文件读取信息
        /// 调用函数ReadFile进行描述文件节点的具体信息处理,根据读取的信息进行设计器的加载。
        /// </summary>
        /// <param name="document">需要加载的xml文件</param>
        /// <returns></returns>
        public bool MyPerformLoad(XmlDocument document)
        {
            ArrayList errors        = new ArrayList();
            bool      successful    = true; //标志加载过程是否成功
            string    baseClassName = null;

            this.hostLoader = this.LoaderHost;  //获取加载程序宿主。(从 BasicDesignerLoader 继承。)

            if (hostLoader == null)
            {
                //CassMessageBox.Warning("设计器加载异常!");
                return(false);
            }

            //存放错误信息,如果加载期间遇到错误,则必须将这些错误作为异常集合传递到 errorCollection 参数中。
            baseClassName = ReadFile(document, errors);

            if (baseClassName == null)
            {
                return(false);
            }

            if (errors.Count > 0)
            {
                successful = false;
            }

            // 结束设计器加载操作。
            //baseClassName 此设计器正在设计的文档的基类的完全限定名。
            //successful 如果设计器已成功加载,则为 true;否则为 false。
            //errorCollection 包含加载期间遇到的错误(如果有的话)的集合。
            hostLoader.EndLoad(baseClassName, successful, errors);
            return(successful);
        }
 public WorkflowDesignerEventsCoordinator(IDesignerLoaderHost serviceProvider)
 {
     this.serviceProvider = serviceProvider;
     this.serviceProvider.LoadComplete += new EventHandler(this.OnDesignerReloaded);
     IDesignerEventService service = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService;
     if (service != null)
     {
         service.ActiveDesignerChanged += new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
     }
     ITypeProvider provider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;
     if (provider != null)
     {
         provider.TypesChanged += new EventHandler(this.OnTypeSystemTypesChanged);
     }
     ISelectionService service2 = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;
     if (service2 != null)
     {
         service2.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     IComponentChangeService service3 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
     if (service3 != null)
     {
         service3.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
     }
     IPropertyValueUIService service4 = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService;
     if (service4 != null)
     {
         service4.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.OnPropertyGridAdornments));
     }
 }
Example #7
0
        /// <summary>
        /// Flushes all changes to the designer.
        /// </summary>
        /// <param name="serializationManager">An <see cref="T:System.ComponentModel.Design.Serialization.IDesignerSerializationManager"/> to use for persisting the state of loaded designers.</param>
        protected override void PerformFlush(IDesignerSerializationManager serializationManager)
        {
            bool          success = true;
            ArrayList     errors  = new ArrayList();
            IDesignerHost idh     = (IDesignerHost)this.Host.GetService(typeof(IDesignerHost));

            Controls.ISerializableControl serializable = (LoaderHost.RootComponent as Controls.ISerializableControl);
            if (serializable == null)
            {
                throw new ApplicationException("Invalid root control type in designer.");
            }

            Serialization.SerializationObject serializationObject = this.GetSerializationObject();

            try
            {
                this.Buffer = this.SerializeFrameXml(serializationObject);
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);

                success = false;
                errors.Add(exception);
            }

            IDesignerLoaderHost host = this.LoaderHost;

            host.EndLoad(FrameXmlDesignerLoader.hostedBaseClassName, success, errors);

            Trace.WriteLine("PerformFlush");
        }
        /// <include file='doc\VSDesignerLoader.uex' path='docs/doc[@for="VSDesignerLoader.CreateCodeLoader"]/*' />
        /// <devdoc>
        ///     Called to create the MCM loader.
        /// </devdoc>
        protected override CodeLoader CreateCodeLoader(TextBuffer buffer, IDesignerLoaderHost host)
        {
            CodeLoader loader = null;

            // Get the context object off of the hierarchy, and ask it for an IVSMDCodeDomProvider
            // instance.
            //
            IVsHierarchy hier = Hierarchy;

            if (hier is IVsProject)
            {
                NativeMethods.IOleServiceProvider oleProvider = (NativeMethods.IOleServiceProvider)((IVsProject)hier).GetItemContext(ItemId);

                if (oleProvider != null)
                {
                    ServiceProvider      contextProv     = new ServiceProvider(oleProvider);
                    IVSMDCodeDomProvider codeDomProvider = (IVSMDCodeDomProvider)contextProv.GetService(typeof(IVSMDCodeDomProvider));
                    if (codeDomProvider != null)
                    {
                        loader = new VsCodeDomLoader(this, hier, ItemId, (CodeDomProvider)codeDomProvider.CodeDomProvider, buffer, host);
                    }
                }
            }

            if (loader == null)
            {
                throw new NotSupportedException(SR.GetString(SR.DESIGNERLOADERNoLanguageSupport));
            }

            return(loader);
        }
		void SetDesignerSupportsProjectResourcesToFalse(IDesignerLoaderHost host)
		{
			ProjectResourceService projectResourceService = host.GetService(typeof(ProjectResourceService)) as ProjectResourceService;
			if (projectResourceService != null) {
				projectResourceService.DesignerSupportsProjectResources = false;
			}
		}
        public WorkflowDesignerEventsCoordinator(IDesignerLoaderHost serviceProvider)
        {
            this.serviceProvider = serviceProvider;
            this.serviceProvider.LoadComplete += new EventHandler(this.OnDesignerReloaded);
            IDesignerEventService service = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService;

            if (service != null)
            {
                service.ActiveDesignerChanged += new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
            }
            ITypeProvider provider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;

            if (provider != null)
            {
                provider.TypesChanged += new EventHandler(this.OnTypeSystemTypesChanged);
            }
            ISelectionService service2 = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;

            if (service2 != null)
            {
                service2.SelectionChanged += new EventHandler(this.OnSelectionChanged);
            }
            IComponentChangeService service3 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (service3 != null)
            {
                service3.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
            }
            IPropertyValueUIService service4 = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService;

            if (service4 != null)
            {
                service4.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.OnPropertyGridAdornments));
            }
        }
        // TODO: toggle comments of exception handlers
        //
        public override void BeginLoad(IDesignerLoaderHost host)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (_loaded)
            {
                throw new InvalidOperationException("Already loaded.");
            }
            if (_host != null && _host != host)
            {
                throw new InvalidOperationException("Trying to load with a different host");
            }

            if (_host == null)               // beingload is called on reload - no need to initialize twice.
            {
                _host = host;
                Initialize();
            }
            IDisposable session = _serializationMananger.CreateSession();

            IDesignerLoaderService loader = _host.GetService(typeof(IDesignerLoaderService)) as IDesignerLoaderService;

            if (loader != null)
            {
                _dependenciesCount = -1;
                loader.AddLoadDependency();
            }
            else
            {
                OnBeginLoad();
            }

            bool successful = true;

//          try {
            PerformLoad(_serializationMananger);
//          } catch (Exception e) {
//              successful = false;
//              _serializationMananger.Errors.Add (e);
//              while (e.InnerException != null) {
//                  _serializationMananger.Errors.Add (e);
//                  Console.WriteLine (e.InnerException);
//                  e = e.InnerException;
//              }
//          }

            if (loader != null)
            {
                loader.DependentLoadComplete(successful, _serializationMananger.Errors);
            }
            else
            {
                OnEndLoad(successful, _serializationMananger.Errors);
            }

            session.Dispose();
        }
Example #12
0
        /// <include file='doc\SoapDesignerLoader.uex' path='docs/doc[@for="SoapDesignerLoader.CreateCodeLoader"]/*' />
        /// <devdoc>
        ///     Called to create the MCM loader.
        /// </devdoc>
        protected override CodeLoader CreateCodeLoader(TextBuffer buffer, IDesignerLoaderHost host)
        {
            // Now create the generic loader
            //
            CodeDomProvider provider = new SoapCodeProvider();

            return(new CodeDomLoader(this, provider, buffer, host));
        }
        public override void BeginLoad(IDesignerLoaderHost host)
        {
            this.loading = true;
            this.typeResolutionService = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService));
            this.designerLoaderHost    = host;

            base.BeginLoad(host);
        }
 /// <include file='doc\DocumentManager.uex' path='docs/doc[@for="DocumentManager.ComponentDesignerLoader.Dispose"]/*' />
 /// <devdoc>
 ///     The host will call this method when it no longer needs the
 ///     code stream.  Typically, this only happens when the document is closed.
 /// </devdoc>
 public override void Dispose()
 {
     if (host != null)
     {
         host.RemoveService(typeof(IDesignerLoaderService));
     }
     host = null;
 }
 protected BasicDesignerLoader()
 {
     _loading = _loaded = _flushing = _reloadScheduled = false;
     _host    = null;
     _notificationsEnabled = false;
     _modified             = false;
     _dependenciesCount    = 0;
 }
		protected BasicDesignerLoader ()
		{
			_loading = _loaded = _flushing = _reloadScheduled = false;
			_host = null;
			_notificationsEnabled = false;
			_modified = false;
			_dependenciesCount = 0;
		}
		public override void BeginLoad(IDesignerLoaderHost host)
		{
			this.loading = true;
			this.typeResolutionService = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService));
			this.designerLoaderHost = host;
			
			base.BeginLoad(host);
		}
 public override void BeginLoad(IDesignerLoaderHost host)
 {
     Debug.Assert(host != null);
     this.host = host;
     host.AddService(typeof(INameCreationService), new NameCreationService(host));
     host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host));
     host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService((IServiceProvider)host));
     base.BeginLoad(host);
 }
        void SetDesignerSupportsProjectResourcesToFalse(IDesignerLoaderHost host)
        {
            ProjectResourceService projectResourceService = host.GetService(typeof(ProjectResourceService)) as ProjectResourceService;

            if (projectResourceService != null)
            {
                projectResourceService.DesignerSupportsProjectResources = false;
            }
        }
		public override void BeginLoad(IDesignerLoaderHost host)
		{
			Debug.Assert(host != null);
			this.host = host;
			host.AddService(typeof(INameCreationService), new NameCreationService(host));
			host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host));
			host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService((IServiceProvider)host));
			base.BeginLoad(host);
		}
Example #21
0
        protected override void PerformLoad(IDesignerSerializationManager designerSerializationManager)
        {
            this.host = this.LoaderHost;

            if (host == null)
            {
                throw new ArgumentNullException("BasicHostLoader.BeginLoad: Invalid designerLoaderHost.");
            }

            ArrayList errors     = new ArrayList();
            bool      successful = true;
            string    baseClassName;

            if (fileName == null)
            {
                if (rootComponentType == typeof(Form))
                {
                    IComponent component = host.CreateComponent(rootComponentType);
                    (component as Form).FormBorderStyle = FormBorderStyle.None;
                    (component as Form).Size            = Screen.PrimaryScreen.Bounds.Size;
                    baseClassName = "Form1";
                }
                else if (rootComponentType == typeof(UserControl))
                {
                    host.CreateComponent(typeof(UserControl));
                    baseClassName = "UserControl1";
                }
                else if (rootComponentType == typeof(Component))
                {
                    host.CreateComponent(typeof(Component));
                    baseClassName = "Component1";
                }
                else
                {
                    throw new Exception("Undefined Host Type: " + rootComponentType.ToString());
                }
            }
            else
            {
                baseClassName = AssemblyHelper.ReadFile(fileName, errors, out xmlDocument, host);
            }

            IComponentChangeService cs = host.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (cs != null)
            {
                cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
                cs.ComponentAdded   += new ComponentEventHandler(OnComponentAddedRemoved);
                cs.ComponentRemoved += new ComponentEventHandler(OnComponentAddedRemoved);
            }

            host.EndLoad(baseClassName, successful, errors);

            _dirty   = true;
            _unsaved = false;
        }
Example #22
0
		public override void BeginLoad(IDesignerLoaderHost host)
		{
			if (host == null) {
				throw new ArgumentNullException("host");
			}
			this.host = host;
			host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host));
			host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService((IServiceProvider)host));
			base.BeginLoad(host);
		}
Example #23
0
 /// <summary>
 /// CTOR
 /// </summary>
 /// <param name="host"></param>
 /// <param name="createAllOwnerDrawControlsDelegate"></param>
 /// <param name="getControlDesignerInfo"></param>
 internal ControlFactory(IDesignerLoaderHost host,
                         CreateAllOwnerDrawControlsDelegate createAllOwnerDrawControlsDelegate,
                         GetControlDesignerInfoDelegate getControlDesignerInfo,
                         RuntimeHostSurface runtimeHostSurface)
 {
     this.host = host;
     this.createAllOwnerDrawControls = createAllOwnerDrawControlsDelegate;
     this.getControlDesignerInfo     = getControlDesignerInfo;
     this.runtimeHostSurface         = runtimeHostSurface;
 }
Example #24
0
        protected override void PerformLoad(IDesignerSerializationManager designerSerializationManager)
        {
            this.host = this.LoaderHost;
            ArrayList errors     = new ArrayList();
            bool      successful = true;
            string    baseClassName;

            baseClassName = "Home";
            host.EndLoad(baseClassName, successful, errors);
        }
Example #25
0
			// Note that IDesignerLoader : IDesignerHost
			//
			public override void BeginLoad (IDesignerLoaderHost loaderHost)
			{
				_loading = true;
				// initializa root component and designer
				//
				loaderHost.CreateComponent (_componentType);
				// finish off loading - no error collection here.
				//
				loaderHost.EndLoad (_componentType.FullName, true, null);
				_loading = false;
			}
        public override void BeginLoad(IDesignerLoaderHost host)
        {
            VerifyDesignerHasDialogId();

            GetDialogElement();
            VerifyDialogElementFound();

            AddServicesToHost(host);

            base.BeginLoad(host);
        }
Example #27
0
 // Note that IDesignerLoader : IDesignerHost
 //
 public override void BeginLoad(IDesignerLoaderHost loaderHost)
 {
     _loading = true;
     // initializa root component and designer
     //
     loaderHost.CreateComponent(_componentType);
     // finish off loading - no error collection here.
     //
     loaderHost.EndLoad(_componentType.FullName, true, null);
     _loading = false;
 }
Example #28
0
 public override void BeginLoad(IDesignerLoaderHost host)
 {
     if (host == null)
     {
         throw new ArgumentNullException("host");
     }
     this.host = host;
     host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host));
     host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService((IServiceProvider)host));
     base.BeginLoad(host);
 }
		public override void BeginLoad(IDesignerLoaderHost host)
		{
			VerifyDesignerHasDialogId();
			
			GetDialogElement();
			VerifyDialogElementFound();
			
			AddServicesToHost(host);
			
			base.BeginLoad(host);
		}
Example #30
0
        protected override void Initialize()
        {
            base.Initialize();

            IDesignerLoaderHost host = LoaderHost;

            if (host != null)
            {
                TypeProvider typeProvider = new TypeProvider(host);
                typeProvider.AddAssemblyReference(typeof(string).Assembly.Location);
            }
        }
		public InternalReportLoader(IDesignerLoaderHost host,IDesignerGenerator generator, Stream stream)
		{
			if (host == null) {
				throw new ArgumentNullException("host");
			}
		
			if (generator == null) {
				throw new ArgumentNullException("generator");
			}
			this.host = host;
			this.generator = generator;
			this.stream = stream;
		}
Example #32
0
 public static IComponent CreateComponent(IDesignerLoaderHost host, Type type, string name)
 {
     if (typeof(IComponent).IsAssignableFrom(type))
     {
         if (host != null)
         {
             INameCreationService cs = host.GetService(typeof(INameCreationService)) as INameCreationService;
             if (cs != null)
             {
                 IVplNameService ns = cs as IVplNameService;
                 if (ns != null)
                 {
                     ns.ComponentType = type;
                 }
             }
             return(host.CreateComponent(type, name));
         }
         else
         {
             IComponent ic = (IComponent)CreateObject(type);
             ic.Site      = new XTypeSite(ic);
             ic.Site.Name = name;
             return(ic);
         }
     }
     if (host != null)
     {
         INameCreationService cs = host.GetService(typeof(INameCreationService)) as INameCreationService;
         if (cs != null)
         {
             IVplNameService ns = cs as IVplNameService;
             if (ns != null)
             {
                 ns.ComponentType = typeof(XClass);
             }
         }
         XClass obj = (XClass)host.CreateComponent(typeof(XClass), name);
         obj.AssignType(type);
         obj.AssignValue(CreateObject(type));
         return(obj);
     }
     else
     {
         XClass obj = new XClass();
         obj.Site      = new XTypeSite(obj);
         obj.Site.Name = name;
         obj.AssignType(type);
         obj.AssignValue(CreateObject(type));
         return(obj);
     }
 }
Example #33
0
        // Called by the host when we load a document.
        protected override void PerformLoad(IDesignerSerializationManager designerSerializationManager)
        {
            this.host = this.LoaderHost;

            if (host == null)
            {
                throw new ArgumentNullException("BasicHostLoader.BeginLoad: Invalid designerLoaderHost.");
            }

            // The loader will put error messages in here.
            ArrayList errors        = new ArrayList();
            bool      successful    = true;
            string    baseClassName = "Form1";


            if (rootComponentType == typeof(Form))
            {
                //Control control = (Control)host.CreateComponent(typeof(GuiForm));

                ControlFactory factory = new ControlFactory(host, createAllOwnerDrawControls, getControlDesignerInfo, runtimeHostSurface);
                Form           form    = factory.PrepearForm(formToClone, null) as Form;
                TypeDescriptor.GetProperties(form)["Locked"].SetValue(form, true);
                baseClassName = "Form1";

                SetSerializedValues(form);

                SetVisibility(form);
            }

            // Now that we are done with the load work, we need to begin to listen to events.
            // Listening to event notifications is how a designer "Loader" can also be used
            // to save data.  If we wanted to integrate this loader with source code control,
            // we would listen to the "ing" events as well as the "ed" events.
            IComponentChangeService cs = host.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (cs != null)
            {
                cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
                cs.ComponentAdded   += new ComponentEventHandler(OnComponentAddedRemoved);
                cs.ComponentRemoved += new ComponentEventHandler(OnComponentAddedRemoved);
            }

            // Let the host know we are done loading.
            host.EndLoad(baseClassName, successful, errors);

            // We've just loaded a document, so you can bet we need to flush changes.
            dirty   = true;
            unsaved = false;
        }
        public override void BeginLoad(IDesignerLoaderHost host)
        {
            host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host));
            host.AddService(typeof(INameCreationService), new RubyNameCreationService(host));
            host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(host));

            ProjectResourceService projectResourceService = host.GetService(typeof(ProjectResourceService)) as ProjectResourceService;

            if (projectResourceService != null)
            {
                projectResourceService.DesignerSupportsProjectResources = false;
            }

            base.BeginLoad(host);
        }
Example #35
0
        public InternalReportLoader(IDesignerLoaderHost host, IDesignerGenerator generator, Stream stream)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            if (generator == null)
            {
                throw new ArgumentNullException("generator");
            }
            this.host      = host;
            this.generator = generator;
            this.stream    = stream;
        }
Example #36
0
 public override void Dispose()
 {
     try
     {
         IDesignerLoaderHost host = LoaderHost;
         if (host != null)
         {
             host.RemoveService(typeof(ITypeProvider), true);
         }
     }
     finally
     {
         base.Dispose();
     }
 }
Example #37
0
        public override void Dispose()
        {
            IDesignerLoaderHost host = LoaderHost;

            if (host != null)
            {
                host.RemoveService(typeof(IIdentifierCreationService));
                host.RemoveService(typeof(IMenuCommandService));
                host.RemoveService(typeof(IToolboxService));
                host.RemoveService(typeof(ITypeProvider), true);
                host.RemoveService(typeof(IWorkflowCompilerOptionsService));
                host.RemoveService(typeof(IEventBindingService));
            }

            base.Dispose();
        }
Example #38
0
 public override void Flush()
 {
     if ((!this._state[StateFlushInProgress] && this._state[StateLoaded]) && this.Modified)
     {
         this._state[StateFlushInProgress] = true;
         Cursor current = Cursor.Current;
         Cursor.Current = Cursors.WaitCursor;
         try
         {
             IDesignerLoaderHost host = this._host;
             bool flag = true;
             if ((host != null) && (host.RootComponent != null))
             {
                 using (this._serializationManager.CreateSession())
                 {
                     try
                     {
                         this.PerformFlush(this._serializationManager);
                     }
                     catch (CheckoutException)
                     {
                         flag = false;
                         throw;
                     }
                     catch (Exception exception)
                     {
                         this._serializationManager.Errors.Add(exception);
                     }
                     ICollection errors = this._serializationManager.Errors;
                     if ((errors != null) && (errors.Count > 0))
                     {
                         this.ReportFlushErrors(errors);
                     }
                 }
             }
             if (flag)
             {
                 this.Modified = false;
             }
         }
         finally
         {
             this._state[StateFlushInProgress] = false;
             Cursor.Current = current;
         }
     }
 }
Example #39
0
        protected override void Initialize()
        {
            base.Initialize();

            IDesignerLoaderHost host = LoaderHost;

            if (host != null)
            {
                host.RemoveService(typeof(IIdentifierCreationService));
                host.AddService(typeof(IIdentifierCreationService), new IdentifierCreationService(host));
                host.AddService(typeof(IMenuCommandService), new MenuCommandService(host));
                TypeProvider typeProvider = new TypeProvider(host);
                typeProvider.AddAssemblyReference(typeof(string).Assembly.Location);
                host.AddService(typeof(ITypeProvider), typeProvider, true);
                host.AddService(typeof(IEventBindingService), new EventBindingService());
            }
        }
Example #40
0
        // Called by the host when we load a document.
        protected override void PerformLoad(IDesignerSerializationManager designerSerializationManager)
        {
            this.host = this.LoaderHost;

            if (host == null)
            {
                throw new ArgumentNullException("BasicHostLoader.BeginLoad: Invalid designerLoaderHost.");
            }

            // The loader will put error messages in here.
            ArrayList errors     = new ArrayList();
            bool      successful = true;
            string    baseClassName;

            // If no filename was passed in, just create a form and be done with it.  If a file name
            // was passed, read it.
            if (fileName == null)
            {
                host.CreateComponent(rootComponentType);
                baseClassName = rootComponentType.Name;
            }
            else
            {
                baseClassName = ReadFile(fileName, errors, out xmlDocument);
            }

            // Now that we are done with the load work, we need to begin to listen to events.
            // Listening to event notifications is how a designer "Loader" can also be used
            // to save data.  If we wanted to integrate this loader with source code control,
            // we would listen to the "ing" events as well as the "ed" events.
            IComponentChangeService cs = host.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (cs != null)
            {
                cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
                cs.ComponentAdded   += new ComponentEventHandler(OnComponentAddedRemoved);
                cs.ComponentRemoved += new ComponentEventHandler(OnComponentAddedRemoved);
            }

            // Let the host know we are done loading.
            host.EndLoad(baseClassName, successful, errors);

            // We've just loaded a document, so you can bet we need to flush changes.
            dirty   = true;
            unsaved = false;
        }
		public InternalReportLoader(IDesignerLoaderHost host,IDesignerGenerator generator, Stream stream)
		{
			if (host == null) {
				throw new ArgumentNullException("host");
			}
		
			if (generator == null) {
				throw new ArgumentNullException("generator");
			}
			if (stream == null) {
				throw new ArgumentNullException("stream");
			}
			Console.WriteLine("---------InternalReportLoader------------");
			this.host = host;
			this.generator = generator;
			this.stream = stream;
		}
		public override void BeginLoad(IDesignerLoaderHost host)
		{
			// Check dialog id.
			if (designer.DialogId == null) {
				throw new FormsDesignerLoadException(StringParser.Parse("${res:ICSharpCode.WixBinding.WixDialogDesigner.NoDialogSelectedInDocumentMessage}"));
			}
			
			// Get dialog element.
			WixDocument document = CreateWixDocument();
			document.LoadXml(designer.GetDocumentXml());
			wixDialog = document.GetDialog(designer.DialogId, new WorkbenchTextFileReader());
			if (wixDialog == null) {
				throw new FormsDesignerLoadException(String.Format(StringParser.Parse("${res:ICSharpCode.WixBinding.DialogDesignerGenerator.DialogIdNotFoundMessage}"), designer.DialogId));
			}
			
			host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host));
			host.AddService(typeof(INameCreationService), new XmlDesignerLoader.NameCreationService(host));
			host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(host));

			base.BeginLoad(host);
		}
Example #43
0
		public override void BeginLoad (IDesignerLoaderHost host)
		{
			if (host == null)
				throw new ArgumentNullException ("host");
			if (_loaded)
				throw new InvalidOperationException ("Already loaded.");
			if (_host != null && _host != host)
				throw new InvalidOperationException ("Trying to load with a different host");

			if (_host == null) { // beingload is called on reload - no need to initialize twice.
				_host = host;
				Initialize ();
			}
			IDisposable session = _serializationMananger.CreateSession ();

			IDesignerLoaderService loader = _host.GetService (typeof (IDesignerLoaderService)) as IDesignerLoaderService;

			if (loader != null) {
				_dependenciesCount = -1;
				loader.AddLoadDependency ();
			} else {
				OnBeginLoad ();
			}

			bool successful = true;

			try {
				PerformLoad (_serializationMananger);
			} catch (Exception e) {
				successful = false;
				_serializationMananger.Errors.Add (e);
			}

			if (loader != null)
				loader.DependentLoadComplete (successful, _serializationMananger.Errors);
			else
				OnEndLoad (successful, _serializationMananger.Errors);

			session.Dispose ();
		}
 public override void BeginLoad(IDesignerLoaderHost loaderHost)
 {
     string baseClassName = null;
     if (this._type != null)
     {
         loaderHost.CreateComponent(this._type);
         baseClassName = this._type.FullName;
     }
     else
     {
         foreach (IComponent component in this._components)
         {
             loaderHost.Container.Add(component);
         }
     }
     loaderHost.EndLoad(baseClassName, true, null);
 }
		void AddServicesToHost(IDesignerLoaderHost host)
		{
			host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host));
			host.AddService(typeof(INameCreationService), new XmlDesignerNameCreationService(host));
			host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(host));
		}
		void BeginLoad(IDesignerLoaderHost host)
		{
			loader = new ScriptingDesignerLoader(new MockDesignerGenerator());			
			loader.BeginLoad(host);
		}
		public override void BeginLoad(IDesignerLoaderHost host)
		{
			AddServices(host);
			SetDesignerSupportsProjectResourcesToFalse(host);
			base.BeginLoad(host);
		}
        public WorkflowDesignerEventsCoordinator(IDesignerLoaderHost serviceProvider)
        {
            this.serviceProvider = serviceProvider;

            this.serviceProvider.LoadComplete += new EventHandler(OnDesignerReloaded);

            //Listen to the events so that we are sure that we appropriately refresh the designer actions and tasks when the types
            //change
            IDesignerEventService designerEventService = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService;
            if (designerEventService != null)
                designerEventService.ActiveDesignerChanged += new ActiveDesignerEventHandler(OnActiveDesignerChanged);

            ITypeProvider typeProvider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;
            if (typeProvider != null)
                typeProvider.TypesChanged += new EventHandler(OnTypeSystemTypesChanged);

            ISelectionService selectionService = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;
            if (selectionService != null)
                selectionService.SelectionChanged += new EventHandler(OnSelectionChanged);

            IComponentChangeService componentChangedService = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
            if (componentChangedService != null)
                componentChangedService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);

            IPropertyValueUIService propertyValueService = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService;
            if (propertyValueService != null)
                propertyValueService.AddPropertyValueUIHandler(new PropertyValueUIHandler(OnPropertyGridAdornments));
        }
 public override void Dispose()
 {
     if (this._state[StateReloadAtIdle])
     {
         Application.Idle -= new EventHandler(this.OnIdle);
     }
     this.UnloadDocument();
     IComponentChangeService service = (IComponentChangeService) this.GetService(typeof(IComponentChangeService));
     if (service != null)
     {
         service.ComponentAdded -= new ComponentEventHandler(this.OnComponentAdded);
         service.ComponentAdding -= new ComponentEventHandler(this.OnComponentAdding);
         service.ComponentRemoving -= new ComponentEventHandler(this.OnComponentRemoving);
         service.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
         service.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
         service.ComponentChanging -= new ComponentChangingEventHandler(this.OnComponentChanging);
         service.ComponentRename -= new ComponentRenameEventHandler(this.OnComponentRename);
     }
     if (this._host != null)
     {
         this._host.RemoveService(typeof(IDesignerLoaderService));
         this._host.Activated -= new EventHandler(this.OnDesignerActivate);
         this._host.Deactivated -= new EventHandler(this.OnDesignerDeactivate);
         this._host = null;
     }
 }
Example #50
0
		// Called by the host when we load a document.
		protected override void PerformLoad(IDesignerSerializationManager designerSerializationManager)
		{
			this.host = this.LoaderHost;

			if (host == null)
			{
				throw new ArgumentNullException("BasicHostLoader.BeginLoad: Invalid designerLoaderHost.");
			}

			// The loader will put error messages in here.
			ArrayList errors = new ArrayList();
			bool successful = true;
			string baseClassName;

			// If no filename was passed in, just create a form and be done with it.  If a file name
			// was passed, read it.
			if (fileName == null)
			{
                baseClassName = name;
				if (rootComponentType == typeof(Form))
				{
					host.CreateComponent(typeof(Form));
				}
				else if (rootComponentType == typeof(UserControl))
				{
					host.CreateComponent(typeof(UserControl));
				}
				else if (rootComponentType == typeof(Component))
				{
					host.CreateComponent(typeof(Component));
				}
				else
				{
					throw new Exception("Undefined Host Type: " + rootComponentType.ToString());
				}
			}
			else
			{
				baseClassName = ReadFile(fileName, errors, out xmlDocument);
			}

			// Now that we are done with the load work, we need to begin to listen to events.
			// Listening to event notifications is how a designer "Loader" can also be used
			// to save data.  If we wanted to integrate this loader with source code control,
			// we would listen to the "ing" events as well as the "ed" events.
			IComponentChangeService cs = host.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

			if (cs != null)
			{
				cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
				cs.ComponentAdded += new ComponentEventHandler(OnComponentAddedRemoved);
				cs.ComponentRemoved += new ComponentEventHandler(OnComponentAddedRemoved);
			}

			// Let the host know we are done loading.
			host.EndLoad(baseClassName, successful, errors);

			// We've just loaded a document, so you can bet we need to flush changes.
			dirty = true;
			unsaved = false;
		}
	// Methods
	public virtual void BeginLoad(IDesignerLoaderHost host) {}
		// Called by the host when we load a document.
		public override void BeginLoad(IDesignerLoaderHost host) 
		{
			if (host == null) 
			{
				throw new ArgumentNullException("SampleDesignerLoader.BeginLoad: Invalid designerLoaderHost.");
			}

			this.host = host;

			// The loader will put error messages in here.
			//
			ArrayList errors = new ArrayList();
			bool successful = true;
			string baseClassName;
			
			// The loader is responsible for providing certain services to the host.
			//
			host.AddService(typeof(IDesignerSerializationManager), new SampleDesignerSerializationManager(this));
			host.AddService(typeof(IEventBindingService), new SampleEventBindingService(host));
			host.AddService(typeof(ITypeResolutionService), new SampleTypeResolutionService());
			host.AddService(typeof(CodeDomProvider), new CSharpCodeProvider());
			host.AddService(typeof(IResourceService), new SampleResourceService(host));

			// If no filename was passed in, just create a form and be done with it.  If a file name
			// was passed, read it.
			//
			if (fileName == null) 
			{
				baseClassName = host.CreateComponent(typeof(System.Windows.Forms.Form)).Site.Name;
			}
			else 
			{
				baseClassName = ReadFile(fileName, errors, out xmlDocument);
			}

			// Now that we are done with the load work, we need to begin to listen to events.
			// Listening to event notifications is how a designer "Loader" can also be used
			// to save data.  If we wanted to integrate this loader with source code control,
			// we would listen to the "ing" events as well as the "ed" events.
			//
			IComponentChangeService cs = host.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
			if (cs != null)
			{
				cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
				cs.ComponentAdded += new ComponentEventHandler(OnComponentAddedRemoved);
				cs.ComponentRemoved += new ComponentEventHandler(OnComponentAddedRemoved);
			}

			// Let the host know we are done loading.
			host.EndLoad(baseClassName, successful, errors);
			
			// We've just loaded a document, so you can bet we need to flush changes.
			dirty = true;
			unsaved = false;
		}
Example #53
0
 /// <devdoc>
 ///     Called by the designer host to begin the loading process.  The designer
 ///     host passes in an instance of a designer loader host (which is typically
 ///     the same object as the designer host.  This loader host allows
 ///     the designer loader to reload the design document and also allows
 ///     the designer loader to indicate that it has finished loading the
 ///     design document.
 /// </devdoc>
 public abstract void BeginLoad(IDesignerLoaderHost host);
	// Methods
	public abstract virtual void BeginLoad(IDesignerLoaderHost host) {}
 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;
     }
 }
        /// <summary>
        /// ����ҳ���ʱ����ã������xml�ļ���ȡ��Ϣ
        /// ���ú���ReadFile���������ļ��ڵ�ľ�����Ϣ��������ݶ�ȡ����Ϣ����������ļ��ء�
        /// </summary>
        /// <param name="document">��Ҫ���ص�xml�ļ�</param>
        /// <returns></returns>
        public bool MyPerformLoad(XmlDocument document)
        {
            ArrayList errors = new ArrayList();
            bool successful = true;        //��־���ع����Ƿ�ɹ�
            string baseClassName = null;
            this.hostLoader = this.LoaderHost;  //��ȡ���س������������� BasicDesignerLoader �̳С���

            if (hostLoader == null)
            {
                //CassMessageBox.Warning("����������쳣��");
                return false;
            }

            //��Ŵ�����Ϣ,��������ڼ�������������뽫��Щ������Ϊ�쳣���ϴ��ݵ� errorCollection �����С�
            baseClassName = ReadFile(document, errors);

            if (baseClassName == null)
            {
                return false;
            }

            if (errors.Count > 0)
            {
                successful = false;
            }

            // ������������ز�����
            //baseClassName �������������Ƶ��ĵ��Ļ������ȫ�޶�����
            //successful ���������ѳɹ����أ���Ϊ true������Ϊ false��
            //errorCollection ���������ڼ������Ĵ�������еĻ����ļ��ϡ�
            hostLoader.EndLoad(baseClassName, successful, errors);
            return successful;
        }