public void SetUpFixture() { resourceWriter = new MockResourceWriter(); resourceService = new MockResourceService(); resourceService.SetResourceWriter(resourceWriter); 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(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()) { AvalonEditDocumentAdapter adapter = new AvalonEditDocumentAdapter(document, null); MockTextEditorOptions options = new MockTextEditorOptions(); PythonDesignerGenerator generator = new PythonDesignerGenerator(options); generator.Merge(host, adapter, compilationUnit, serializationManager); } } }
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent, ITextEditorOptions textEditorOptions) { foreach (IViewContent existingView in viewContent.SecondaryViewContents) { if (existingView.GetType() == typeof(FormsDesignerViewContent)) { return new IViewContent[0]; } } IDesignerLoaderProvider loader = new PythonDesignerLoaderProvider(); IDesignerGenerator generator = new PythonDesignerGenerator(textEditorOptions); return new IViewContent[] { new FormsDesignerViewContent(viewContent, loader, generator) }; }
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent, ITextEditorProperties textEditorProperties) { foreach (IViewContent existingView in viewContent.SecondaryViewContents) { if (existingView.GetType() == typeof(FormsDesignerViewContent)) { return(new IViewContent[0]); } } IDesignerLoaderProvider loader = new PythonDesignerLoaderProvider(); IDesignerGenerator generator = new PythonDesignerGenerator(textEditorProperties); return(new IViewContent[] { new FormsDesignerViewContent(viewContent, loader, generator) }); }
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); } } }
public void Init() { MockTextEditorOptions options = new MockTextEditorOptions(); generator = new PythonDesignerGenerator(options); }
public void SetUpFixture() { provider = new PythonDesignerLoaderProvider(); generator = new PythonDesignerGenerator(null); }