private void UpdateTask(ListViewItem lvi)
        {
            if (lvi != null && lvi.Tag != null)
            {
                VideoConvertTask t = lvi.Tag as VideoConvertTask;
                if (t != null)
                {
                    if (this.InvokeRequired)
                    {
                        this.Invoke(new UpdateListItem(UpdateTask), lvi);
                    }
                    else
                    {
                        lvi.SubItems[1].Text = string.Format("{0}x{1}", t.ConversionOption.VideoOption.Width, t.ConversionOption.VideoOption.Height);
                        lvi.SubItems[2].Text = Path.GetExtension(t.ConversionOption.OutputPath);
                        lvi.SubItems[3].Text = "no change";

                        if (t.IsCompleted)
                        {
                            lvi.SubItems[4].Text = string.Format("Completed in {0}", t.ConversionTime);
                            lvi.Tag = null; //no longer needs update...
                        }
                        else
                        {
                            lvi.SubItems[4].Text = t.Progress;
                        }
                    }
                }
            }
        }
 private void listView_Tasks_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.listView_Tasks.SelectedItems != null && this.listView_Tasks.SelectedItems.Count > 0)
     {
         VideoConvertTask vt = listView_Tasks.SelectedItems[0].Tag as VideoConvertTask;
         this.ConversionOption2Setting(vt.ConversionOption);
     }
 }
        private ListViewItem TaskToLVI(VideoConvertTask t)
        {
            ListViewItem lvi = new ListViewItem(Path.GetFileName(t.VideoFilePath));

            lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, string.Format("{0}x{1}", t.ConversionOption.VideoOption.Width, t.ConversionOption.VideoOption.Height)));
            lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, Path.GetExtension(t.ConversionOption.OutputPath)));
            lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, "no change"));
            lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, "Waiting"));
            lvi.Tag = t;
            return(lvi);
        }
 private void timer_Progress_Tick(object sender, EventArgs e)
 {
     foreach (ListViewItem i in listView_Tasks.Items)
     {
         VideoConvertTask t = i.Tag as VideoConvertTask;
         if (t != null && t.IsStarted())
         {
             UpdateTask(i);
         }
     }
 }
        private void backgroundWorker_StartWork_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkArgs args = e.Argument as WorkArgs;

            foreach (string f in args.files)
            {
                string           newFilePath = Path.Combine(Properties.Settings.Default.OutputPath, Path.GetFileNameWithoutExtension(f) + args.fileExtension);
                VideoConvertTask vt          = new VideoConvertTask(args.TaskContainer.Count + 1, f, newFilePath);
                args.TaskContainer.Add(vt);
            }
        }