/// <summary> /// load the toolbar /// </summary> /// <param name="parentName"></param> /// <param name="curNode"></param> /// <returns></returns> public Boolean LoadToolbar(string parentName, XmlNode curNode) { List <XmlNode> children = TYml2Xml.GetChildren(curNode, true); XmlNode rootBarNode = FCodeStorage.GetRootControl("tbr").xmlNode; foreach (XmlNode childNode in children) { // the check for tbb works around problems with elements list, shortcutkeys if (childNode.Name.StartsWith("tbb") || childNode.Name.StartsWith("tbc")) { string tbbName = childNode.Name; if (tbbName == "tbbSeparator") { // UniqueName is not stored to yml again; just used temporary TYml2Xml.SetAttribute(childNode, "UniqueName", tbbName + FToolbarSeparatorCount.ToString()); FToolbarSeparatorCount++; } TControlDef tbbItem = FCodeStorage.AddControl(childNode); tbbItem.parentName = parentName; rootBarNode.AppendChild(childNode); } else { // use ToolStripControlHost to host any control TControlDef tbbItem = FCodeStorage.AddControl(childNode); string prefix = TControlDef.GetLowerCasePrefix(childNode.Name); tbbItem.parentName = "tch" + childNode.Name.Substring(prefix.Length); XmlNode controlHostNode = rootBarNode.OwnerDocument.CreateElement(tbbItem.parentName); TYml2Xml.SetAttribute(controlHostNode, "depth", TYml2Xml.GetAttribute(childNode, "depth")); TYml2Xml.SetAttribute(controlHostNode, "HostedControl", childNode.Name); rootBarNode.AppendChild(controlHostNode); XmlNode controlsNode = rootBarNode.OwnerDocument.CreateElement("Controls"); controlHostNode.AppendChild(controlsNode); XmlNode elementNode = rootBarNode.OwnerDocument.CreateElement("Element"); controlsNode.AppendChild(elementNode); TYml2Xml.SetAttribute(elementNode, "name", childNode.Name); TControlDef hostItem = FCodeStorage.AddControl(controlHostNode); hostItem.parentName = parentName; } } return(true); }
/// <summary> /// load the menu /// </summary> /// <param name="parentName"></param> /// <param name="curNode"></param> /// <returns></returns> public Boolean LoadMenu(string parentName, XmlNode curNode) { string menuName = curNode.Name; if (menuName == "mniSeparator") { // UniqueName is not stored to yml again; just used temporary TYml2Xml.SetAttribute(curNode, "UniqueName", menuName + FMenuSeparatorCount.ToString()); FMenuSeparatorCount++; } if (curNode.ParentNode.Name == TParseYAMLFormsDefinition.ROOTNODEYML) { // add each menu, but obviously not the "Menu" tag XmlNode menuNode = curNode; List <XmlNode> children = TYml2Xml.GetChildren(menuNode, true); foreach (XmlNode childNode in children) { LoadMenu(parentName, childNode); // attach the menu to the appropriate root control XmlNode rootMenu = FCodeStorage.GetRootControl("mnu").xmlNode; rootMenu.AppendChild(childNode); } return(true); } TControlDef menuItem = FCodeStorage.AddControl(curNode); menuItem.parentName = parentName; List <XmlNode> children2 = TYml2Xml.GetChildren(curNode, true); foreach (XmlNode childNode in children2) { // the check for mni works around problems with elements list, shortcutkeys if (childNode.Name.StartsWith("mni")) { LoadMenu(menuName, childNode); } } return(true); }
/// <summary> /// write attribute value to the yaml /// </summary> /// <param name="name"></param> /// <param name="value"></param> public void SetAttribute(string name, string value) { TYml2Xml.SetAttribute(xmlNode, name, value); }