Exemple #1
0
        public void SetUpFixture()
        {
            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");

                EventLog eventLog = (EventLog)host.CreateComponent(typeof(EventLog), "eventLog1");

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
                }
            }
        }
Exemple #2
0
        public void SetUpFixture()
        {
            using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
                IDesignerHost        host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                IEventBindingService eventBindingService = new MockEventBindingService(host);
                host.AddService(typeof(IEventBindingService), eventBindingService);

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

                Panel panel = (Panel)host.CreateComponent(typeof(Panel), "panel1");
                panel.Location = new Point(10, 15);
                panel.Anchor   = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                panel.TabIndex = 0;
                panel.Size     = new Size(100, 120);
                TextBox textBox = (TextBox)host.CreateComponent(typeof(TextBox), "textBox1");
                textBox.Location = new Point(5, 5);
                textBox.TabIndex = 0;
                textBox.Size     = new Size(110, 20);
                panel.Controls.Add(textBox);

                // Add an event handler to the panel to check that this code is generated
                // before the text box is initialized.
                EventDescriptorCollection events             = TypeDescriptor.GetEvents(panel);
                EventDescriptor           clickEvent         = events.Find("Click", false);
                PropertyDescriptor        clickEventProperty = eventBindingService.GetEventProperty(clickEvent);
                clickEventProperty.SetValue(panel, "Panel1Click");

                form.Controls.Add(panel);

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
                }
            }
        }
Exemple #3
0
        public void SetUpFixture()
        {
            using (DesignSurface designSurface = new DesignSurface(typeof(PublicToolTipDerivedForm))) {
                IDesignerHost            host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                IEventBindingService     eventBindingService = new MockEventBindingService(host);
                PublicToolTipDerivedForm form = (PublicToolTipDerivedForm)host.RootComponent;
                form.ClientSize = new Size(284, 264);

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

                form.toolTip.SetToolTip(form, "test");

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
                }
            }
        }
Exemple #4
0
        public void SetUpFixture()
        {
            using (DesignSurface designSurface = new DesignSurface(typeof(ProtectedPanelDerivedForm))) {
                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");

                // Move protected panel so we generate code for the new location.
                ProtectedPanelDerivedForm derivedForm = (ProtectedPanelDerivedForm)form;
                derivedForm.PanelLocation = new Point(10, 15);

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
                }
            }
        }
        public void SetUpFixture()
        {
            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");

                FolderBrowserDialog dialog = (FolderBrowserDialog)host.CreateComponent(typeof(FolderBrowserDialog), "folderBrowserDialog1");
                dialog.RootFolder = Environment.SpecialFolder.ApplicationData;

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
                }
            }
        }
Exemple #6
0
        public void SetUpFixture()
        {
            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           propertyDescriptor = descriptors.Find("Name", false);
                propertyDescriptor.SetValue(form, "MainForm");

                BackgroundWorker worker = (BackgroundWorker)host.CreateComponent(typeof(BackgroundWorker), "backgroundWorker1");
                descriptors        = TypeDescriptor.GetProperties(worker);
                propertyDescriptor = descriptors.Find("WorkerReportsProgress", false);
                propertyDescriptor.SetValue(worker, true);

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
                }
            }
        }
        public void SetUpFixture()
        {
            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 custom control
                CustomUserControl userControl = (CustomUserControl)host.CreateComponent(typeof(CustomUserControl), "userControl1");
                userControl.Location   = new Point(0, 0);
                userControl.ClientSize = new Size(200, 100);

                DesignerSerializationManager  designerSerializationManager = new DesignerSerializationManager(host);
                IDesignerSerializationManager serializationManager         = (IDesignerSerializationManager)designerSerializationManager;
                using (designerSerializationManager.CreateSession()) {
                    FooItem fooItem = (FooItem)serializationManager.CreateInstance(typeof(FooItem), new object[] { "aa" }, "fooItem1", false);
                    userControl.FooItems.Add(fooItem);
                    fooItem = (FooItem)serializationManager.CreateInstance(typeof(FooItem), new object[] { "bb" }, "fooItem2", false);
                    userControl.FooItems.Add(fooItem);

                    BarItem barItem = (BarItem)serializationManager.CreateInstance(typeof(BarItem), new object[] { "cc" }, "barItem1", false);
                    userControl.ParentComponent.ParentBarItems.Add(barItem);
                    barItem = (BarItem)serializationManager.CreateInstance(typeof(BarItem), new object[] { "dd" }, "barItem2", false);
                    userControl.ParentComponent.ParentBarItems.Add(barItem);
                    form.Controls.Add(userControl);

                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
                }
            }
        }
Exemple #8
0
        public void SetUpFixture()
        {
            using (DesignSurface designSurface = new DesignSurface(typeof(UserControl))) {
                IDesignerHost        host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                IEventBindingService eventBindingService = new MockEventBindingService(host);
                UserControl          userControl         = (UserControl)host.RootComponent;
                userControl.ClientSize = new Size(200, 300);

                NullPropertyUserControl control = (NullPropertyUserControl)host.CreateComponent(typeof(NullPropertyUserControl), "userControl1");
                control.Location = new Point(0, 0);
                control.Size     = new Size(10, 10);
                userControl.Controls.Add(control);

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

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
                }
            }
        }
Exemple #9
0
        public void SetUpFixture()
        {
            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");

                Panel panel1 = (Panel)host.CreateComponent(typeof(Panel), "panel1");
                panel1.Location = new Point(0, 0);
                panel1.TabIndex = 0;
                panel1.Size     = new Size(200, 220);

                Panel panel2 = (Panel)host.CreateComponent(typeof(Panel), "panel2");
                panel2.Location = new Point(10, 15);
                panel2.TabIndex = 0;
                panel2.Size     = new Size(100, 120);
                TextBox textBox = (TextBox)host.CreateComponent(typeof(TextBox), "textBox1");
                textBox.Location = new Point(5, 5);
                textBox.TabIndex = 0;
                textBox.Size     = new Size(110, 20);
                panel2.Controls.Add(textBox);

                panel1.Controls.Add(panel2);
                form.Controls.Add(panel1);

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