private void LoadTitles() { if (System.IO.File.Exists(fTitles)) { XmlDocument xDoc = new XmlDocument(); XmlElement xTitle; xDoc.Load(fTitles); if (xDoc.DocumentElement.HasChildNodes) { foreach (XmlNode xNode in xDoc.DocumentElement.ChildNodes) { xTitle = (XmlElement)xNode; title oTitle = new title(); XmlAttribute xAttr = (XmlAttribute)xTitle.Attributes.GetNamedItem(@"filename"); if (xAttr != null) { oTitle.Filename = xAttr.Value; oTitle.Title = xTitle.InnerText; Titles.Add(oTitle); } } } } Utilities.DebugLine("[OMLFileWatcher] LoadTitles (#{0} titles)", Titles.Count); }
private void fsw_Changed(object sender, System.IO.FileSystemEventArgs e) { OnChanged(e); string filepath = Path.GetDirectoryName(e.FullPath); string fileext = Path.GetExtension(e.FullPath); title oTitle = FindTitle(e.FullPath); SaveTitles(); }
private void fsw_Deleted(object sender, System.IO.FileSystemEventArgs e) { OnDeleted(e); string filepath = Path.GetDirectoryName(e.FullPath); string fileext = Path.GetExtension(e.FullPath); title oTitle = FindTitle(e.FullPath); if (oTitle != null) { Titles.Remove(oTitle); } SaveTitles(); }
private void fsw_Renamed(object sender, System.IO.RenamedEventArgs e) { OnRenamed(e); string filepath = Path.GetDirectoryName(e.FullPath); string fileext = Path.GetExtension(e.FullPath); title oTitle = FindTitle(e.FullPath); if (oTitle != null) { oTitle.Filename = e.FullPath; if (oTitle.Title == Path.GetFileNameWithoutExtension(e.OldFullPath)) { oTitle.Title = Path.GetFileNameWithoutExtension(e.FullPath); } } SaveTitles(); }
private title FindTitle(String fPath) { title oTitle = null; List <title> query = new List <title>(); foreach (title lTitle in Titles) { if (lTitle.Filename == fPath) { query.Add(oTitle); } } if (query.Count == 1) { oTitle = query[0]; } return(oTitle); }