示例#1
0
        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();
                }
            }
        }
示例#2
0
 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());
 }
示例#3
0
 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();
 }
示例#4
0
        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)));
            }
        }