Improved removing/adding spaces in Fix Common Errors - thx Zoltán

Improved "Compare" to differences with space in red background color


git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@495 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-06-15 05:22:32 +00:00
parent a30a7c2cdc
commit 8212a92838
6 changed files with 169 additions and 93 deletions

View File

@ -404,6 +404,7 @@ namespace Nikse.SubtitleEdit.Forms
private void ShowTextDifference()
{
// from start
int minLength = Math.Min(richTextBox1.Text.Length, richTextBox2.Text.Length);
@ -427,10 +428,14 @@ namespace Nikse.SubtitleEdit.Forms
richTextBox1.SelectionStart = i;
richTextBox1.SelectionLength = 1;
richTextBox1.SelectionColor = Color.Red;
if (richTextBox1.SelectedText.Trim() == string.Empty)
richTextBox1.SelectionBackColor = Color.Red;
richTextBox2.SelectionStart = i;
richTextBox2.SelectionLength = 1;
richTextBox2.SelectionColor = Color.Red;
if (richTextBox2.SelectedText.Trim() == string.Empty)
richTextBox2.SelectionBackColor = Color.Red;
}
else
{
@ -438,6 +443,8 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
bool first = true;
int maxLength = Math.Max(richTextBox1.Text.Length, richTextBox2.Text.Length);
for (int i = startCharactersOk; i <= maxLength; i++)
{
@ -445,13 +452,17 @@ namespace Nikse.SubtitleEdit.Forms
{
richTextBox1.SelectionStart = i;
richTextBox1.SelectionLength = 1;
richTextBox1.SelectionColor = Color.Red;
richTextBox1.SelectionBackColor = Color.Red;
if (richTextBox1.SelectedText.Trim() == string.Empty)
richTextBox1.SelectionBackColor = Color.Red;
}
if (i < richTextBox2.Text.Length)
{
richTextBox2.SelectionStart = i;
richTextBox2.SelectionLength = 1;
richTextBox2.SelectionColor = Color.Red;
if (richTextBox2.SelectedText.Trim() == string.Empty)
richTextBox2.SelectionBackColor = Color.Red;
}
}
@ -463,10 +474,12 @@ namespace Nikse.SubtitleEdit.Forms
richTextBox1.SelectionStart = richTextBox1.Text.Length - i;
richTextBox1.SelectionLength = 1;
richTextBox1.SelectionColor = Color.Black;
richTextBox1.SelectionBackColor = richTextBox1.BackColor;
richTextBox2.SelectionStart = richTextBox2.Text.Length - i;
richTextBox2.SelectionLength = 1;
richTextBox2.SelectionColor = Color.Black;
richTextBox2.SelectionBackColor = richTextBox1.BackColor;
}
else
{

View File

@ -56,7 +56,6 @@ namespace Nikse.SubtitleEdit.Forms
this.buttonRefreshFixes = new System.Windows.Forms.Button();
this.buttonFixesSelectAll = new System.Windows.Forms.Button();
this.buttonFixesInverse = new System.Windows.Forms.Button();
this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.contextMenuStripListview = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItemDelete = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
@ -68,7 +67,6 @@ namespace Nikse.SubtitleEdit.Forms
this.buttonAutoBreak = new System.Windows.Forms.Button();
this.labelStartTimeWarning = new System.Windows.Forms.Label();
this.labelDurationWarning = new System.Windows.Forms.Label();
this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.numericUpDownDuration = new System.Windows.Forms.NumericUpDown();
this.labelDuration = new System.Windows.Forms.Label();
this.labelStartTime = new System.Windows.Forms.Label();
@ -78,6 +76,8 @@ namespace Nikse.SubtitleEdit.Forms
this.tabPageLog = new System.Windows.Forms.TabPage();
this.textBoxFixedIssues = new System.Windows.Forms.TextBox();
this.labelNumberOfImportantLogMessages = new System.Windows.Forms.Label();
this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.groupBoxStep1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.tabControl1.SuspendLayout();
@ -96,7 +96,7 @@ namespace Nikse.SubtitleEdit.Forms
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(759, 540);
this.buttonCancel.Location = new System.Drawing.Point(759, 559);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 10;
@ -108,7 +108,7 @@ namespace Nikse.SubtitleEdit.Forms
//
this.buttonNextFinish.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonNextFinish.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonNextFinish.Location = new System.Drawing.Point(678, 540);
this.buttonNextFinish.Location = new System.Drawing.Point(678, 559);
this.buttonNextFinish.Name = "buttonNextFinish";
this.buttonNextFinish.Size = new System.Drawing.Size(75, 21);
this.buttonNextFinish.TabIndex = 9;
@ -120,7 +120,7 @@ namespace Nikse.SubtitleEdit.Forms
//
this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelStatus.AutoSize = true;
this.labelStatus.Location = new System.Drawing.Point(12, 542);
this.labelStatus.Location = new System.Drawing.Point(12, 561);
this.labelStatus.Name = "labelStatus";
this.labelStatus.Size = new System.Drawing.Size(60, 13);
this.labelStatus.TabIndex = 5;
@ -131,7 +131,7 @@ namespace Nikse.SubtitleEdit.Forms
this.buttonBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonBack.Enabled = false;
this.buttonBack.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonBack.Location = new System.Drawing.Point(597, 540);
this.buttonBack.Location = new System.Drawing.Point(597, 559);
this.buttonBack.Name = "buttonBack";
this.buttonBack.Size = new System.Drawing.Size(75, 21);
this.buttonBack.TabIndex = 8;
@ -141,15 +141,15 @@ namespace Nikse.SubtitleEdit.Forms
//
// groupBoxStep1
//
this.groupBoxStep1.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.groupBoxStep1.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.groupBoxStep1.Controls.Add(this.buttonInverseSelection);
this.groupBoxStep1.Controls.Add(this.buttonSelectAll);
this.groupBoxStep1.Controls.Add(this.listView1);
this.groupBoxStep1.Location = new System.Drawing.Point(12, 12);
this.groupBoxStep1.Name = "groupBoxStep1";
this.groupBoxStep1.Size = new System.Drawing.Size(822, 522);
this.groupBoxStep1.Size = new System.Drawing.Size(822, 541);
this.groupBoxStep1.TabIndex = 9;
this.groupBoxStep1.TabStop = false;
this.groupBoxStep1.Text = "Step 1/2 - Choose which errors to fix";
@ -158,7 +158,7 @@ namespace Nikse.SubtitleEdit.Forms
//
this.buttonInverseSelection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonInverseSelection.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonInverseSelection.Location = new System.Drawing.Point(87, 495);
this.buttonInverseSelection.Location = new System.Drawing.Point(87, 514);
this.buttonInverseSelection.Name = "buttonInverseSelection";
this.buttonInverseSelection.Size = new System.Drawing.Size(100, 21);
this.buttonInverseSelection.TabIndex = 10;
@ -170,7 +170,7 @@ namespace Nikse.SubtitleEdit.Forms
//
this.buttonSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonSelectAll.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonSelectAll.Location = new System.Drawing.Point(6, 495);
this.buttonSelectAll.Location = new System.Drawing.Point(6, 514);
this.buttonSelectAll.Name = "buttonSelectAll";
this.buttonSelectAll.Size = new System.Drawing.Size(75, 21);
this.buttonSelectAll.TabIndex = 9;
@ -180,9 +180,9 @@ namespace Nikse.SubtitleEdit.Forms
//
// listView1
//
this.listView1.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.listView1.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.listView1.CheckBoxes = true;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
@ -191,7 +191,7 @@ namespace Nikse.SubtitleEdit.Forms
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(6, 19);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(810, 471);
this.listView1.Size = new System.Drawing.Size(810, 490);
this.listView1.TabIndex = 3;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
@ -213,28 +213,28 @@ namespace Nikse.SubtitleEdit.Forms
//
// groupBox2
//
this.groupBox2.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.groupBox2.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.groupBox2.Controls.Add(this.tabControl1);
this.groupBox2.Location = new System.Drawing.Point(12, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(822, 522);
this.groupBox2.Size = new System.Drawing.Size(822, 541);
this.groupBox2.TabIndex = 10;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Step 2/2 - Verify fixes";
//
// tabControl1
//
this.tabControl1.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.tabControl1.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.tabControl1.Controls.Add(this.tabPageFixes);
this.tabControl1.Controls.Add(this.tabPageLog);
this.tabControl1.Location = new System.Drawing.Point(6, 19);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(810, 497);
this.tabControl1.Size = new System.Drawing.Size(810, 516);
this.tabControl1.TabIndex = 7;
//
// tabPageFixes
@ -243,7 +243,7 @@ namespace Nikse.SubtitleEdit.Forms
this.tabPageFixes.Location = new System.Drawing.Point(4, 22);
this.tabPageFixes.Name = "tabPageFixes";
this.tabPageFixes.Padding = new System.Windows.Forms.Padding(3);
this.tabPageFixes.Size = new System.Drawing.Size(802, 471);
this.tabPageFixes.Size = new System.Drawing.Size(802, 490);
this.tabPageFixes.TabIndex = 1;
this.tabPageFixes.Text = "Fixes";
this.tabPageFixes.UseVisualStyleBackColor = true;
@ -267,15 +267,15 @@ namespace Nikse.SubtitleEdit.Forms
//
this.splitContainerStep2.Panel2.Controls.Add(this.subtitleListView1);
this.splitContainerStep2.Panel2.Controls.Add(this.groupBoxEditPanel);
this.splitContainerStep2.Size = new System.Drawing.Size(796, 465);
this.splitContainerStep2.SplitterDistance = 217;
this.splitContainerStep2.Size = new System.Drawing.Size(796, 484);
this.splitContainerStep2.SplitterDistance = 225;
this.splitContainerStep2.TabIndex = 112;
//
// listViewFixes
//
this.listViewFixes.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.listViewFixes.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.listViewFixes.CheckBoxes = true;
this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader4,
@ -287,7 +287,7 @@ namespace Nikse.SubtitleEdit.Forms
this.listViewFixes.HideSelection = false;
this.listViewFixes.Location = new System.Drawing.Point(3, 3);
this.listViewFixes.Name = "listViewFixes";
this.listViewFixes.Size = new System.Drawing.Size(790, 184);
this.listViewFixes.Size = new System.Drawing.Size(790, 192);
this.listViewFixes.TabIndex = 100;
this.listViewFixes.UseCompatibleStateImageBehavior = false;
this.listViewFixes.View = System.Windows.Forms.View.Details;
@ -324,7 +324,7 @@ namespace Nikse.SubtitleEdit.Forms
this.buttonFixesApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonFixesApply.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.buttonFixesApply.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonFixesApply.Location = new System.Drawing.Point(628, 192);
this.buttonFixesApply.Location = new System.Drawing.Point(628, 200);
this.buttonFixesApply.Name = "buttonFixesApply";
this.buttonFixesApply.Size = new System.Drawing.Size(165, 21);
this.buttonFixesApply.TabIndex = 108;
@ -336,7 +336,7 @@ namespace Nikse.SubtitleEdit.Forms
//
this.buttonRefreshFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRefreshFixes.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonRefreshFixes.Location = new System.Drawing.Point(457, 192);
this.buttonRefreshFixes.Location = new System.Drawing.Point(457, 200);
this.buttonRefreshFixes.Name = "buttonRefreshFixes";
this.buttonRefreshFixes.Size = new System.Drawing.Size(165, 21);
this.buttonRefreshFixes.TabIndex = 106;
@ -348,7 +348,7 @@ namespace Nikse.SubtitleEdit.Forms
//
this.buttonFixesSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonFixesSelectAll.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonFixesSelectAll.Location = new System.Drawing.Point(3, 192);
this.buttonFixesSelectAll.Location = new System.Drawing.Point(3, 200);
this.buttonFixesSelectAll.Name = "buttonFixesSelectAll";
this.buttonFixesSelectAll.Size = new System.Drawing.Size(75, 21);
this.buttonFixesSelectAll.TabIndex = 102;
@ -360,7 +360,7 @@ namespace Nikse.SubtitleEdit.Forms
//
this.buttonFixesInverse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonFixesInverse.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonFixesInverse.Location = new System.Drawing.Point(84, 192);
this.buttonFixesInverse.Location = new System.Drawing.Point(84, 200);
this.buttonFixesInverse.Name = "buttonFixesInverse";
this.buttonFixesInverse.Size = new System.Drawing.Size(100, 21);
this.buttonFixesInverse.TabIndex = 104;
@ -368,25 +368,6 @@ namespace Nikse.SubtitleEdit.Forms
this.buttonFixesInverse.UseVisualStyleBackColor = true;
this.buttonFixesInverse.Click += new System.EventHandler(this.ButtonFixesInverseClick);
//
// subtitleListView1
//
this.subtitleListView1.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.subtitleListView1.ContextMenuStrip = this.contextMenuStripListview;
this.subtitleListView1.FirstVisibleIndex = -1;
this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.subtitleListView1.FullRowSelect = true;
this.subtitleListView1.GridLines = true;
this.subtitleListView1.HideSelection = false;
this.subtitleListView1.Location = new System.Drawing.Point(3, 5);
this.subtitleListView1.Name = "subtitleListView1";
this.subtitleListView1.Size = new System.Drawing.Size(785, 145);
this.subtitleListView1.TabIndex = 110;
this.subtitleListView1.UseCompatibleStateImageBehavior = false;
this.subtitleListView1.View = System.Windows.Forms.View.Details;
this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged);
//
// contextMenuStripListview
//
this.contextMenuStripListview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -418,8 +399,8 @@ namespace Nikse.SubtitleEdit.Forms
//
// groupBoxEditPanel
//
this.groupBoxEditPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxEditPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxEditPanel.Controls.Add(this.buttonSplitLine);
this.groupBoxEditPanel.Controls.Add(this.labelSingleLine);
this.groupBoxEditPanel.Controls.Add(this.buttonUnBreak);
@ -433,7 +414,7 @@ namespace Nikse.SubtitleEdit.Forms
this.groupBoxEditPanel.Controls.Add(this.labelTextLineTotal);
this.groupBoxEditPanel.Controls.Add(this.labelTextLineLengths);
this.groupBoxEditPanel.Controls.Add(this.textBoxListViewText);
this.groupBoxEditPanel.Location = new System.Drawing.Point(8, 149);
this.groupBoxEditPanel.Location = new System.Drawing.Point(8, 160);
this.groupBoxEditPanel.Name = "groupBoxEditPanel";
this.groupBoxEditPanel.Size = new System.Drawing.Size(780, 85);
this.groupBoxEditPanel.TabIndex = 111;
@ -502,16 +483,6 @@ namespace Nikse.SubtitleEdit.Forms
this.labelDurationWarning.TabIndex = 31;
this.labelDurationWarning.Text = "labelDurationWarning";
//
// timeUpDownStartTime
//
this.timeUpDownStartTime.AutoSize = true;
this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownStartTime.Location = new System.Drawing.Point(8, 27);
this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownStartTime.Name = "timeUpDownStartTime";
this.timeUpDownStartTime.Size = new System.Drawing.Size(92, 25);
this.timeUpDownStartTime.TabIndex = 112;
//
// numericUpDownDuration
//
this.numericUpDownDuration.DecimalPlaces = 3;
@ -575,8 +546,8 @@ namespace Nikse.SubtitleEdit.Forms
//
// textBoxListViewText
//
this.textBoxListViewText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBoxListViewText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBoxListViewText.HideSelection = false;
this.textBoxListViewText.Location = new System.Drawing.Point(194, 9);
this.textBoxListViewText.Multiline = true;
@ -591,16 +562,16 @@ namespace Nikse.SubtitleEdit.Forms
this.tabPageLog.Controls.Add(this.textBoxFixedIssues);
this.tabPageLog.Location = new System.Drawing.Point(4, 22);
this.tabPageLog.Name = "tabPageLog";
this.tabPageLog.Size = new System.Drawing.Size(802, 471);
this.tabPageLog.Size = new System.Drawing.Size(802, 482);
this.tabPageLog.TabIndex = 2;
this.tabPageLog.Text = "Log";
this.tabPageLog.UseVisualStyleBackColor = true;
//
// textBoxFixedIssues
//
this.textBoxFixedIssues.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.textBoxFixedIssues.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.textBoxFixedIssues.Location = new System.Drawing.Point(3, 3);
this.textBoxFixedIssues.MaxLength = 65767;
this.textBoxFixedIssues.Multiline = true;
@ -616,18 +587,48 @@ namespace Nikse.SubtitleEdit.Forms
this.labelNumberOfImportantLogMessages.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelNumberOfImportantLogMessages.AutoSize = true;
this.labelNumberOfImportantLogMessages.ForeColor = System.Drawing.Color.Red;
this.labelNumberOfImportantLogMessages.Location = new System.Drawing.Point(12, 558);
this.labelNumberOfImportantLogMessages.Location = new System.Drawing.Point(12, 577);
this.labelNumberOfImportantLogMessages.Name = "labelNumberOfImportantLogMessages";
this.labelNumberOfImportantLogMessages.Size = new System.Drawing.Size(190, 13);
this.labelNumberOfImportantLogMessages.TabIndex = 11;
this.labelNumberOfImportantLogMessages.Text = "labelNumberOfImportantLogMessages";
//
// subtitleListView1
//
this.subtitleListView1.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.subtitleListView1.ContextMenuStrip = this.contextMenuStripListview;
this.subtitleListView1.DisplayExtraFromExtra = false;
this.subtitleListView1.FirstVisibleIndex = -1;
this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.subtitleListView1.FullRowSelect = true;
this.subtitleListView1.GridLines = true;
this.subtitleListView1.HideSelection = false;
this.subtitleListView1.Location = new System.Drawing.Point(3, 5);
this.subtitleListView1.Name = "subtitleListView1";
this.subtitleListView1.Size = new System.Drawing.Size(785, 156);
this.subtitleListView1.TabIndex = 110;
this.subtitleListView1.UseCompatibleStateImageBehavior = false;
this.subtitleListView1.View = System.Windows.Forms.View.Details;
this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged);
//
// timeUpDownStartTime
//
this.timeUpDownStartTime.AutoSize = true;
this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownStartTime.Location = new System.Drawing.Point(8, 27);
this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownStartTime.Name = "timeUpDownStartTime";
this.timeUpDownStartTime.Size = new System.Drawing.Size(92, 25);
this.timeUpDownStartTime.TabIndex = 112;
//
// FixCommonErrors
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(846, 573);
this.ClientSize = new System.Drawing.Size(846, 592);
this.Controls.Add(this.labelStatus);
this.Controls.Add(this.labelNumberOfImportantLogMessages);
this.Controls.Add(this.buttonBack);

