protected FormProcess(ProcessingSession session) { _session = session; InitializeComponent(); _session.OnProgress += OnProgress; _processTask = new Task(() => { _session.Process(); this.Invoke((MethodInvoker) delegate { MessageBox.Show("Done!"); Close(); }); _session.Dispose(); _session = null; }); }
public static FormProcess Make() { // Bekerjuk az utvonalakat var paths = new string[2]; var titles = new string[2] { "Path to input video", "Path to output video" }; var filters = new string[2] { "All files (*.*)|*.*", "MP4 files (*.mp4)|*.mp4|All files (*.*)|*.*" }; var isOutput = new bool[2] { false, true }; for (int i = 0; i < titles.Length; i++) { var dlg = isOutput[i] ? (FileDialog) new SaveFileDialog() : (FileDialog) new OpenFileDialog(); dlg.Filter = filters[i]; dlg.Title = titles[i]; var res = dlg.ShowDialog(); if (res != DialogResult.OK) { return(null); } paths[i] = dlg.FileName; } var session = ProcessingSession.Make(paths[0], paths[1]); if (session == null) { return(null); } return(new FormProcess(session)); }