Esempio n. 1
0
        private void Initialize()
        {
            // 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.Default);//.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();
        }
Esempio n. 2
0
 public void SetDesigner(IRootDesigner document)
 {
     if (this.designerView != null)
     {
         base.Controls.Clear();
         this.designerView.Dispose();
         this.designerView = null;
     }
     if (document != null)
     {
         ViewTechnology[] technologies        = document.SupportedTechnologies;
         bool             supportedTechnology = false;
         foreach (ViewTechnology tech in technologies)
         {
             if (tech == ViewTechnology.WindowsForms)
             {
                 {
                     this.designerView      = (Control)document.GetView(ViewTechnology.WindowsForms);
                     this.designerView.Dock = DockStyle.Fill;
                     base.Controls.Add(this.designerView);
                     supportedTechnology = true;
                 }
             }
             if (supportedTechnology)
             {
                 break;
             }
         }
         if (!supportedTechnology)
         {
             throw new Exception("Unsupported Technology " + this.designerHost.RootComponent.GetType().FullName);
         }
     }
 }
Esempio n. 3
0
        private void GetView()
        {
            IRootDesigner rd = (IRootDesigner)host.GetDesigner(host.RootComponent);

            this.view = (RootDesignerView)rd.GetView(ViewTechnology.Passthrough);

            view.BeginLoad();
            System.Diagnostics.Trace.WriteLine("Document created.");
        }
        public void LoadWorkflow(string xoml, string ruleSetXml)
        {
            SuspendLayout();

            DesignSurface  designSurface = new DesignSurface();
            WorkflowLoader loader        = new WorkflowLoader();

            loader.RuleSetXml = ruleSetXml;
            loader.Xoml       = xoml;
            designSurface.BeginLoad(loader);

            IDesignerHost designerHost = designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (designerHost != null && designerHost.RootComponent != null)
            {
                IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;
                if (rootDesigner != null)
                {
                    UnloadWorkflow();

                    this.designSurface = designSurface;
                    this.loader        = loader;
                    this.workflowView  = rootDesigner.GetView(ViewTechnology.Default) as WorkflowView;
                    this.workflowViewSplitter.Panel2.Controls.Add(this.workflowView);
                    this.workflowView.Dock               = DockStyle.Fill;
                    this.workflowView.TabIndex           = 1;
                    this.workflowView.TabStop            = true;
                    this.workflowView.HScrollBar.TabStop = false;
                    this.workflowView.VScrollBar.TabStop = false;
                    this.workflowView.Focus();
                    this.propertyGrid.Site = designerHost.RootComponent.Site;

                    ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
                    if (selectionService != null)
                    {
                        selectionService.SelectionChanged += new EventHandler(OnSelectionChanged);
                    }
                }
            }

            ResumeLayout(true);

            //Add the code compile unit for the xaml file
            TypeProvider typeProvider = (TypeProvider)GetService(typeof(ITypeProvider));

            this.loader.XamlCodeCompileUnit = new CodeCompileUnit();
            this.loader.XamlCodeCompileUnit.Namespaces.Add(Helpers.GenerateCodeFromXomlDocument(Helpers.GetRootActivity(xoml), this, ref this.nameSpace, ref this.typeName));
            typeProvider.AddCodeCompileUnit(this.loader.XamlCodeCompileUnit);

            this.loader.CodeBesideCCU = new CodeCompileUnit();
            this.loader.CodeBesideCCU.Namespaces.Add(Helpers.GenerateCodeBeside(Helpers.GetRootActivity(xoml), this));
            typeProvider.AddCodeCompileUnit(this.loader.CodeBesideCCU);
        }
        ///     Establishes the given designer as the main top level designer for the document.
        public void SetDesigner(IRootDesigner document)
        {
            if (designerView != null)
            {
                Controls.Clear();
                designerView.Dispose();
                designerView = null;
            }

            if (document != null)
            {
                // Demand create the designer holder, if it doesn't already exist.
                ViewTechnology[] technologies        = document.SupportedTechnologies;
                bool             supportedTechnology = false;

                // Search for supported technologies that we know how to design.
                // In our case, we only know how to design WindowsForms.
                //
                foreach (ViewTechnology tech in technologies)
                {
                    switch (tech)
                    {
                    case ViewTechnology.WindowsForms:
                    {
                        designerView      = (Control)document.GetView(ViewTechnology.WindowsForms);
                        designerView.Dock = DockStyle.Fill;
                        Controls.Add(designerView);
                        supportedTechnology = true;
                        break;
                    }
                    }

                    // Stop looping if we found one
                    //
                    if (supportedTechnology)
                    {
                        break;
                    }
                }

                // If we didn't find a supported technology, report it.
                //
                if (!supportedTechnology)
                {
                    throw new Exception("Unsupported Technology " + designerHost.RootComponent.GetType().FullName);
                }
            }
        }
