Esempio n. 1
0
        /// <summary>
        /// Bootstrap method - loads a blank Form
        /// </summary>
        /// <returns></returns>
        protected override CodeCompileUnit Parse( )
        {
            CodeCompileUnit ccu = null;



            if (String.IsNullOrWhiteSpace(SourceCodeToPasrse))
            {
                DesignSurface ds = new DesignSurface();
                ds.BeginLoad(typeof(ABCControls.ABCView));
                IDesignerHost idh = (IDesignerHost)ds.GetService(typeof(IDesignerHost));
                idh.RootComponent.Site.Name = "Form1";

                ccu = new CodeGen().GetCodeCompileUnit(idh);
            }
            else
            {
                //    ccu=ConvertToCodeComlieUnit( SourceCodeToPasrse );
                ccu = DeSerializationCodeCompileUnit();
            }

            AssemblyName[] names = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
            for (int i = 0; i < names.Length; i++)
            {
                Assembly assembly = Assembly.Load(names[i]);
                ccu.ReferencedAssemblies.Add(assembly.Location);
            }

            codeCompileUnit = ccu;



            return(ccu);
        }
        /// <summary>
        /// Bootstrap method - loads a blank Form
        /// </summary>
        /// <returns></returns>
        protected override CodeCompileUnit Parse()
        {
            CodeCompileUnit ccu = null;

            DesignSurface ds = new DesignSurface();

            ds.BeginLoad(typeof(Form));



            IDesignerHost idh = (IDesignerHost)ds.GetService(typeof(IDesignerHost));


            idh.RootComponent.Site.Name = "Form1";



            cg  = new CodeGen();
            ccu = cg.GetCodeCompileUnit(idh);

            AssemblyName[] names = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
            for (int i = 0; i < names.Length; i++)
            {
                Assembly assembly = Assembly.Load(names[i]);
                ccu.ReferencedAssemblies.Add(assembly.Location);
            }

            codeCompileUnit = ccu;
            return(ccu);
        }
Esempio n. 3
0
        /// <summary>
        /// it must be called from a separated app domain other than the designer.
        /// </summary>
        /// <param name="xmlFile"></param>
        public void Load(string xmlFile)
        {
            ProjectEnvironment.RunMode = true;
            XmlDocument doc = new XmlDocument();

            doc.Load(xmlFile);
            XmlNode       _node   = doc.DocumentElement;
            LimnorProject project = new LimnorProject(LimnorProject.GetProjectFileByComponentFile(xmlFile));
            //create root object
            UInt32          classId  = XmlUtil.GetAttributeUInt(_node, XmlTags.XMLATT_ClassID);
            UInt32          memberId = XmlUtil.GetAttributeUInt(_node, XmlTags.XMLATT_ComponentID);
            ObjectIDmap     map      = new ObjectIDmap(project, DesignUtil.MakeDDWord(memberId, classId), _node);
            XmlObjectReader xr       = new XmlObjectReader(map, ClassPointer.OnAfterReadRootComponent, ClassPointer.OnRootComponentCreated);

            map.SetReader(xr);
            _rootId = new ClassPointer(classId, memberId, map, null);
            string          file   = project.GetComponentFileByClassId(classId);
            ComponentLoader loader = new ComponentLoader(xr, file);
            DesignSurface   ds     = new DesignSurface();

            ds.BeginLoad(loader);
            if (xr.Errors != null && xr.Errors.Count > 0)
            {
                MathNode.Log(xr.Errors);
            }
            _rootId.LoadActionInstances();
        }
Esempio n. 4
0
        protected override void OnLoad(EventArgs args)
        {
            base.OnLoad(args);

            _DesignSurface         = new DesignSurface();
            _DesignSurface.Loaded += new LoadedEventHandler(OnDesignSurfaceLoaded);

            _ToolboxControl.AddToolboxItem(new ToolboxItem()
            {
                TypeName = NameConsts.Pointer, DisplayName = Properties.Resources.Tool_Pointer, Bitmap = new Bitmap(1, 1)
            });
            ToolMap.All(pair =>
            {
                _ToolboxControl.AddToolboxItem(new ToolboxItem(pair.Key)
                {
                    DisplayName = pair.Value
                });
                return(true);
            });

            DesignerHost = _DesignSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;
            DesignerHost.AddService(typeof(IToolboxService), _ToolboxControl.ToolboxService);
            //DesignerHost.AddService( typeof( IPropertyValueUIService ), new GlyphService() );

            SelectionService = _DesignSurface.GetService(typeof(ISelectionService)) as ISelectionService;
            SelectionService.SelectionChanged += OnDesignerSurfaceView_SelectionChanged;

            // Initialise the DesignSurface class
            _DesignSurface.BeginLoad(typeof(RootDesignedComponent));
        }
