예제 #1
0
        public void ToolBoxItemButtonKeyDown(System.Windows.Forms.KeyEventArgs e, System.Drawing.Design.ToolboxItem toolboxItem)
        {
            if (toolboxItem == null)
            {
                return;
            }


            switch (e.KeyCode)
            {
            case Keys.Enter:
                if (DesignerHost == null)
                {
                    MessageBox.Show("idh Null");
                }

                IToolboxUser tbu = DesignerHost.GetDesigner(DesignerHost.RootComponent as IComponent) as IToolboxUser;

                if (tbu != null)
                {
                    // Enter means place the tool with default location and default size.
                    tbu.ToolPicked(toolboxItem);
                }
                break;

            default:
            {
                Console.WriteLine("Error: Not able to add");
                break;
            }
            }
        }
            private AccessibleObject GetDesignerAccessibleObject(Control.ControlAccessibleObject cao)
            {
                if (cao is null)
                {
                    return(null);
                }

                if (DesignerHost.GetDesigner(cao.Owner) is ControlDesigner ctlDesigner)
                {
                    return(ctlDesigner.AccessibilityObject);
                }

                return(null);
            }
예제 #3
0
        public void Initialise()
        {
            DispatchService.AssertGuiThread();
            System.Diagnostics.Trace.WriteLine("Loading document into DesignerHost");
            designerHost.LoadDocument();
            System.Diagnostics.Trace.WriteLine("Loaded document into DesignerHost");

            designerHost.Activate();
            System.Diagnostics.Trace.WriteLine("DesignerHost activated; getting designer view");

            IRootDesigner rootDesigner = (IRootDesigner)designerHost.GetDesigner(designerHost.RootComponent);

            designerView = (RootDesignerView)rootDesigner.GetView(ViewTechnology.Default);
//			designerView.Realized += delegate {
//				System.Diagnostics.Trace.WriteLine ("Designer view realized");
//			};
            designerView.Realized += new EventHandler(designerHost.RootDesignerView_Realized);
        }
예제 #4
0
        public void Initialise(string document, string fileName)
        {
            DispatchService.AssertGuiThread();

            System.Diagnostics.Trace.WriteLine("Loading document into DesignerHost");
            if (document != null)
            {
                host.Load(document, fileName);
            }
            else
            {
                host.NewFile();
            }
            System.Diagnostics.Trace.WriteLine("Loaded document into DesignerHost");

            host.Activate();
            System.Diagnostics.Trace.WriteLine("DesignerHost activated; getting designer view");

            IRootDesigner rootDesigner = (IRootDesigner)host.GetDesigner(host.RootComponent);

            designerView           = (RootDesignerView)rootDesigner.GetView(ViewTechnology.Passthrough);
            designerView.Realized += delegate { System.Diagnostics.Trace.WriteLine("Designer view realized"); };
        }
예제 #5
0
        // This is used to add a control to the design surface
        // when it was added to the object tree, this is not used
        // when the control is dragged directly to the design surface
        internal void AddControl(ObjectInfo objInfo, Control control)
        {
            // For some reason, property grid gets an error when
            // initially associated with the image panel, associated
            // it with another panel first.
            //if (control is PropertyGrid)
            //	ObjectBrowser._testPanel.Controls.Add(control);

            IDesigner    designer = null;
            DesignerHost host     = DesignerHost.Host;

            if (host.DesignMode)
            {
                host.AddingControls = true;
                designer            = host.GetDesigner(control, objInfo);
                if (designer != null)
                {
                    designer.Initialize(control);
                }

                // If no designer, can't add it to design surface
                if (designer != null)
                {
                    _designPanel.Controls.Add(control);
                }
                host.AddingControls = false;
            }
            else
            {
                _nonDesignPanel.Controls.Add(control);
            }


            // FIXME - Hack
            //if (control is PropertyGrid)
            //	designer.Initialize(control);
        }
