void ApplyTextCfg(string src) { string[] lines = src.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); int ix; string ln, tm; TargetClip tcl, pcl = null; TrackTimeT trt; List <TargetClip> rz = new List <TargetClip>(); TimeSpan tsp; double gapSec = 2; foreach (var ts in lines) { ln = ts.Trim(); ix = ln.IndexOf(' '); if (ix < 0) { continue; } tm = ln.Substring(0, ix); if (TryParseTS(tm, out tsp)) { tcl = new TargetClip() { TargetFile = "+-" + ln.Substring(ix + 1).Trim(), SourceFrame = new TrackTimeT() { Start = tsp } }; if (pcl != null) { pcl.SourceFrame.Stop = tcl.SourceFrame.Start.Value - TimeSpan.FromSeconds(gapSec); } rz.Add(tcl); pcl = tcl; // prev clip } } if (this.CurrentSource != null) { foreach (var t in rz) { this.CurrentSource.Targets.Add(t); } } }
IEnumerable <CodeValuePair> EnumerateTrgParams(TargetClip trg) { string tfn; if (!string.IsNullOrEmpty(trg.TargetFile)) { if (trg.TargetFile.StartsWith("+")) { tfn = System.IO.Path.GetFileNameWithoutExtension(trg.Source.SourcePath) + trg.TargetFile.Substring(1); } else { tfn = trg.TargetFile; } } else { tfn = System.IO.Path.GetFileNameWithoutExtension(trg.Source.SourcePath); } yield return(new CodeValuePair() { Code = TemplParams.TrgFileName, Value = tfn }); yield return(new CodeValuePair() { Code = TemplParams.TrgDirPath, Value = System.IO.Path.GetDirectoryName(trg.Source.SourcePath) }); yield return(new CodeValuePair() { Code = TemplParams.TimeStart, Value = ToTimeCodeStr(trg.SourceFrame.Start) }); yield return(new CodeValuePair() { Code = TemplParams.TimeStop, Value = ToTimeCodeStr(trg.SourceFrame.Stop) }); yield return(new CodeValuePair() { Code = TemplParams.TimeDuration, Value = ToTimeCodeStr(trg.SourceFrame.Duration) }); }