private ServerSoundLibrary() { _XMLFilePath = ConfigurationManager.AppSettings["severXMLLibraryName"]; if (File.Exists(_XMLFilePath)) { XDocument xdoc = XDocument.Load(_XMLFilePath); this._soundLibrary = RTS.Tools.FileAccessor.LoadLibrary(xdoc); } else { this._soundLibrary = new SoundLibraryModel(); } this.Save(); }
public static SoundLibraryModel LoadLibrary(XDocument xdoc) { SoundLibraryModel slm = new SoundLibraryModel(); XElement root = xdoc.Root; IEnumerable<XElement> list = root.Descendants("Sound"); foreach (XElement item in list) { string id = item.Element("id").Value; string name = item.Element("name").Value; string path = item.Element("path").Value; if (File.Exists(path)) { slm.AddSound(id, path, name); } } return slm; }
static void Main() { string XMLFilePath = ConfigurationManager.AppSettings["XMLSamplesList"]; SoundLibraryModel library; if (File.Exists(XMLFilePath)) { try { XDocument xdoc = XDocument.Load(XMLFilePath); library = Tools.FileAccessor.LoadLibrary(xdoc); } catch (XmlException) { library = new SoundLibraryModel(); } } else { library = new SoundLibraryModel(); } Model.Model.GetInstance().SoundLibrary = library; Tools.FileAccessor.SaveLibrary(); XMLShortcutManager.Load(ShortcutManager<Keys>.GetInstance(), ShortcutManager<NoteID>.GetInstance(NoteID.Comparer)); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); RTS.View.MainFrame mainFrame = new RTS.View.MainFrame(); List<PadView> padList = new List<PadView>(); foreach (Control ctrl in mainFrame.Controls) { if (ctrl is PadView) { padList.Add((PadView)ctrl); } } PadsManager.Load(padList); Application.Run(mainFrame); }