Esempio n. 6
0
        //Expand or collapse all composite activities

        static public byte[] GetWorkflowImageBinary(Activity workflowDefinition, Dictionary <string, ActivityStatusInfo> activityStatusList)
        {
            AutoResetEvent waitHandle = new AutoResetEvent(false);

            byte[] results = null;
            Thread thread  = new Thread(delegate()
            {
                Loader loader = new Loader();
                WorkflowDesignSurface surface = new WorkflowDesignSurface(new MemberCreationService());
                IDesignerHost host            = (IDesignerHost)surface.GetService(typeof(IDesignerHost));
                if (host == null)
                {
                    waitHandle.Set();
                    return;
                }
                loader.WorkflowDefinition = workflowDefinition;
                surface.BeginLoad(loader);
                if (activityStatusList != null)
                {
                    IDesignerGlyphProviderService glyphService         = surface.GetService(typeof(IDesignerGlyphProviderService)) as IDesignerGlyphProviderService;
                    WorkflowMonitorDesignerGlyphProvider glyphProvider = new WorkflowMonitorDesignerGlyphProvider(activityStatusList);
                    glyphService.AddGlyphProvider(glyphProvider);
                }
                ((IDesignerLoaderHost)host).EndLoad(host.RootComponent.Site.Name, true, null);
                IDesignerHost designerHost = surface.GetService(typeof(IDesignerHost)) as IDesignerHost;
                if (designerHost != null && designerHost.RootComponent != null)
                {
                    IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;
                    if (rootDesigner != null)
                    {
                        MemoryStream ms           = new MemoryStream();
                        WorkflowView workflowView = rootDesigner.GetView(ViewTechnology.Default) as WorkflowView;
                        workflowView.SaveWorkflowImage(ms, ImageFormat.Png);
                        results = ms.GetBuffer();
                    }
                }
                waitHandle.Set();
            });

            thread.IsBackground = true;
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            waitHandle.WaitOne();
            return(results);
        }
Esempio n. 7
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);
        }
        private bool SendKeyDownCommand(Keys key)
        {
            IDesignerHost service = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (service != null)
            {
                IRootDesigner designer = ActivityDesigner.GetDesigner(service.RootComponent as Activity);
                if (designer != null)
                {
                    WorkflowView view = designer.GetView(ViewTechnology.Default) as WorkflowView;
                    if (view != null)
                    {
                        KeyEventArgs e = new KeyEventArgs(key);
                        view.OnCommandKey(e);
                        return(e.Handled);
                    }
                }
            }
            return(false);
        }
Esempio n. 9
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"); };
        }
Esempio n. 10
0
        private void LoadWorkflow()
        {
            SuspendLayout();

            DesignSurface  designSurface = new DesignSurface();
            WorkflowLoader loader        = new WorkflowLoader();

            loader.WorkflowType = workflowTypeValue;
            loader.Xaml         = xamlValue;
            designSurface.BeginLoad(loader);

            IDesignerHost designerHost = designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (designerHost != null && designerHost.RootComponent != null)
            {
                IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;
                if (rootDesigner != null)
                {
                    UnloadWorkflow();

                    this.designSurface = designSurface;
                    this.loader        = loader;
                    this.workflowView  = rootDesigner.GetView(ViewTechnology.Default) as WorkflowView;
                    this.panel1.Controls.Add(this.workflowView);
                    this.workflowView.Dock               = DockStyle.Fill;
                    this.workflowView.TabIndex           = 1;
                    this.workflowView.TabStop            = true;
                    this.workflowView.HScrollBar.TabStop = false;
                    this.workflowView.VScrollBar.TabStop = false;
                    this.workflowView.Focus();
                    this.workflowView.FitToScreenSize();
                }
            }

            ResumeLayout(true);
        }
