mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
Allow sort/move for "Add end time of prev" in "Join subtitles" - thx Leon :)
Work on #8257
This commit is contained in:
parent
2122a8dc30
commit
443d88d195
58
src/ui/Forms/JoinSubtitles.Designer.cs
generated
58
src/ui/Forms/JoinSubtitles.Designer.cs
generated
@ -28,6 +28,7 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonJoin = new System.Windows.Forms.Button();
|
||||
this.listViewParts = new System.Windows.Forms.ListView();
|
||||
@ -45,7 +46,13 @@
|
||||
this.numericUpDownAddMs = new Nikse.SubtitleEdit.Controls.NikseUpDown();
|
||||
this.radioButtonJoinAddTime = new System.Windows.Forms.RadioButton();
|
||||
this.labelAddTime = new Nikse.SubtitleEdit.Controls.NikseLabel();
|
||||
this.contextMenuStripParts = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.moveUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.moveDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.moveTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.moveBottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.groupBoxPreview.SuspendLayout();
|
||||
this.contextMenuStripParts.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
@ -83,6 +90,7 @@
|
||||
this.columnHeaderStartTime,
|
||||
this.columnHeaderEndTime,
|
||||
this.columnHeaderFileName});
|
||||
this.listViewParts.ContextMenuStrip = this.contextMenuStripParts;
|
||||
this.listViewParts.FullRowSelect = true;
|
||||
this.listViewParts.HideSelection = false;
|
||||
this.listViewParts.Location = new System.Drawing.Point(6, 19);
|
||||
@ -91,6 +99,7 @@
|
||||
this.listViewParts.TabIndex = 101;
|
||||
this.listViewParts.UseCompatibleStateImageBehavior = false;
|
||||
this.listViewParts.View = System.Windows.Forms.View.Details;
|
||||
this.listViewParts.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewParts_ColumnClick);
|
||||
this.listViewParts.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewParts_DragDrop);
|
||||
this.listViewParts.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewParts_DragEnter);
|
||||
//
|
||||
@ -252,6 +261,49 @@
|
||||
this.labelAddTime.TabIndex = 34;
|
||||
this.labelAddTime.Text = "Add milliseconds after each file";
|
||||
//
|
||||
// contextMenuStripParts
|
||||
//
|
||||
this.contextMenuStripParts.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.moveUpToolStripMenuItem,
|
||||
this.moveDownToolStripMenuItem,
|
||||
this.moveTopToolStripMenuItem,
|
||||
this.moveBottomToolStripMenuItem});
|
||||
this.contextMenuStripParts.Name = "contextMenuStrip1";
|
||||
this.contextMenuStripParts.Size = new System.Drawing.Size(216, 92);
|
||||
this.contextMenuStripParts.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripParts_Opening);
|
||||
//
|
||||
// moveUpToolStripMenuItem
|
||||
//
|
||||
this.moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem";
|
||||
this.moveUpToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Up)));
|
||||
this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
|
||||
this.moveUpToolStripMenuItem.Text = "Move up";
|
||||
this.moveUpToolStripMenuItem.Click += new System.EventHandler(this.moveUpToolStripMenuItem_Click);
|
||||
//
|
||||
// moveDownToolStripMenuItem
|
||||
//
|
||||
this.moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem";
|
||||
this.moveDownToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Down)));
|
||||
this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
|
||||
this.moveDownToolStripMenuItem.Text = "Move down";
|
||||
this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click);
|
||||
//
|
||||
// moveTopToolStripMenuItem
|
||||
//
|
||||
this.moveTopToolStripMenuItem.Name = "moveTopToolStripMenuItem";
|
||||
this.moveTopToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Home)));
|
||||
this.moveTopToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
|
||||
this.moveTopToolStripMenuItem.Text = "Move to top";
|
||||
this.moveTopToolStripMenuItem.Click += new System.EventHandler(this.moveTopToolStripMenuItem_Click);
|
||||
//
|
||||
// moveBottomToolStripMenuItem
|
||||
//
|
||||
this.moveBottomToolStripMenuItem.Name = "moveBottomToolStripMenuItem";
|
||||
this.moveBottomToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.End)));
|
||||
this.moveBottomToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
|
||||
this.moveBottomToolStripMenuItem.Text = "Move to bottom";
|
||||
this.moveBottomToolStripMenuItem.Click += new System.EventHandler(this.moveBottomToolStripMenuItem_Click);
|
||||
//
|
||||
// JoinSubtitles
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -279,6 +331,7 @@
|
||||
this.Resize += new System.EventHandler(this.JoinSubtitles_Resize);
|
||||
this.groupBoxPreview.ResumeLayout(false);
|
||||
this.groupBoxPreview.PerformLayout();
|
||||
this.contextMenuStripParts.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -303,5 +356,10 @@
|
||||
private Nikse.SubtitleEdit.Controls.NikseUpDown numericUpDownAddMs;
|
||||
private System.Windows.Forms.RadioButton radioButtonJoinAddTime;
|
||||
private Nikse.SubtitleEdit.Controls.NikseLabel labelAddTime;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStripParts;
|
||||
private System.Windows.Forms.ToolStripMenuItem moveUpToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem moveDownToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem moveTopToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem moveBottomToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -30,6 +30,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
listViewParts.Columns[2].Text = LanguageSettings.Current.JoinSubtitles.EndTime;
|
||||
listViewParts.Columns[3].Text = LanguageSettings.Current.JoinSubtitles.FileName;
|
||||
|
||||
moveUpToolStripMenuItem.Text = LanguageSettings.Current.DvdSubRip.MoveUp;
|
||||
moveDownToolStripMenuItem.Text = LanguageSettings.Current.DvdSubRip.MoveDown;
|
||||
moveTopToolStripMenuItem.Text = LanguageSettings.Current.MultipleReplace.MoveToTop;
|
||||
moveBottomToolStripMenuItem.Text = LanguageSettings.Current.MultipleReplace.MoveToBottom;
|
||||
|
||||
buttonAddFile.Text = LanguageSettings.Current.DvdSubRip.Add;
|
||||
buttonRemoveFile.Text = LanguageSettings.Current.DvdSubRip.Remove;
|
||||
buttonClear.Text = LanguageSettings.Current.DvdSubRip.Clear;
|
||||
@ -388,6 +393,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
MessageBox.Show(sb.ToString());
|
||||
}
|
||||
|
||||
JoinSubtitles_Resize(sender, e);
|
||||
}
|
||||
}
|
||||
@ -438,5 +444,203 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
labelAddTime.Enabled = radioButtonJoinAddTime.Checked;
|
||||
SortAndLoad();
|
||||
}
|
||||
|
||||
private void contextMenuStripParts_Opening(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (radioButtonJoinPlain.Checked)
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveUp(ListView listView)
|
||||
{
|
||||
if (listView.SelectedItems.Count != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var idx = listView.SelectedItems[0].Index;
|
||||
if (idx == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var item = listView.SelectedItems[0];
|
||||
listView.Items.RemoveAt(idx);
|
||||
var style = _fileNamesToJoin[idx];
|
||||
_fileNamesToJoin.RemoveAt(idx);
|
||||
_fileNamesToJoin.Insert(idx - 1, style);
|
||||
|
||||
idx--;
|
||||
listView.Items.Insert(idx, item);
|
||||
UpdateSelectedIndices(listView, idx);
|
||||
}
|
||||
|
||||
private void MoveDown(ListView listView)
|
||||
{
|
||||
if (listView.SelectedItems.Count != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var idx = listView.SelectedItems[0].Index;
|
||||
if (idx >= listView.Items.Count - 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var item = listView.SelectedItems[0];
|
||||
listView.Items.RemoveAt(idx);
|
||||
var style = _fileNamesToJoin[idx];
|
||||
_fileNamesToJoin.RemoveAt(idx);
|
||||
_fileNamesToJoin.Insert(idx + 1, style);
|
||||
|
||||
idx++;
|
||||
listView.Items.Insert(idx, item);
|
||||
UpdateSelectedIndices(listView, idx);
|
||||
}
|
||||
|
||||
private void MoveToTop(ListView listView)
|
||||
{
|
||||
if (listView.SelectedItems.Count != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var idx = listView.SelectedItems[0].Index;
|
||||
if (idx == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var item = listView.SelectedItems[0];
|
||||
listView.Items.RemoveAt(idx);
|
||||
var style = _fileNamesToJoin[idx];
|
||||
_fileNamesToJoin.RemoveAt(idx);
|
||||
_fileNamesToJoin.Insert(0, style);
|
||||
|
||||
idx = 0;
|
||||
listView.Items.Insert(idx, item);
|
||||
UpdateSelectedIndices(listView, idx);
|
||||
}
|
||||
|
||||
private void MoveToBottom(ListView listView)
|
||||
{
|
||||
if (listView.SelectedItems.Count != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var idx = listView.SelectedItems[0].Index;
|
||||
if (idx == listView.Items.Count - 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var item = listView.SelectedItems[0];
|
||||
listView.Items.RemoveAt(idx);
|
||||
var style = _fileNamesToJoin[idx];
|
||||
_fileNamesToJoin.RemoveAt(idx);
|
||||
_fileNamesToJoin.Add(style);
|
||||
|
||||
listView.Items.Add(item);
|
||||
UpdateSelectedIndices(listView);
|
||||
}
|
||||
|
||||
private static void UpdateSelectedIndices(ListView listView, int startingIndex = -1, int numberOfSelectedItems = 1)
|
||||
{
|
||||
if (numberOfSelectedItems == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (startingIndex == -1 || startingIndex >= listView.Items.Count)
|
||||
{
|
||||
startingIndex = listView.Items.Count - 1;
|
||||
}
|
||||
|
||||
if (startingIndex - numberOfSelectedItems < -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
listView.SelectedItems.Clear();
|
||||
for (var i = 0; i < numberOfSelectedItems; i++)
|
||||
{
|
||||
listView.Items[startingIndex - i].Selected = true;
|
||||
listView.Items[startingIndex - i].EnsureVisible();
|
||||
listView.Items[startingIndex - i].Focused = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void moveUpToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (radioButtonJoinPlain.Checked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MoveUp(listViewParts);
|
||||
}
|
||||
|
||||
private void moveDownToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (radioButtonJoinPlain.Checked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MoveDown(listViewParts);
|
||||
}
|
||||
|
||||
private void moveTopToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (radioButtonJoinPlain.Checked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MoveToTop(listViewParts);
|
||||
}
|
||||
|
||||
private void moveBottomToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (radioButtonJoinPlain.Checked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MoveToBottom(listViewParts);
|
||||
}
|
||||
|
||||
private void listViewParts_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||
{
|
||||
if (radioButtonJoinPlain.Checked || e.Column != 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var lv = (ListView)sender;
|
||||
if (!(lv.ListViewItemSorter is ListViewSorter sorter))
|
||||
{
|
||||
sorter = new ListViewSorter
|
||||
{
|
||||
ColumnNumber = e.Column,
|
||||
};
|
||||
lv.ListViewItemSorter = sorter;
|
||||
}
|
||||
|
||||
if (e.Column == sorter.ColumnNumber)
|
||||
{
|
||||
sorter.Descending = !sorter.Descending; // inverse sort direction
|
||||
}
|
||||
else
|
||||
{
|
||||
sorter.ColumnNumber = e.Column;
|
||||
}
|
||||
|
||||
lv.Sort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +117,9 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="contextMenuStripParts.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>159, 22</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
|
@ -13,7 +13,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public bool IsDisplayFileSize { get; set; }
|
||||
public bool Descending { get; set; }
|
||||
|
||||
private Regex _invariantNumber = new Regex(@"\d+\.{1,2}", RegexOptions.Compiled);
|
||||
private readonly Regex _invariantNumber = new Regex(@"\d+\.{1,2}", RegexOptions.Compiled);
|
||||
|
||||
public int Compare(object o1, object o2)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user