Esempio n. 5
0
        /// <summary>
        /// Parses a source code and creates a new design surface.
        /// </summary>
        /// <param name="serviceContainer"></param>
        /// <param name="surfaceManager"></param>
        /// <param name="file">The source file to deserialize.</param>
        /// <returns></returns>
        public DesignSurface Deserialize(DesignSurfaceManager surfaceManager, IServiceContainer serviceContainer, OpenedFile file)
        {
            DesignSurface surface      = surfaceManager.CreateDesignSurface(serviceContainer);
            IDesignerHost designerHost = surface.GetService(typeof(IDesignerHost)) as IDesignerHost;

            Type componentType = CompileTypeFromFile(file);

            // load base type.
            surface.BeginLoad(componentType.BaseType);

            // get instance to copy components and properties from.
            Control instance = Activator.CreateInstance(componentType) as Control;

            // add components
            var components = CreateComponents(componentType, instance, designerHost);

            InitializeComponents(components, designerHost);

            Control rootControl = designerHost.RootComponent as Control;

            Control parent = rootControl.Parent;
            ISite   site   = rootControl.Site;

            // copy instance properties to root control.
            CopyProperties(instance, designerHost.RootComponent);

            rootControl.AllowDrop = true;
            rootControl.Parent    = parent;
            rootControl.Visible   = true;
            rootControl.Site      = site;
            designerHost.RootComponent.Site.Name = instance.Name;
            return(surface);
        }
Esempio n. 6
0
        public void DesignSurface_BeginLoad_Disposed_ThrowsObjectDisposedException()
        {
            var surface = new DesignSurface();

            surface.Dispose();
            var mockLoader = new Mock <DesignerLoader>(MockBehavior.Strict);

            Assert.Throws <ObjectDisposedException>(() => surface.BeginLoad(mockLoader.Object));
        }
        public void LoadWorkflow(string xoml, string ruleSetXml)
        {
            SuspendLayout();

            DesignSurface  designSurface = new DesignSurface();
            WorkflowLoader loader        = new WorkflowLoader();

            loader.RuleSetXml = ruleSetXml;
            loader.Xoml       = xoml;
            designSurface.BeginLoad(loader);

            IDesignerHost designerHost = designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (designerHost != null && designerHost.RootComponent != null)
            {
                IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;
                if (rootDesigner != null)
                {
                    UnloadWorkflow();

                    this.designSurface = designSurface;
                    this.loader        = loader;
                    this.workflowView  = rootDesigner.GetView(ViewTechnology.Default) as WorkflowView;
                    this.workflowViewSplitter.Panel2.Controls.Add(this.workflowView);
                    this.workflowView.Dock               = DockStyle.Fill;
                    this.workflowView.TabIndex           = 1;
                    this.workflowView.TabStop            = true;
                    this.workflowView.HScrollBar.TabStop = false;
                    this.workflowView.VScrollBar.TabStop = false;
                    this.workflowView.Focus();
                    this.propertyGrid.Site = designerHost.RootComponent.Site;

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

            ResumeLayout(true);

            //Add the code compile unit for the xaml file
            TypeProvider typeProvider = (TypeProvider)GetService(typeof(ITypeProvider));

            this.loader.XamlCodeCompileUnit = new CodeCompileUnit();
            this.loader.XamlCodeCompileUnit.Namespaces.Add(Helpers.GenerateCodeFromXomlDocument(Helpers.GetRootActivity(xoml), this, ref this.nameSpace, ref this.typeName));
            typeProvider.AddCodeCompileUnit(this.loader.XamlCodeCompileUnit);

            this.loader.CodeBesideCCU = new CodeCompileUnit();
            this.loader.CodeBesideCCU.Namespaces.Add(Helpers.GenerateCodeBeside(Helpers.GetRootActivity(xoml), this));
            typeProvider.AddCodeCompileUnit(this.loader.CodeBesideCCU);
        }
Esempio n. 8
0
        public Control GetControl()
        {
            ServiceContainer serviceContainer = new ServiceContainer();

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IDesignerEventService), new DesignerEventService());
            serviceContainer.AddService(typeof(System.ComponentModel.Design.Serialization.INameCreationService), new NameCreationService());
            _toolboxService = new CustomToolboxService();
            serviceContainer.AddService(typeof(IToolboxService), _toolboxService);

            DesignSurface surface = new DesignSurface(serviceContainer);

            _host = (IDesignerHost)surface.GetService(typeof(IDesignerHost));

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), new Services.EventBindingService(surface));

            _menuCommandService = new MenuCommandService(surface);
            serviceContainer.AddService(typeof(IMenuCommandService), _menuCommandService);

            //surface.BeginLoad(typeof(Form));
            _CodeDomHostLoader = new Loader.CodeDomHostLoader();
            surface.BeginLoad(_CodeDomHostLoader);

            Control designerContorl = (Control)surface.View;


            designerContorl.BackColor = Color.Aqua;
            designerContorl.Dock      = DockStyle.Fill;
            //获取root组件
            var designerHost = (IDesignerHost)this._host;

            if (designerHost != null)
            {
                rootComponent = (Form)designerHost.RootComponent;
            }

            rootComponent.FormBorderStyle = FormBorderStyle.None;

            #region 初始化窗体大小

            //- set the Size
            PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(designerContorl);
            //- Sets a PropertyDescriptor to the specific property.
            PropertyDescriptor pdS = pdc.Find("Size", false);
            if (null != pdS)
            {
                pdS.SetValue(_host.RootComponent, new Size(800, 480));
            }
            #endregion

            return(designerContorl);
        }
