/// <summary> /// Opens a List component. /// </summary> /// <param name="sender">Object associated with the event.</param> /// <param name="list">List component that needs to be opened.</param> public static void OpenList(object sender, List list) { if (_list == null) { _dropdown = (Dropdown)sender; _list = list; _list.TapOptionEvent += new OnTapOption(list_TapOptionEvent); for (int i = 0; i < MainWindow.NumChildren; i++) MainWindow[i].Interactive = false; MainWindow.AddChild(list); MainWindow.Invalidate(); } else throw new SystemException("You already have a List open."); }
/// <summary> /// Parses the Dropdown XML into a UI component. /// </summary> /// <param name="reader">XML reader object.</param> /// <returns>Dropdown object.</returns> private static Dropdown LoadDropdown(XmlReader reader) { string name = reader.GetAttribute("Name"); ushort alpha = (reader.GetAttribute("Alpha") != null) ? Convert.ToUInt16(reader.GetAttribute("Alpha")) : _defaultDisplayObject.Alpha; int x = Convert.ToInt32(reader.GetAttribute("X")); int y = Convert.ToInt32(reader.GetAttribute("Y")); int width = Convert.ToInt32(reader.GetAttribute("Width")); int height = Convert.ToInt32(reader.GetAttribute("Height")); bool visible = (reader.GetAttribute("Visible") != null) ? (reader.GetAttribute("Visible") == bool.TrueString) : _defaultDisplayObject.Visible; bool enabled = (reader.GetAttribute("Enabled") != null) ? (reader.GetAttribute("Enabled") == bool.TrueString) : _defaultDisplayObject.Enabled; string text = reader.GetAttribute("Text"); Font font = GlideUtils.Convert.ToFont(reader.GetAttribute("Font")); Color fontColor = GlideUtils.Convert.ToColor(reader.GetAttribute("FontColor")); Dropdown dropdown = new Dropdown(name, alpha, x, y, width, height); dropdown.Visible = visible; dropdown.Enabled = enabled; dropdown.Text = text; dropdown.Font = font; dropdown.FontColor = fontColor; if (!reader.IsEmptyElement) { dropdown.Options = new ArrayList(); while (reader.Read() && !(reader.NodeType == XmlNodeType.EndElement && reader.Name == "Dropdown")) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "Option") { // Apparently if you readstring before getattribute you'll lose position and it cannot find the attribute. string value = reader.GetAttribute("Value"); object[] item = new object[2] { reader.ReadString(), value }; dropdown.Options.Add(item); } } } return dropdown; }