View File

@ -38,8 +38,9 @@ namespace Nikse.SubtitleEdit.Forms
const int IndexFixMissingOpenBracket = 23;
const int IndexAloneLowercaseIToUppercaseIEnglish = 24;
const int IndexFixOcrErrorsViaReplaceList = 25;
const int IndexDanishLetterI = 26;
const int IndexFixSpanishInvertedQuestionAndExclamationMarks = 27;
const int IndexRemoveSpaceBetweenNumbers = 26;
const int IndexDanishLetterI = 27;
const int IndexFixSpanishInvertedQuestionAndExclamationMarks = 28;
int _danishLetterIIndex = -1;
int _spanishInvertedQuestionAndExclamationMarksIndex = -1;
@ -153,6 +154,7 @@ namespace Nikse.SubtitleEdit.Forms
_fixActions.Add(new FixItem(_language.FixMissingOpenBracket, _language.FixMissingOpenBracketExample, delegate { FixMissingOpenBracket(); }, ce.FixMissingOpenBracketTicked));
_fixActions.Add(new FixItem(_language.FixLowercaseIToUppercaseI, _language.FixLowercaseIToUppercaseIExample, delegate { FixAloneLowercaseIToUppercaseI(); }, ce.AloneLowercaseIToUppercaseIEnglishTicked));
_fixActions.Add(new FixItem(_language.FixCommonOcrErrors, "D0n't -> Don't", delegate { FixOcrErrorsViaReplaceList(threeLetterISOLanguageName); }, ce.FixOcrErrorsViaReplaceListTicked));
_fixActions.Add(new FixItem(_language.RemoveSpaceBetweenNumber, "1 100 -> 1100", delegate { RemoveSpaceBetweenNumbers(); }, ce.RemoveSpaceBetweenNumberTicked));
if (_autoDetectGoogleLanguage == "da" || subtitle.Paragraphs.Count < 25) // && Thread.CurrentThread.CurrentCulture.Name == "da-DK" &&
{
@ -770,6 +772,23 @@ namespace Nikse.SubtitleEdit.Forms
{
p.Text = p.Text.TrimEnd(' ');
}
p.Text = p.Text.Replace(". . ..", "...");
p.Text = p.Text.Replace(". ...", "...");
p.Text = p.Text.Replace(". .. .", "...");
p.Text = p.Text.Replace(". . .", "...");
p.Text = p.Text.Replace(". ..", "...");
p.Text = p.Text.Replace(".. .", "...");
p.Text = p.Text.Replace("....", "...");
p.Text = p.Text.Replace("....", "...");
p.Text = p.Text.Replace("....", "...");
p.Text = p.Text.Replace("... ?", "...?");
p.Text = p.Text.Replace("... !", "...!");
p.Text = p.Text.Replace(" :", ":");
p.Text = p.Text.Replace(" :", ":");
while (p.Text.Contains(" ,"))
{
p.Text = p.Text.Replace(" ,", ",");
@ -873,7 +892,6 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
if (doubleSpaces > 0)
LogStatus(_language.RemoveUnneededSpaces, string.Format(_language.XUnneededSpacesRemoved, doubleSpaces));
@ -1114,22 +1132,23 @@ namespace Nikse.SubtitleEdit.Forms
string[] arr = p.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
if (arr.Length == 2 && arr[0].Length > 1 && arr[1].Length > 1)
{
if (arr[0].StartsWith("-") && arr[1].StartsWith("-"))
if (arr[0][0] == '-' && arr[0][1] != ' ')
arr[0] = arr[0].Insert(1, " ");
if (arr[0].Length > 6 && arr[0].StartsWith("<i>-") && arr[0][4] != ' ')
arr[0] = arr[0].Insert(4, " ");
if (arr[1][0] == '-' && arr[1][1] != ' ')
arr[1] = arr[1].Insert(1, " ");
if (arr[1].Length > 6 && arr[1].StartsWith("<i>-") && arr[1][4] != ' ')
arr[1] = arr[1].Insert(4, " ");
string newText = arr[0] + Environment.NewLine + arr[1];
if (newText != p.Text && AllowFix(i + 1, fixAction))
{
if (arr[0][1] != ' ')
arr[0] = arr[0].Insert(1, " ");
if (arr[1][1] != ' ')
arr[1] = arr[1].Insert(1, " ");
string newText = arr[0] + Environment.NewLine + arr[1];
if (newText != p.Text && AllowFix(i + 1, fixAction))
{
_totalFixes++;
missingSpaces++;
_totalFixes++;
missingSpaces++;
string oldText = p.Text;
p.Text = newText;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text);
}
string oldText = p.Text;
p.Text = newText;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text);
}
}
@ -1851,6 +1870,39 @@ namespace Nikse.SubtitleEdit.Forms
LogStatus(_language.FixCommonOcrErrors, string.Format(_language.CommonOcrErrorsFixed, noOfFixes));
}
private void RemoveSpaceBetweenNumbers()
{
string fixAction = _language.FixCommonOcrErrors;
int noOfFixes = 0;
Regex regex = new Regex(@"\d \d", RegexOptions.Compiled);
for (int i = 0; i < _subtitle.Paragraphs.Count; i++)
{
Paragraph p = _subtitle.Paragraphs[i];
string text = p.Text;
Match match = regex.Match(text);
while (match.Success)
{
text = text.Remove(match.Index + 1, 1);
match = regex.Match(text);
}
if (p.Text != text)
{
if (AllowFix(i + 1, fixAction))
{
string oldText = p.Text;
p.Text = text;
noOfFixes++;
_totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text);
}
}
}
if (noOfFixes > 0)
LogStatus(_language.FixCommonOcrErrors, string.Format(_language.RemoveSpaceBetweenNumbersFixed, noOfFixes));
}
private void FixAloneLowercaseIToUppercaseI()
{
string fixAction = _language.FixLowercaseIToUppercaseI;
@ -3155,6 +3207,7 @@ namespace Nikse.SubtitleEdit.Forms
ce.FixMissingOpenBracketTicked = listView1.Items[IndexFixMissingOpenBracket].Checked;
ce.AloneLowercaseIToUppercaseIEnglishTicked = listView1.Items[IndexAloneLowercaseIToUppercaseIEnglish].Checked;
ce.FixOcrErrorsViaReplaceListTicked = listView1.Items[IndexFixOcrErrorsViaReplaceList].Checked;
ce.RemoveSpaceBetweenNumberTicked = listView1.Items[IndexRemoveSpaceBetweenNumbers].Checked;
if (_danishLetterIIndex > -1)
ce.DanishLetterITicked = listView1.Items[_danishLetterIIndex].Checked;

View File

@ -373,6 +373,8 @@ namespace Nikse.SubtitleEdit.Logic
StartWithUppercaseLetterAfterParagraph = "Start with uppercase letter after paragraph",
StartWithUppercaseLetterAfterPeriodInsideParagraph = "Start with uppercase letter after period inside paragraph",
CommonOcrErrorsFixed = "Common OCR errors fixed (OcrReplaceList file used): {0}",
RemoveSpaceBetweenNumber = "Remove space between numbers",
RemoveSpaceBetweenNumbersFixed = "Remove space between numbers fixed: {0}",
FixLowercaseIToUppercaseI = "Fix alone lowercase 'i' to 'I' (English)",
FixDanishLetterI = "Fix Danish letter 'i'",
FixSpanishInvertedQuestionAndExclamationMarks = "Fix Spanish inverted question and exclamation marks",

View File

@ -303,6 +303,8 @@
public string FixLowercaseIToUppercaseI { get; set; }
public string FixCommonOcrErrors { get; set; }
public string CommonOcrErrorsFixed { get; set; }
public string RemoveSpaceBetweenNumber { get; set; }
public string RemoveSpaceBetweenNumbersFixed { get; set; }
public string FixDanishLetterI { get; set; }
public string FixSpanishInvertedQuestionAndExclamationMarks { get; set; }
public string AddMissingQuote { get; set; }

View File

@ -161,6 +161,7 @@ namespace Nikse.SubtitleEdit.Logic
public bool StartWithUppercaseLetterAfterPeriodInsideParagraphTicked { get; set; }
public bool AloneLowercaseIToUppercaseIEnglishTicked { get; set; }
public bool FixOcrErrorsViaReplaceListTicked { get; set; }
public bool RemoveSpaceBetweenNumberTicked { get; set; }
public bool DanishLetterITicked { get; set; }
public bool SpanishInvertedQuestionAndExclamationMarksTicked { get; set; }
public bool FixDoubleDashTicked { get; set; }
@ -919,6 +920,9 @@ namespace Nikse.SubtitleEdit.Logic
subNode = node.SelectSingleNode("FixOcrErrorsViaReplaceListTicked");
if (subNode != null)
settings.CommonErrors.FixOcrErrorsViaReplaceListTicked = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("RemoveSpaceBetweenNumberTicked");
if (subNode != null)
settings.CommonErrors.RemoveSpaceBetweenNumberTicked = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("DanishLetterITicked");
if (subNode != null)
settings.CommonErrors.DanishLetterITicked = Convert.ToBoolean(subNode.InnerText);
@ -1262,6 +1266,7 @@ namespace Nikse.SubtitleEdit.Logic
textWriter.WriteElementString("StartWithUppercaseLetterAfterPeriodInsideParagraphTicked", settings.CommonErrors.StartWithUppercaseLetterAfterPeriodInsideParagraphTicked.ToString());
textWriter.WriteElementString("AloneLowercaseIToUppercaseIEnglishTicked", settings.CommonErrors.AloneLowercaseIToUppercaseIEnglishTicked.ToString());
textWriter.WriteElementString("FixOcrErrorsViaReplaceListTicked", settings.CommonErrors.FixOcrErrorsViaReplaceListTicked.ToString());
textWriter.WriteElementString("RemoveSpaceBetweenNumberTicked", settings.CommonErrors.RemoveSpaceBetweenNumberTicked.ToString());
textWriter.WriteElementString("DanishLetterITicked", settings.CommonErrors.DanishLetterITicked.ToString());
textWriter.WriteElementString("SpanishInvertedQuestionAndExclamationMarksTicked", settings.CommonErrors.SpanishInvertedQuestionAndExclamationMarksTicked.ToString());
textWriter.WriteElementString("FixDoubleDashTicked", settings.CommonErrors.FixDoubleDashTicked.ToString());