Esempio n. 9
0
        /// <summary>
        /// Creates the workflow view.
        /// </summary>
        /// <param name="workflow">The workflow.</param>
        /// <returns></returns>
        public static WorkflowView CreateWorkflowView(Activity workflow)
        {
            if (workflow == null)
            {
                throw new ArgumentNullException("workflow");
            }

            WorkflowLoader loader = new WorkflowLoader(workflow);

            DesignSurface surface = new DesignSurface();

            surface.BeginLoad(loader);

            WorkflowView retVal = new WorkflowView(surface);

            return(retVal);
        }
        public void InitializeDesignSurface(Type rootControlType)
        {
            if (_surface == null)
            {
                _mainView = new TestForm();
#if NET_2_0
                _surface = new DesignSurface();
                _surface.BeginLoad(rootControlType);
                _mainView.Controls.Add((Control)_surface.View);
#else
                _surface = new Mono.Design.Test.DesignerHost();
                Control rootControl = (Control)Activator.CreateInstance(rootControlType, BindingFlags.CreateInstance | BindingFlags.Public
                                                                        | BindingFlags.Instance, null, null, null);
                _surface.Add(rootControl, null);
                _mainView.Controls.Add(rootControl);
#endif
                _mainView.Controls[0].Visible = true;
                _mainView.Show();
            }
        }
Esempio n. 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);
        }
Esempio n. 12
0
        /// <summary>
        /// Parse:分析文本或其他永久存储区并返回 CodeCompileUnit。
        /// 当 CodeDomDesignerLoader 需要分析源代码时,会调用 Parse 方法。
        /// 必须通过派生类指定源代码的位置和格式。
        /// 在设计器中装载Form,并对当前设计根组件进行命名。
        /// </summary>
        /// 返回值:从分析操作生成的 CodeCompileUnit。
        /// <returns></returns>
        protected override CodeCompileUnit Parse()
        {
            CodeCompileUnit compileUnit   = null;
            DesignSurface   designSurface = new DesignSurface();

            designSurface.BeginLoad(typeof(CassView));

            IDesignerHost designerHost = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));

            designerHost.RootComponent.Site.Name = currentForm;

            compileUnit = GetCodeCompileUnit(designerHost);

            AssemblyName[] names = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
            for (int i = 0; i < names.Length; i++)
            {
                Assembly assembly = Assembly.Load(names[i]);
                compileUnit.ReferencedAssemblies.Add(assembly.Location);
            }

            codeCompileUnit = compileUnit;
            return(compileUnit);
        }
Esempio n. 13
0
        /// <summary>
        /// Bootstrap method - loads a blank Form
        /// </summary>
        /// <returns></returns>
        protected override CodeCompileUnit Parse()
        {
            if (formFile == null)
            {
                CodeCompileUnit ccu = null;

                DesignSurface ds = new DesignSurface();
                ds.BeginLoad(typeof(Form));
                IDesignerHost idh = (IDesignerHost)ds.GetService(typeof(IDesignerHost));
                idh.RootComponent.Site.Name = GetNextFormName();

                cg  = new CodeGen();
                ccu = cg.GetCodeCompileUnit(idh);

                AssemblyName[] names = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
                for (int i = 0; i < names.Length; i++)
                {
                    Assembly assembly = Assembly.Load(names[i]);
                    ccu.ReferencedAssemblies.Add(assembly.Location);
                }

                codeCompileUnit = ccu;
                Designer        = ds;
                codeCompileUnit = ccu;
                return(ccu);
            }
            else
            {
                FileStream      fs        = new FileStream(formFile, FileMode.Open);
                BinaryFormatter formatter = new BinaryFormatter();
                CodeCompileUnit ccu       = (CodeCompileUnit)formatter.Deserialize(fs);
                fs.Close();
                codeCompileUnit = ccu;
                return(ccu);
            }
        }
