public void SetUpFixture()
        {
            MockTextEditorProperties textEditorProperties = new MockTextEditorProperties();

            generator       = new DerivedPythonDesignerGenerator();
            mockViewContent = new MockTextEditorViewContent();
            viewContent     = new FormsDesignerViewContent(mockViewContent, new MockOpenedFile("Test.py"));
            viewContent.DesignerCodeFileContent = GetTextEditorCode();
            generator.Attach(viewContent);
            viewContentAttached = generator.GetViewContent();

            ParseInformation parseInfo             = new ParseInformation();
            PythonParser     parser                = new PythonParser();
            ICompilationUnit parserCompilationUnit = parser.Parse(new DefaultProjectContent(), "Test.py", GetTextEditorCode());

            parseInfo.SetCompilationUnit(parserCompilationUnit);
            generator.ParseInfoToReturnFromParseFileMethod = parseInfo;

            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()) {
                    generator.MergeRootComponentChanges(host, serializationManager);
                    generator.Detach();
                }
            }
        }
        public void SetUpFixture()
        {
            textEditorOptions = new MockTextEditorOptions();
            generator         = new DerivedPythonDesignerGenerator(textEditorOptions);
            mockViewContent   = new MockTextEditorViewContent();
            viewContent       = new DerivedFormDesignerViewContent(mockViewContent, new MockOpenedFile(fileName));
            generator.Attach(viewContent);
            viewContent.DesignerCodeFileContent = GetTextEditorCode();

            PythonParser     parser = new PythonParser();
            ICompilationUnit parserCompilationUnit = parser.Parse(new DefaultProjectContent(), fileName, GetTextEditorCode());
            ParseInformation parseInfo             = new ParseInformation(parserCompilationUnit);

            generator.ParseInfoToReturnFromParseFileMethod = parseInfo;

            AfterSetUpFixture();
        }
示例#3
0
        public void SetUpFixture()
        {
            using (FormsDesignerViewContent viewContent = new FormsDesignerViewContent(null, new MockOpenedFile("Test.py"))) {
                viewContent.DesignerCodeFileContent = "class MainForm(Form):\r\n" +
                                                      " def __init__(self):\r\n" +
                                                      "  self.InitializeComponent()\r\n" +
                                                      "\r\n" +
                                                      " def InitializeComponent(self):\r\n" +
                                                      "  pass\r\n";

                document = viewContent.DesignerCodeFileDocument;

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

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

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

                    MockTextEditorProperties textEditorProperties = new MockTextEditorProperties();
                    textEditorProperties.ConvertTabsToSpaces = true;
                    textEditorProperties.IndentationSize     = 1;

                    DerivedPythonDesignerGenerator generator = new DerivedPythonDesignerGenerator(textEditorProperties);
                    generator.ParseInfoToReturnFromParseFileMethod = parseInfo;
                    generator.Attach(viewContent);
                    DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                    using (serializationManager.CreateSession()) {
                        generator.MergeRootComponentChanges(host, serializationManager);
                    }
                }
            }
        }
示例#4
0
        public void SetUpFixture()
        {
            DerivedPythonDesignerGenerator generator       = new DerivedPythonDesignerGenerator();
            MockTextEditorViewContent      mockViewContent = new MockTextEditorViewContent();
            DerivedFormDesignerViewContent viewContent     = new DerivedFormDesignerViewContent(mockViewContent, new MockOpenedFile("Test.py"));

            viewContent.DesignerCodeFileContent = GetTextEditorCode();

            // Create parse info.
            PythonParser     parser    = new PythonParser();
            ICompilationUnit unit      = parser.Parse(new MockProjectContent(), @"C:\Projects\MyProject\test.py", GetTextEditorCode());
            ParseInformation parseInfo = new ParseInformation();

            parseInfo.SetCompilationUnit(unit);
            generator.ParseInfoToReturnFromParseFileMethod = parseInfo;

            // Attach view content to generator.
            generator.Attach(viewContent);

            // Get compatible methods for event.
            MockEventDescriptor eventDescriptor = new MockEventDescriptor("Click");

            compatibleMethods = generator.GetCompatibleMethods(eventDescriptor);
        }