This commit is contained in:
Nikolaj Olsson 2024-04-20 07:33:28 +02:00
parent 7e0fa1f56a
commit 903b2c2a73
2 changed files with 66 additions and 14 deletions

View File

@ -87,6 +87,8 @@ namespace Nikse.SubtitleEdit.Forms
this.x352ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.x352ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.x272ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.x272ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonMode = new System.Windows.Forms.Button(); this.buttonMode = new System.Windows.Forms.Button();
this.removeSubtitleFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.labelPreviewPleaseWait = new Nikse.SubtitleEdit.Controls.NikseLabel(); this.labelPreviewPleaseWait = new Nikse.SubtitleEdit.Controls.NikseLabel();
this.videoPlayerContainer1 = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); this.videoPlayerContainer1 = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer();
this.numericUpDownCutToSeconds = new Nikse.SubtitleEdit.Controls.NikseUpDown(); this.numericUpDownCutToSeconds = new Nikse.SubtitleEdit.Controls.NikseUpDown();
@ -493,6 +495,7 @@ namespace Nikse.SubtitleEdit.Forms
this.columnHeaderSubtitleFile, this.columnHeaderSubtitleFile,
this.columnHeaderStatus}); this.columnHeaderStatus});
this.listViewBatch.ContextMenuStrip = this.contextMenuStripBatch; this.listViewBatch.ContextMenuStrip = this.contextMenuStripBatch;
this.listViewBatch.FullRowSelect = true;
this.listViewBatch.HideSelection = false; this.listViewBatch.HideSelection = false;
this.listViewBatch.Location = new System.Drawing.Point(6, 316); this.listViewBatch.Location = new System.Drawing.Point(6, 316);
this.listViewBatch.Name = "listViewBatch"; this.listViewBatch.Name = "listViewBatch";
@ -502,6 +505,7 @@ namespace Nikse.SubtitleEdit.Forms
this.listViewBatch.View = System.Windows.Forms.View.Details; this.listViewBatch.View = System.Windows.Forms.View.Details;
this.listViewBatch.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewBatch_DragDrop); this.listViewBatch.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewBatch_DragDrop);
this.listViewBatch.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewBatch_DragEnter); this.listViewBatch.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewBatch_DragEnter);
this.listViewBatch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listViewBatch_KeyDown);
// //
// columnHeaderVideoFile // columnHeaderVideoFile
// //
@ -527,44 +531,46 @@ namespace Nikse.SubtitleEdit.Forms
// //
this.contextMenuStripBatch.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.contextMenuStripBatch.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addFilesToolStripMenuItem, this.addFilesToolStripMenuItem,
this.toolStripSeparator2,
this.pickSubtitleFileToolStripMenuItem, this.pickSubtitleFileToolStripMenuItem,
this.removeSubtitleFileToolStripMenuItem,
this.toolStripSeparator1, this.toolStripSeparator1,
this.deleteToolStripMenuItem, this.deleteToolStripMenuItem,
this.clearToolStripMenuItem}); this.clearToolStripMenuItem});
this.contextMenuStripBatch.Name = "contextMenuStripBatch"; this.contextMenuStripBatch.Name = "contextMenuStripBatch";
this.contextMenuStripBatch.Size = new System.Drawing.Size(167, 98); this.contextMenuStripBatch.Size = new System.Drawing.Size(179, 126);
this.contextMenuStripBatch.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripBatch_Opening); this.contextMenuStripBatch.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripBatch_Opening);
// //
// addFilesToolStripMenuItem // addFilesToolStripMenuItem
// //
this.addFilesToolStripMenuItem.Name = "addFilesToolStripMenuItem"; this.addFilesToolStripMenuItem.Name = "addFilesToolStripMenuItem";
this.addFilesToolStripMenuItem.Size = new System.Drawing.Size(166, 22); this.addFilesToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.addFilesToolStripMenuItem.Text = "Add video files..."; this.addFilesToolStripMenuItem.Text = "Add video files...";
this.addFilesToolStripMenuItem.Click += new System.EventHandler(this.addFilesToolStripMenuItem_Click); this.addFilesToolStripMenuItem.Click += new System.EventHandler(this.addFilesToolStripMenuItem_Click);
// //
// pickSubtitleFileToolStripMenuItem // pickSubtitleFileToolStripMenuItem
// //
this.pickSubtitleFileToolStripMenuItem.Name = "pickSubtitleFileToolStripMenuItem"; this.pickSubtitleFileToolStripMenuItem.Name = "pickSubtitleFileToolStripMenuItem";
this.pickSubtitleFileToolStripMenuItem.Size = new System.Drawing.Size(166, 22); this.pickSubtitleFileToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.pickSubtitleFileToolStripMenuItem.Text = "Pick subtitle file..."; this.pickSubtitleFileToolStripMenuItem.Text = "Pick subtitle file...";
this.pickSubtitleFileToolStripMenuItem.Click += new System.EventHandler(this.pickSubtitleFileToolStripMenuItem_Click); this.pickSubtitleFileToolStripMenuItem.Click += new System.EventHandler(this.pickSubtitleFileToolStripMenuItem_Click);
// //
// toolStripSeparator1 // toolStripSeparator1
// //
this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(163, 6); this.toolStripSeparator1.Size = new System.Drawing.Size(175, 6);
// //
// deleteToolStripMenuItem // deleteToolStripMenuItem
// //
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(166, 22); this.deleteToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.deleteToolStripMenuItem.Text = "Delete"; this.deleteToolStripMenuItem.Text = "Delete";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
// //
// clearToolStripMenuItem // clearToolStripMenuItem
// //
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem"; this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
this.clearToolStripMenuItem.Size = new System.Drawing.Size(166, 22); this.clearToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.clearToolStripMenuItem.Text = "Clear"; this.clearToolStripMenuItem.Text = "Clear";
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click); this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
// //
@ -721,6 +727,18 @@ namespace Nikse.SubtitleEdit.Forms
this.buttonMode.UseVisualStyleBackColor = true; this.buttonMode.UseVisualStyleBackColor = true;
this.buttonMode.Click += new System.EventHandler(this.buttonMode_Click); this.buttonMode.Click += new System.EventHandler(this.buttonMode_Click);
// //
// removeSubtitleFileToolStripMenuItem
//
this.removeSubtitleFileToolStripMenuItem.Name = "removeSubtitleFileToolStripMenuItem";
this.removeSubtitleFileToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.removeSubtitleFileToolStripMenuItem.Text = "Remove subtitle file";
this.removeSubtitleFileToolStripMenuItem.Click += new System.EventHandler(this.removeSubtitleFileToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(175, 6);
//
// labelPreviewPleaseWait // labelPreviewPleaseWait
// //
this.labelPreviewPleaseWait.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.labelPreviewPleaseWait.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@ -1602,6 +1620,7 @@ namespace Nikse.SubtitleEdit.Forms
this.Shown += new System.EventHandler(this.GenerateVideoWithHardSubs_Shown); this.Shown += new System.EventHandler(this.GenerateVideoWithHardSubs_Shown);
this.ResizeEnd += new System.EventHandler(this.GenerateVideoWithHardSubs_ResizeEnd); this.ResizeEnd += new System.EventHandler(this.GenerateVideoWithHardSubs_ResizeEnd);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GenerateVideoWithHardSubs_KeyDown); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GenerateVideoWithHardSubs_KeyDown);
this.Resize += new System.EventHandler(this.GenerateVideoWithHardSubs_Resize);
this.contextMenuStripGenerate.ResumeLayout(false); this.contextMenuStripGenerate.ResumeLayout(false);
this.groupBoxSettings.ResumeLayout(false); this.groupBoxSettings.ResumeLayout(false);
this.groupBoxSettings.PerformLayout(); this.groupBoxSettings.PerformLayout();
@ -1719,5 +1738,7 @@ namespace Nikse.SubtitleEdit.Forms
private System.Windows.Forms.Button buttonAddFile; private System.Windows.Forms.Button buttonAddFile;
private System.Windows.Forms.ListView listViewAudioTracks; private System.Windows.Forms.ListView listViewAudioTracks;
private System.Windows.Forms.ColumnHeader columnHeaderAudioTrack; private System.Windows.Forms.ColumnHeader columnHeaderAudioTrack;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem removeSubtitleFileToolStripMenuItem;
} }
} }

