Ejemplo n.º 1
0
        private void LoadDesigner(Stream stream)
        {
            LoggingService.Info("Form Designer: BEGIN INITIALIZE");

            defaultServiceContainer = new DefaultServiceContainer();

            defaultServiceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService),
                                               new UIService());

            defaultServiceContainer.AddService(typeof(IToolboxService), new ToolboxService());
            defaultServiceContainer.AddService(typeof(IHelpService), new HelpService());

            this.designSurface       = CreateDesignSurface(defaultServiceContainer);
            designSurface.Loading   += this.DesignerLoading;
            designSurface.Loaded    += this.DesignerLoaded;
            designSurface.Flushed   += this.DesignerFlushed;
            designSurface.Unloading += this.DesingerUnloading;

            AmbientProperties ambientProperties = new AmbientProperties();

            defaultServiceContainer.AddService(typeof(AmbientProperties), ambientProperties);

            defaultServiceContainer.AddService(typeof(ITypeResolutionService), new TypeResolutionService());

            defaultServiceContainer.AddService(typeof(ITypeDiscoveryService),
                                               new TypeDiscoveryService());

            defaultServiceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService),
                                               new MenuCommandService(panel, this.designSurface));

            defaultServiceContainer.AddService(typeof(MemberRelationshipService),
                                               new DefaultMemberRelationshipService());

            //need this to resolve the filename and manipulate
            //ReportSettings in ReportDefinitionDeserializer.LoadObjectFromXmlDocument
            //if the filename in ReportSettings is different from load location

            defaultServiceContainer.AddService(typeof(OpenedFile), base.PrimaryFile);

            DesignerOptionService dos = new System.Windows.Forms.Design.WindowsFormsDesignerOptionService();

            dos.Options.Properties.Find("UseSmartTags", true).SetValue(dos, true);
            dos.Options.Properties.Find("ShowGrid", true).SetValue(dos, false);
            dos.Options.Properties.Find("UseSnapLines", true).SetValue(dos, true);
            defaultServiceContainer.AddService(typeof(DesignerOptionService), dos);
            this.loader = new ReportDesignerLoader(generator, stream);
            this.designSurface.BeginLoad(this.loader);
            if (!designSurface.IsLoaded)
            {
                throw new FormsDesignerLoadException(FormatLoadErrors(designSurface));
            }
            defaultServiceContainer.AddService(typeof(System.ComponentModel.Design.Serialization.INameCreationService),
                                               new NameCreationService());

            ISelectionService selectionService = (ISelectionService)this.designSurface.GetService(typeof(ISelectionService));

            selectionService.SelectionChanged += SelectionChangedHandler;

            undoEngine = new ReportDesignerUndoEngine(Host);

            IComponentChangeService componentChangeService = (IComponentChangeService)this.designSurface.GetService(typeof(IComponentChangeService));

            componentChangeService.ComponentChanged += OnComponentChanged;
            componentChangeService.ComponentAdded   += OnComponentListChanged;
            componentChangeService.ComponentRemoved += OnComponentListChanged;
            componentChangeService.ComponentRename  += OnComponentListChanged;

            this.Host.TransactionClosed += TransactionClose;

            UpdatePropertyPad();
            hasUnmergedChanges = false;

            LoggingService.Info("Form Designer: END INITIALIZE");
        }
Ejemplo n.º 2
0
		private void LoadDesigner(Stream stream)
		{
			Console.WriteLine("LoadDesigner(Stream stream)");
			LoggingService.Info("Form Designer: BEGIN INITIALIZE");
			CreatePanel();
			defaultServiceContainer = new DefaultServiceContainer();
			
			defaultServiceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService),
			                                   new UIService());

			defaultServiceContainer.AddService(typeof(IToolboxService),new ToolboxService());
			defaultServiceContainer.AddService(typeof(IHelpService), new HelpService());
			
			this.designSurface = CreateDesignSurface(defaultServiceContainer);
			designSurface.Loading += this.DesignerLoading;
			designSurface.Loaded += this.DesignerLoaded;
			designSurface.Flushed += this.DesignerFlushed;
			designSurface.Unloading += this.DesingerUnloading;
			
			AmbientProperties ambientProperties = new AmbientProperties();
			defaultServiceContainer.AddService(typeof(AmbientProperties), ambientProperties);
			
			defaultServiceContainer.AddService(typeof(ITypeResolutionService), new TypeResolutionService());
			
			defaultServiceContainer.AddService(typeof(ITypeDiscoveryService),
			                                   new TypeDiscoveryService());

			defaultServiceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService),
			                                   new MenuCommandService(panel,this.designSurface ));
			
			defaultServiceContainer.AddService(typeof(MemberRelationshipService),
			                                   new DefaultMemberRelationshipService());
			
			//need this to resolve the filename and manipulate
			//ReportSettings in ReportDefinitionDeserializer.LoadObjectFromXmlDocument
			//if the filename in ReportSettings is different from load location
			
			defaultServiceContainer.AddService(typeof(OpenedFile),base.PrimaryFile);
			
			DesignerOptionService dos = new System.Windows.Forms.Design.WindowsFormsDesignerOptionService();
			dos.Options.Properties.Find( "UseSmartTags", true ).SetValue( dos, true );
			dos.Options.Properties.Find( "ShowGrid", true ).SetValue( dos, false );
			dos.Options.Properties.Find( "UseSnapLines", true ).SetValue( dos, true );
			defaultServiceContainer.AddService( typeof( DesignerOptionService ), dos );
			this.loader = new ReportDesignerLoader(generator,stream);
			this.designSurface.BeginLoad(this.loader);
			if (!designSurface.IsLoaded) {
				throw new FormsDesignerLoadException(FormatLoadErrors(designSurface));
			}
			defaultServiceContainer.AddService(typeof(System.ComponentModel.Design.Serialization.INameCreationService),
			                                   new NameCreationService());
			
			ISelectionService selectionService = (ISelectionService)this.designSurface.GetService(typeof(ISelectionService));
			selectionService.SelectionChanged  += SelectionChangedHandler;
			
			undoEngine = new ReportDesignerUndoEngine(Host);
			
			IComponentChangeService componentChangeService = (IComponentChangeService)this.designSurface.GetService(typeof(IComponentChangeService));
			
			componentChangeService.ComponentChanged += OnComponentChanged;
			componentChangeService.ComponentAdded   += OnComponentListChanged;
			componentChangeService.ComponentRemoved += OnComponentListChanged;
			componentChangeService.ComponentRename  += OnComponentListChanged;
			
			this.Host.TransactionClosed += TransactionClose;
			
			UpdatePropertyPad();
			hasUnmergedChanges = false;
			
			LoggingService.Info("Form Designer: END INITIALIZE");
		}