diff --git a/src/Controls/SubtitleListView.cs b/src/Controls/SubtitleListView.cs index f9421c1c6..515a87a51 100644 --- a/src/Controls/SubtitleListView.cs +++ b/src/Controls/SubtitleListView.cs @@ -265,9 +265,9 @@ namespace Nikse.SubtitleEdit.Controls subItem = new ListViewItem.ListViewSubItem(item, paragraph.Text.Replace(Environment.NewLine, _lineSeparatorString)); if (SubtitleFontBold) - subItem.Font = new Font(SubtitleFontName, subItem.Font.Size, FontStyle.Bold); + subItem.Font = new Font(SubtitleFontName, SubtitleFontSize , FontStyle.Bold); else - subItem.Font = new Font(SubtitleFontName, subItem.Font.Size); + subItem.Font = new Font(SubtitleFontName, SubtitleFontSize); item.UseItemStyleForSubItems = false; item.SubItems.Add(subItem); diff --git a/src/Forms/Interjections.Designer.cs b/src/Forms/Interjections.Designer.cs new file mode 100644 index 000000000..85eccc6dc --- /dev/null +++ b/src/Forms/Interjections.Designer.cs @@ -0,0 +1,142 @@ +namespace Nikse.SubtitleEdit.Forms +{ + partial class Interjections + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxNamesIgonoreLists = new System.Windows.Forms.GroupBox(); + this.buttonRemove = new System.Windows.Forms.Button(); + this.listBoxInterjections = new System.Windows.Forms.ListBox(); + this.textBoxInterjection = new System.Windows.Forms.TextBox(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxNamesIgonoreLists.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxNamesIgonoreLists + // + this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonRemove); + this.groupBoxNamesIgonoreLists.Controls.Add(this.listBoxInterjections); + this.groupBoxNamesIgonoreLists.Controls.Add(this.textBoxInterjection); + this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonAdd); + this.groupBoxNamesIgonoreLists.Location = new System.Drawing.Point(12, 12); + this.groupBoxNamesIgonoreLists.Name = "groupBoxNamesIgonoreLists"; + this.groupBoxNamesIgonoreLists.Size = new System.Drawing.Size(241, 250); + this.groupBoxNamesIgonoreLists.TabIndex = 3; + this.groupBoxNamesIgonoreLists.TabStop = false; + // + // buttonRemove + // + this.buttonRemove.Location = new System.Drawing.Point(159, 16); + this.buttonRemove.Name = "buttonRemove"; + this.buttonRemove.Size = new System.Drawing.Size(75, 23); + this.buttonRemove.TabIndex = 22; + this.buttonRemove.Text = "Remove"; + this.buttonRemove.UseVisualStyleBackColor = true; + this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click); + // + // listBoxInterjections + // + this.listBoxInterjections.FormattingEnabled = true; + this.listBoxInterjections.Location = new System.Drawing.Point(3, 16); + this.listBoxInterjections.Name = "listBoxInterjections"; + this.listBoxInterjections.Size = new System.Drawing.Size(150, 199); + this.listBoxInterjections.TabIndex = 20; + this.listBoxInterjections.SelectedIndexChanged += new System.EventHandler(this.listBoxInterjections_SelectedIndexChanged); + // + // textBoxInterjection + // + this.textBoxInterjection.Location = new System.Drawing.Point(2, 220); + this.textBoxInterjection.Name = "textBoxInterjection"; + this.textBoxInterjection.Size = new System.Drawing.Size(151, 20); + this.textBoxInterjection.TabIndex = 24; + this.textBoxInterjection.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxInterjection_KeyDown); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(159, 217); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(75, 23); + this.buttonAdd.TabIndex = 26; + this.buttonAdd.Text = "Add"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(178, 281); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 21); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOK + // + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.Location = new System.Drawing.Point(99, 281); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 21); + this.buttonOK.TabIndex = 4; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + // + // Interjections + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(268, 315); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.groupBoxNamesIgonoreLists); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Interjections"; + this.ShowIcon = false; + this.Text = "Interjections"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Interjections_KeyDown); + this.groupBoxNamesIgonoreLists.ResumeLayout(false); + this.groupBoxNamesIgonoreLists.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxNamesIgonoreLists; + private System.Windows.Forms.Button buttonRemove; + private System.Windows.Forms.ListBox listBoxInterjections; + private System.Windows.Forms.TextBox textBoxInterjection; + private System.Windows.Forms.Button buttonAdd; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + } +} \ No newline at end of file diff --git a/src/Forms/Interjections.cs b/src/Forms/Interjections.cs new file mode 100644 index 000000000..b4ff1eff6 --- /dev/null +++ b/src/Forms/Interjections.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Logic; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class Interjections : Form + { + private List _interjections; + + public Interjections() + { + InitializeComponent(); + } + + public string GetInterjectionsSemiColonSeperatedString() + { + StringBuilder sb = new StringBuilder(); + foreach (string s in _interjections) + sb.Append(";" + s.Trim()); + return sb.ToString().Trim(';'); + } + + private void Interjections_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + DialogResult = DialogResult.Cancel; + } + + public void Initialize(string semiColonSeperatedList) + { + _interjections = new List(); + string[] arr = semiColonSeperatedList.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + foreach (string s in arr) + { + _interjections.Add(s.Trim()); + } + FillListBox(); + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + string text = textBoxInterjection.Text.Trim(); + if (text.Length > 1 && !_interjections.Contains(text)) + { + _interjections.Add(text); + FillListBox(); + textBoxInterjection.Text = string.Empty; + textBoxInterjection.Focus(); + for (int i = 0; i < listBoxInterjections.Items.Count; i++) + { + if (listBoxInterjections.Items[i].ToString() == text) + { + listBoxInterjections.SelectedIndex = i; + int top = i - 5; + if (top < 0) + top = 0; + listBoxInterjections.TopIndex = top; + break; + } + } + } + else + { + MessageBox.Show(Configuration.Settings.Language.Settings.WordAlreadyExists); + } + } + + private void FillListBox() + { + _interjections.Sort(); + listBoxInterjections.BeginUpdate(); + listBoxInterjections.Items.Clear(); + foreach (string s in _interjections) + { + listBoxInterjections.Items.Add(s); + } + listBoxInterjections.EndUpdate(); + } + + private void buttonRemove_Click(object sender, EventArgs e) + { + int index = listBoxInterjections.SelectedIndex; + string text = listBoxInterjections.Items[index].ToString(); + if (index >= 0) + { + if (MessageBox.Show(string.Format(Configuration.Settings.Language.Settings.RemoveX, text), null, MessageBoxButtons.YesNo) == DialogResult.Yes) + { + _interjections.Remove(text); + listBoxInterjections.Items.RemoveAt(index); + if (index < listBoxInterjections.Items.Count) + listBoxInterjections.SelectedIndex = index; + else if (listBoxInterjections.Items.Count > 0) + listBoxInterjections.SelectedIndex = index - 1; + listBoxInterjections.Focus(); + + return; + } + MessageBox.Show(Configuration.Settings.Language.Settings.WordNotFound); + } + } + + private void listBoxInterjections_SelectedIndexChanged(object sender, EventArgs e) + { + buttonRemove.Enabled = listBoxInterjections.SelectedIndex >= 0; + } + + private void textBoxInterjection_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + buttonAdd_Click(null, null); + } + + } +} diff --git a/src/Forms/Interjections.resx b/src/Forms/Interjections.resx new file mode 100644 index 000000000..5ea0895e3 --- /dev/null +++ b/src/Forms/Interjections.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index e6e8b4e6e..de8d43f62 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -5,7 +5,6 @@ using System.IO; using System.Net; using System.Text; using System.Text.RegularExpressions; -using System.Web; using System.Windows.Forms; using Nikse.SubtitleEdit.Controls; using Nikse.SubtitleEdit.Logic; @@ -197,7 +196,7 @@ namespace Nikse.SubtitleEdit.Forms InitializeToolbar(); Utilities.InitializeSubtitleFont(textBoxSource); Utilities.InitializeSubtitleFont(textBoxListViewText); - + Utilities.InitializeSubtitleFont(SubtitleListview1); tabControlSubtitle.SelectTab(TabControlSourceView); // AC ShowSourceLineNumber(); // AC @@ -1619,6 +1618,7 @@ namespace Nikse.SubtitleEdit.Forms UpdateRecentFilesUI(); Utilities.InitializeSubtitleFont(textBoxSource); Utilities.InitializeSubtitleFont(textBoxListViewText); + Utilities.InitializeSubtitleFont(SubtitleListview1); buttonCustomUrl.Text = Configuration.Settings.VideoControls.CustomSearchText; buttonCustomUrl.Enabled = Configuration.Settings.VideoControls.CustomSearchUrl.Length > 1; @@ -1637,6 +1637,7 @@ namespace Nikse.SubtitleEdit.Forms { Utilities.InitializeSubtitleFont(textBoxListViewText); Utilities.InitializeSubtitleFont(textBoxSource); + Utilities.InitializeSubtitleFont(SubtitleListview1); SubtitleListview1.SubtitleFontName = Configuration.Settings.General.SubtitleFontName; SubtitleListview1.SubtitleFontBold = Configuration.Settings.General.SubtitleFontBold; SubtitleListview1.SubtitleFontSize = Configuration.Settings.General.SubtitleFontSize; @@ -6245,6 +6246,9 @@ namespace Nikse.SubtitleEdit.Forms if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate.Paragraphs.Count > 1) { + InsertMissingParagraphs(_subtitle, _subtitleAlternate); + InsertMissingParagraphs(_subtitleAlternate, _subtitle); + buttonUnBreak.Visible = false; buttonUndoListViewChanges.Visible = false; @@ -6274,6 +6278,24 @@ namespace Nikse.SubtitleEdit.Forms return true; } + private void InsertMissingParagraphs(Subtitle masterSubtitle, Subtitle insertIntoSubtitle) + { + int index = 0; + foreach (Paragraph p in masterSubtitle.Paragraphs) + { + + Paragraph insertParagraph = Utilities.GetOriginalParagraph(index, p, insertIntoSubtitle.Paragraphs); + if (insertParagraph == null) + { + insertParagraph = new Paragraph(p); + insertParagraph.Text = string.Empty; + insertIntoSubtitle.InsertParagraphInCorrectTimeOrder(insertParagraph); + } + index++; + } + insertIntoSubtitle.Renumber(1); + } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -7203,7 +7225,9 @@ namespace Nikse.SubtitleEdit.Forms { toolStripMenuItemOpenContainingFolder.Visible = !string.IsNullOrEmpty(_fileName) && File.Exists(_fileName); - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + bool subtitleLoaded = _subtitle != null && _subtitle.Paragraphs.Count > 0; + openOriginalToolStripMenuItem.Visible = subtitleLoaded; + if (subtitleLoaded && Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) { saveOriginalToolStripMenuItem.Visible = true; saveOriginalAstoolStripMenuItem.Visible = true; @@ -7214,14 +7238,8 @@ namespace Nikse.SubtitleEdit.Forms saveOriginalToolStripMenuItem.Visible = false; saveOriginalAstoolStripMenuItem.Visible = false; removeOriginalToolStripMenuItem.Visible = false; - - if (_subtitle == null || _subtitle.Paragraphs.Count < 1) - { - openOriginalToolStripMenuItem.Visible = false; - toolStripSeparator20.Visible = false; - } - } + toolStripSeparator20.Visible = subtitleLoaded; } private void toolStripMenuItemOpenContainingFolder_Click(object sender, EventArgs e) @@ -8809,7 +8827,7 @@ namespace Nikse.SubtitleEdit.Forms } else { - //NIO:TODO: TextBoxListViewToogleTag("i"); + TextBoxListViewToogleTag("i"); } } if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D) diff --git a/src/Forms/Main.resx b/src/Forms/Main.resx index 90e941f94..d5f535fd5 100644 --- a/src/Forms/Main.resx +++ b/src/Forms/Main.resx @@ -580,9 +580,6 @@ 208, 56 - - 208, 56 - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 @@ -687,7 +684,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2 - CAAAAk1TRnQBSQFMAgEBAgEAAcABAAHAAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAgEAAegBAAHoAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/src/Forms/RemoveTextFromHearImpaired.Designer.cs b/src/Forms/RemoveTextFromHearImpaired.Designer.cs index ea9b27b94..d90bec128 100644 --- a/src/Forms/RemoveTextFromHearImpaired.Designer.cs +++ b/src/Forms/RemoveTextFromHearImpaired.Designer.cs @@ -38,6 +38,8 @@ this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.checkBoxRemoveTextBeforeColon = new System.Windows.Forms.CheckBox(); this.groupBoxRemoveTextConditions = new System.Windows.Forms.GroupBox(); + this.buttonEditInterjections = new System.Windows.Forms.Button(); + this.checkBoxRemoveInterjections = new System.Windows.Forms.CheckBox(); this.labelRemoveTextBetween = new System.Windows.Forms.Label(); this.comboBoxRemoveIfTextContains = new System.Windows.Forms.ComboBox(); this.checkBoxRemoveWhereContains = new System.Windows.Forms.CheckBox(); @@ -136,8 +138,8 @@ this.checkBoxRemoveTextBeforeColon.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBoxRemoveTextBeforeColon.Location = new System.Drawing.Point(241, 26); this.checkBoxRemoveTextBeforeColon.Name = "checkBoxRemoveTextBeforeColon"; - this.checkBoxRemoveTextBeforeColon.Size = new System.Drawing.Size(265, 25); - this.checkBoxRemoveTextBeforeColon.TabIndex = 9; + this.checkBoxRemoveTextBeforeColon.Size = new System.Drawing.Size(175, 17); + this.checkBoxRemoveTextBeforeColon.TabIndex = 10; this.checkBoxRemoveTextBeforeColon.Text = "Remove text before a colon (:)"; this.checkBoxRemoveTextBeforeColon.UseVisualStyleBackColor = true; this.checkBoxRemoveTextBeforeColon.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); @@ -146,6 +148,8 @@ // this.groupBoxRemoveTextConditions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxRemoveTextConditions.Controls.Add(this.buttonEditInterjections); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveInterjections); this.groupBoxRemoveTextConditions.Controls.Add(this.labelRemoveTextBetween); this.groupBoxRemoveTextConditions.Controls.Add(this.comboBoxRemoveIfTextContains); this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveWhereContains); @@ -167,13 +171,34 @@ this.groupBoxRemoveTextConditions.TabStop = false; this.groupBoxRemoveTextConditions.Text = "Remove text conditions"; // + // buttonEditInterjections + // + this.buttonEditInterjections.Location = new System.Drawing.Point(377, 137); + this.buttonEditInterjections.Name = "buttonEditInterjections"; + this.buttonEditInterjections.Size = new System.Drawing.Size(103, 23); + this.buttonEditInterjections.TabIndex = 15; + this.buttonEditInterjections.Text = "Edit..."; + this.buttonEditInterjections.UseVisualStyleBackColor = true; + this.buttonEditInterjections.Click += new System.EventHandler(this.buttonEditInterjections_Click); + // + // checkBoxRemoveInterjections + // + this.checkBoxRemoveInterjections.AutoSize = true; + this.checkBoxRemoveInterjections.Location = new System.Drawing.Point(241, 141); + this.checkBoxRemoveInterjections.Name = "checkBoxRemoveInterjections"; + this.checkBoxRemoveInterjections.Size = new System.Drawing.Size(130, 17); + this.checkBoxRemoveInterjections.TabIndex = 14; + this.checkBoxRemoveInterjections.Text = "Remove interjections "; + this.checkBoxRemoveInterjections.UseVisualStyleBackColor = true; + this.checkBoxRemoveInterjections.CheckedChanged += new System.EventHandler(this.checkBoxRemoveInterjections_CheckedChanged); + // // labelRemoveTextBetween // this.labelRemoveTextBetween.AutoSize = true; this.labelRemoveTextBetween.Location = new System.Drawing.Point(8, 26); this.labelRemoveTextBetween.Name = "labelRemoveTextBetween"; - this.labelRemoveTextBetween.Size = new System.Drawing.Size(173, 21); - this.labelRemoveTextBetween.TabIndex = 13; + this.labelRemoveTextBetween.Size = new System.Drawing.Size(114, 13); + this.labelRemoveTextBetween.TabIndex = 0; this.labelRemoveTextBetween.Text = "Remove text between"; // // comboBoxRemoveIfTextContains @@ -183,21 +208,21 @@ "¶", "♪", "♫"}); - this.comboBoxRemoveIfTextContains.Location = new System.Drawing.Point(427, 133); + this.comboBoxRemoveIfTextContains.Location = new System.Drawing.Point(427, 88); this.comboBoxRemoveIfTextContains.MaxLength = 10; this.comboBoxRemoveIfTextContains.Name = "comboBoxRemoveIfTextContains"; - this.comboBoxRemoveIfTextContains.Size = new System.Drawing.Size(100, 29); - this.comboBoxRemoveIfTextContains.TabIndex = 12; + this.comboBoxRemoveIfTextContains.Size = new System.Drawing.Size(100, 21); + this.comboBoxRemoveIfTextContains.TabIndex = 13; this.comboBoxRemoveIfTextContains.Text = "¶"; this.comboBoxRemoveIfTextContains.TextChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); // // checkBoxRemoveWhereContains // this.checkBoxRemoveWhereContains.AutoSize = true; - this.checkBoxRemoveWhereContains.Location = new System.Drawing.Point(241, 137); + this.checkBoxRemoveWhereContains.Location = new System.Drawing.Point(241, 92); this.checkBoxRemoveWhereContains.Name = "checkBoxRemoveWhereContains"; - this.checkBoxRemoveWhereContains.Size = new System.Drawing.Size(232, 25); - this.checkBoxRemoveWhereContains.TabIndex = 11; + this.checkBoxRemoveWhereContains.Size = new System.Drawing.Size(153, 17); + this.checkBoxRemoveWhereContains.TabIndex = 12; this.checkBoxRemoveWhereContains.Text = "Remove text if it contains:"; this.checkBoxRemoveWhereContains.UseVisualStyleBackColor = true; this.checkBoxRemoveWhereContains.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); @@ -212,8 +237,8 @@ this.comboBoxCustomEnd.Location = new System.Drawing.Point(116, 135); this.comboBoxCustomEnd.MaxLength = 2; this.comboBoxCustomEnd.Name = "comboBoxCustomEnd"; - this.comboBoxCustomEnd.Size = new System.Drawing.Size(38, 29); - this.comboBoxCustomEnd.TabIndex = 7; + this.comboBoxCustomEnd.Size = new System.Drawing.Size(38, 21); + this.comboBoxCustomEnd.TabIndex = 8; this.comboBoxCustomEnd.Text = "¶"; this.comboBoxCustomEnd.TextChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); // @@ -227,8 +252,8 @@ this.comboBoxCustomStart.Location = new System.Drawing.Point(41, 135); this.comboBoxCustomStart.MaxLength = 2; this.comboBoxCustomStart.Name = "comboBoxCustomStart"; - this.comboBoxCustomStart.Size = new System.Drawing.Size(38, 29); - this.comboBoxCustomStart.TabIndex = 5; + this.comboBoxCustomStart.Size = new System.Drawing.Size(38, 21); + this.comboBoxCustomStart.TabIndex = 6; this.comboBoxCustomStart.Text = "¶"; this.comboBoxCustomStart.TextChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); // @@ -237,8 +262,8 @@ this.checkBoxRemoveTextBeforeColonOnlyUppercase.AutoSize = true; this.checkBoxRemoveTextBeforeColonOnlyUppercase.Location = new System.Drawing.Point(261, 46); this.checkBoxRemoveTextBeforeColonOnlyUppercase.Name = "checkBoxRemoveTextBeforeColonOnlyUppercase"; - this.checkBoxRemoveTextBeforeColonOnlyUppercase.Size = new System.Drawing.Size(229, 25); - this.checkBoxRemoveTextBeforeColonOnlyUppercase.TabIndex = 10; + this.checkBoxRemoveTextBeforeColonOnlyUppercase.Size = new System.Drawing.Size(151, 17); + this.checkBoxRemoveTextBeforeColonOnlyUppercase.TabIndex = 11; this.checkBoxRemoveTextBeforeColonOnlyUppercase.Text = "Only if text is UPPERCASE"; this.checkBoxRemoveTextBeforeColonOnlyUppercase.UseVisualStyleBackColor = true; this.checkBoxRemoveTextBeforeColonOnlyUppercase.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); @@ -248,8 +273,8 @@ this.checkBoxOnlyIfInSeparateLine.AutoSize = true; this.checkBoxOnlyIfInSeparateLine.Location = new System.Drawing.Point(11, 169); this.checkBoxOnlyIfInSeparateLine.Name = "checkBoxOnlyIfInSeparateLine"; - this.checkBoxOnlyIfInSeparateLine.Size = new System.Drawing.Size(207, 25); - this.checkBoxOnlyIfInSeparateLine.TabIndex = 8; + this.checkBoxOnlyIfInSeparateLine.Size = new System.Drawing.Size(137, 17); + this.checkBoxOnlyIfInSeparateLine.TabIndex = 9; this.checkBoxOnlyIfInSeparateLine.Text = "Only if on separate line"; this.checkBoxOnlyIfInSeparateLine.UseVisualStyleBackColor = true; this.checkBoxOnlyIfInSeparateLine.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); @@ -261,8 +286,8 @@ this.checkBoxRemoveTextBetweenCustomTags.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBoxRemoveTextBetweenCustomTags.Location = new System.Drawing.Point(20, 138); this.checkBoxRemoveTextBetweenCustomTags.Name = "checkBoxRemoveTextBetweenCustomTags"; - this.checkBoxRemoveTextBetweenCustomTags.Size = new System.Drawing.Size(22, 21); - this.checkBoxRemoveTextBetweenCustomTags.TabIndex = 4; + this.checkBoxRemoveTextBetweenCustomTags.Size = new System.Drawing.Size(15, 14); + this.checkBoxRemoveTextBetweenCustomTags.TabIndex = 5; this.checkBoxRemoveTextBetweenCustomTags.UseVisualStyleBackColor = true; this.checkBoxRemoveTextBetweenCustomTags.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); // @@ -273,8 +298,8 @@ this.checkBoxRemoveTextBetweenQuestionMarks.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBoxRemoveTextBetweenQuestionMarks.Location = new System.Drawing.Point(20, 115); this.checkBoxRemoveTextBetweenQuestionMarks.Name = "checkBoxRemoveTextBetweenQuestionMarks"; - this.checkBoxRemoveTextBetweenQuestionMarks.Size = new System.Drawing.Size(117, 25); - this.checkBoxRemoveTextBetweenQuestionMarks.TabIndex = 3; + this.checkBoxRemoveTextBetweenQuestionMarks.Size = new System.Drawing.Size(76, 17); + this.checkBoxRemoveTextBetweenQuestionMarks.TabIndex = 4; this.checkBoxRemoveTextBetweenQuestionMarks.Text = "\"?\" and \"?\""; this.checkBoxRemoveTextBetweenQuestionMarks.UseVisualStyleBackColor = true; this.checkBoxRemoveTextBetweenQuestionMarks.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); @@ -286,8 +311,8 @@ this.checkBoxRemoveTextBetweenParentheses.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBoxRemoveTextBetweenParentheses.Location = new System.Drawing.Point(20, 69); this.checkBoxRemoveTextBetweenParentheses.Name = "checkBoxRemoveTextBetweenParentheses"; - this.checkBoxRemoveTextBetweenParentheses.Size = new System.Drawing.Size(115, 25); - this.checkBoxRemoveTextBetweenParentheses.TabIndex = 1; + this.checkBoxRemoveTextBetweenParentheses.Size = new System.Drawing.Size(74, 17); + this.checkBoxRemoveTextBetweenParentheses.TabIndex = 2; this.checkBoxRemoveTextBetweenParentheses.Text = "\"(\" and \")\""; this.checkBoxRemoveTextBetweenParentheses.UseVisualStyleBackColor = true; this.checkBoxRemoveTextBetweenParentheses.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); @@ -299,8 +324,8 @@ this.checkBoxRemoveTextBetweenBrackets.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBoxRemoveTextBetweenBrackets.Location = new System.Drawing.Point(20, 92); this.checkBoxRemoveTextBetweenBrackets.Name = "checkBoxRemoveTextBetweenBrackets"; - this.checkBoxRemoveTextBetweenBrackets.Size = new System.Drawing.Size(117, 25); - this.checkBoxRemoveTextBetweenBrackets.TabIndex = 2; + this.checkBoxRemoveTextBetweenBrackets.Size = new System.Drawing.Size(76, 17); + this.checkBoxRemoveTextBetweenBrackets.TabIndex = 3; this.checkBoxRemoveTextBetweenBrackets.Text = "\"{\" and \"}\""; this.checkBoxRemoveTextBetweenBrackets.UseVisualStyleBackColor = true; this.checkBoxRemoveTextBetweenBrackets.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); @@ -312,8 +337,8 @@ this.checkBoxRemoveTextBetweenSquares.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBoxRemoveTextBetweenSquares.Location = new System.Drawing.Point(20, 45); this.checkBoxRemoveTextBetweenSquares.Name = "checkBoxRemoveTextBetweenSquares"; - this.checkBoxRemoveTextBetweenSquares.Size = new System.Drawing.Size(115, 25); - this.checkBoxRemoveTextBetweenSquares.TabIndex = 0; + this.checkBoxRemoveTextBetweenSquares.Size = new System.Drawing.Size(74, 17); + this.checkBoxRemoveTextBetweenSquares.TabIndex = 1; this.checkBoxRemoveTextBetweenSquares.Text = "\"[\" and \"]\""; this.checkBoxRemoveTextBetweenSquares.UseVisualStyleBackColor = true; this.checkBoxRemoveTextBetweenSquares.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); @@ -323,13 +348,13 @@ this.labelAnd.AutoSize = true; this.labelAnd.Location = new System.Drawing.Point(85, 141); this.labelAnd.Name = "labelAnd"; - this.labelAnd.Size = new System.Drawing.Size(37, 21); - this.labelAnd.TabIndex = 6; + this.labelAnd.Size = new System.Drawing.Size(25, 13); + this.labelAnd.TabIndex = 7; this.labelAnd.Text = "and"; // // FormRemoveTextForHearImpaired // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(697, 507); this.Controls.Add(this.groupBoxRemoveTextConditions); @@ -377,5 +402,7 @@ private System.Windows.Forms.ComboBox comboBoxRemoveIfTextContains; private System.Windows.Forms.CheckBox checkBoxRemoveWhereContains; private System.Windows.Forms.Label labelRemoveTextBetween; + private System.Windows.Forms.CheckBox checkBoxRemoveInterjections; + private System.Windows.Forms.Button buttonEditInterjections; } } \ No newline at end of file diff --git a/src/Forms/RemoveTextFromHearImpaired.cs b/src/Forms/RemoveTextFromHearImpaired.cs index 4bf56aabb..819811eff 100644 --- a/src/Forms/RemoveTextFromHearImpaired.cs +++ b/src/Forms/RemoveTextFromHearImpaired.cs @@ -1,9 +1,10 @@ using System; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Logic; using System.Collections.Generic; using System.Drawing; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Logic; namespace Nikse.SubtitleEdit.Forms { @@ -29,7 +30,10 @@ namespace Nikse.SubtitleEdit.Forms checkBoxRemoveTextBetweenParentheses.Text = _language.Parentheses; checkBoxRemoveTextBetweenQuestionMarks.Text = _language.QuestionMarks; checkBoxRemoveTextBetweenSquares.Text = _language.SquareBrackets; - checkBoxRemoveWhereContains.Text = _language.RemoveTextIfContains; + checkBoxRemoveWhereContains.Text = _language.RemoveTextIfContains; + checkBoxRemoveInterjections.Text = _language.RemoveInterjections; + buttonEditInterjections.Text = _language.EditInterjections; + buttonEditInterjections.Left = checkBoxRemoveInterjections.Left + checkBoxRemoveInterjections.Width; listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; listViewFixes.Columns[1].Text = _language.LineNumber; listViewFixes.Columns[2].Text = _language.Before; @@ -180,6 +184,11 @@ namespace Nikse.SubtitleEdit.Forms hit = true; } + if (checkBoxRemoveInterjections.Checked && RemoveInterjections(p.Text) != p.Text.Trim()) + { + hit = true; + } + if (!hit) { string[] parts = p.Text.Trim().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); @@ -286,8 +295,8 @@ namespace Nikse.SubtitleEdit.Forms int index = s2.LastIndexOf("!"); if (index == -1 || s2.LastIndexOf("?") > index) index = s2.LastIndexOf("?"); - if (index == -1 || s2.LastIndexOf(".") > index) - index = s2.LastIndexOf("."); + if (index == -1 || s2.LastIndexOf(". ") > index) + index = s2.LastIndexOf(". "); if (index > 3) sb.AppendLine(s2.Substring(0, index+1)); } @@ -359,7 +368,6 @@ namespace Nikse.SubtitleEdit.Forms if (HasHearImpariedTagsAtEnd(newText)) newText = RemoveEndTags(newText); sb.AppendLine(stSub.Pre + newText + stSub.Post); - } else { @@ -377,6 +385,8 @@ namespace Nikse.SubtitleEdit.Forms text = st.Pre + sb.ToString().Trim() + st.Post; text = RemoveColon(text); + if (checkBoxRemoveInterjections.Checked) + text = RemoveInterjections(text); st = new StripableText(text, " >-\"'‘`´♪¿¡.…—", " -\"'`´♪.!?:…—"); text = st.StrippedText; @@ -397,6 +407,38 @@ namespace Nikse.SubtitleEdit.Forms return text; } + private string RemoveInterjections(string text) + { + string[] arr = Configuration.Settings.Tools.Interjections.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + foreach (string s in arr) + { + if (text.Contains(s)) + { + Regex regex = new Regex(s); + Match match = regex.Match(text); + if (match.Success) + { + int index = match.Index; + string temp = text.Remove(index, s.Length); + while (temp.Length > 0 && (temp.StartsWith(" ") || temp.StartsWith(","))) + { + temp = temp.Remove(0, 1); + } + if (temp.Length > 0 && s[0].ToString() != s[0].ToString().ToLower()) + { + temp = temp.Remove(0,1).Insert(0, temp[0].ToString().ToUpper()); + } + + StripableText st = new StripableText(temp); + if (st.StrippedText.Length == 0) + return string.Empty; + return temp; + } + } + } + return text; + } + private string RemoveEndTags(string newText) { string s = newText; @@ -514,5 +556,28 @@ namespace Nikse.SubtitleEdit.Forms Cursor = Cursors.Default; } + private void checkBoxRemoveInterjections_CheckedChanged(object sender, EventArgs e) + { + Cursor = Cursors.WaitCursor; + GeneratePreview(); + Cursor = Cursors.Default; + } + + private void buttonEditInterjections_Click(object sender, EventArgs e) + { + Interjections editInterjections = new Interjections(); + editInterjections.Initialize(Configuration.Settings.Tools.Interjections); + if (editInterjections.ShowDialog(this) == DialogResult.OK) + { + Configuration.Settings.Tools.Interjections = editInterjections.GetInterjectionsSemiColonSeperatedString(); + if (checkBoxRemoveInterjections.Checked) + { + Cursor = Cursors.WaitCursor; + GeneratePreview(); + Cursor = Cursors.Default; + } + } + } + } } diff --git a/src/Forms/ShowEarlierLater.Designer.cs b/src/Forms/ShowEarlierLater.Designer.cs index be132b302..54717f663 100644 --- a/src/Forms/ShowEarlierLater.Designer.cs +++ b/src/Forms/ShowEarlierLater.Designer.cs @@ -130,7 +130,7 @@ namespace Nikse.SubtitleEdit.Forms this.Controls.Add(this.timeUpDownAdjust); this.Controls.Add(this.labelHoursMinSecsMilliSecs); this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.KeyPreview = true; this.MaximizeBox = false; this.MinimizeBox = false; diff --git a/src/Logic/Language.cs b/src/Logic/Language.cs index 8028cccc2..27cebd652 100644 --- a/src/Logic/Language.cs +++ b/src/Logic/Language.cs @@ -993,6 +993,8 @@ can edit in same subtitle file (collaboration)", After = "After", LinesFoundX = "Lines found: {0}", RemoveTextIfContains = "Remove text if it contains:", + RemoveInterjections = "Remove interjections (shh, hmm, etc.)", + EditInterjections = "Edit...", }; ReplaceDialog = new LanguageStructure.ReplaceDialog diff --git a/src/Logic/LanguageStructure.cs b/src/Logic/LanguageStructure.cs index ebaeba8fb..0e5f0d43d 100644 --- a/src/Logic/LanguageStructure.cs +++ b/src/Logic/LanguageStructure.cs @@ -928,6 +928,8 @@ public string After { get; set; } public string LinesFoundX { get; set; } public string RemoveTextIfContains { get; set; } + public string RemoveInterjections { get; set; } + public string EditInterjections { get; set; } } public class ReplaceDialog diff --git a/src/Logic/Settings.cs b/src/Logic/Settings.cs index e00b40368..b3290574a 100644 --- a/src/Logic/Settings.cs +++ b/src/Logic/Settings.cs @@ -77,6 +77,7 @@ namespace Nikse.SubtitleEdit.Logic public string MusicSymbol { get; set; } public string MusicSymbolToReplace { get; set; } public bool SpellCheckAutoChangeNames { get; set; } + public string Interjections { get; set; } public ToolsSettings() { @@ -87,6 +88,7 @@ namespace Nikse.SubtitleEdit.Logic MusicSymbol = "♪"; MusicSymbolToReplace = "♪ ⶠ♪ âTª ã¢â™âª ?t×3 ?t¤3"; SpellCheckAutoChangeNames = true; + Interjections = "Ugh;Ughh;Hm;Hmm;Hmmm;Ahh;Whew;Phew;Gah;Oh;Ohh;Uh;Uhh;"; } } @@ -672,6 +674,9 @@ namespace Nikse.SubtitleEdit.Logic subNode = node.SelectSingleNode("SpellCheckAutoChangeNames"); if (subNode != null) settings.Tools.SpellCheckAutoChangeNames = Convert.ToBoolean(subNode.InnerText); + subNode = node.SelectSingleNode("Interjections"); + if (subNode != null) + settings.Tools.Interjections = subNode.InnerText; settings.SsaStyle = new Nikse.SubtitleEdit.Logic.SsaStyleSettings(); node = doc.DocumentElement.SelectSingleNode("SsaStyle"); @@ -968,6 +973,7 @@ namespace Nikse.SubtitleEdit.Logic textWriter.WriteElementString("MusicSymbol", settings.Tools.MusicSymbol); textWriter.WriteElementString("MusicSymbolToReplace", settings.Tools.MusicSymbolToReplace); textWriter.WriteElementString("SpellCheckAutoChangeNames", settings.Tools.SpellCheckAutoChangeNames.ToString()); + textWriter.WriteElementString("Interjections", settings.Tools.Interjections); textWriter.WriteEndElement(); textWriter.WriteStartElement("SsaStyle", ""); diff --git a/src/Logic/StripableText.cs b/src/Logic/StripableText.cs index 70486d855..4430b0049 100644 --- a/src/Logic/StripableText.cs +++ b/src/Logic/StripableText.cs @@ -35,7 +35,7 @@ namespace Nikse.SubtitleEdit.Logic { for (int i = 0; i < 5; i++) { - while (text.Length > 1 && _stripStartCharacters.Contains(text.Substring(0, 1))) + while (text.Length > 0 && _stripStartCharacters.Contains(text.Substring(0, 1))) { Pre += text.Substring(0, 1); text = text.Substring(1); @@ -56,7 +56,7 @@ namespace Nikse.SubtitleEdit.Logic { for (int i = 0; i < 5; i++) { - while (text.Length > 1 && _stripEndCharacters.Contains(text.Substring(text.Length - 1, 1))) + while (text.Length > 0 && _stripEndCharacters.Contains(text.Substring(text.Length - 1, 1))) { Post = text.Substring(text.Length - 1, 1) + Post; text = text.Substring(0, text.Length - 1); diff --git a/src/SubtitleEdit.csproj b/src/SubtitleEdit.csproj index 6c96f6daf..d30a7422d 100644 --- a/src/SubtitleEdit.csproj +++ b/src/SubtitleEdit.csproj @@ -225,6 +225,12 @@ GetDictionaries.cs + + Form + + + Interjections.cs + Form @@ -660,6 +666,9 @@ GetDictionaries.cs Designer + + Interjections.cs + NetworkChat.cs diff --git a/src/Test/RemoveTextForHearImpairedTest.cs b/src/Test/RemoveTextForHearImpairedTest.cs new file mode 100644 index 000000000..f0dc862b5 --- /dev/null +++ b/src/Test/RemoveTextForHearImpairedTest.cs @@ -0,0 +1,81 @@ +using Nikse.SubtitleEdit.Forms; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; + +namespace Test +{ + + + /// + ///This is a test class for FormRemoveTextForHearImpairedTest and is intended + ///to contain all FormRemoveTextForHearImpairedTest Unit Tests + /// + [TestClass()] + public class RemoveTextForHearImpairedTest + { + + + private TestContext testContextInstance; + + /// + ///Gets or sets the test context which provides + ///information about and functionality for the current test run. + /// + public TestContext TestContext + { + get + { + return testContextInstance; + } + set + { + testContextInstance = value; + } + } + + #region Additional test attributes + // + //You can use the following additional attributes as you write your tests: + // + //Use ClassInitialize to run code before running the first test in the class + //[ClassInitialize()] + //public static void MyClassInitialize(TestContext testContext) + //{ + //} + // + //Use ClassCleanup to run code after all tests in a class have run + //[ClassCleanup()] + //public static void MyClassCleanup() + //{ + //} + // + //Use TestInitialize to run code before running each test + //[TestInitialize()] + //public void MyTestInitialize() + //{ + //} + // + //Use TestCleanup to run code after each test has run + //[TestCleanup()] + //public void MyTestCleanup() + //{ + //} + // + #endregion + + + /// + ///A test for RemoveColon + /// + [TestMethod()] + [DeploymentItem("SubtitleEdit.exe")] + public void RemoveColonTest() + { + FormRemoveTextForHearImpaired_Accessor target = new FormRemoveTextForHearImpaired_Accessor(); // TODO: Initialize to an appropriate value + string text = "Man over P.A.:\r\nGive back our homes."; + string expected = "Give back our homes."; + string actual = target.RemoveColon(text); + Assert.AreEqual(expected, actual); + } + } +} diff --git a/src/Test/Test.csproj b/src/Test/Test.csproj index a45fb3196..b5a2094a0 100644 --- a/src/Test/Test.csproj +++ b/src/Test/Test.csproj @@ -69,6 +69,7 @@ +