Minor UI improvements for "Batch convert" UI

This commit is contained in:
Nikolaj Olsson 2020-03-14 08:29:07 +01:00
parent 76e1a704b2
commit b68ad27230
2 changed files with 56 additions and 2 deletions

View File

@ -88,6 +88,7 @@
this.comboBoxEncoding = new System.Windows.Forms.ComboBox();
this.labelOutputFormat = new System.Windows.Forms.Label();
this.groupBoxInput = new System.Windows.Forms.GroupBox();
this.labelNumberOfFiles = new System.Windows.Forms.Label();
this.textBoxFilter = new System.Windows.Forms.TextBox();
this.labelFilter = new System.Windows.Forms.Label();
this.comboBoxFilter = new System.Windows.Forms.ComboBox();
@ -806,6 +807,7 @@
this.groupBoxInput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxInput.Controls.Add(this.labelNumberOfFiles);
this.groupBoxInput.Controls.Add(this.textBoxFilter);
this.groupBoxInput.Controls.Add(this.labelFilter);
this.groupBoxInput.Controls.Add(this.comboBoxFilter);
@ -821,6 +823,16 @@
this.groupBoxInput.TabStop = false;
this.groupBoxInput.Text = "Input";
//
// labelNumberOfFiles
//
this.labelNumberOfFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.labelNumberOfFiles.Location = new System.Drawing.Point(872, 258);
this.labelNumberOfFiles.Name = "labelNumberOfFiles";
this.labelNumberOfFiles.Size = new System.Drawing.Size(100, 16);
this.labelNumberOfFiles.TabIndex = 14;
this.labelNumberOfFiles.Text = "labelNumberOfFiles";
this.labelNumberOfFiles.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// textBoxFilter
//
this.textBoxFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@ -1116,5 +1128,6 @@
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll;
private System.Windows.Forms.ToolStripMenuItem inverseSelectionToolStripMenuItem;
private System.Windows.Forms.Button buttonBrowseEncoding;
private System.Windows.Forms.Label labelNumberOfFiles;
}
}

View File

@ -322,6 +322,7 @@ namespace Nikse.SubtitleEdit.Forms
inverseSelectionToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection;
toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll;
UpdateNumberOfFiles();
var fixItems = new List<FixActionItem>
{
@ -691,6 +692,7 @@ namespace Nikse.SubtitleEdit.Forms
{
// ignored
}
UpdateNumberOfFiles();
}
private void listViewInputFiles_DragEnter(object sender, DragEventArgs e)
@ -733,7 +735,7 @@ namespace Nikse.SubtitleEdit.Forms
}
finally
{
labelStatus.Text = Configuration.Settings.Language.General.PleaseWait;
labelStatus.Text = string.Empty;
listViewInputFiles.EndUpdate();
}
}
@ -1520,14 +1522,20 @@ namespace Nikse.SubtitleEdit.Forms
{
progressBar1.Value++;
}
else
{
progressBar1.Value = progressBar1.Maximum;
}
progressBar1.Refresh();
TaskbarList.SetProgressValue(Handle, progressBar1.Value, progressBar1.Maximum);
labelStatus.Text = progressBar1.Value + " / " + progressBar1.Maximum;
if (progressBar1.Value == progressBar1.Maximum)
{
labelStatus.Text = string.Empty;
}
Application.DoEvents();
}
private static void DoThreadWork(object sender, DoWorkEventArgs e)
@ -1936,6 +1944,7 @@ namespace Nikse.SubtitleEdit.Forms
private void RemoveAllToolStripMenuItemClick(object sender, EventArgs e)
{
listViewInputFiles.Items.Clear();
UpdateNumberOfFiles();
}
private void RemoveSelectedFiles()
@ -1945,10 +1954,28 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
int first = -1;
for (int i = listViewInputFiles.SelectedIndices.Count - 1; i >= 0; i--)
{
if (first < 0)
{
first = listViewInputFiles.SelectedIndices[i];
}
listViewInputFiles.Items.RemoveAt(listViewInputFiles.SelectedIndices[i]);
}
// keep an item selected/focused for improved UX
if (first < listViewInputFiles.Items.Count)
{
listViewInputFiles.Items[first].Selected = true;
listViewInputFiles.FocusedItem = listViewInputFiles.Items[first];
}
else if (listViewInputFiles.Items.Count > 0)
{
listViewInputFiles.Items[listViewInputFiles.Items.Count - 1].Selected = true;
listViewInputFiles.FocusedItem = listViewInputFiles.Items[listViewInputFiles.Items.Count - 1];
}
UpdateNumberOfFiles();
}
private void RemoveToolStripMenuItemClick(object sender, EventArgs e)
@ -2062,6 +2089,7 @@ namespace Nikse.SubtitleEdit.Forms
}
progressBar1.Value = 0;
progressBar1.Visible = false;
UpdateNumberOfFiles();
}
private void SetControlState(bool enabled)
@ -2238,6 +2266,7 @@ namespace Nikse.SubtitleEdit.Forms
item.SubItems.Add(nameOfFormat);
item.SubItems.Add("-");
listViewInputFiles.Items.Add(item);
UpdateNumberOfFiles();
}
private void BatchConvert_KeyDown(object sender, KeyEventArgs e)
@ -2519,5 +2548,17 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
private void UpdateNumberOfFiles()
{
if (listViewInputFiles.Items.Count > 0)
{
labelNumberOfFiles.Text = $"{listViewInputFiles.Items.Count:#,###,##0}";
}
else
{
labelNumberOfFiles.Text = string.Empty;
}
}
}
}