Esempio n. 14
0
        private void LoadWorkflow()
        {
            SuspendLayout();

            DesignSurface  designSurface = new DesignSurface();
            WorkflowLoader loader        = new WorkflowLoader();

            loader.WorkflowType = workflowTypeValue;
            loader.Xaml         = xamlValue;
            designSurface.BeginLoad(loader);

            IDesignerHost designerHost = designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (designerHost != null && designerHost.RootComponent != null)
            {
                IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;
                if (rootDesigner != null)
                {
                    UnloadWorkflow();

                    this.designSurface = designSurface;
                    this.loader        = loader;
                    this.workflowView  = rootDesigner.GetView(ViewTechnology.Default) as WorkflowView;
                    this.panel1.Controls.Add(this.workflowView);
                    this.workflowView.Dock               = DockStyle.Fill;
                    this.workflowView.TabIndex           = 1;
                    this.workflowView.TabStop            = true;
                    this.workflowView.HScrollBar.TabStop = false;
                    this.workflowView.VScrollBar.TabStop = false;
                    this.workflowView.Focus();
                    this.workflowView.FitToScreenSize();
                }
            }

            ResumeLayout(true);
        }
        public ComponentDesigner(Type componentType)
        {
            originalComponentType = componentType;

            surfaceManager = new DesignSurfaceManager();
            surface        = surfaceManager.CreateDesignSurface();

            surface.BeginLoad(componentType);


            this._serviceProvider = surface;
            componentInDesign     = DesignerHost.RootComponent;


            NameCreationService _nameCreationService = new NameCreationService();

            if (_nameCreationService != null)
            {
                this.DesignerHost.RemoveService(typeof(INameCreationService), false);
                this.DesignerHost.AddService(typeof(INameCreationService), _nameCreationService);
            }

            try
            {
                MethodInfo m = componentInDesign.GetType().GetMethod(InvokeInitMethod);

                if (m != null)
                {
                    m.Invoke(componentInDesign, new object[] { });
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 窗体初始化
        /// </summary>
        void CustomInitialize()
        {
            #region 添加ToolBox

            string fileName = Application.StartupPath + @"\..\data\SharpDevelopControlLibrary.xml";
            ComponentLibraryLoader componentLibraryLoader = new ComponentLibraryLoader();
            componentLibraryLoader.LoadToolComponentLibrary(fileName);

            Guanjinke.Windows.Forms.ToolBox toolBox = new Guanjinke.Windows.Forms.ToolBox {
                Dock = DockStyle.Fill
            };

            foreach (Category category in componentLibraryLoader.Categories)
            {
                if (category.IsEnabled)
                {
                    Guanjinke.Windows.Forms.ToolBoxCategory cate = new Guanjinke.Windows.Forms.ToolBoxCategory();
                    cate.ImageIndex = -1;
                    cate.IsOpen     = false;
                    cate.Name       = category.Name;
                    cate.Parent     = null;

                    Guanjinke.Windows.Forms.ToolBoxItem item = new Guanjinke.Windows.Forms.ToolBoxItem();
                    item.Tag    = null;
                    item.Name   = "<Pointer>";
                    item.Parent = null;
                    cate.Items.Add(item);

                    foreach (ToolComponent component in category.ToolComponents)
                    {
                        item = new Guanjinke.Windows.Forms.ToolBoxItem();

                        System.Drawing.Design.ToolboxItem toolboxItem = new System.Drawing.Design.ToolboxItem();
                        toolboxItem.TypeName    = component.FullName;
                        toolboxItem.Bitmap      = componentLibraryLoader.GetIcon(component);
                        toolboxItem.DisplayName = component.Name;
                        Assembly asm = component.LoadAssembly();
                        toolboxItem.AssemblyName = asm.GetName();

                        item.Image  = toolboxItem.Bitmap;
                        item.Tag    = toolboxItem;
                        item.Name   = component.Name;
                        item.Parent = null;

                        cate.Items.Add(item);
                    }

                    toolBox.Categories.Add(cate);
                }
            }

            pnlToolBox.Controls.Add(toolBox);//左边panel添加控件

            #endregion

            #region 添加PropertyPad

            _propertyGrid = new PropertyGrid {
                Dock = DockStyle.Fill
            };
            pnlPropertyGrid.Controls.Add(_propertyGrid);//右边属性表

            #endregion


            #region 添加 "服务" 、 "设计器" 及 "Code"窗口

            ServiceContainer serviceContainer = new ServiceContainer();
            serviceContainer.AddService(typeof(System.ComponentModel.Design.IDesignerEventService), new DesignerEventService());
            serviceContainer.AddService(typeof(System.ComponentModel.Design.Serialization.INameCreationService), new NameCreationService());
            _toolboxService = new CustomToolboxService();
            serviceContainer.AddService(typeof(IToolboxService), _toolboxService);

            DesignSurface surface = new DesignSurface(serviceContainer);
            _host = (IDesignerHost)surface.GetService(typeof(IDesignerHost));

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), new ICSharpCode.FormsDesigner.Services.EventBindingService(surface));

            _menuCommandService = new MenuCommandService(surface);
            serviceContainer.AddService(typeof(IMenuCommandService), _menuCommandService);

            //surface.BeginLoad(typeof(Form));
            _CodeDomHostLoader = new Loader.CodeDomHostLoader();
            surface.BeginLoad(_CodeDomHostLoader);

            Control designerContorl = (Control)surface.View;


            designerContorl.BackColor = Color.Aqua;
            designerContorl.Dock      = DockStyle.Fill;
            //获取root组件
            rootComponent = (Form)((IDesignerHost)this._host).RootComponent;

            rootComponent.FormBorderStyle = FormBorderStyle.None;


            #region 初始化窗体大小

            //- set the Size
            PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(designerContorl);
            //- Sets a PropertyDescriptor to the specific property.
            PropertyDescriptor pdS = pdc.Find("Size", false);
            if (null != pdS)
            {
                pdS.SetValue(_host.RootComponent, new Size(800, 480));
            }
            #endregion

            tpDesign.Controls.Add(designerContorl);//窗体


            _textEditor = new TextEditorControl
            {
                IsReadOnly = true,
                Dock       = DockStyle.Fill,
                Document   = { HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("C#") }
            }; //代码编辑器
            tpCode.Controls.Add(_textEditor);

            #endregion

            _propertyGrid.SelectedObject = surface.ComponentContainer.Components[0];
            SetAlignMenuEnabled(false);


            _propertyGrid.Site = (new IDEContainer(_host)).CreateSite(_propertyGrid);
            _propertyGrid.PropertyTabs.AddTabType(typeof(System.Windows.Forms.Design.EventsTab), PropertyTabScope.Document);

            #region 事件响应

            // 选中项改变时的事件
            _selectionService = surface.GetService(typeof(ISelectionService)) as ISelectionService;//获取surface中的SelectionService
            _selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);

            // 增/删/重命名组件的事件
            IComponentChangeService componentChangeService = (IComponentChangeService)surface.GetService(typeof(IComponentChangeService));
            componentChangeService.ComponentAdded   += ComponentListChanged;
            componentChangeService.ComponentRemoved += ComponentListChanged;
            componentChangeService.ComponentRename  += ComponentListChanged;
            _host.TransactionClosed += new DesignerTransactionCloseEventHandler(TransactionClosed);

            // 选中不同的工具条项目
            toolBox.SelectedItemChanged += delegate(object sender, Guanjinke.Windows.Forms.ToolBoxItem newItem)
            {
                _toolboxService.SetSelectedToolboxItem(newItem.Tag as System.Drawing.Design.ToolboxItem);
            };

            // 双击工具栏项目时增加到设计器中
            toolBox.ItemDoubleClicked += delegate(object sender, Guanjinke.Windows.Forms.ToolBoxItem newItem)
            {
                System.Drawing.Design.ToolboxItem toolboxItem = newItem.Tag as System.Drawing.Design.ToolboxItem;
                if (null != toolboxItem)
                {
                    IToolboxUser toolboxUser = _host.GetDesigner(_host.RootComponent as IComponent) as IToolboxUser;
                    if (null != toolboxUser)
                    {
                        toolboxUser.ToolPicked(toolboxItem);
                    }
                }
            };

            // 拖动工具栏项目的支持代码
            toolBox.ItemDragStart += delegate(object sender, Guanjinke.Windows.Forms.ToolBoxItem newItem)
            {
                System.Drawing.Design.ToolboxItem toolboxItem = newItem.Tag as System.Drawing.Design.ToolboxItem;
                if (null != toolboxItem)
                {
                    DataObject dataObject = ((IToolboxService)_toolboxService).SerializeToolboxItem(toolboxItem) as DataObject;
                    toolBox.DoDragDrop(dataObject, DragDropEffects.Copy);
                }
            };

            _toolboxService.ResetToolboxItem += delegate
            {
                toolBox.ResetSelection();
            };


            #endregion

            tsmiDelete.ShortcutKeys    = Keys.Delete;
            tsmiSelectAll.ShortcutKeys = Keys.Control | Keys.A;

            cmbControls.Sorted    = true;
            cmbControls.DrawMode  = DrawMode.OwnerDrawFixed;
            cmbControls.DrawItem += new DrawItemEventHandler(cmbControls_DrawItem);
            UpdateComboBox();

            #region 串口加载

            foreach (string com in System.IO.Ports.SerialPort.GetPortNames())
            {
                this.comPortName.Items.Add(com);
            }
            comParity.SelectedIndex = 0;
            if (comPortName.Items.Count > 0)
            {
                comPortName.SelectedIndex = 0;
            }

            #endregion
        }
