Beispiel #1
0
        public void SetUpFixture()
        {
            resourceWriter  = new MockResourceWriter();
            resourceService = new MockResourceService();
            resourceService.SetResourceWriter(resourceWriter);

            using (TextEditorControl textEditor = new TextEditorControl()) {
                document        = textEditor.Document;
                textEditor.Text = GetTextEditorCode();

                PythonParser     parser          = new PythonParser();
                ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.py", document.TextContent);

                using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
                    IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                    Form          form = (Form)host.RootComponent;
                    form.ClientSize = new Size(499, 309);

                    PropertyDescriptorCollection descriptors            = TypeDescriptor.GetProperties(form);
                    PropertyDescriptor           namePropertyDescriptor = descriptors.Find("Name", false);
                    namePropertyDescriptor.SetValue(form, "MainForm");

                    DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                    using (serializationManager.CreateSession()) {
                        PythonDesignerGenerator.Merge(host, document, compilationUnit, new MockTextEditorProperties(), serializationManager);
                    }
                }
            }
        }
        public void SetUpFixture()
        {
            AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
            document        = textEditor.Document;
            textEditor.Text = GetTextEditorCode();

            PythonParser     parser          = new PythonParser();
            ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.py", document.Text);

            using (DesignSurface designSurface = new DesignSurface(typeof(UserControl))) {
                IDesignerHost host        = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                UserControl   userControl = (UserControl)host.RootComponent;
                userControl.ClientSize = new Size(489, 389);

                PropertyDescriptorCollection descriptors            = TypeDescriptor.GetProperties(userControl);
                PropertyDescriptor           namePropertyDescriptor = descriptors.Find("Name", false);
                namePropertyDescriptor.SetValue(userControl, "userControl1");

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    AvalonEditDocumentAdapter adapter   = new AvalonEditDocumentAdapter(document, null);
                    MockTextEditorOptions     options   = new MockTextEditorOptions();
                    PythonDesignerGenerator   generator = new PythonDesignerGenerator(options);
                    generator.Merge(host, adapter, compilationUnit, serializationManager);
                }
            }
        }
        public void SetUpFixture()
        {
            AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
            document        = textEditor.Document;
            textEditor.Text = GetTextEditorCode();

            PythonParser       parser         = new PythonParser();
            MockProjectContent projectContent = new MockProjectContent();
            MockProject        project        = new MockProject();

            project.RootNamespace  = "RootNamespace";
            projectContent.Project = project;
            ICompilationUnit compilationUnit = parser.Parse(projectContent, @"test.py", document.Text);

            using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
                IDesignerHost        host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                IEventBindingService eventBindingService = new MockEventBindingService(host);
                Form form = (Form)host.RootComponent;
                form.ClientSize = new Size(200, 300);

                PropertyDescriptorCollection descriptors            = TypeDescriptor.GetProperties(form);
                PropertyDescriptor           namePropertyDescriptor = descriptors.Find("Name", false);
                namePropertyDescriptor.SetValue(form, "MainForm");

                // Add picture box
                PictureBox pictureBox = (PictureBox)host.CreateComponent(typeof(PictureBox), "pictureBox1");
                pictureBox.Location = new Point(0, 0);
                pictureBox.Image    = new Bitmap(10, 10);
                pictureBox.Size     = new Size(100, 120);
                pictureBox.TabIndex = 0;
                form.Controls.Add(pictureBox);

                MockTextEditorOptions options = new MockTextEditorOptions();
                options.ConvertTabsToSpaces = true;
                options.IndentationSize     = 4;

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    AvalonEditDocumentAdapter adapter   = new AvalonEditDocumentAdapter(document, null);
                    PythonDesignerGenerator   generator = new PythonDesignerGenerator(options);
                    generator.Merge(host, adapter, compilationUnit, serializationManager);
                }
            }
        }