/// <summary> /// Adds a catagory /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _Bu_SoundBoardCatagoryAdd_Click(object sender, EventArgs e) { if (_TB_SoundBoardCatKey.Text != "" && _TB_SoundBoardCatDes.Text != "") { SBCatagories Temp = new SBCatagories(_TB_SoundBoardCatKey.Text, _TB_SoundBoardCatDes.Text); if (!_LB_SoundBoardCatagoryBinder.Items.Contains(Temp)) { _LB_SoundBoardCatagoryBinder.Items.Add(Temp); } else { MessageBox.Show("Can not Duplicate Key"); } } }
public static SBSound XMLRead(XmlReader XReader, SBCatagories Cat) { try { SBSound Sound = null; string Key = null; string File = null; while (XReader.Read()) { switch (XReader.NodeType) { case XmlNodeType.Element: switch (XReader.Name) { case "Key": Key = XReader.ReadContentAsString(); break; case "File": File = XReader.ReadContentAsString(); break; } break; case XmlNodeType.EndElement: if (XReader.Name == "MemberSound") { if (Key != null && File != null) { return(new SBSound(Cat, Key, File)); } else { throw new XmlException("Unexpected close of MemberSound. MemberSound is not complete!"); } } break; } } } catch (XmlException e) { throw new XmlException(e.Message, e.InnerException, e.LineNumber, e.LinePosition); } throw new XmlException("Unexpected end of file. Before end of Soundboard"); }
/// <summary> /// Creates a sound binding /// </summary> /// <param name="_Key">The key to call it</param> /// <param name="_Dec">The description</param> public SBSound(SBCatagories _Cat, string _Key, string _File) { Cat = _Cat; Key = _Key; File = _File; }
public SBCatagories XMLRead(XmlReader XReader) { try { SBCatagories Cat = null; List <SBSound> Sounds = new List <SBSound>(); string Key = null; string Desc = null; while (XReader.Read()) { switch (XReader.NodeType) { case XmlNodeType.Element: switch (XReader.Name) { case "Key": Key = XReader.ReadContentAsString(); break; case "Description": Desc = XReader.ReadContentAsString(); break; case "Members": if (Key == null || Desc == null) { throw new XmlException("Unexpected Members before Key or Description. Members must come after!"); } Cat = new SBCatagories(Key, Desc, Sounds); // make the obj as we can pass the ref of this to fill break; case "MemberSound": if (Cat == null) { throw new XmlException("Unexpected Member before before Members, Key, or Description. Members must come after!"); } Sounds.Add(SBSound.XMLRead(XReader, Cat)); break; } break; case XmlNodeType.EndElement: if (XReader.Name == "MemberSound") { if (Key != null && Desc != null) { return(Cat); } else { throw new XmlException("Unexpected close of MemberSound. MemberSound is not complete!"); } } break; } } } catch (XmlException e) { throw new XmlException(e.Message, e.InnerException, e.LineNumber, e.LinePosition); } throw new XmlException("Unexpected end of file. Before end of Soundboard"); }