Esempio n. 17
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");
        }
Esempio n. 18
0
        private void InitializeRunner()
        {
            StartGuiThread();
            RunMWFThread();
            while (_mwfContainer == null)
            {
            }
            while (!_mwfContainer.IsHandleCreated)
            {
            }                                                      // wait for the mwf handle


            // Hopefully by the time LoadGui is done the MWF Application.Run
            // will be done with whatever it's doing, because else strange things
            // might happen.
            Gtk.Application.Invoke(delegate {
                InitializeGTK();
            });
            while (_gtkContainer == null)
            {
            }
            while (_gtkContainer.Handle == IntPtr.Zero)
            {
            }                                                           // wait for the gtk handle

            bool parented = false;

            Gtk.Application.Invoke(delegate {
                Gdk.Window window = Gdk.Window.ForeignNew((uint)_mwfContainer.Handle);
                window.Reparent(_gtkContainer.GdkWindow, 0, 0);
                parented = true;
            });
            while (!parented)
            {
            }

            EventHandler loadSurfaceDelegate = delegate {
                DesignSurface surface = new DesignSurface();
                ((IServiceContainer)surface.GetService(typeof(IServiceContainer))).AddService(typeof(ITypeResolutionService),
                                                                                              new TypeResolutionService());
                surface.BeginLoad(new MDDesignerLoader(_designerFile));
                if (surface.IsLoaded)
                {
                    _mwfContainer.Controls.Add((Control)surface.View);
                    _mwfContainer.Refresh();
                }
            };

            _mwfContainer.Invoke(loadSurfaceDelegate);

            _gtkContainer.SizeAllocated += delegate(object o, SizeAllocatedArgs args) {
                EventHandler resizeDelegate = delegate {
                    _mwfContainer.Width  = args.Allocation.Width;
                    _mwfContainer.Height = args.Allocation.Height;
                };
                _mwfContainer.Invoke(resizeDelegate);
            };

            EventHandler resizeNow = delegate {
                _mwfContainer.Width  = _gtkContainer.Allocation.Width;
                _mwfContainer.Height = _gtkContainer.Allocation.Height;
            };

            _mwfContainer.Invoke(resizeNow);
        }
