/// <summary> /// Create a new set of recordings data for the specified MythTV backend. /// </summary> /// <param name="mythhost">Hostname or IP address for the MythTV backend</param> /// <param name="mythport">Services API port for the MythTV backend</param> /// <param name="sortOption">How the shows should be sorted</param> public MythRecordings(string mythhost, int mythport, RecordingSortOption sortOption) { _mythHost = mythhost; _mythPort = mythport; SortOption = sortOption; Refresh(); }
public bool Load() { if(File.Exists(SettingsFilePath)) { using(FileStream stream = File.Open(SettingsFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { XmlDocument xml = new XmlDocument(); xml.Load(stream); foreach(XmlNode node in xml.LastChild.ChildNodes) // LastChild because the document's children are the xml declaration and then the root node try { switch(node.Name) { case "ServerName": ServerName = node.InnerText; break; case "ServerPort": int.TryParse(node.InnerText, out ServerPort); break; case "RawFilesDirectory": RawFilesDirectory = node.InnerText; break; case "LastExportDirectory": LastExportDirectory = node.InnerText; try { while(!Directory.Exists(LastExportDirectory)) { LastExportDirectory = Directory.GetParent(LastExportDirectory).FullName; } } catch { LastExportDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos); } break; case "SortOption": int so; if(int.TryParse(node.InnerText, out so)) switch(so) { case (int)RecordingSortOption.Title: SortOption = RecordingSortOption.Title; break; case (int)RecordingSortOption.OldestRecorded: SortOption = RecordingSortOption.OldestRecorded; break; } break; case "Display": Display = new DisplaySettings(node); break; case "Export": // pre-1.0 setting that translates to 1.0 LastExportDirectory = ((XmlElement)node).ElementValue("Where"); try { while(!Directory.Exists(LastExportDirectory)) { LastExportDirectory = Directory.GetParent(LastExportDirectory).FullName; } } catch { LastExportDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos); } break; } } catch(Exception e) { Trace.WriteLine("MythSettings.Load() ERROR reading node " + node.Name + " so it was skipped. Details:\n" + e); } } return true; } return false; }