private UICommand[] ParseUICommands(XElement itElement) { List <UICommand> uicommands = new List <UICommand>(); foreach (XElement ele in itElement.Elements()) { string name = ele.Name.LocalName; switch (name) { case "UIButton": UIButton btn = ParseUIButton(ele); if (btn != null) { uicommands.Add(btn); } break; case "UIDropDownButton": UIDropDownButton dbtn = ParseUIDropDownButton(ele); if (dbtn != null) { uicommands.Add(dbtn); } break; } } return(uicommands.Count > 0 ? uicommands.ToArray() : null); }
private UIDropDownButton ParseUIDropDownButton(XElement ele) { UIDropDownButton btn = new UIDropDownButton(); btn.Text = ele.Attribute("text").Value; btn.Image = ele.Attribute("image").Value; if (ele.Attribute("font") != null) { btn.Font = ele.Attribute("font").Value; } btn.ExpandArrowButton = bool.Parse(ele.Attribute("expandarrowbutton").Value); btn.ArrowPosition = ele.Attribute("arrowposition").Value; if (ele.Attribute("textaligment") != null) { btn.TextAligment = ele.Attribute("textaligment").Value; } if (ele.Attribute("imagealigment") != null) { btn.ImageAligment = ele.Attribute("imagealigment").Value; } List <UIItem> items = new List <UIItem>(); foreach (XElement e in ele.Elements()) { switch (e.Name.LocalName) { case "MenuHeaderItem": items.Add(new UIMenuHeader(e.Attribute("text").Value)); break; case "MenuItem": UIMenuItem it = new UIMenuItem(); it.Text = e.Attribute("text").Value; int id = 0; int.TryParse(e.Attribute("identify").Value, out id); it.Identify = id; it.Image = e.Attribute("image").Value; it.Argument = e.Attribute("argument").Value; items.Add(it); break; } } btn.MenuItems = items.Count > 0 ? items.ToArray() : null; return(btn); }