Esempio n. 19
0
        /// <summary>
        /// InitDesigner
        /// </summary>
        /// <param name="formId"></param>
        /// <param name="version"></param>
        void InitDesigner(int formId, int version)
        {
            if (this.isSelected)
            {
                return;
            }
            this.Loading = true;
            try
            {
                SuspendLayoutUc();
                this.Cursor   = Cursors.WaitCursor;
                designSurface = new DesignSurface();
                this.pnlDesignPanel.Controls.Clear();

                //服务容器
                IServiceContainer serviceContainer = designSurface.GetService(typeof(IServiceContainer)) as IServiceContainer;

                idh = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                _KeyStrokeMessageFilter.SetHostAndMDIForm(idh, designSurface);

                //工具箱服务
                this.toolboxServiceXtraTree.host = idh;
                serviceContainer.AddService(typeof(IToolboxService), this.toolboxServiceXtraTree);
                PopulateToolbox(this.toolboxServiceXtraTree);
                this.toolboxServiceXtraTree.designPanel = this.pnlDesignPanel;

                //菜单命令服务
                menuService = new MenuCommandServiceImpl(serviceContainer);
                serviceContainer.AddService(typeof(IMenuCommandService), menuService);

                //命名服务
                serviceContainer.AddService(typeof(INameCreationService), new NameCreationService(idh));

                //控件序列化反序列化服务
                serviceContainer.AddService(typeof(IDesignerSerializationService), new DesignerSerializationServiceForm(idh));
                //获取控件信息
                EntityFormDesign formVo = new EntityFormDesign();

                if (formId > 0)
                {
                    this.IsExists = true;
                    ProxyFormDesign proxy = new ProxyFormDesign();
                    proxy.Service.GetForm(formId, version, out formVo);
                    proxy = null;
                    this.PrintTemplateId = formVo.Printtemplateid;
                }
                if (formVo != null && formVo.Formid > 0)
                {
                    SetMainInfo(formVo);
                    if (!string.IsNullOrEmpty(formVo.Layout))
                    {
                        formCtrlData = FormTool.Entities(formVo.Layout);
                    }
                }
                else
                {
                    this.cboEfStatus.SelectedIndex = 1;
                    this.pnlDesignPanel.Height     = this.Height - 80;
                }

                if ((this.FormType > 2 && formId <= 0 && (formVo == null || string.IsNullOrEmpty(formVo.Layout))))
                {
                    this.txtEfCode.Properties.ReadOnly = true;
                    this.txtEfName.Properties.ReadOnly = true;
                }
                if (this.FormType > 2)
                {
                    this.cboVersion.Text = "1";
                    this.cboVersion.Properties.ReadOnly  = true;
                    this.cboEfStatus.SelectedIndex       = 1;
                    this.cboEfStatus.Properties.ReadOnly = true;
                }
                if (this.FormType > 10)
                {
                    this.txtEfCode.Properties.ReadOnly = true;
                    this.txtEfName.Properties.ReadOnly = true;
                    this.cboVersion.Text = "1";
                    this.cboVersion.Properties.ReadOnly  = true;
                    this.cboEfStatus.SelectedIndex       = 1;
                    this.cboEfStatus.Properties.ReadOnly = true;
                }
                //if (this.TemplateMainVo != null)
                //{
                //    this.txtEfCode.Text = this.TemplateMainVo.templateCode;
                //    this.txtEfName.Text = this.TemplateMainVo.templateName;
                //}
                if (this.txtEfCode.Text.Trim() == string.Empty)
                {
                    this.txtEfCode.Text = DateTime.Now.ToString("yyMMddHHmm");
                }
                loader            = new DesignLoaderForm(idh, formCtrlData);
                loader.InitWidth  = this.pnlDesignPanel.Width - 30;
                loader.InitHeight = this.pnlDesignPanel.Height - 30;
                loader.FormFlag   = true;

                //绑定事件
                loader.ComponentAdded   -= new ComponentEventHandler(loader_ComponentAdded);
                loader.ComponentAdded   += new ComponentEventHandler(loader_ComponentAdded);
                loader.ComponentChanged -= new ComponentChangedEventHandler(loader_ComponentChanged);
                loader.ComponentChanged += new ComponentChangedEventHandler(loader_ComponentChanged);
                loader.ComponentRemoved -= new ComponentEventHandler(loader_ComponentRemoved);
                loader.ComponentRemoved += new ComponentEventHandler(loader_ComponentRemoved);

                designSurface.BeginLoad(loader);

                Control ctrl = designSurface.View as Control;
                ctrl.Parent = pnlDesignPanel;
                ctrl.Dock   = DockStyle.Fill;

                ISelectionService selectionService = designSurface.GetService(typeof(ISelectionService)) as ISelectionService;
                selectionService.SelectionChanged -= new EventHandler(selectionService_SelectionChanged);
                selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);

                BehaviorService bhsvc = idh.GetService(typeof(BehaviorService)) as BehaviorService;

                //undo/redo服务
                serializationService = new ComponentSerializationServiceImpl(idh);
                serviceContainer.AddService(typeof(ComponentSerializationService), serializationService);
                undoEngine = new UndoEngineImpl(idh);
                serviceContainer.AddService(typeof(UndoEngine), undoEngine);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ResumeLayoutUc();
                Loading     = false;
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Finish the process of loading an existing
        /// or new workflow
        /// </summary>
        /// <returns></returns>
        private Boolean CommonWorkflowLoading()
        {
            Boolean result = false;

            //tell the designer to begin loading
            _designSurface.BeginLoad(_wfLoader);

            //retrieve the designer host
            IDesignerHost designer
                = _designSurface.GetService(typeof(IDesignerHost))
                  as IDesignerHost;

            if (designer == null || designer.RootComponent == null)
            {
                return(false);
            }

            IRootDesigner rootDesigner
                = designer.GetDesigner(designer.RootComponent)
                  as IRootDesigner;

            if (rootDesigner != null)
            {
                SuspendLayout();
                //get the default workflow view from the designer
                _workflowView = rootDesigner.GetView(
                    ViewTechnology.Default)
                                as WorkflowView;
                //add the workflow view to a panel for display
                splitContainer1.Panel2.Controls.Add(_workflowView);
                _workflowView.Dock = DockStyle.Fill;
                _workflowView.Focus();

                //link the propertyGrid with the designer
                propertyGrid1.Site = designer.RootComponent.Site;

                //setup the toolbar for the workflow using the one
                //constructed by the workflow loader
                IToolboxService toolboxService = designer.GetService(
                    typeof(IToolboxService)) as IToolboxService;
                if (toolboxService != null)
                {
                    if (toolboxService is Control)
                    {
                        //add the toolbox control to a panel
                        _toolboxControl = (Control)toolboxService;
                        splitContainer2.Panel1.Controls.Add(
                            _toolboxControl);
                    }
                }

                //get the ISelectionService from the workflow view
                //and add a handler for the SelectionChanged event
                ISelectionService selectionService
                    = ((IServiceProvider)_workflowView).GetService(
                          typeof(ISelectionService)) as ISelectionService;
                if (selectionService != null)
                {
                    selectionService.SelectionChanged += new EventHandler(
                        selectionService_SelectionChanged);
                }

                ResumeLayout();
                result = true;
            }
            return(result);
        }
Esempio n. 21
0
        protected override void OnBeginLoad()
        {
            CodeCompileUnit ccu = null;

            ds = new DesignSurface();
            ds.BeginLoad(typeof(Form));
            IDesignerHost idh = (IDesignerHost)ds.GetService(typeof(IDesignerHost));

            idh.RootComponent.Site.Name = "Form1";

            cg  = new CodeGen();
            ccu = cg.GetCodeCompileUnit(idh);

            AssemblyName[] names = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
            for (int i = 0; i < names.Length; i++)
            {
                Assembly assembly = Assembly.Load(names[i]);
                ccu.ReferencedAssemblies.Add(assembly.Location);
            }

            codeCompileUnit = ccu;

            this.host = this.LoaderHost;

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

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

                // 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 = 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;
            }
        }
