public ChapterFileSelector() { this.InitializeComponent(); this.Item = new ChapterItem(); this.bindingSource.DataSource = this.Item; }
private void AddFiles(IEnumerable <string> files) { foreach (var path in files) { var chapter = new ChapterItem(path); if (!string.IsNullOrEmpty(chapter.ChapterFileName)) { this.AddFileList(new ChapterItem(path)); } } }
private void AddFileList(ChapterItem chapter) { var item = new ListViewItem { Text = Path.GetFileName(chapter.VideoFileName), ToolTipText = chapter.VideoFileName, }; item.SubItems.Add(Path.GetFileName(chapter.ChapterFileName)); item.SubItems.Add(Path.GetFileName(chapter.ChapterFileName2)); item.Tag = chapter; this.chapterItemList.Items.Add(item); this.UpdateRunButtonStatus(); }
private async ValueTask <bool> RegisterChapters(ChapterItem chapter) { var textBox = this.consoleTextBox; if (!File.Exists(chapter.VideoFileName)) { textBox.AppendText("動画ファイルが見つかりません。\n"); return(false); } if (!File.Exists(chapter.ChapterFileName)) { textBox.AppendText("チャプター情報1に指定されたファイルが見つかりません。\n"); return(false); } var procArgs = $"\"{ chapter.VideoFileName }\" -chap \"{ chapter.ChapterFileName }\""; if (!string.IsNullOrEmpty(chapter.ChapterFileName2)) { if (!File.Exists(chapter.ChapterFileName2)) { textBox.AppendText("チャプター情報2に指定されたファイルが見つかりません。\n"); return(false); } else { procArgs += $" -add \"{ chapter.ChapterFileName2 }\":chap"; } } var pInfo = new ProcessStartInfo { FileName = this.Settings.Mp4BoxPath, Arguments = procArgs, CreateNoWindow = true, UseShellExecute = false, ErrorDialog = false, StandardErrorEncoding = Encoding.UTF8, StandardOutputEncoding = Encoding.UTF8, RedirectStandardOutput = true, RedirectStandardError = true, RedirectStandardInput = true, }; var p = Process.Start(pInfo); var outputStream = p.StandardOutput; var errorStream = p.StandardError; this._currentProcess = p; var outputTask = Task.Run(() => { while (!outputStream.EndOfStream) { this.OnMessageReceived(outputStream.ReadLine()); } }); var errorTask = Task.Run(() => { while (!errorStream.EndOfStream) { this.OnMessageReceived(errorStream.ReadLine()); } }); await Task.Run((Action)p.WaitForExit); await Task.WhenAll(outputTask, errorTask); this._currentProcess = null; return(p.ExitCode == 0); }