private void btnAddTrim_Click(object sender, EventArgs e) { var node = treeFiles.SelectedNode; if (node == null) { return; } if (node is VideoFileTrimNode) { node = node.Parent; } var file = node as VideoFileNode; if (file == null) { return; } using (var dlg = new EditTrimDialog(GetTrimNames())) { dlg.Text = "Add Trim"; if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { var trim = new VideoFileTrimNode(); ApplyTrim(trim, dlg); file.Nodes.Add(trim); file.Expand(); } } }
private string[] GetTrimNames(VideoFileTrimNode trim = null) { return(treeFiles.Nodes.OfType <VideoFileNode>() .SelectMany(n => n.Nodes.OfType <VideoFileTrimNode>()) .Where(n => n != trim) .Select(n => n.TrimName) .ToArray()); }
private void ApplyTrim(VideoFileTrimNode trim, EditTrimDialog dlg) { trim.Start = dlg.Start; trim.End = dlg.End; trim.SpecifyEnd = dlg.SpecifyEnd; trim.TrimName = dlg.TrimName; trim.UpdateText(); }
public string GenerateTrimPath(int number, VideoFileTrimNode trim) { string name = Path.GetFileNameWithoutExtension(file.FullName); string ext = file.Extension; string dir = file.Directory.FullName; string trimName = ToSafeFileName(trim.TrimName); if (string.IsNullOrWhiteSpace(trimName)) { return(Path.Combine(dir, string.Format("{0}_trim{1:00}{2}", name, number, ext))); } else { return(Path.Combine(dir, string.Format("{0}_{1}{2}", name, trimName, ext))); } }