Esempio n. 22
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();
        }
Esempio n. 23
0
        internal Guid pageGuid;//与model的编号对应



        public DesignWorkbench(string pageName)
        {
            InitializeComponent();
            AutoScaleMode = AutoScaleMode.Dpi;

            PageMoel pm = new PageMoel();

            _propertyGrid = new PropertyGrid {
                Dock = DockStyle.Fill
            };
            pm.propertyGrid = _propertyGrid;
            pm.PageName     = pageName;

            ServiceContainer serviceContainer = new ServiceContainer();

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IDesignerEventService), new DesignerEventService());
            serviceContainer.AddService(typeof(System.ComponentModel.Design.Serialization.INameCreationService), new NameCreationService());
            _toolboxService = new CustomToolboxService();
            serviceContainer.AddService(typeof(IToolboxService), _toolboxService);

            surface = new DesignSurface(serviceContainer);
            _host   = (IDesignerHost)surface.GetService(typeof(IDesignerHost));

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), new Services.EventBindingService(surface));

            _menuCommandService = new MenuCommandService(surface);
            serviceContainer.AddService(typeof(IMenuCommandService), _menuCommandService);

            //surface.BeginLoad(typeof(Form));
            _CodeDomHostLoader = new Loader.CodeDomHostLoader();
            surface.BeginLoad(_CodeDomHostLoader);

            Control designerContorl = (Control)surface.View;


            designerContorl.BackColor = Color.Aqua;
            designerContorl.Dock      = DockStyle.Fill;
            //获取root组件
            var designerHost = (IDesignerHost)this._host;

            if (designerHost != null)
            {
                rootComponent = (Form)designerHost.RootComponent;
            }

            rootComponent.FormBorderStyle = FormBorderStyle.None;

            #region 初始化窗体大小

            //- set the Size
            PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(designerContorl);
            //- Sets a PropertyDescriptor to the specific property.
            PropertyDescriptor pdS = pdc.Find("Size", false);
            if (null != pdS)
            {
                pdS.SetValue(_host.RootComponent, new Size(800, 480));
            }
            #endregion
            tpDesign.Controls.Add(designerContorl);//窗体

            _textEditor = new TextEditorControl
            {
                IsReadOnly = true,
                Dock       = DockStyle.Fill,
                Document   = { HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("C#") }
            }; //代码编辑器
            tpCode.Controls.Add(_textEditor);

            _propertyGrid.SelectedObject = surface.ComponentContainer.Components[0];
            _propertyGrid.Site           = (new IDEContainer(_host)).CreateSite(_propertyGrid);
            _propertyGrid.PropertyTabs.AddTabType(typeof(System.Windows.Forms.Design.EventsTab), PropertyTabScope.Document);


            pm.serviceContainer = serviceContainer;
            pm.surFace          = surface;
            pageGuid            = Guid.NewGuid();
            pm.PageGuid         = pageGuid;
            List <PageMoel> pages = GolableInstance.PageList();
            pages.Add(pm);


            //if (ChangeSur != null) ChangeSur();
        }
