[UI] - Add button (Remove/Remove All)

This commit is contained in:
ivandrofly 2015-09-06 11:02:59 +01:00
parent 46d28647e7
commit c9ce0e4654
7 changed files with 93 additions and 4 deletions

View File

@ -672,6 +672,8 @@ Note: Do check free disk space.</WaveFileMalformed>
<ImageFiles>Image files</ImageFiles>
<Input>Input</Input>
<InputDescription>Choose input files (browse or drag-n-drop)</InputDescription>
<Remove>Remove</Remove>
<RemoveAll>Remove all</RemoveAll>
</ImportImages>
<ImportSceneChanges>
<Title>Import scene changes</Title>

View File

@ -866,6 +866,8 @@ namespace Nikse.SubtitleEdit.Core
Input = "Input",
InputDescription = "Choose input files (browse or drag-n-drop)",
ImageFiles = "Image files",
Remove = "Remove",
RemoveAll = "Remove all"
};
ImportSceneChanges = new LanguageStructure.ImportSceneChanges

View File

@ -747,6 +747,8 @@
public string ImageFiles { get; set; }
public string Input { get; set; }
public string InputDescription { get; set; }
public string Remove { get; set; }
public string RemoveAll { get; set; }
}
public class ImportSceneChanges

View File

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.groupBoxInput = new System.Windows.Forms.GroupBox();
this.buttonInputBrowse = new System.Windows.Forms.Button();
this.labelChooseInputFiles = new System.Windows.Forms.Label();
@ -40,7 +41,11 @@
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBoxInput.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// groupBoxInput
@ -90,6 +95,7 @@
this.columnHeaderStartTime,
this.columnHeaderEndTime,
this.columnHeaderDuration});
this.listViewInputFiles.ContextMenuStrip = this.contextMenuStrip1;
this.listViewInputFiles.FullRowSelect = true;
this.listViewInputFiles.HideSelection = false;
this.listViewInputFiles.Location = new System.Drawing.Point(8, 41);
@ -153,6 +159,29 @@
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.removeToolStripMenuItem,
this.removeAllToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(133, 48);
this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
//
// removeToolStripMenuItem
//
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
this.removeToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
this.removeToolStripMenuItem.Text = "Remove";
this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click);
//
// removeAllToolStripMenuItem
//
this.removeAllToolStripMenuItem.Name = "removeAllToolStripMenuItem";
this.removeAllToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
this.removeAllToolStripMenuItem.Text = "Remove all";
this.removeAllToolStripMenuItem.Click += new System.EventHandler(this.removeAllToolStripMenuItem_Click);
//
// ImportImages
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -170,6 +199,7 @@
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ImportImages_KeyDown);
this.groupBoxInput.ResumeLayout(false);
this.groupBoxInput.PerformLayout();
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -188,5 +218,8 @@
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.ColumnHeader columnHeaderDuration;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeAllToolStripMenuItem;
}
}

View File

@ -2,14 +2,14 @@
using System;
using System.IO;
using System.Windows.Forms;
using System.Collections;
using System.Collections.Generic;
namespace Nikse.SubtitleEdit.Forms
{
public sealed partial class ImportImages : PositionAndSizeForm
{
public Subtitle Subtitle { get; private set; }
private readonly Hashtable FilesAlreadyInList;
private readonly HashSet<string> FilesAlreadyInList;
public ImportImages()
{
InitializeComponent();
@ -17,6 +17,8 @@ namespace Nikse.SubtitleEdit.Forms
Text = Configuration.Settings.Language.ImportImages.Title;
groupBoxInput.Text = Configuration.Settings.Language.ImportImages.Input;
labelChooseInputFiles.Text = Configuration.Settings.Language.ImportImages.InputDescription;
removeToolStripMenuItem.Text = Configuration.Settings.Language.ImportImages.Remove;
removeAllToolStripMenuItem.Text = Configuration.Settings.Language.ImportImages.RemoveAll;
columnHeaderFName.Text = Configuration.Settings.Language.JoinSubtitles.FileName;
columnHeaderSize.Text = Configuration.Settings.Language.General.Size;
columnHeaderStartTime.Text = Configuration.Settings.Language.General.StartTime;
@ -24,7 +26,7 @@ namespace Nikse.SubtitleEdit.Forms
columnHeaderDuration.Text = Configuration.Settings.Language.General.Duration;
buttonOK.Text = Configuration.Settings.Language.General.Ok;
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
FilesAlreadyInList = new Hashtable();
FilesAlreadyInList = new HashSet<string>();
}
private void buttonInputBrowse_Click(object sender, EventArgs e)
@ -54,7 +56,7 @@ namespace Nikse.SubtitleEdit.Forms
var ext = fi.Extension.ToLowerInvariant();
if (ext == ".png" || ext == ".jpg" || ext == ".bmp" || ext == ".gif" || ext == ".tif" || ext == ".tiff")
{
FilesAlreadyInList.Add(fileName, null);
FilesAlreadyInList.Add(fileName);
SetTimeCodes(fileName, item);
listViewInputFiles.Items.Add(item);
}
@ -136,5 +138,44 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
if (listViewInputFiles.Items.Count == 0)
e.Cancel = true;
else
removeToolStripMenuItem.Visible = listViewInputFiles.SelectedItems.Count > 0;
}
private void RemoveSelection(bool removeAll = false)
{
if (listViewInputFiles.Items.Count == 0)
return;
if (removeAll)
{
foreach (ListViewItem item in listViewInputFiles.Items)
{
item.Remove();
FilesAlreadyInList.Remove(item.Text);
}
}
else if (listViewInputFiles.SelectedItems.Count > 0)
{
foreach (ListViewItem item in listViewInputFiles.SelectedItems)
{
item.Remove();
FilesAlreadyInList.Remove(item.Text);
}
}
}
private void removeToolStripMenuItem_Click(object sender, EventArgs e)
{
RemoveSelection();
}
private void removeAllToolStripMenuItem_Click(object sender, EventArgs e)
{
RemoveSelection(true);
}
}
}

View File

@ -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="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>157, 17</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>

View File

@ -1763,6 +1763,12 @@ namespace Nikse.SubtitleEdit.Logic
case "ImportImages/InputDescription":
language.ImportImages.InputDescription = reader.Value;
break;
case "ImportImages/Remove":
language.ImportImages.Remove = reader.Value;
break;
case "ImportImages/RemoveAll":
language.ImportImages.RemoveAll = reader.Value;
break;
case "ImportSceneChanges/Title":
language.ImportSceneChanges.Title = reader.Value;
break;