new public static WPFTranscription Deserialize(string path) { WPFTranscription t; using (var s = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)) t = WPFTranscription.Deserialize(s); t.FileName = path; return(t); }
public WPFTranscription ExecuteImport(string sourcefile = null) { if (sourcefile == null) { OpenFileDialog opf = new OpenFileDialog(); opf.CheckFileExists = true; opf.CheckPathExists = true; opf.Filter = _mask; if (opf.ShowDialog() == true) { sourcefile = opf.FileName; } } if (File.Exists(sourcefile)) { try { if (Isassembly) { using (var f = File.OpenRead(sourcefile)) { var imp = new WPFTranscription(); if (!_importDelegate.Invoke(f, imp)) { throw new Exception(); } imp.FileName = sourcefile; return(imp); } } else { string inputfile = sourcefile; string tempFolder = FilePaths.TempDirectory; string tempFile = System.IO.Path.Combine(tempFolder, System.IO.Path.GetRandomFileName()) + ".trsx"; ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = Path.Combine(FilePaths.GetReadPath(FilePaths.PluginsPath), _fileName); psi.Arguments = string.Format(_parameters, "\"" + inputfile + "\"", "\"" + tempFile + "\"", "\"" + tempFolder + "\""); Process p = new Process(); p.StartInfo = psi; p.Start(); p.WaitForExit(); var data = WPFTranscription.Deserialize(tempFile); return(data); } } catch { MessageBox.Show(Properties.Strings.MessageBoxImportError, Properties.Strings.MessageBoxErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error); } } return(null); }