Esempio n. 24
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");
        }
Esempio n. 25
0
		private void InitializeRunner ()
		{
			StartGuiThread ();
			RunMWFThread ();
            while (_mwfContainer == null) {}
			while (!_mwfContainer.IsHandleCreated) { } // wait for the mwf handle


			// Hopefully by the time LoadGui is done the MWF Application.Run
			// will be done with whatever it's doing, because else strange things
			// might happen.
			Gtk.Application.Invoke (delegate { 
				InitializeGTK ();
			});
            while (_gtkContainer == null) {}
			while (_gtkContainer.Handle == IntPtr.Zero) { } // wait for the gtk handle

			bool parented = false;
			Gtk.Application.Invoke ( delegate { 
				Gdk.Window window = Gdk.Window.ForeignNew ((uint) _mwfContainer.Handle);
				window.Reparent (_gtkContainer.GdkWindow, 0, 0);
				parented = true;
			});
			while (!parented) { }

			EventHandler loadSurfaceDelegate = delegate {
				DesignSurface surface = new DesignSurface ();
				((IServiceContainer)surface.GetService (typeof (IServiceContainer))).AddService (typeof (ITypeResolutionService),
																								 new TypeResolutionService ());
				surface.BeginLoad (new MDDesignerLoader (_designerFile));
				if (surface.IsLoaded) {
					_mwfContainer.Controls.Add ((Control)surface.View);
					_mwfContainer.Refresh ();
				}
			};
			_mwfContainer.Invoke (loadSurfaceDelegate);

			_gtkContainer.SizeAllocated += delegate (object o, SizeAllocatedArgs args) {
				EventHandler resizeDelegate = delegate {
					_mwfContainer.Width = args.Allocation.Width;
					_mwfContainer.Height = args.Allocation.Height;
				};
				_mwfContainer.Invoke (resizeDelegate);
			};	

			EventHandler resizeNow = delegate {
				_mwfContainer.Width = _gtkContainer.Allocation.Width;
				_mwfContainer.Height = _gtkContainer.Allocation.Height;
			};
			_mwfContainer.Invoke (resizeNow);
		}
Esempio n. 26
0
        public void DesignSurface_BeginLoad_NullLoader_ThrowsArgumentNullException()
        {
            var surface = new DesignSurface();

            Assert.Throws <ArgumentNullException>("loader", () => surface.BeginLoad((DesignerLoader)null));
        }