public void SetUpFixture()
        {
            resourceWriter   = new MockResourceWriter();
            componentCreator = new MockComponentCreator();
            componentCreator.SetResourceWriter(resourceWriter);

            using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
                IDesignerHost        host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                IEventBindingService eventBindingService = new MockEventBindingService(host);
                host.AddService(typeof(IResourceService), componentCreator);

                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");

                // Set bitmap as form background image.
                bitmap = new Bitmap(10, 10);
                form.BackgroundImage = bitmap;

                icon      = new Icon(typeof(GenerateFormResourceTestFixture), "App.ico");
                form.Icon = icon;

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, "RootNamespace", 1);
                }
            }
        }
        public void SetUpFixture()
        {
            resourceWriter   = new MockResourceWriter();
            componentCreator = new MockComponentCreator();
            componentCreator.SetResourceWriter(resourceWriter);

            using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
                IDesignerHost        host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                IEventBindingService eventBindingService = new MockEventBindingService(host);
                host.AddService(typeof(IResourceService), componentCreator);

                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 ImageList.
                icon = new Icon(typeof(GenerateFormResourceTestFixture), "App.ico");
                ImageList imageList = (ImageList)host.CreateComponent(typeof(ImageList), "imageList1");
                imageList.Images.Add("App.ico", icon);
                imageList.Images.Add("", icon);
                imageList.Images.Add("", icon);

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    RubyCodeDomSerializer serializer = new RubyCodeDomSerializer("    ");
                    generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, "RootNamespace", 1);
                }
            }
        }
        public void SetUpFixture()
        {
            resourceWriter  = new MockResourceWriter();
            resourceService = new MockResourceService();
            resourceService.SetResourceWriter(resourceWriter);

            AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
            document        = textEditor.Document;
            textEditor.Text = GetTextEditorCode();

            RubyParser       parser          = new RubyParser();
            ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.rb", 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()) {
                    RubyDesignerGenerator generator = new RubyDesignerGenerator(new MockTextEditorOptions());
                    generator.Merge(host, new AvalonEditDocumentAdapter(document, null), compilationUnit, serializationManager);
                }
            }
        }
示例#4
0
 void CreateResourceService()
 {
     fakeReader      = new MockResourceReader();
     fakeWriter      = new MockResourceWriter();
     resourceService = new MockResourceService();
     resourceService.SetResourceReader(fakeReader);
     resourceService.SetResourceWriter(fakeWriter);
 }
        public void SetUpFixture()
        {
            resourceWriter   = new MockResourceWriter();
            componentCreator = new MockComponentCreator();
            componentCreator.SetResourceWriter(resourceWriter);

            resourceWriter2   = new MockResourceWriter();
            componentCreator2 = new MockComponentCreator();
            componentCreator2.SetResourceWriter(resourceWriter2);

            using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
                IDesignerHost        host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                IEventBindingService eventBindingService = new MockEventBindingService(host);
                host.AddService(typeof(IResourceService), componentCreator);

                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);
                bitmap              = new Bitmap(10, 10);
                pictureBox.Image    = bitmap;
                pictureBox.Size     = new Size(100, 120);
                pictureBox.TabIndex = 0;
                form.Controls.Add(pictureBox);

                // Add bitmap to form.
                form.BackgroundImage = new Bitmap(10, 10);

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
                }

                // Check that calling the GenerateInitializeComponentMethodBody also generates a resource file.
                host.RemoveService(typeof(IResourceService));
                host.AddService(typeof(IResourceService), componentCreator2);

                serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
                }
            }
        }
示例#6
0
        public void Init()
        {
            dummyReader     = new MockResourceReader();
            dummyWriter     = new MockResourceWriter();
            resourceService = new MockResourceService();
            resourceService.SetResourceReader(dummyReader);
            resourceService.SetResourceWriter(dummyWriter);
            host = new MockDesignerLoaderHost();
            host.AddService(typeof(IResourceService), resourceService);
            loader = new PythonDesignerLoader(new MockDesignerGenerator());
            loader.BeginLoad(host);

            reader = loader.GetResourceReader(CultureInfo.InvariantCulture) as MockResourceReader;
            writer = loader.GetResourceWriter(CultureInfo.InvariantCulture) as MockResourceWriter;
        }
示例#7
0
 void GetResourceWriter()
 {
     writer = loader.GetResourceWriter(CultureInfo.InvariantCulture) as MockResourceWriter;
 }