private void BuildControls()
        {
            // Build RunAs context menu
            List <ActionVerb> actions = new List <ActionVerb>();

            actions.Add(new ActionVerb()
            {
                Name = "Run", Verb = ""
            });
            if (!RuntimeInfo.Inst.IsElevated)
            {
                actions.Add(new ActionVerb()
                {
                    Name = "RunAs Admin", Verb = "runas"
                });
            }
            actions.Add(new ActionVerb()
            {
                Name = "UpdateFiles", Verb = "updatefiles"
            });

            var runAsContextMenuItems = GUIUtility.GenerateContextActionMenus(_runAsContext.Name, "ContextMenu", actions, ToolButtonOrContextMenuItem_Click);

            _runAsContext.Items.AddRange(runAsContextMenuItems);

            //Build main tool bar
            if (RuntimeInfo.Inst.ToolBar != null && RuntimeInfo.Inst.ToolBar.Count > 0)
            {
                GenerateToolbar(_mainToolBar, RuntimeInfo.Inst.ToolBar, actions);
            }

            //Build main menu bar Tools, Editors, Integration
            RuntimeInfo.Inst.UpdateMenuBar(_mainMenu, actions, ToolButtonOrContextMenuItem_Click);

            //Build config context menu
            if (RuntimeInfo.Inst.ContextMenu != null && RuntimeInfo.Inst.ContextMenu.Count > 0)
            {
                GenerateContextMenu(_configListContextMenu, RuntimeInfo.Inst.ContextMenu);
            }
        }
        private void GenerateToolbar(ToolStrip rootToolStrip, List <ToolBarItem> toolsBarItem, List <ActionVerb> actions)
        {
            rootToolStrip.SuspendLayout();

            foreach (var item in toolsBarItem)
            {
                if (item.Tools != null && item.Tools.Count > 1)
                {
                    bool toolAvaialble = false;
                    var  splitButton   = new ToolStripSplitButton();
                    splitButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
                    splitButton.Image        = Image.FromFile(string.Format(@"{0}\Resource\img\{1}.png", RuntimeInfo.Inst.LaunchEnvExeDir, item.Name));
                    splitButton.Name         = string.Format("{0}_toolStripBttn{1}", rootToolStrip.Name, item.Name);
                    splitButton.Text         = item.Name;
                    splitButton.Tag          = item.Name;
                    splitButton.MouseDown   += StripButton_MouseDown;

                    foreach (var splitItem in item.Tools)
                    {
                        if (RuntimeInfo.Inst.IsToolAvailable(splitItem))
                        {
                            var tool = RuntimeInfo.Inst.GetTool(splitItem);
                            toolAvaialble = true;
                            var toolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
                            toolStripMenuItem.Image  = Image.FromFile(string.Format(@"{0}\Resource\img\{1}.png", RuntimeInfo.Inst.LaunchEnvExeDir, tool.Name));
                            toolStripMenuItem.Name   = string.Format("{0}_toolStripBttn{1}_{2}", rootToolStrip.Name, item.Name, tool.Name);
                            toolStripMenuItem.Text   = tool.Name;
                            toolStripMenuItem.Tag    = tool.Name;
                            toolStripMenuItem.Click += ToolButtonOrContextMenuItem_Click;
                            if (RuntimeInfo.Inst.ShowRunAsForAll)
                            {
                                var retMenu = GUIUtility.GenerateContextActionMenus(toolStripMenuItem.Name, toolStripMenuItem.Tag as string, actions, ToolButtonOrContextMenuItem_Click);
                                if (retMenu.Length > 0)
                                {
                                    toolStripMenuItem.DropDownItems.AddRange(retMenu);
                                }
                            }
                            splitButton.DropDownItems.Add(toolStripMenuItem);
                        }
                    }

                    if (toolAvaialble)
                    {
                        rootToolStrip.Items.Add(splitButton);
                        _toolStripItem.Add(splitButton);
                    }
                }
                else
                {
                    var splitItem = item.Tools != null && item.Tools.Count > 0 ? item.Tools.FirstOrDefault() : item.Name;
                    if (splitItem != null)
                    {
                        if (RuntimeInfo.Inst.IsToolAvailable(splitItem))
                        {
                            var           tool        = RuntimeInfo.Inst.GetTool(splitItem);
                            ToolStripItem stripButton = new ToolStripButton();
                            stripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
                            stripButton.Image        = Image.FromFile(string.Format(@"{0}\Resource\img\{1}.png", RuntimeInfo.Inst.LaunchEnvExeDir, tool.Name));
                            stripButton.Name         = string.Format("{0}_toolStripBttn{1}", rootToolStrip.Name, tool.Name);
                            stripButton.Text         = tool.Name;
                            stripButton.Tag          = tool.Name;
                            stripButton.MouseDown   += StripButton_MouseDown;
                            rootToolStrip.Items.Add(stripButton);
                        }
                    }
                }
            }
            rootToolStrip.ResumeLayout(false);
            rootToolStrip.PerformLayout();
        }