Пример #1
0
 private static void RemoveControls(CommandBarControls parentControls, XmlNodeList xmlNodes)
 {
     foreach (XmlNode childNode in xmlNodes)
     {
         RemoveControl(parentControls, childNode);
     }
 }
Пример #2
0
 private static void AddControls(CommandBarControls parentControls, XmlNodeList xmlNodes, GetImageDelegate getImage)
 {
     foreach (XmlNode childNode in xmlNodes)
     {
         AddControl(parentControls, childNode, getImage);
     }
 }
Пример #3
0
 private static void AddControl(CommandBarControls parentControls, XmlNode xmlNode, GetImageDelegate getImage)
 {
     if (xmlNode.Name == "popup")
     {
         string          controlName = xmlNode.Attributes["caption"].Value;
         object          before      = ReadControlBeforeAttribute(xmlNode);
         CommandBarPopup newPopup    = parentControls.AddPopup(controlName, before);
         ApplyControlAttributes(newPopup, xmlNode, getImage);
         AddControls(newPopup.Controls, xmlNode.ChildNodes, getImage);
     }
     else if (xmlNode.Name == "button")
     {
         object           before    = ReadControlBeforeAttribute(xmlNode);
         CommandBarButton newButton = parentControls.AddButton(before);
         ApplyControlAttributes(newButton, xmlNode, getImage);
     }
 }
Пример #4
0
 private static void RemoveControl(CommandBarControls parentControls, XmlNode xmlNode)
 {
     if (xmlNode.Name == "popup")
     {
         string          controlName = xmlNode.Attributes["caption"].Value;
         CommandBarPopup cb          = (parentControls[controlName] as CommandBarPopup);
         if (cb != null)
         {
             RemoveControls(cb.Controls, xmlNode.ChildNodes);
             if (cb.Controls.Count() == 0)
             {
                 cb.Delete(true);
             }
         }
     }
     if (xmlNode.Name == "button")
     {
         string controlName = xmlNode.Attributes["caption"].Value;
         parentControls[controlName].Delete(true);
     }
 }
Пример #5
0
 //// We cannot rely only on name to recover the proper CommandBar so we have the possibility to use the ID (which is used in priority).
 //// Indeed there are two CommandBar for "Cell" see  http://msdn.microsoft.com/en-us/library/office/gg469862(v=office.14).aspx
 //// However, at the time of the writing there is a mistake: "Application.CommandBars(Application.CommandBars("Cell").Index + 3)" is false in practice
 //private static CommandBar GetCommandBarFromIdOrName(Application excelApp,XmlAttributeCollection nodeAttributes, out string barName)
 //{
 //    var id =  nodeAttributes["id"];
 //    var name = nodeAttributes["name"];
 //    if(name ==null) throw new ArgumentException("commandBar attributes must contain name");
 //    barName = name.Value;
 //    if (id != null)
 //    {
 //        string barId = id.Value;
 //        CommandBar bar = null;
 //        for (int i = 1; i <= excelApp.CommandBars.Count; i++)
 //        {
 //            if (excelApp.CommandBars[i].Id == barId)
 //            {
 //                bar = excelApp.CommandBars[i];
 //                break;
 //            }
 //        }
 //        return bar;
 //    }
 //    else
 //    {
 //        CommandBar bar = null;
 //        for (int i = 1; i <= excelApp.CommandBars.Count; i++)
 //        {
 //            if (excelApp.CommandBars[i].Name == barName)
 //            {
 //                bar = excelApp.CommandBars[i];
 //                break;
 //            }
 //        }
 //        return bar;
 //    }
 //}
 private static void AddControls(CommandBarControls parentControls, XmlNodeList xmlNodes, GetImageDelegate getImage)
 {
     foreach (XmlNode childNode in xmlNodes)
     {
         AddControl(parentControls, childNode, getImage);
     }
 }
Пример #6
0
 private static void AddControl(CommandBarControls parentControls, XmlNode xmlNode, GetImageDelegate getImage)
 {
     if (xmlNode.Name == "popup")
     {
         string controlName = xmlNode.Attributes["caption"].Value;
         object before = ReadControlBeforeAttribute(xmlNode);
         CommandBarPopup newPopup = parentControls.AddPopup(controlName, before);
         ApplyControlAttributes(newPopup, xmlNode, getImage);
         AddControls(newPopup.Controls, xmlNode.ChildNodes, getImage);
     }
     else if (xmlNode.Name == "button")
     {
         object before = ReadControlBeforeAttribute(xmlNode);
         CommandBarButton newButton = parentControls.AddButton(before);
         ApplyControlAttributes(newButton, xmlNode, getImage);
     }
 }
Пример #7
0
 private static void RemoveControls(CommandBarControls parentControls, XmlNodeList xmlNodes)
 {
     foreach (XmlNode childNode in xmlNodes)
     {
         RemoveControl(parentControls, childNode);
     }
 }
Пример #8
0
 private static void RemoveControl(CommandBarControls parentControls, XmlNode xmlNode)
 {
     if (xmlNode.Name == "popup")
     {
         string controlName = xmlNode.Attributes["caption"].Value;
         CommandBarPopup cb = (parentControls[controlName] as CommandBarPopup);
         if (cb != null)
         {
             RemoveControls(cb.Controls, xmlNode.ChildNodes);
             if (cb.Controls.Count() == 0)
             {
                 cb.Delete(true);
             }
         }
     }
     if (xmlNode.Name == "button")
     {
         string controlName = xmlNode.Attributes["caption"].Value;
         parentControls[controlName].Delete(true);
     }
 }