public void loadProject(string filepath) { string workdir = Path.GetDirectoryName(filepath); XmlDocument doc = new XmlDocument(); try { doc.Load(filepath); foreach (XmlNode node in doc.SelectNodes("//media")) { bool isvideo = true; string path = node.InnerText; if (Path.GetExtension(path) == ".wav") { isvideo = false; } loadMedia(FileTools.GetAbsolutePath(path, workdir), isvideo); } foreach (XmlNode node in doc.SelectNodes("//signal")) { string background = node.Attributes["bg"].LastChild.Value; string foreground = node.Attributes["fg"].LastChild.Value; string path = node.InnerText; if (Path.GetExtension(path) == ".wav") { loadWav(FileTools.GetAbsolutePath(path, workdir), foreground, background); } else { loadStream(FileTools.GetAbsolutePath(path, workdir), foreground, background); } } foreach (XmlNode node in (doc.SelectNodes("//tier"))) { string path = node.InnerText; if (path == "") { path = node.Attributes["filepath"].LastChild.Value; } loadFileHandler(FileTools.GetAbsolutePath(path, workdir)); } } catch (Exception e) { MessageTools.Error(e.ToString()); } }
public void loadProjectFile(string filepath) { clearWorkspace(); string workdir = Path.GetDirectoryName(filepath); XmlDocument doc = new XmlDocument(); try { doc.Load(filepath); foreach (XmlNode node in doc.SelectNodes("//media")) { string path = FileTools.GetAbsolutePath(node.InnerText, workdir); loadFile(path); } foreach (XmlNode node in doc.SelectNodes("//signal")) { Color background = Defaults.Colors.Background; Color foreground = Defaults.Colors.Foreground; if (node.Attributes["bg"] != null) { background = (Color)ColorConverter.ConvertFromString(node.Attributes["bg"].LastChild.Value); } if (node.Attributes["fg"] != null) { foreground = (Color)ColorConverter.ConvertFromString(node.Attributes["fg"].LastChild.Value); } string path = FileTools.GetAbsolutePath(node.InnerText, workdir); loadFile(path, foreground, background); } if (DatabaseHandler.IsConnected) { XmlNode node = doc.SelectSingleNode("//tiers"); if (node != null && node.Attributes["database"] != null) { DatabaseHandler.ChangeDatabase(node.Attributes["database"].LastChild.Value); } } foreach (XmlNode node in (doc.SelectNodes("//tier"))) { string path = node.InnerText; if (!Path.HasExtension(path)) { AnnoList annoList = DatabaseHandler.LoadAnnoList(path); if (annoList != null) { addAnnoTier(annoList); } else { MessageTools.Warning("Could not load annotation from database with id '" + node.InnerText + "'"); } } else { if (path == "") { path = node.Attributes["filepath"].LastChild.Value; } path = FileTools.GetAbsolutePath(path, workdir); loadFile(path); } } } catch (Exception e) { MessageTools.Error(e.ToString()); } }