private string[] GetItemValues(VsItem vsItem) { var showFullName = AppSettings.ListShowFileFullName; var subRenameDict = GetSubRenameDict(); // 重命名字幕文件路径词典 var videoText = vsItem.Video != null ? (showFullName ? vsItem.Video : Path.GetFileName(vsItem.Video)) : ""; var subText = vsItem.Sub != null ? (showFullName ? vsItem.Sub : Path.GetFileName(vsItem.Sub)) : ""; // 显示预览内容 if (PreviewCheckBox.Checked) { videoText = subText; if (vsItem.Sub != null && subRenameDict.ContainsKey(vsItem.Sub)) { subText = showFullName ? subRenameDict[vsItem.Sub] : Path.GetFileName(subRenameDict[vsItem.Sub]); } else { subText = "(不修改)"; } } return(new string[] { vsItem.MatchKey ?? "", videoText, subText, vsItem.GetStatusStr() }); }
private void NextItemBtn_Click(object sender, EventArgs e) { int pos = vsList.IndexOf(vsItem) + 1; if (pos >= vsList.Count) { return; } mainForm.RefreshFileListUi(removeNull: false); vsItem = vsList[pos]; RefreshByVsItem(); }
public VsItemEditor(MainForm mainForm, List <VsItem> vsList, VsItem vsItem) { this.mainForm = mainForm; this.vsList = vsList; this.vsItem = vsItem; InitializeComponent(); MainToolTip.SetToolTip(PrevItemBtn, "上一个项目"); MainToolTip.SetToolTip(NextItemBtn, "下一个项目"); MainToolTip.SetToolTip(AddItemBtn, "新增一个项目"); MainToolTip.SetToolTip(RemoveItemBtn, "删除此项目"); MainToolTip.SetToolTip(Video_ClearBtn, "删除视频"); MainToolTip.SetToolTip(Video_SelectFileBtn, "选择新视频"); MainToolTip.SetToolTip(Sub_ClearBtn, "删除字幕"); MainToolTip.SetToolTip(Sub_SelectFileBtn, "选择新字幕"); }
// 文件添加 private void FileListAdd(FileInfo file) { AppFileType fileType; if (VideoExts.Contains(file.Extension.ToString().ToLower())) { fileType = AppFileType.Video; } else if (SubExts.Contains(file.Extension.ToString().ToLower())) { fileType = AppFileType.Sub; } else { return; } var vsItem = new VsItem(); if (fileType == AppFileType.Video) { if (VsList.Exists(o => o.Video == file.FullName)) { return; // 重名排除 } vsItem.Video = file.FullName; } else if (fileType == AppFileType.Sub) { if (VsList.Exists(o => o.Sub == file.FullName)) { return; } vsItem.Sub = file.FullName; } vsItem.Status = VsStatus.Unmatched; VsList.Add(vsItem); }
private void RemoveItemBtn_Click(object sender, EventArgs e) { if (AppSettings.ListItemRemovePrompt) { var result = MessageBox.Show($"你要删除当前编辑的项目吗?", "删除编辑项", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { return; } } int pos = vsList.IndexOf(vsItem); if (pos < 0) { return; } vsList.Remove(vsItem); if (vsList.Count > 0) { if (pos < vsList.Count) { vsItem = vsList[pos]; } else { vsItem = vsList[pos - 1]; } RefreshByVsItem(); } else { CreateItem(); } mainForm.RefreshFileListUi(removeNull: false); }
private void CreateItem() { vsItem = new VsItem(); vsList.Add(vsItem); RefreshByVsItem(); }
// 打开 VsItem 编辑器 private void OpenVsItemEditor(VsItem vsItem) { var form = new VsItemEditor(this, VsList, vsItem); form.ShowDialog(); }