Exemplo n.º 1
0
        static DefaultServiceContainer CreateAndInitServiceContainer()
        {
            LoggingService.Debug("ReportDesigner: CreateAndInitServiceContainer...");
            var serviceContainer = new DefaultServiceContainer();

            serviceContainer.AddService(typeof(IUIService), new UIService());
            serviceContainer.AddService(typeof(IToolboxService), new ICSharpCode.Reporting.Addin.Services.ToolboxService());
            serviceContainer.AddService(typeof(IHelpService), new HelpService());
            return(serviceContainer);
        }
Exemplo n.º 2
0
 private void LoadDesigner()
 {
     //LoggingService.Info("Form Designer: BEGIN INITIALIZE");
     DefaultServiceContainer parentProvider = new DefaultServiceContainer();
     parentProvider.AddService(typeof(IUIService), new UIService());
     parentProvider.AddService(typeof(IToolboxService), new ToolboxService());
     parentProvider.AddService(typeof(IPropertyValueUIService), new PropertyValueUIService());
     AmbientProperties serviceInstance = new AmbientProperties();
     parentProvider.AddService(typeof(AmbientProperties), serviceInstance);
     parentProvider.AddService(typeof(IDesignerEventService), new FormsDesigner.Services.DesignerEventService());
     this.designSurface = new System.ComponentModel.Design.DesignSurface(parentProvider);
     parentProvider.AddService(typeof(IMenuCommandService), new FormsDesigner.Services.MenuCommandService(this.p, this.designSurface));
     parentProvider.AddService(typeof(ITypeResolutionService), new TypeResolutionService());
     DesignerLoader loader = this.loaderProvider.CreateLoader(this.generator);
     //加载XML内容
     this.designSurface.BeginLoad(loader);
     this.generator.Attach(this);
     this.undoEngine = new FormsDesignerUndoEngine(this.Host);
     IComponentChangeService service = (IComponentChangeService) this.designSurface.GetService(typeof(IComponentChangeService));
     service.ComponentChanged += delegate {
         this.viewContent.IsDirty = true;
     };
     service.ComponentAdded += new ComponentEventHandler(this.ComponentListChanged);
     service.ComponentRemoved += new ComponentEventHandler(this.ComponentListChanged);
     service.ComponentRename += new ComponentRenameEventHandler(this.ComponentListChanged);
     this.Host.TransactionClosed += new DesignerTransactionCloseEventHandler(this.TransactionClose);
     ISelectionService service2 = (ISelectionService) this.designSurface.GetService(typeof(ISelectionService));
     service2.SelectionChanged += new EventHandler(this.SelectionChangedHandler);
     if (this.IsTabOrderMode)
     {
         this.tabOrderMode = false;
         this.ShowTabOrder();
     }
     //LoggingService.Info("Form Designer: END INITIALIZE");
 }
Exemplo n.º 3
0
        void LoadDesigner()
        {
            LoggingService.Info("Form Designer: BEGIN INITIALIZE");

            DefaultServiceContainer serviceContainer = new DefaultServiceContainer();

            serviceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService());
            serviceContainer.AddService(typeof(System.Drawing.Design.IToolboxService), ToolboxProvider.ToolboxService);

            serviceContainer.AddService(typeof(IHelpService), new HelpService());
            serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService());

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), new DesignerResourceService(this.resourceStore));
            AmbientProperties ambientProperties = new AmbientProperties();

            serviceContainer.AddService(typeof(AmbientProperties), ambientProperties);
            this.typeResolutionService = new TypeResolutionService(this.PrimaryFileName);
            serviceContainer.AddService(typeof(ITypeResolutionService), this.typeResolutionService);
            serviceContainer.AddService(typeof(DesignerOptionService), new SharpDevelopDesignerOptionService());
            serviceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService());
            serviceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService());
            serviceContainer.AddService(typeof(ProjectResourceService), new ProjectResourceService(ParserService.GetParseInformation(this.DesignerCodeFile.FileName).MostRecentCompilationUnit.ProjectContent));

            // Provide the ImageResourceEditor for all Image and Icon properties
            this.addedTypeDescriptionProviders.Add(typeof(Image), TypeDescriptor.AddAttributes(typeof(Image), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor))));
            this.addedTypeDescriptionProviders.Add(typeof(Icon), TypeDescriptor.AddAttributes(typeof(Icon), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor))));

            if (generator.CodeDomProvider != null)
            {
                serviceContainer.AddService(typeof(System.CodeDom.Compiler.CodeDomProvider), generator.CodeDomProvider);
            }

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

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormsDesigner.Services.MenuCommandService(this.Control, designSurface));
            ICSharpCode.FormsDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormsDesigner.Services.EventBindingService(this, designSurface);
            serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService);

            this.loader = loaderProvider.CreateLoader(generator);
            designSurface.BeginLoad(this.loader);

            if (!designSurface.IsLoaded)
            {
                throw new FormsDesignerLoadException(FormatLoadErrors(designSurface));
            }

            undoEngine = new FormsDesignerUndoEngine(Host);
            serviceContainer.AddService(typeof(UndoEngine), undoEngine);

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

            componentChangeService.ComponentChanged += ComponentChanged;
            componentChangeService.ComponentAdded   += ComponentListChanged;
            componentChangeService.ComponentRemoved += ComponentListChanged;
            componentChangeService.ComponentRename  += ComponentListChanged;
            this.Host.TransactionClosed             += TransactionClose;

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

            selectionService.SelectionChanged += SelectionChangedHandler;

            if (IsTabOrderMode)               // fixes SD2-1015
            {
                tabOrderMode = false;         // let ShowTabOrder call the designer command again
                ShowTabOrder();
            }

            UpdatePropertyPad();

            hasUnmergedChanges = false;

            LoggingService.Info("Form Designer: END INITIALIZE");
        }