View File

@ -1925,6 +1925,8 @@ namespace Nikse.SubtitleEdit.Forms
private void contextMenuStripBatch_Opening(object sender, System.ComponentModel.CancelEventArgs e) private void contextMenuStripBatch_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{ {
pickSubtitleFileToolStripMenuItem.Visible = listViewBatch.SelectedItems.Count == 1; pickSubtitleFileToolStripMenuItem.Visible = listViewBatch.SelectedItems.Count == 1;
removeSubtitleFileToolStripMenuItem.Visible = listViewBatch.SelectedItems.Count >= 1;
toolStripSeparator2.Visible = listViewBatch.SelectedItems.Count >= 1;
if (listViewBatch.Items.Count == 0) if (listViewBatch.Items.Count == 0)
{ {
@ -1998,16 +2000,16 @@ namespace Nikse.SubtitleEdit.Forms
var path = Path.GetDirectoryName(fileName); var path = Path.GetDirectoryName(fileName);
var fileNameNoExt = Path.GetFileNameWithoutExtension(fileName); var fileNameNoExt = Path.GetFileNameWithoutExtension(fileName);
var subFileName = Path.ChangeExtension(fileName, ".srt"); var subFileName = Path.ChangeExtension(fileName, ".ass");
if (!File.Exists(subFileName)) if (!File.Exists(subFileName))
{ {
subFileName = Path.ChangeExtension(fileName, ".ass"); subFileName = Path.ChangeExtension(fileName, ".srt");
} }
if (!File.Exists(subFileName)) if (!File.Exists(subFileName))
{ {
var files = Directory.GetFiles(path, fileNameNoExt + "*.srt"); var files = Directory.GetFiles(path, fileNameNoExt + "*.ass");
if (files.Length > 0) if (files.Length > 0)
{ {
subFileName = files[0]; subFileName = files[0];
@ -2016,7 +2018,7 @@ namespace Nikse.SubtitleEdit.Forms
if (!File.Exists(subFileName)) if (!File.Exists(subFileName))
{ {
var files = Directory.GetFiles(path, fileNameNoExt + "*.ass"); var files = Directory.GetFiles(path, fileNameNoExt + "*.srt");
if (files.Length > 0) if (files.Length > 0)
{ {
subFileName = files[0]; subFileName = files[0];
@ -2042,10 +2044,17 @@ namespace Nikse.SubtitleEdit.Forms
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{ {
for (var i = listViewBatch.SelectedIndices.Count - 1; i >= 0; i--) var indices = new List<int>();
foreach (int i in listViewBatch.SelectedIndices)
{ {
listViewBatch.Items.RemoveAt(listViewBatch.SelectedIndices[i]); indices.Add(i);
_batchVideoAndSubList.RemoveAt(listViewBatch.SelectedIndices[i]); }
indices = indices.OrderBy(p => p).ToList();
for (var i = indices.Count - 1; i >= 0; i--)
{
listViewBatch.Items.RemoveAt(i);
_batchVideoAndSubList.RemoveAt(i);
} }
} }
@ -2061,6 +2070,11 @@ namespace Nikse.SubtitleEdit.Forms
listViewAudioTracks.AutoSizeLastColumn(); listViewAudioTracks.AutoSizeLastColumn();
} }
private void GenerateVideoWithHardSubs_Resize(object sender, EventArgs e)
{
GenerateVideoWithHardSubs_ResizeEnd(null, null);
}
private void listViewBatch_DragEnter(object sender, DragEventArgs e) private void listViewBatch_DragEnter(object sender, DragEventArgs e)
{ {
if (_converting) if (_converting)
@ -2101,7 +2115,6 @@ namespace Nikse.SubtitleEdit.Forms
} }
} }
}); });
} }
finally finally
{ {
@ -2151,5 +2164,23 @@ namespace Nikse.SubtitleEdit.Forms
listViewBatch.Items[idx].SubItems[2].Text = Path.GetFileName(openFileDialog1.FileName); listViewBatch.Items[idx].SubItems[2].Text = Path.GetFileName(openFileDialog1.FileName);
} }
} }
private void listViewBatch_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
deleteToolStripMenuItem_Click(null, null);
e.SuppressKeyPress = true;
}
}
private void removeSubtitleFileToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (int i in listViewBatch.SelectedIndices)
{
listViewBatch.Items[i].SubItems[2].Text = string.Empty;
_batchVideoAndSubList[i].SubtitleFileName = null;
}
}
} }
} }