예제 #6
0
        private void list_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            try
            {
                ListBox   lbSender           = sender as ListBox;
                Rectangle lastSelectedBounds = lbSender.GetItemRectangle(0);
                try
                {
                    lastSelectedBounds = lbSender.GetItemRectangle(selectedIndex);
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }

                switch (e.KeyCode)
                {
                case Keys.Up: if (selectedIndex > 0)
                    {
                        selectedIndex--;                                                 // change selection
                        lbSender.SelectedIndex = selectedIndex;
                        lbSender.Invalidate(lastSelectedBounds);                         // clear old highlight
                        lbSender.Invalidate(lbSender.GetItemRectangle(selectedIndex));   // add new one
                    }
                    break;

                case Keys.Down: if (selectedIndex + 1 < lbSender.Items.Count)
                    {
                        selectedIndex++;                                                         // change selection
                        lbSender.SelectedIndex = selectedIndex;
                        lbSender.Invalidate(lastSelectedBounds);                                 // clear old highlight
                        lbSender.Invalidate(lbSender.GetItemRectangle(selectedIndex));           // add new one
                    }
                    break;

                case Keys.Enter:
                    if (DesignerHost == null)
                    {
                        MessageBox.Show("idh Null");
                    }

                    IToolboxUser tbu = DesignerHost.GetDesigner(DesignerHost.RootComponent as IComponent) as IToolboxUser;

                    if (tbu != null)
                    {
                        // Enter means place the tool with default location and default size.
                        tbu.ToolPicked((System.Drawing.Design.ToolboxItem)(lbSender.Items[selectedIndex]));
                        lbSender.Invalidate(lastSelectedBounds);                                  // clear old highlight
                        lbSender.Invalidate(lbSender.GetItemRectangle(selectedIndex));            // add new one
                    }

                    break;

                default:
                {
                    Console.WriteLine("Error: Not able to add");
                    break;
                }
                }                 // switch
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #7
0
        static void Main()
        {
            #if TRACE
                System.Diagnostics.TextWriterTraceListener listener
                    = new System.Diagnostics.TextWriterTraceListener (System.Console.Out);
                System.Diagnostics.Trace.Listeners.Add (listener);
            #endif

            Application.Init ();

            #region Packing and layout

            Window window = new Window ("AspNetEdit Host Sample");
            window.SetDefaultSize (1000, 700);
            window.DeleteEvent += new DeleteEventHandler (window_DeleteEvent);

            VBox outerBox = new VBox ();
            window.Add (outerBox);

            HPaned leftBox = new HPaned ();
            outerBox.PackEnd (leftBox, true, true, 0);
            HPaned rightBox = new HPaned ();
            leftBox.Add2 (rightBox);

            geckoFrame = new Frame ();
            geckoFrame.Shadow = ShadowType.In;
            rightBox.Pack1 (geckoFrame, true, false);

            #endregion

            #region Toolbar

            // * Save/Open

            Toolbar buttons = new Toolbar ();
            outerBox.PackStart (buttons, false, false, 0);

            ToolButton saveButton = new ToolButton (Stock.Save);
            buttons.Add (saveButton);
            saveButton.Clicked += new EventHandler (saveButton_Clicked);

            ToolButton openButton = new ToolButton(Stock.Open);
            buttons.Add(openButton);
            openButton.Clicked += new EventHandler(openButton_Clicked);

            buttons.Add (new SeparatorToolItem());

            // * Clipboard

            ToolButton undoButton = new ToolButton (Stock.Undo);
            buttons.Add (undoButton);
            undoButton.Clicked +=new EventHandler (undoButton_Clicked);

            ToolButton redoButton = new ToolButton (Stock.Redo);
            buttons.Add (redoButton);
            redoButton.Clicked += new EventHandler (redoButton_Clicked);

            ToolButton cutButton = new ToolButton (Stock.Cut);
            buttons.Add (cutButton);
            cutButton.Clicked += new EventHandler (cutButton_Clicked);

            ToolButton copyButton = new ToolButton (Stock.Copy);
            buttons.Add (copyButton);
            copyButton.Clicked += new EventHandler (copyButton_Clicked);

            ToolButton pasteButton = new ToolButton (Stock.Paste);
            buttons.Add (pasteButton);
            pasteButton.Clicked += new EventHandler (pasteButton_Clicked);

            buttons.Add (new SeparatorToolItem());

            // * Text style

            ToolButton boldButton = new ToolButton (Stock.Bold);
            buttons.Add (boldButton);
            boldButton.Clicked += new EventHandler (boldButton_Clicked);

            ToolButton italicButton = new ToolButton (Stock.Italic);
            buttons.Add (italicButton);
            italicButton.Clicked += new EventHandler (italicButton_Clicked);

            ToolButton underlineButton = new ToolButton (Stock.Underline);
            buttons.Add (underlineButton);
            underlineButton.Clicked += new EventHandler (underlineButton_Clicked);

            ToolButton indentButton = new ToolButton (Stock.Indent);
            buttons.Add (indentButton);
            indentButton.Clicked += new EventHandler (indentButton_Clicked);

            ToolButton unindentButton = new ToolButton (Stock.Unindent);
            buttons.Add (unindentButton);
            unindentButton.Clicked += new EventHandler (unindentButton_Clicked);

            buttons.Add (new SeparatorToolItem());

            // * Toolbox

            ToolButton toolboxAddButton = new ToolButton (Stock.Add);
            buttons.Add (toolboxAddButton);
            toolboxAddButton.Clicked += new EventHandler (toolboxAddButton_Clicked);

            #endregion

            #region Designer services and host

            //set up the services
            ServiceContainer services = new ServiceContainer ();
            services.AddService (typeof (INameCreationService), new NameCreationService ());
            services.AddService (typeof (ISelectionService), new SelectionService ());
            services.AddService (typeof (IEventBindingService), new EventBindingService (window));
            services.AddService (typeof (ITypeResolutionService), new TypeResolutionService ());
            ExtenderListService extListServ = new AspNetEdit.Editor.ComponentModel.ExtenderListService ();
            services.AddService (typeof (IExtenderListService), extListServ);
            services.AddService (typeof (IExtenderProviderService), extListServ);
            services.AddService (typeof (ITypeDescriptorFilterService), new TypeDescriptorFilterService ());
            toolboxService = new ToolboxService ();
            services.AddService (typeof (IToolboxService), toolboxService);

            //create our host
            host = new DesignerHost(services);
            host.NewFile();
            host.Activate();

            #endregion

            #region Designer UI and panels

            IRootDesigner rootDesigner = (IRootDesigner) host.GetDesigner (host.RootComponent);
            RootDesignerView designerView = (RootDesignerView) rootDesigner.GetView (ViewTechnology.Passthrough);
            geckoFrame.Add (designerView);

            PropertyGrid p = new PropertyGrid (services);
            p.WidthRequest = 200;
            rightBox.Pack2 (p, false, false);

            Toolbox toolbox = new Toolbox (services);
            leftBox.Pack1 (toolbox, false, false);
            toolboxService.PopulateFromAssembly (System.Reflection.Assembly.GetAssembly (typeof (System.Web.UI.Control)));
            toolboxService.AddToolboxItem (new TextToolboxItem ("<table><tr><td></td><td></td></tr><tr><td></td><td></td></tr></table>", "Table"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<div style=\"width: 100px; height: 100px;\"></div>", "Div"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<hr />", "Horizontal Rule"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<select><option></option></select>", "Select"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<img src=\"\" />", "Image"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<textarea cols=\"20\" rows=\"2\"></textarea>", "Textarea"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"hidden\" />", "Input [Hidden]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"radio\" />", "Input [Radio]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"checkbox\" />", "Input [Checkbox]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"password\" />", "Input [Password]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"file\" />", "Input [File]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"text\" />", "Input [Text]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"submit\" value=\"submit\" />", "Input [Submit]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"reset\" value=\"reset\" />", "Input [Reset]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"button\" value=\"button\" />", "Input [Button]"), "Html");
            toolbox.Refresh ();

            #endregion

            window.ShowAll ();
            Application.Run ();
        }
예제 #8
0
        static void Main()
        {
                        #if TRACE
            System.Diagnostics.TextWriterTraceListener listener
                = new System.Diagnostics.TextWriterTraceListener(System.Console.Out);
            System.Diagnostics.Trace.Listeners.Add(listener);
                        #endif

            Application.Init();

            #region Packing and layout

            Window window = new Window("AspNetEdit Host Sample");
            window.SetDefaultSize(1000, 700);
            window.DeleteEvent += new DeleteEventHandler(window_DeleteEvent);

            VBox outerBox = new VBox();
            window.Add(outerBox);

            HPaned leftBox = new HPaned();
            outerBox.PackEnd(leftBox, true, true, 0);
            HPaned rightBox = new HPaned();
            leftBox.Add2(rightBox);

            geckoFrame        = new Frame();
            geckoFrame.Shadow = ShadowType.In;
            rightBox.Pack1(geckoFrame, true, false);

            #endregion

            #region Toolbar

            // * Save/Open

            Toolbar buttons = new Toolbar();
            outerBox.PackStart(buttons, false, false, 0);

            ToolButton saveButton = new ToolButton(Stock.Save);
            buttons.Add(saveButton);
            saveButton.Clicked += new EventHandler(saveButton_Clicked);

            ToolButton openButton = new ToolButton(Stock.Open);
            buttons.Add(openButton);
            openButton.Clicked += new EventHandler(openButton_Clicked);

            buttons.Add(new SeparatorToolItem());

            // * Clipboard

            ToolButton undoButton = new ToolButton(Stock.Undo);
            buttons.Add(undoButton);
            undoButton.Clicked += new EventHandler(undoButton_Clicked);

            ToolButton redoButton = new ToolButton(Stock.Redo);
            buttons.Add(redoButton);
            redoButton.Clicked += new EventHandler(redoButton_Clicked);

            ToolButton cutButton = new ToolButton(Stock.Cut);
            buttons.Add(cutButton);
            cutButton.Clicked += new EventHandler(cutButton_Clicked);

            ToolButton copyButton = new ToolButton(Stock.Copy);
            buttons.Add(copyButton);
            copyButton.Clicked += new EventHandler(copyButton_Clicked);

            ToolButton pasteButton = new ToolButton(Stock.Paste);
            buttons.Add(pasteButton);
            pasteButton.Clicked += new EventHandler(pasteButton_Clicked);

            buttons.Add(new SeparatorToolItem());

            // * Text style

            ToolButton boldButton = new ToolButton(Stock.Bold);
            buttons.Add(boldButton);
            boldButton.Clicked += new EventHandler(boldButton_Clicked);

            ToolButton italicButton = new ToolButton(Stock.Italic);
            buttons.Add(italicButton);
            italicButton.Clicked += new EventHandler(italicButton_Clicked);

            ToolButton underlineButton = new ToolButton(Stock.Underline);
            buttons.Add(underlineButton);
            underlineButton.Clicked += new EventHandler(underlineButton_Clicked);

            ToolButton indentButton = new ToolButton(Stock.Indent);
            buttons.Add(indentButton);
            indentButton.Clicked += new EventHandler(indentButton_Clicked);

            ToolButton unindentButton = new ToolButton(Stock.Unindent);
            buttons.Add(unindentButton);
            unindentButton.Clicked += new EventHandler(unindentButton_Clicked);

            buttons.Add(new SeparatorToolItem());

            // * Toolbox

            ToolButton toolboxAddButton = new ToolButton(Stock.Add);
            buttons.Add(toolboxAddButton);
            toolboxAddButton.Clicked += new EventHandler(toolboxAddButton_Clicked);

            #endregion

            #region Designer services and host

            //set up the services
            ServiceContainer services = new ServiceContainer();
            services.AddService(typeof(INameCreationService), new NameCreationService());
            services.AddService(typeof(ISelectionService), new SelectionService());
            services.AddService(typeof(IEventBindingService), new EventBindingService(window));
            services.AddService(typeof(ITypeResolutionService), new TypeResolutionService());
            ExtenderListService extListServ = new AspNetEdit.Editor.ComponentModel.ExtenderListService();
            services.AddService(typeof(IExtenderListService), extListServ);
            services.AddService(typeof(IExtenderProviderService), extListServ);
            services.AddService(typeof(ITypeDescriptorFilterService), new TypeDescriptorFilterService());
            toolboxService = new ToolboxService();
            services.AddService(typeof(IToolboxService), toolboxService);

            //create our host
            host = new DesignerHost(services);
            host.NewFile();
            host.Activate();

            #endregion

            #region Designer UI and panels

            IRootDesigner    rootDesigner = (IRootDesigner)host.GetDesigner(host.RootComponent);
            RootDesignerView designerView = (RootDesignerView)rootDesigner.GetView(ViewTechnology.Passthrough);
            geckoFrame.Add(designerView);

            PropertyGrid p = new PropertyGrid(services);
            p.WidthRequest = 200;
            rightBox.Pack2(p, false, false);

            Toolbox toolbox = new Toolbox(services);
            leftBox.Pack1(toolbox, false, false);
            toolboxService.PopulateFromAssembly(System.Reflection.Assembly.GetAssembly(typeof(System.Web.UI.Control)));
            toolboxService.AddToolboxItem(new TextToolboxItem("<table><tr><td></td><td></td></tr><tr><td></td><td></td></tr></table>", "Table"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<div style=\"width: 100px; height: 100px;\"></div>", "Div"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<hr />", "Horizontal Rule"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<select><option></option></select>", "Select"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<img src=\"\" />", "Image"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<textarea cols=\"20\" rows=\"2\"></textarea>", "Textarea"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<input type=\"hidden\" />", "Input [Hidden]"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<input type=\"radio\" />", "Input [Radio]"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<input type=\"checkbox\" />", "Input [Checkbox]"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<input type=\"password\" />", "Input [Password]"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<input type=\"file\" />", "Input [File]"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<input type=\"text\" />", "Input [Text]"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<input type=\"submit\" value=\"submit\" />", "Input [Submit]"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<input type=\"reset\" value=\"reset\" />", "Input [Reset]"), "Html");
            toolboxService.AddToolboxItem(new TextToolboxItem("<input type=\"button\" value=\"button\" />", "Input [Button]"), "Html");
            toolbox.Refresh();

            #endregion

            window.ShowAll();
            Application.Run();
        }
예제 #9
0
        /// <summary>
        /// Makes a association between an element and a native element class.
        /// </summary><remarks>
        /// In case of an already created object the object is returned instead of creating a new one.
        /// This class returns <see cref="System.Web.UI.Control">Control</see>, but all element classes internally
        /// used are using IElement, too. So in any case an internal HTML element object is being retrieved, it's
        /// possible to cast to IElement instead. In case of a plug-in this is not required, because plug-ins may handle
        /// their elements differently and such a cast is not appropriate. Consult the documentation of the plug-in to
        /// understand the requirements for object handling.
        /// </remarks>
        /// <param name="el">The element for that a native object is needed.</param>
        /// <returns>System.Web.UI.Control if creating or retrieving was successful, otherwise <c>null</c>. The caller is responsible to cast to the right class type.</returns>
        public Control CreateElement(Interop.IHTMLElement el)
        {
            if (el == null)
            {
                return(null);
            }

            Type    type    = null;
            Control element = null;
            // each element will be stored in a hashtable to increase performance, subsequent calls
            // to this factory will retrieve stored objects instead of creating new ones.
            string uniqueName;

            ((Interop.IHTMLUniqueName)el).uniqueID(out uniqueName);
            // look whether we have it already in the designer
            if (designerHost[uniqueName] is Control)
            {
                Control returnEl = designerHost[uniqueName] as Control;
                if (returnEl is IElement)
                {
                    ((IElement)returnEl).HtmlEditor = this.htmlEditor;
                }
                return(returnEl);
            }
            // if not, try plug-ins, and finally add
            try
            {
                // get tag name
                type = GetElementType(el);
                ConstructorInfo cinfo;
                if (type != null)
                {
                    // default ctor
                    cinfo = type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(Interop.IHTMLElement), typeof(IHtmlEditor) }, null);
                    // not found - get it from plug-in
                    if (cinfo == null)
                    {
                        // probably an plugin-driven control, plug-ins register their elements in designer host
                        foreach (IComponent icomp in designerHost.Container.Components)
                        {
                            IDesigner id = designerHost.GetDesigner(icomp);
                            if (id == null)
                            {
                                continue;
                            }
                            if (id is ControlDesigner)
                            {
                                IHtmlControlDesignerBehavior db = ((ControlDesigner)id).Behavior as IHtmlControlDesignerBehavior;
                                if (db != null && db.DesignTimeElement.Equals(el))
                                {
                                    element = icomp as Control;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        // usually, we get and invoke here
                        element = (Control)cinfo.Invoke(new object[] { el, htmlEditor });
                    }
                    // still not found, try other ctors plugins- could usually define
                    while (element == null)
                    {
                        //throw new NotSupportedException("Element " + ns + ":" + str1 + " not supported. Did you miss a registration?");
                        cinfo = type.GetConstructor(new Type[] { typeof(Interop.IHTMLElement), typeof(IHtmlEditor) });
                        if (cinfo != null)
                        {
                            element = (Control)cinfo.Invoke(new object[] { el, htmlEditor });
                            break;
                        }
                        cinfo = type.GetConstructor(new Type[] { typeof(IHtmlEditor) });
                        if (cinfo != null)
                        {
                            element = (Control)cinfo.Invoke(new object[] { htmlEditor });
                            break;
                        }
                        cinfo = type.GetConstructor(Type.EmptyTypes);
                        if (cinfo != null)
                        {
                            element = (Control)cinfo.Invoke(null);
                            break;
                        }
                    }
                }
            }
            catch
            {
                // whatever is goind wrong we don't care, returning null is "bad state" for caller
                //return null;
                throw;
            }
            finally
            {
                if (element != null)
                {
                    if (element is IElement)
                    {
                        ((IElement)element).HtmlEditor = this.htmlEditor;
                    }
                    // not there, then we add it
                    if (designerHost[uniqueName] == null)
                    {
                        designerHost.Add(element, uniqueName);
                        ((HtmlEditor)htmlEditor).OnElementCreated(element);
                    }
                }
            }
            return(element);
        }
예제 #10
0
        private void Initialize()
        {
            IDesignerHost host;
            Form form;
            IRootDesigner rootDesigner;
            Control view;

            // Initialise service container and designer host
            serviceContainer = new ServiceContainer();
            serviceContainer.AddService(typeof(INameCreationService), new NameCreationService());
            serviceContainer.AddService(typeof(IUIService), new UIService(this));
            host = new DesignerHost(serviceContainer);

            // Add toolbox service
            serviceContainer.AddService(typeof(IToolboxService), lstToolbox);
            lstToolbox.designPanel = pnlViewHost;
            PopulateToolbox(lstToolbox);

            // Add menu command service
            menuService = new MenuCommandService();
            serviceContainer.AddService(typeof(IMenuCommandService), menuService);

            // Start the designer host off with a Form to design
            form = (Form)host.CreateComponent(typeof(Form));
            form.TopLevel = false;
            form.Text = "Form1";

            // Get the root designer for the form and add its design view to this form
            rootDesigner = (IRootDesigner)host.GetDesigner(form);
            view = (Control)rootDesigner.GetView(ViewTechnology.WindowsForms);
            view.Dock = DockStyle.Fill;
            pnlViewHost.Controls.Add(view);

            // Subscribe to the selectionchanged event and activate the designer
            ISelectionService s = (ISelectionService)serviceContainer.GetService(typeof(ISelectionService));
            s.SelectionChanged += new EventHandler(OnSelectionChanged);
            host.Activate();
        }