/// <summary>
 ///
 /// </summary>
 private void DoDelete()
 {
     if (MessageBox.Show("This operation will delete template and related permissions,Are you sure to do this operation?", "Message - RSystems FinanceTools", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         KeyValuePair <string, string> obj = (KeyValuePair <string, string>) this.cbTmpName.SelectedItem;
         DeleteFile();
         DeleteTemplate(obj.Value);
         DeleteTemplateButtons(obj.Value);
         DeleteTemplatePermissions(obj.Value);
         DeleteTemplateVisible(obj.Value);
         TempName = obj.Key;
         Predicate <KeyValuePair <string, string> > pred2 = EquaWithButtonName;
         KeyValuePair <string, string> kv = Ribbon2.TemplateAndPath.Find(pred2);
         if (kv.Key != null)
         {
             cbTmpName.Items.Remove(kv);
             Ribbon2.TemplateAndPath.Remove(kv);
             for (int i = 0; i < Ribbon2.ButtonViewCount; i++)
             {
                 try
                 {
                     Microsoft.Office.Tools.Ribbon.RibbonControl rb = (Microsoft.Office.Tools.Ribbon.RibbonButton)Globals.Ribbons[0].Tabs[0].Groups[2].Items[i];
                     string[] sArray     = System.Text.RegularExpressions.Regex.Split(rb.Tag.ToString(), ",");
                     string   templateid = sArray[0];
                     if (templateid == obj.Value)
                     {
                         rb.Visible = false;
                     }
                 }
                 catch { }
             }
             Microsoft.Office.Tools.Ribbon.RibbonGroup rg = (Microsoft.Office.Tools.Ribbon.RibbonGroup)Globals.Ribbons[0].Tabs[0].Groups[3];
             for (int j = 0; j < rg.Items.Count; j++)
             {
                 Microsoft.Office.Tools.Ribbon.RibbonMenu rm = (Microsoft.Office.Tools.Ribbon.RibbonMenu)rg.Items[j];
                 for (int k = 0; k < rm.Items.Count; k++)
                 {
                     Microsoft.Office.Tools.Ribbon.RibbonToggleButton rtb = (Microsoft.Office.Tools.Ribbon.RibbonToggleButton)rm.Items[k];
                     if (rtb.Tag == obj.Value)
                     {
                         rtb.Visible = false;
                     }
                 }
             }
         }
     }
 }
 /// <summary>
 /// 设计器支持所需的方法 - 请勿
 /// 使用代码编辑器修改此方法的内容。
 /// </summary>
 private void InitializeComponent()
 {
     Microsoft.Office.Tools.Ribbon.RibbonDropDownItem ribbonDropDownItem1 = new Microsoft.Office.Tools.Ribbon.RibbonDropDownItem();
     Microsoft.Office.Tools.Ribbon.RibbonDropDownItem ribbonDropDownItem2 = new Microsoft.Office.Tools.Ribbon.RibbonDropDownItem();
     Microsoft.Office.Tools.Ribbon.RibbonDropDownItem ribbonDropDownItem3 = new Microsoft.Office.Tools.Ribbon.RibbonDropDownItem();
     Microsoft.Office.Tools.Ribbon.RibbonDropDownItem ribbonDropDownItem4 = new Microsoft.Office.Tools.Ribbon.RibbonDropDownItem();
     Microsoft.Office.Tools.Ribbon.RibbonDropDownItem ribbonDropDownItem5 = new Microsoft.Office.Tools.Ribbon.RibbonDropDownItem();
     Microsoft.Office.Tools.Ribbon.RibbonDropDownItem ribbonDropDownItem6 = new Microsoft.Office.Tools.Ribbon.RibbonDropDownItem();
     Microsoft.Office.Tools.Ribbon.RibbonDropDownItem ribbonDropDownItem7 = new Microsoft.Office.Tools.Ribbon.RibbonDropDownItem();
     Microsoft.Office.Tools.Ribbon.RibbonDropDownItem ribbonDropDownItem8 = new Microsoft.Office.Tools.Ribbon.RibbonDropDownItem();
     this.tControls = new Microsoft.Office.Tools.Ribbon.RibbonTab();
     this.gButtons = new Microsoft.Office.Tools.Ribbon.RibbonGroup();
     this.btnActionsPane = new Microsoft.Office.Tools.Ribbon.RibbonToggleButton();
     this.bgMoodFace = new Microsoft.Office.Tools.Ribbon.RibbonButtonGroup();
     this.btnHappy = new Microsoft.Office.Tools.Ribbon.RibbonToggleButton();
     this.btnNeutral = new Microsoft.Office.Tools.Ribbon.RibbonToggleButton();
     this.btnSad = new Microsoft.Office.Tools.Ribbon.RibbonToggleButton();
     this.sbtnAlign = new Microsoft.Office.Tools.Ribbon.RibbonSplitButton();
     this.btnLeft = new Microsoft.Office.Tools.Ribbon.RibbonButton();
     this.btnCenter = new Microsoft.Office.Tools.Ribbon.RibbonButton();
     this.btnRight = new Microsoft.Office.Tools.Ribbon.RibbonButton();
     this.separator1 = new Microsoft.Office.Tools.Ribbon.RibbonSeparator();
     this.ddFormatChart = new Microsoft.Office.Tools.Ribbon.RibbonDropDown();
     this.cbMRUFind = new Microsoft.Office.Tools.Ribbon.RibbonComboBox();
     this.galShapes = new Microsoft.Office.Tools.Ribbon.RibbonGallery();
     this.gDynamicMenu = new Microsoft.Office.Tools.Ribbon.RibbonGroup();
     this.mDynamicMenu = new Microsoft.Office.Tools.Ribbon.RibbonMenu();
     this.cbButton = new Microsoft.Office.Tools.Ribbon.RibbonCheckBox();
     this.cbSeparator = new Microsoft.Office.Tools.Ribbon.RibbonCheckBox();
     this.cbSubMenu = new Microsoft.Office.Tools.Ribbon.RibbonCheckBox();
     this.tControls.SuspendLayout();
     this.gButtons.SuspendLayout();
     this.bgMoodFace.SuspendLayout();
     this.gDynamicMenu.SuspendLayout();
     this.SuspendLayout();
     //
     // tControls
     //
     this.tControls.Groups.Add(this.gButtons);
     this.tControls.Groups.Add(this.gDynamicMenu);
     this.tControls.Label = "Ribbon Control Sample";
     this.tControls.Name = "tControls";
     //
     // gButtons
     //
     this.gButtons.Items.Add(this.btnActionsPane);
     this.gButtons.Items.Add(this.bgMoodFace);
     this.gButtons.Items.Add(this.sbtnAlign);
     this.gButtons.Items.Add(this.separator1);
     this.gButtons.Items.Add(this.ddFormatChart);
     this.gButtons.Items.Add(this.cbMRUFind);
     this.gButtons.Items.Add(this.galShapes);
     this.gButtons.Label = "Working with Sheets";
     this.gButtons.Name = "gButtons";
     //
     // btnActionsPane
     //
     this.btnActionsPane.Label = "Show Actions Pane";
     this.btnActionsPane.Name = "btnActionsPane";
     this.btnActionsPane.ScreenTip = "Toggle Button";
     this.btnActionsPane.ShowImage = true;
     this.btnActionsPane.SuperTip = "A ToggleButton that appears pressed or unpressed.  Click the ToggleButton to show" +
         "/hide the Actions Pane.";
     this.btnActionsPane.Click += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.btnActionsPane_Click);
     //
     // bgMoodFace
     //
     this.bgMoodFace.Items.Add(this.btnHappy);
     this.bgMoodFace.Items.Add(this.btnNeutral);
     this.bgMoodFace.Items.Add(this.btnSad);
     this.bgMoodFace.Name = "bgMoodFace";
     //
     // btnHappy
     //
     this.btnHappy.Image = global::RibbonControlsExcelWorkbook.Properties.Resources.happy;
     this.btnHappy.Label = "toggleButton1";
     this.btnHappy.Name = "btnHappy";
     this.btnHappy.ShowImage = true;
     this.btnHappy.ShowLabel = false;
     this.btnHappy.Click += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.btnHappy_Click);
     //
     // btnNeutral
     //
     this.btnNeutral.Image = global::RibbonControlsExcelWorkbook.Properties.Resources.Neutral;
     this.btnNeutral.Label = "toggleButton2";
     this.btnNeutral.Name = "btnNeutral";
     this.btnNeutral.ShowImage = true;
     this.btnNeutral.ShowLabel = false;
     this.btnNeutral.Click += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.btnNeutral_Click);
     //
     // btnSad
     //
     this.btnSad.Image = global::RibbonControlsExcelWorkbook.Properties.Resources.sad;
     this.btnSad.Label = "toggleButton3";
     this.btnSad.Name = "btnSad";
     this.btnSad.ShowImage = true;
     this.btnSad.ShowLabel = false;
     this.btnSad.Click += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.btnSad_Click);
     //
     // sbtnAlign
     //
     this.sbtnAlign.Items.Add(this.btnLeft);
     this.sbtnAlign.Items.Add(this.btnCenter);
     this.sbtnAlign.Items.Add(this.btnRight);
     this.sbtnAlign.Label = "Alignment";
     this.sbtnAlign.Name = "sbtnAlign";
     this.sbtnAlign.OfficeImageId = "AlignCenter";
     this.sbtnAlign.ScreenTip = "Split Button";
     this.sbtnAlign.SuperTip = "A Split Button is a button with a menu.  Click the button to center align text in" +
         " cell A4 or select the menu for other alignment options.";
     this.sbtnAlign.Click += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.sbtnAlign_Click);
     //
     // btnLeft
     //
     this.btnLeft.Label = "Left Align";
     this.btnLeft.Name = "btnLeft";
     this.btnLeft.OfficeImageId = "AlignLeft";
     this.btnLeft.ScreenTip = "Button";
     this.btnLeft.ShowImage = true;
     this.btnLeft.SuperTip = "Button in a Split Button.";
     this.btnLeft.Click += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.btnLeft_Click);
     //
     // btnCenter
     //
     this.btnCenter.Label = "Center Align";
     this.btnCenter.Name = "btnCenter";
     this.btnCenter.OfficeImageId = "AlignCenter";
     this.btnCenter.ScreenTip = "Button";
     this.btnCenter.ShowImage = true;
     this.btnCenter.SuperTip = "Button in a Split Button.";
     this.btnCenter.Click += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.btnCenter_Click);
     //
     // btnRight
     //
     this.btnRight.Label = "Right Align";
     this.btnRight.Name = "btnRight";
     this.btnRight.OfficeImageId = "AlignRight";
     this.btnRight.ScreenTip = "Button";
     this.btnRight.ShowImage = true;
     this.btnRight.SuperTip = "Button in a Split Button.";
     this.btnRight.Click += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.btnRight_Click);
     //
     // separator1
     //
     this.separator1.Name = "separator1";
     //
     // ddFormatChart
     //
     ribbonDropDownItem1.Label = "Bar";
     ribbonDropDownItem1.OfficeImageId = "ChartTypeBarInsertGallery";
     ribbonDropDownItem1.ScreenTip = "DropDown Item";
     ribbonDropDownItem1.SuperTip = "Select DropDown Item to format the chart.";
     ribbonDropDownItem2.Label = "Column";
     ribbonDropDownItem2.OfficeImageId = "ChartTypeColumnInsertGallery";
     ribbonDropDownItem2.ScreenTip = "DropDown Item";
     ribbonDropDownItem2.SuperTip = "Select DropDown Item to format the chart.";
     ribbonDropDownItem3.Label = "Area";
     ribbonDropDownItem3.OfficeImageId = "ChartTypeAreaInsertGallery";
     ribbonDropDownItem3.ScreenTip = "DropDown Item";
     ribbonDropDownItem3.SuperTip = "Select DropDown Item to format the chart.";
     ribbonDropDownItem4.Label = "Pie";
     ribbonDropDownItem4.OfficeImageId = "ChartTypePieInsertGallery";
     ribbonDropDownItem4.ScreenTip = "DropDown Item";
     ribbonDropDownItem4.SuperTip = "Select DropDown Item to format the chart.";
     this.ddFormatChart.Items.Add(ribbonDropDownItem1);
     this.ddFormatChart.Items.Add(ribbonDropDownItem2);
     this.ddFormatChart.Items.Add(ribbonDropDownItem3);
     this.ddFormatChart.Items.Add(ribbonDropDownItem4);
     this.ddFormatChart.Label = "Format Chart";
     this.ddFormatChart.Name = "ddFormatChart";
     this.ddFormatChart.ScreenTip = "Drop Down";
     this.ddFormatChart.SuperTip = "A drop down list of options.  Select a chart type to format the chart on Sheet1.";
     this.ddFormatChart.SelectionChanged += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.ddFormatChart_SelectionChanged);
     //
     // cbMRUFind
     //
     ribbonDropDownItem5.Label = "Q1";
     ribbonDropDownItem6.Label = "Q2";
     ribbonDropDownItem7.Label = "Q3";
     ribbonDropDownItem8.Label = "Q4";
     this.cbMRUFind.Items.Add(ribbonDropDownItem5);
     this.cbMRUFind.Items.Add(ribbonDropDownItem6);
     this.cbMRUFind.Items.Add(ribbonDropDownItem7);
     this.cbMRUFind.Items.Add(ribbonDropDownItem8);
     this.cbMRUFind.Label = "MRU Find";
     this.cbMRUFind.Name = "cbMRUFind";
     this.cbMRUFind.ScreenTip = "Combo Box";
     this.cbMRUFind.SizeString = "Enter or select search text.";
     this.cbMRUFind.SuperTip = "ComboBox is a EditBox with a DropDown.  Select text from the list to find it in t" +
         "he spreadsheet.  Or, enter your own search string to add to the list.";
     this.cbMRUFind.Text = "Enter or select search text.";
     this.cbMRUFind.TextChanged += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.cbMRUFind_TextChanged);
     //
     // galShapes
     //
     this.galShapes.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
     this.galShapes.Image = global::RibbonControlsExcelWorkbook.Properties.Resources.AvocadoGreen;
     this.galShapes.Label = "Color";
     this.galShapes.Name = "galShapes";
     this.galShapes.ScreenTip = "Gallery";
     this.galShapes.ShowImage = true;
     this.galShapes.SuperTip = "A gallery is a multi-dimensional dropdown.  This gallery will format insert a dif" +
         "ferent colored sphere on to Sheet1.";
     this.galShapes.ItemsLoading += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.galShapes_ItemsLoading);
     this.galShapes.Click += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.galShapes_Click);
     //
     // gDynamicMenu
     //
     this.gDynamicMenu.Items.Add(this.mDynamicMenu);
     this.gDynamicMenu.Items.Add(this.cbButton);
     this.gDynamicMenu.Items.Add(this.cbSeparator);
     this.gDynamicMenu.Items.Add(this.cbSubMenu);
     this.gDynamicMenu.Label = "Build Dynamic Menu";
     this.gDynamicMenu.Name = "gDynamicMenu";
     //
     // mDynamicMenu
     //
     this.mDynamicMenu.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
     this.mDynamicMenu.Dynamic = true;
     this.mDynamicMenu.Label = "Dynamic Menu";
     this.mDynamicMenu.Name = "mDynamicMenu";
     this.mDynamicMenu.OfficeImageId = "QueryAppend";
     this.mDynamicMenu.ScreenTip = "Dynamic Menu";
     this.mDynamicMenu.ShowImage = true;
     this.mDynamicMenu.SuperTip = "This is a dynamic menu.  Use the checkboxes at the right to determine which contr" +
         "ols to add at runtime.";
     this.mDynamicMenu.ItemsLoading += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs>(this.mDynamicMenu_ItemsLoading);
     //
     // cbButton
     //
     this.cbButton.Label = "Button";
     this.cbButton.Name = "cbButton";
     this.cbButton.ScreenTip = "Check Box";
     this.cbButton.SuperTip = "Select to add control to Dynamic Menu.";
     //
     // cbSeparator
     //
     this.cbSeparator.Label = "Separator";
     this.cbSeparator.Name = "cbSeparator";
     this.cbSeparator.ScreenTip = "Check Box";
     this.cbSeparator.SuperTip = "Select to add control to Dynamic Menu.";
     //
     // cbSubMenu
     //
     this.cbSubMenu.Label = "SubMenu";
     this.cbSubMenu.Name = "cbSubMenu";
     this.cbSubMenu.ScreenTip = "Check Box";
     this.cbSubMenu.SuperTip = "Select to add control to Dynamic Menu.";
     //
     // RibbonControls
     //
     this.Name = "RibbonControls";
     this.RibbonType = "Microsoft.Excel.Workbook";
     this.StartFromScratch = true;
     this.Tabs.Add(this.tControls);
     this.Load += new System.EventHandler<Microsoft.Office.Tools.Ribbon.RibbonUIEventArgs>(this.RibbonControls_Load);
     this.tControls.ResumeLayout(false);
     this.tControls.PerformLayout();
     this.gButtons.ResumeLayout(false);
     this.gButtons.PerformLayout();
     this.bgMoodFace.ResumeLayout(false);
     this.bgMoodFace.PerformLayout();
     this.gDynamicMenu.ResumeLayout(false);
     this.gDynamicMenu.PerformLayout();
     this.ResumeLayout(false);
 }