Esempio n. 11
0
 private void GenerateControls()
 {
     try
     {
         form = (Form)host.CreateComponent(typeof(Form), null);
         form.Controls.Clear();
         form.TopLevel = false;
         form.Text     = "Design view";
         DataTable dtControlsList = DBEngine.execReturnDataTable("FormLayout_ControlList", "@FormName", this.Name);
         if (dtControlsList != null && dtControlsList.Rows.Count > 0)
         {
             foreach (DataRow dr in dtControlsList.Rows)
             {
                 if (dr["ControlName"] != DBNull.Value && !dr["ControlName"].ToString().Trim().Equals(string.Empty) && !dr["ControlName"].ToString().Equals(this.Name))
                 {
                     Control ctr = (Control)host.CreateComponent(dr["SystemType"].ToString(), dr["ControlName"].ToString());
                     ctr.Location = new Point((int)dr["LocationX"], (int)dr["LocationY"]);
                     ctr.Text     = HPA.Common.UIMessage.Get_Message(ctr.Name);
                     ctr.Size     = new Size((int)dr["Width"], (int)dr["Height"]);
                     ctr.Visible  = Convert.ToBoolean(dr["Visible"]);
                     ctr.Enabled  = Convert.ToBoolean(dr["Enabled"]);
                     if (dr[CommonConst.TabIndex] != DBNull.Value)
                     {
                         ctr.TabIndex = Convert.ToInt32(dr[CommonConst.TabIndex]);
                     }
                     // set font style
                     if (dr["FontName"] != DBNull.Value)
                     {
                         HPA.Common.LayOutControlHelper.SetFontStyle(ref ctr, dr);
                     }
                     if (dr[CommonConst.ForeColor] != DBNull.Value)
                     {
                         HPA.Common.LayOutControlHelper.SetForeColor(ref ctr, dr);
                     }
                     if (ctr is PictureBox)
                     {
                         ((PictureBox)ctr).Image = CImageUtility.byteArrayToImage((byte[])dr["Image"]);
                     }
                     form.Controls.Add(ctr);
                 }
                 else if (dr["ControlName"].ToString().Equals(this.Name) || (dr["SystemType"].ToString().Equals("System.Windows.Forms.SplitterPanel,System.Windows.Forms") && dr["ControlName"].ToString().Trim().Equals(string.Empty)))
                 {
                     form.Size = new Size((int)dr["Width"], (int)dr["Height"]);
                     form.Name = dr["FormName"].ToString();
                 }
             }
             foreach (DataRow dr in dtControlsList.Rows)
             {
                 if (dr["ParentControl"] == DBNull.Value)
                 {
                     continue;
                 }
                 string PrentCtrName = dr["ParentControl"].ToString();
                 if (PrentCtrName.Trim().Equals(string.Empty))
                 {
                     PrentCtrName = form.Name;
                 }
                 if (!PrentCtrName.Equals(form.Name) && !dr["ControlName"].ToString().Trim().Equals(string.Empty))
                 {
                     if (form.Controls.Find(PrentCtrName, true).Length > 0 && form.Controls.Find(dr["ControlName"].ToString(), true).Length > 0)
                     {
                         form.Controls.Find(PrentCtrName, true)[0].Controls.Add(form.Controls.Find(dr["ControlName"].ToString(), true)[0]);
                     }
                 }
             }
         }
         IRootDesigner rootDesigner = (IRootDesigner)host.GetDesigner(form);
         Control       designView   = (Control)rootDesigner.GetView(ViewTechnology.Default);
         designView.Dock = DockStyle.Fill;
         designSurfacePanel.Controls.Add(designView);
     }
     catch (Exception ex)
     {
         HPA.Common.Helper.LogError(ex, this.Text, "GenerateControls");
     }
 }
        ///     Establishes the given designer as the main top level designer for the document.
        public void SetDesigner(IRootDesigner document) {

            if (designerView != null) {
				Controls.Clear();
                designerView.Dispose();
				designerView = null;
            }
            
            if (document != null) {
                // Demand create the designer holder, if it doesn't already exist.
                ViewTechnology[] technologies = document.SupportedTechnologies;
                bool supportedTechnology = false;
                
				// Search for supported technologies that we know how to design.
				// In our case, we only know how to design WindowsForms.
				//
                foreach(ViewTechnology tech in technologies) {
                    switch(tech) {
                        case ViewTechnology.WindowsForms: {
                            designerView = (Control)document.GetView(ViewTechnology.WindowsForms);
                            designerView.Dock = DockStyle.Fill;
							Controls.Add(designerView);
                            supportedTechnology = true;
                            break;
                        }
                    }
                    
                    // Stop looping if we found one
                    //
                    if (supportedTechnology) {
                        break;
                    }
                }
                
                // If we didn't find a supported technology, report it.
                //
                if (!supportedTechnology) {
                    throw new Exception("Unsupported Technology " + designerHost.RootComponent.GetType().FullName);
                }

            }
        }