Exemplo n.º 4
0
        public void LoadDesigner(string formFile)
        {
            UnloadDesigner();
            DefaultServiceContainer serviceContainer = new DefaultServiceContainer();

            serviceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService());
            serviceContainer.AddService(typeof(System.Drawing.Design.IToolboxService), ToolboxProvider.ToolboxService);

            serviceContainer.AddService(typeof(IHelpService), new HelpService());
            serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService());

            AmbientProperties ambientProperties = new AmbientProperties();

            serviceContainer.AddService(typeof(AmbientProperties), ambientProperties);
            this.typeResolutionService = new TypeResolutionService();
            serviceContainer.AddService(typeof(ITypeResolutionService), this.typeResolutionService);
            serviceContainer.AddService(typeof(DesignerOptionService), new SharpDevelopDesignerOptionService());
            serviceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService());
            serviceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService());

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

            designerResourceService = new DesignerResourceService(this);//roman//
            serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), designerResourceService);
            loader = new CodeDomHostLoader(this.Host, formFile, FileName);

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormsDesigner.Services.MenuCommandService(Host));
            ICSharpCode.FormsDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormsDesigner.Services.EventBindingService(Host);
            serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService);

            designSurface.BeginLoad(loader);

            if (!designSurface.IsLoaded)
            {
                throw new FormsDesignerLoadException(FormatLoadErrors(designSurface));
            }

            undoEngine = new FormsDesignerUndoEngine(Host);
            serviceContainer.AddService(typeof(UndoEngine), undoEngine);

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

            componentChangeService.ComponentChanged += ComponentChanged;
            componentChangeService.ComponentAdded   += ComponentListChanged;
            componentChangeService.ComponentRemoved += ComponentListChanged;
            componentChangeService.ComponentRename  += ComponentListChanged;
            this.Host.TransactionClosed             += TransactionClose;

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

            selectionService.SelectionChanged += SelectionChangedHandler;

            if (IsTabOrderMode)               // fixes SD2-1015
            {
                tabOrderMode = false;         // let ShowTabOrder call the designer command again
                ShowTabOrder();
            }

            UpdatePropertyPad();

            hasUnmergedChanges = false;
            MakeDirty();

            PropertyGrid grid = PropertyPad.Grid;

            var gridView = (Control)grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(grid);
            var edit     = (Control)gridView.GetType().GetField("edit", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(gridView);

            edit.KeyPress   += PropertyPadEditorKeyPress;
            edit.ContextMenu = new ContextMenu();
        }
Exemplo n.º 5
0
        void LoadDesigner(Stream stream)
        {
            LoggingService.Info("ReportDesigner LoadDesigner_Start");
            panel = CreatePanel();
            defaultServiceContainer = CreateAndInitServiceContainer();

            LoggingService.Info("Create DesignSurface and add event's");
            designSurface = CreateDesignSurface(defaultServiceContainer);
            SetDesignerEvents();

            var ambientProperties = new AmbientProperties();

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

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

            defaultServiceContainer.AddService(typeof(IMenuCommandService),
                                               new ICSharpCode.Reporting.Addin.Services.MenuCommandService(panel, designSurface));

            defaultServiceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService());
            defaultServiceContainer.AddService(typeof(OpenedFile), base.PrimaryFile);

            LoggingService.Info("Load DesignerOptionService");
            var designerOptionService = CreateDesignerOptions();

            defaultServiceContainer.AddService(typeof(DesignerOptionService), designerOptionService);

            LoggingService.Info("Create ReportDesignerLoader");

            loader = new ReportDesignerLoader(generator, stream);
            designSurface.BeginLoad(this.loader);
            if (!designSurface.IsLoaded)
            {
                //				throw new FormsDesignerLoadException(FormatLoadErrors(designSurface));
                LoggingService.Error("designer not loaded");
            }
            //-------------

            defaultServiceContainer.AddService(typeof(INameCreationService), new NameCreationService());


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

            selectionService.SelectionChanged += SelectionChangedHandler;

            undoEngine = new ReportDesignerUndoEngine(Host);

            var 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("ReportDesigner LoadDesigner_End");
        }