Exemple #1
0
        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);

                Button button = (Button)host.CreateComponent(typeof(Button), "button1");
                button.Location = new Point(0, 0);
                button.Size     = new Size(10, 10);
                button.Text     = "button1";
                button.UseCompatibleTextRendering = false;
                form.Controls.Add(button);

                PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
                PropertyDescriptor           acceptButtonPropertyDescriptor = descriptors.Find("AcceptButton", false);
                acceptButtonPropertyDescriptor.SetValue(form, button);

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

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    IScriptingCodeDomSerializer serializer = CreateSerializer();
                    generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
                }
            }
        }
Exemple #2
0
        public string GenerateMethodBody(IMethod method, IDesignerHost host, IDesignerSerializationManager serializationManager)
        {
            int    indent        = GetIndent(method);
            string rootNamespace = GetProjectRootNamespace(method.CompilationUnit);
            IScriptingCodeDomSerializer serializer = CreateCodeDomSerializer(textEditorOptions);

            return(serializer.GenerateInitializeComponentMethodBody(host, serializationManager, rootNamespace, indent));
        }
        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);
                form.AllowDrop  = false;
                form.Enabled    = false;

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

                PropertyDescriptor enabledPropertyDescriptor = descriptors.Find("Enabled", false);
                enabledPropertyDescriptor.SetValue(form, false);

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    IScriptingCodeDomSerializer serializer = CreateSerializer();
                    generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
                }
            }
        }
Exemple #4
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()) {
                    IScriptingCodeDomSerializer serializer = CreateSerializer();
                    generatedCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
                }
            }
        }