Esempio n. 13
0
        /// <summary>
        /// Finish the process of loading an existing
        /// or new workflow
        /// </summary>
        /// <returns></returns>
        private Boolean CommonWorkflowLoading()
        {
            Boolean result = false;

            //tell the designer to begin loading
            _designSurface.BeginLoad(_wfLoader);

            //retrieve the designer host
            IDesignerHost designer
                = _designSurface.GetService(typeof(IDesignerHost))
                  as IDesignerHost;

            if (designer == null || designer.RootComponent == null)
            {
                return(false);
            }

            IRootDesigner rootDesigner
                = designer.GetDesigner(designer.RootComponent)
                  as IRootDesigner;

            if (rootDesigner != null)
            {
                SuspendLayout();
                //get the default workflow view from the designer
                _workflowView = rootDesigner.GetView(
                    ViewTechnology.Default)
                                as WorkflowView;
                //add the workflow view to a panel for display
                splitContainer1.Panel2.Controls.Add(_workflowView);
                _workflowView.Dock = DockStyle.Fill;
                _workflowView.Focus();

                //link the propertyGrid with the designer
                propertyGrid1.Site = designer.RootComponent.Site;

                //setup the toolbar for the workflow using the one
                //constructed by the workflow loader
                IToolboxService toolboxService = designer.GetService(
                    typeof(IToolboxService)) as IToolboxService;
                if (toolboxService != null)
                {
                    if (toolboxService is Control)
                    {
                        //add the toolbox control to a panel
                        _toolboxControl = (Control)toolboxService;
                        splitContainer2.Panel1.Controls.Add(
                            _toolboxControl);
                    }
                }

                //get the ISelectionService from the workflow view
                //and add a handler for the SelectionChanged event
                ISelectionService selectionService
                    = ((IServiceProvider)_workflowView).GetService(
                          typeof(ISelectionService)) as ISelectionService;
                if (selectionService != null)
                {
                    selectionService.SelectionChanged += new EventHandler(
                        selectionService_SelectionChanged);
                }

                ResumeLayout();
                result = true;
            }
            return(result);
        }
 public void SetDesigner(IRootDesigner document)
 {
     if (this.designerView != null)
     {
         base.Controls.Clear();
         this.designerView.Dispose();
         this.designerView = null;
     }
     if (document != null)
     {
         ViewTechnology[] technologies = document.SupportedTechnologies;
         bool supportedTechnology = false;
         foreach (ViewTechnology tech in technologies)
         {
             if(tech==ViewTechnology.WindowsForms)
             {
                 {
                     this.designerView = (Control) document.GetView(ViewTechnology.WindowsForms);
                     this.designerView.Dock = DockStyle.Fill;
                     base.Controls.Add(this.designerView);
                     supportedTechnology = true;
                 }
             }
             if (supportedTechnology)
             {
                 break;
             }
         }
         if (!supportedTechnology)
         {
             throw new Exception("Unsupported Technology " + this.designerHost.RootComponent.GetType().FullName);
         }
     }
 }
Esempio n. 15
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();
        }
Esempio n. 16
0
        /// <summary>
        ///     Establishes the given designer as the main top level designer for the document.
        /// </summary>
        /// <param name='document'>
        ///     The designer to make top-level.
        /// </param>
        public void SetDesigner(IRootDesigner document)
        {
            ISelectionService ss = SelectionService;

            if (designerView != null)
            {
                if (ss != null)
                {
                    ss.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
                }
                Controls.Remove(designerView);
                designerView = null;
            }

            docObject = null;

            if (document != null)
            {
                if (ss != null)
                {
                    ss.SelectionChanged += new EventHandler(this.OnSelectionChanged);
                }

                // If we got a designer, then clear our error list.
                if (errorList != null)
                {
                    errorList.Clear();
                }

                // Demand create the designer holder, if it doesn't already exist.
                ViewTechnology[] technologies        = document.SupportedTechnologies;
                bool             supportedTechnology = false;

                foreach (ViewTechnology tech in technologies)
                {
                    switch (tech)
                    {
                    case ViewTechnology.WindowsForms: {
                        designerView      = (Control)document.GetView(ViewTechnology.WindowsForms);
                        designerView.Dock = DockStyle.Fill;
                        Controls.Add(designerView);
                        supportedTechnology = true;
                        break;
                    }

                    case ViewTechnology.Passthrough: {
                        docObject           = document.GetView(ViewTechnology.Passthrough);
                        supportedTechnology = true;
                        break;
                    }
                    }

                    // Stop looping if we found one
                    //
                    if (supportedTechnology)
                    {
                        break;
                    }
                }

                // If we didn't find a supported technology, report it.
                //
                if (!supportedTechnology)
                {
                    throw new Exception(SR.GetString(SR.CODEMANUnsupportedTechnology, designerHost.RootComponent.GetType().FullName));
                }
            }
        }