Working on edit of original sub

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@259 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-01-17 19:44:42 +00:00
parent 97b3f71432
commit 664f3a8377
9 changed files with 718 additions and 158 deletions

View File

@ -198,8 +198,9 @@ namespace Nikse.SubtitleEdit.Controls
foreach (Paragraph paragraph in paragraphs)
{
Add(paragraph, i.ToString());
string alternateText = GetOriginalSubtitle(i, paragraph, paragraphsAlternate);
SetAlternateText(i, alternateText);
Paragraph alternate = Utilities.GetOriginalParagraph(i, paragraph, paragraphsAlternate);
if (alternate != null)
SetAlternateText(i, alternate.Text);
i++;
}
@ -210,26 +211,6 @@ namespace Nikse.SubtitleEdit.Controls
FirstVisibleIndex = -1;
}
private static string GetOriginalSubtitle(int index, Paragraph paragraph, List<Paragraph> originalParagraphs)
{
if (index < originalParagraphs.Count && Math.Abs(originalParagraphs[index].StartTime.TotalMilliseconds - paragraph.StartTime.TotalMilliseconds) < 50)
return originalParagraphs[index].Text;
foreach (Paragraph p in originalParagraphs)
{
if (p.StartTime.TotalMilliseconds == paragraph.StartTime.TotalMilliseconds)
return p.Text;
}
foreach (Paragraph p in originalParagraphs)
{
if (p.StartTime.TotalMilliseconds > paragraph.StartTime.TotalMilliseconds - 200 &&
p.StartTime.TotalMilliseconds < paragraph.StartTime.TotalMilliseconds + 1000)
return p.Text;
}
return string.Empty;
}
private void Add(Paragraph paragraph, string tag)
{
var item = new ListViewItem(paragraph.Number.ToString()) {Tag = tag};
@ -311,6 +292,13 @@ namespace Nikse.SubtitleEdit.Controls
return null;
}
public string GetTextAlternate(int index)
{
if (index >= 0 && index < Items.Count && IsAlternateTextColumnVisible)
return Items[index].SubItems[ColumnIndexTextAlternate].Text.Replace(_lineSeparatorString, Environment.NewLine);
return null;
}
public string GetStartTime(int index)
{
if (index >= 0 && index < Items.Count)

View File

@ -62,7 +62,7 @@ namespace Nikse.SubtitleEdit.Forms
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.mergeSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBoxEditPanel = new System.Windows.Forms.GroupBox();
this.panelSingleLine = new System.Windows.Forms.Panel();
this.labelSingleLine = new System.Windows.Forms.Label();
this.buttonUnBreak = new System.Windows.Forms.Button();
this.buttonAutoBreak = new System.Windows.Forms.Button();
this.labelStartTimeWarning = new System.Windows.Forms.Label();
@ -121,7 +121,7 @@ namespace Nikse.SubtitleEdit.Forms
this.labelStatus.AutoSize = true;
this.labelStatus.Location = new System.Drawing.Point(12, 542);
this.labelStatus.Name = "labelStatus";
this.labelStatus.Size = new System.Drawing.Size(92, 21);
this.labelStatus.Size = new System.Drawing.Size(60, 13);
this.labelStatus.TabIndex = 5;
this.labelStatus.Text = "labelStatus";
//
@ -239,10 +239,10 @@ namespace Nikse.SubtitleEdit.Forms
// tabPageFixes
//
this.tabPageFixes.Controls.Add(this.splitContainerStep2);
this.tabPageFixes.Location = new System.Drawing.Point(4, 30);
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, 463);
this.tabPageFixes.Size = new System.Drawing.Size(802, 471);
this.tabPageFixes.TabIndex = 1;
this.tabPageFixes.Text = "Fixes";
this.tabPageFixes.UseVisualStyleBackColor = true;
@ -266,8 +266,8 @@ 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, 457);
this.splitContainerStep2.SplitterDistance = 214;
this.splitContainerStep2.Size = new System.Drawing.Size(796, 465);
this.splitContainerStep2.SplitterDistance = 217;
this.splitContainerStep2.TabIndex = 112;
//
// listViewFixes
@ -286,7 +286,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, 181);
this.listViewFixes.Size = new System.Drawing.Size(790, 184);
this.listViewFixes.TabIndex = 100;
this.listViewFixes.UseCompatibleStateImageBehavior = false;
this.listViewFixes.View = System.Windows.Forms.View.Details;
@ -323,7 +323,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, 189);
this.buttonFixesApply.Location = new System.Drawing.Point(628, 192);
this.buttonFixesApply.Name = "buttonFixesApply";
this.buttonFixesApply.Size = new System.Drawing.Size(165, 21);
this.buttonFixesApply.TabIndex = 108;
@ -335,7 +335,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, 189);
this.buttonRefreshFixes.Location = new System.Drawing.Point(457, 192);
this.buttonRefreshFixes.Name = "buttonRefreshFixes";
this.buttonRefreshFixes.Size = new System.Drawing.Size(165, 21);
this.buttonRefreshFixes.TabIndex = 106;
@ -347,7 +347,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, 189);
this.buttonFixesSelectAll.Location = new System.Drawing.Point(3, 192);
this.buttonFixesSelectAll.Name = "buttonFixesSelectAll";
this.buttonFixesSelectAll.Size = new System.Drawing.Size(75, 21);
this.buttonFixesSelectAll.TabIndex = 102;
@ -359,7 +359,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, 189);
this.buttonFixesInverse.Location = new System.Drawing.Point(84, 192);
this.buttonFixesInverse.Name = "buttonFixesInverse";
this.buttonFixesInverse.Size = new System.Drawing.Size(100, 21);
this.buttonFixesInverse.TabIndex = 104;
@ -380,7 +380,7 @@ namespace Nikse.SubtitleEdit.Forms
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, 140);
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;
@ -419,7 +419,7 @@ namespace Nikse.SubtitleEdit.Forms
//
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.panelSingleLine);
this.groupBoxEditPanel.Controls.Add(this.labelSingleLine);
this.groupBoxEditPanel.Controls.Add(this.buttonUnBreak);
this.groupBoxEditPanel.Controls.Add(this.buttonAutoBreak);
this.groupBoxEditPanel.Controls.Add(this.labelStartTimeWarning);
@ -431,19 +431,20 @@ 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, 144);
this.groupBoxEditPanel.Location = new System.Drawing.Point(8, 149);
this.groupBoxEditPanel.Name = "groupBoxEditPanel";
this.groupBoxEditPanel.Size = new System.Drawing.Size(732, 85);
this.groupBoxEditPanel.TabIndex = 111;
this.groupBoxEditPanel.TabStop = false;
//
// panelSingleLine
// labelSingleLine
//
this.panelSingleLine.Location = new System.Drawing.Point(302, 66);
this.panelSingleLine.Margin = new System.Windows.Forms.Padding(0);
this.panelSingleLine.Name = "panelSingleLine";
this.panelSingleLine.Size = new System.Drawing.Size(83, 17);
this.panelSingleLine.TabIndex = 35;
this.labelSingleLine.AutoSize = true;
this.labelSingleLine.Location = new System.Drawing.Point(296, 65);
this.labelSingleLine.Name = "labelSingleLine";
this.labelSingleLine.Size = new System.Drawing.Size(23, 13);
this.labelSingleLine.TabIndex = 123;
this.labelSingleLine.Text = "1/1";
//
// buttonUnBreak
//
@ -473,7 +474,7 @@ namespace Nikse.SubtitleEdit.Forms
this.labelStartTimeWarning.ForeColor = System.Drawing.Color.Red;
this.labelStartTimeWarning.Location = new System.Drawing.Point(6, 51);
this.labelStartTimeWarning.Name = "labelStartTimeWarning";
this.labelStartTimeWarning.Size = new System.Drawing.Size(179, 21);
this.labelStartTimeWarning.Size = new System.Drawing.Size(115, 13);
this.labelStartTimeWarning.TabIndex = 32;
this.labelStartTimeWarning.Text = "labelStartTimeWarning";
//
@ -483,7 +484,7 @@ namespace Nikse.SubtitleEdit.Forms
this.labelDurationWarning.ForeColor = System.Drawing.Color.Red;
this.labelDurationWarning.Location = new System.Drawing.Point(57, 64);
this.labelDurationWarning.Name = "labelDurationWarning";
this.labelDurationWarning.Size = new System.Drawing.Size(170, 21);
this.labelDurationWarning.Size = new System.Drawing.Size(110, 13);
this.labelDurationWarning.TabIndex = 31;
this.labelDurationWarning.Text = "labelDurationWarning";
//
@ -494,7 +495,7 @@ namespace Nikse.SubtitleEdit.Forms
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(137, 34);
this.timeUpDownStartTime.Size = new System.Drawing.Size(92, 25);
this.timeUpDownStartTime.TabIndex = 112;
//
// numericUpDownDuration
@ -517,7 +518,7 @@ namespace Nikse.SubtitleEdit.Forms
0,
-2147483648});
this.numericUpDownDuration.Name = "numericUpDownDuration";
this.numericUpDownDuration.Size = new System.Drawing.Size(54, 27);
this.numericUpDownDuration.Size = new System.Drawing.Size(54, 21);
this.numericUpDownDuration.TabIndex = 114;
this.numericUpDownDuration.ValueChanged += new System.EventHandler(this.NumericUpDownDurationValueChanged);
//
@ -526,7 +527,7 @@ namespace Nikse.SubtitleEdit.Forms
this.labelDuration.AutoSize = true;
this.labelDuration.Location = new System.Drawing.Point(97, 12);
this.labelDuration.Name = "labelDuration";
this.labelDuration.Size = new System.Drawing.Size(74, 21);
this.labelDuration.Size = new System.Drawing.Size(48, 13);
this.labelDuration.TabIndex = 28;
this.labelDuration.Text = "Duration";
//
@ -535,7 +536,7 @@ namespace Nikse.SubtitleEdit.Forms
this.labelStartTime.AutoSize = true;
this.labelStartTime.Location = new System.Drawing.Point(6, 12);
this.labelStartTime.Name = "labelStartTime";
this.labelStartTime.Size = new System.Drawing.Size(84, 21);
this.labelStartTime.Size = new System.Drawing.Size(54, 13);
this.labelStartTime.TabIndex = 27;
this.labelStartTime.Text = "Start time";
//
@ -554,7 +555,7 @@ namespace Nikse.SubtitleEdit.Forms
this.labelTextLineLengths.AutoSize = true;
this.labelTextLineLengths.Location = new System.Drawing.Point(191, 65);
this.labelTextLineLengths.Name = "labelTextLineLengths";
this.labelTextLineLengths.Size = new System.Drawing.Size(166, 21);
this.labelTextLineLengths.Size = new System.Drawing.Size(108, 13);
this.labelTextLineLengths.TabIndex = 25;
this.labelTextLineLengths.Text = "labelTextLineLengths";
//
@ -573,9 +574,9 @@ namespace Nikse.SubtitleEdit.Forms
// tabPageLog
//
this.tabPageLog.Controls.Add(this.textBoxFixedIssues);
this.tabPageLog.Location = new System.Drawing.Point(4, 30);
this.tabPageLog.Location = new System.Drawing.Point(4, 22);
this.tabPageLog.Name = "tabPageLog";
this.tabPageLog.Size = new System.Drawing.Size(802, 463);
this.tabPageLog.Size = new System.Drawing.Size(802, 471);
this.tabPageLog.TabIndex = 2;
this.tabPageLog.Text = "Log";
this.tabPageLog.UseVisualStyleBackColor = true;
@ -602,13 +603,13 @@ namespace Nikse.SubtitleEdit.Forms
this.labelNumberOfImportantLogMessages.ForeColor = System.Drawing.Color.Red;
this.labelNumberOfImportantLogMessages.Location = new System.Drawing.Point(12, 558);
this.labelNumberOfImportantLogMessages.Name = "labelNumberOfImportantLogMessages";
this.labelNumberOfImportantLogMessages.Size = new System.Drawing.Size(293, 21);
this.labelNumberOfImportantLogMessages.Size = new System.Drawing.Size(190, 13);
this.labelNumberOfImportantLogMessages.TabIndex = 11;
this.labelNumberOfImportantLogMessages.Text = "labelNumberOfImportantLogMessages";
//
// FixCommonErrors
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F);
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);
@ -693,8 +694,8 @@ namespace Nikse.SubtitleEdit.Forms
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDelete;
private System.Windows.Forms.ToolStripMenuItem mergeSelectedLinesToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.Panel panelSingleLine;
private System.Windows.Forms.Label labelNumberOfImportantLogMessages;
private System.Windows.Forms.SplitContainer splitContainerStep2;
private System.Windows.Forms.Label labelSingleLine;
}
}

View File

@ -669,7 +669,7 @@ namespace Nikse.SubtitleEdit.Forms
{
Paragraph p = _subtitle.Paragraphs[i];
if (p.Text.Length < Configuration.Settings.Tools.MergeLinesShorterThan && p.Text.Contains(Environment.NewLine))
if (Utilities.RemoveHtmlTags(p.Text).Length < Configuration.Settings.Tools.MergeLinesShorterThan && p.Text.Contains(Environment.NewLine))
{
string s = p.Text.TrimEnd(".?!:;".ToCharArray());
s = s.TrimStart('-');
@ -2064,6 +2064,18 @@ namespace Nikse.SubtitleEdit.Forms
}
}
if (p.Text.StartsWith("<i>..."))
{
if (AllowFix(i + 1, fixAction))
{
string oldText = p.Text;
p.Text = "<i>" + p.Text.Substring(6, p.Text.Length - 6);
fixCount++;
_totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text);
}
}
if (p.Text.Contains(": ..."))
{
if (AllowFix(i + 1, fixAction))
@ -3320,17 +3332,8 @@ namespace Nikse.SubtitleEdit.Forms
labelTextLineTotal.Text = string.Empty;
labelTextLineLengths.Text = _languageGeneral.SingleLineLengths;
panelSingleLine.Left = labelTextLineLengths.Left + labelTextLineLengths.Width - 6;
Utilities.DisplayLineLengths(panelSingleLine, text);
//labelTextLineMaxLength.Text = string.Empty;
//int maxLineLength = Utilities.GetMaxLineLength(text);
//labelTextLineMaxLength.Text = string.Format(_languageGeneral.SingleLineMaximumLengthX, maxLineLength);
//if (maxLineLength > Configuration.Settings.General.SubtitleLineMaximumLength)
// labelTextLineMaxLength.ForeColor = System.Drawing.Color.Red;
//else if (maxLineLength > Configuration.Settings.General.SubtitleLineMaximumLength - 5)
// labelTextLineMaxLength.ForeColor = System.Drawing.Color.Orange;
//else
// labelTextLineMaxLength.ForeColor = System.Drawing.Color.Black;
labelSingleLine.Left = labelTextLineLengths.Left + labelTextLineLengths.Width - 6;
Utilities.GetLineLengths(labelSingleLine, text);
string s = Utilities.RemoveHtmlTags(text).Replace(Environment.NewLine, " ");
if (s.Length < Configuration.Settings.General.SubtitleLineMaximumLength * 1.9)

View File

@ -68,6 +68,11 @@
this.reopenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator20 = new System.Windows.Forms.ToolStripSeparator();
this.saveOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveOriginalAstoolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItemOpenContainingFolder = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemCompare = new System.Windows.Forms.ToolStripMenuItem();
@ -294,8 +299,15 @@
this.tabControlSubtitle = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.groupBoxEdit = new System.Windows.Forms.GroupBox();
this.labelAlternateCharactersPerSecond = new System.Windows.Forms.Label();
this.labelTextAlternateLineTotal = new System.Windows.Forms.Label();
this.labelAlternateSingleLine = new System.Windows.Forms.Label();
this.labelTextAlternateLineLengths = new System.Windows.Forms.Label();
this.labelAlternateText = new System.Windows.Forms.Label();
this.labelText = new System.Windows.Forms.Label();
this.textBoxListViewTextAlternate = new System.Windows.Forms.TextBox();
this.labelSingleLine = new System.Windows.Forms.Label();
this.buttonAutoBreak = new System.Windows.Forms.Button();
this.panelSingleLine = new System.Windows.Forms.Panel();
this.labelTextLineLengths = new System.Windows.Forms.Label();
this.labelTextLineTotal = new System.Windows.Forms.Label();
this.labelCharactersPerSecond = new System.Windows.Forms.Label();
@ -307,7 +319,6 @@
this.numericUpDownDuration = new System.Windows.Forms.NumericUpDown();
this.buttonPrevious = new System.Windows.Forms.Button();
this.buttonNext = new System.Windows.Forms.Button();
this.labelText = new System.Windows.Forms.Label();
this.labelStartTime = new System.Windows.Forms.Label();
this.textBoxListViewText = new System.Windows.Forms.TextBox();
this.labelDuration = new System.Windows.Forms.Label();
@ -704,6 +715,11 @@
this.reopenToolStripMenuItem,
this.saveToolStripMenuItem,
this.saveAsToolStripMenuItem,
this.toolStripSeparator20,
this.saveOriginalToolStripMenuItem,
this.saveOriginalAstoolStripMenuItem,
this.openOriginalToolStripMenuItem,
this.removeOriginalToolStripMenuItem,
this.toolStripSeparator12,
this.toolStripMenuItemOpenContainingFolder,
this.toolStripMenuItemCompare,
@ -759,6 +775,39 @@
this.saveAsToolStripMenuItem.Text = "Save as...";
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.SaveAsToolStripMenuItemClick);
//
// toolStripSeparator20
//
this.toolStripSeparator20.Name = "toolStripSeparator20";
this.toolStripSeparator20.Size = new System.Drawing.Size(331, 6);
//
// saveOriginalToolStripMenuItem
//
this.saveOriginalToolStripMenuItem.Name = "saveOriginalToolStripMenuItem";
this.saveOriginalToolStripMenuItem.Size = new System.Drawing.Size(334, 22);
this.saveOriginalToolStripMenuItem.Text = "Save original";
this.saveOriginalToolStripMenuItem.Click += new System.EventHandler(this.saveOriginalToolStripMenuItem_Click);
//
// saveOriginalAstoolStripMenuItem
//
this.saveOriginalAstoolStripMenuItem.Name = "saveOriginalAstoolStripMenuItem";
this.saveOriginalAstoolStripMenuItem.Size = new System.Drawing.Size(334, 22);
this.saveOriginalAstoolStripMenuItem.Text = "Save original as...";
this.saveOriginalAstoolStripMenuItem.Click += new System.EventHandler(this.saveOriginalAstoolStripMenuItem_Click);
//
// openOriginalToolStripMenuItem
//
this.openOriginalToolStripMenuItem.Name = "openOriginalToolStripMenuItem";
this.openOriginalToolStripMenuItem.Size = new System.Drawing.Size(334, 22);
this.openOriginalToolStripMenuItem.Text = "Open original (translator mode)...";
this.openOriginalToolStripMenuItem.Click += new System.EventHandler(this.openOriginalToolStripMenuItem_Click);
//
// removeOriginalToolStripMenuItem
//
this.removeOriginalToolStripMenuItem.Name = "removeOriginalToolStripMenuItem";
this.removeOriginalToolStripMenuItem.Size = new System.Drawing.Size(334, 22);
this.removeOriginalToolStripMenuItem.Text = "Remove original";
this.removeOriginalToolStripMenuItem.Click += new System.EventHandler(this.removeOriginalToolStripMenuItem_Click);
//
// toolStripSeparator12
//
this.toolStripSeparator12.Name = "toolStripSeparator12";
@ -1571,7 +1620,7 @@
this.fixCommonErrorsInSelectedLinesToolStripMenuItem,
this.changeCasingForSelectedLinesToolStripMenuItem});
this.contextMenuStripListview.Name = "contextMenuStripListview";
this.contextMenuStripListview.Size = new System.Drawing.Size(276, 562);
this.contextMenuStripListview.Size = new System.Drawing.Size(276, 584);
this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening);
//
// toolStripMenuItemDelete
@ -2828,8 +2877,15 @@
//
this.groupBoxEdit.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxEdit.Controls.Add(this.labelAlternateCharactersPerSecond);
this.groupBoxEdit.Controls.Add(this.labelTextAlternateLineTotal);
this.groupBoxEdit.Controls.Add(this.labelAlternateSingleLine);
this.groupBoxEdit.Controls.Add(this.labelTextAlternateLineLengths);
this.groupBoxEdit.Controls.Add(this.labelAlternateText);
this.groupBoxEdit.Controls.Add(this.labelText);
this.groupBoxEdit.Controls.Add(this.textBoxListViewTextAlternate);
this.groupBoxEdit.Controls.Add(this.labelSingleLine);
this.groupBoxEdit.Controls.Add(this.buttonAutoBreak);
this.groupBoxEdit.Controls.Add(this.panelSingleLine);
this.groupBoxEdit.Controls.Add(this.labelTextLineLengths);
this.groupBoxEdit.Controls.Add(this.labelTextLineTotal);
this.groupBoxEdit.Controls.Add(this.labelCharactersPerSecond);
@ -2841,7 +2897,6 @@
this.groupBoxEdit.Controls.Add(this.numericUpDownDuration);
this.groupBoxEdit.Controls.Add(this.buttonPrevious);
this.groupBoxEdit.Controls.Add(this.buttonNext);
this.groupBoxEdit.Controls.Add(this.labelText);
this.groupBoxEdit.Controls.Add(this.labelStartTime);
this.groupBoxEdit.Controls.Add(this.textBoxListViewText);
this.groupBoxEdit.Controls.Add(this.labelDuration);
@ -2852,6 +2907,88 @@
this.groupBoxEdit.TabIndex = 1;
this.groupBoxEdit.TabStop = false;
//
// labelAlternateCharactersPerSecond
//
this.labelAlternateCharactersPerSecond.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelAlternateCharactersPerSecond.AutoSize = true;
this.labelAlternateCharactersPerSecond.Location = new System.Drawing.Point(838, 12);
this.labelAlternateCharactersPerSecond.Name = "labelAlternateCharactersPerSecond";
this.labelAlternateCharactersPerSecond.Size = new System.Drawing.Size(64, 13);
this.labelAlternateCharactersPerSecond.TabIndex = 38;
this.labelAlternateCharactersPerSecond.Text = "altCharsSec";
//
// labelTextAlternateLineTotal
//
this.labelTextAlternateLineTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelTextAlternateLineTotal.AutoSize = true;
this.labelTextAlternateLineTotal.Location = new System.Drawing.Point(884, 86);
this.labelTextAlternateLineTotal.Name = "labelTextAlternateLineTotal";
this.labelTextAlternateLineTotal.Size = new System.Drawing.Size(36, 13);
this.labelTextAlternateLineTotal.TabIndex = 37;
this.labelTextAlternateLineTotal.Text = "AltTot";
//
// labelAlternateSingleLine
//
this.labelAlternateSingleLine.AutoSize = true;
this.labelAlternateSingleLine.Location = new System.Drawing.Point(839, 86);
this.labelAlternateSingleLine.Name = "labelAlternateSingleLine";
this.labelAlternateSingleLine.Size = new System.Drawing.Size(47, 13);
this.labelAlternateSingleLine.TabIndex = 36;
this.labelAlternateSingleLine.Text = "AltSinLin";
//
// labelTextAlternateLineLengths
//
this.labelTextAlternateLineLengths.AutoSize = true;
this.labelTextAlternateLineLengths.Location = new System.Drawing.Point(786, 86);
this.labelTextAlternateLineLengths.Name = "labelTextAlternateLineLengths";
this.labelTextAlternateLineLengths.Size = new System.Drawing.Size(56, 13);
this.labelTextAlternateLineLengths.TabIndex = 35;
this.labelTextAlternateLineLengths.Text = "AltLineLen";
//
// labelAlternateText
//
this.labelAlternateText.AutoSize = true;
this.labelAlternateText.Location = new System.Drawing.Point(803, 12);
this.labelAlternateText.Name = "labelAlternateText";
this.labelAlternateText.Size = new System.Drawing.Size(29, 13);
this.labelAlternateText.TabIndex = 34;
this.labelAlternateText.Text = "Text";
this.labelAlternateText.Visible = false;
//
// labelText
//
this.labelText.AutoSize = true;
this.labelText.Location = new System.Drawing.Point(203, 11);
this.labelText.Name = "labelText";
this.labelText.Size = new System.Drawing.Size(29, 13);
this.labelText.TabIndex = 5;
this.labelText.Text = "Text";
//
// textBoxListViewTextAlternate
//
this.textBoxListViewTextAlternate.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBoxListViewTextAlternate.ContextMenuStrip = this.contextMenuStripTextBoxListView;
this.textBoxListViewTextAlternate.Enabled = false;
this.textBoxListViewTextAlternate.HideSelection = false;
this.textBoxListViewTextAlternate.Location = new System.Drawing.Point(806, 28);
this.textBoxListViewTextAlternate.Multiline = true;
this.textBoxListViewTextAlternate.Name = "textBoxListViewTextAlternate";
this.textBoxListViewTextAlternate.Size = new System.Drawing.Size(13, 56);
this.textBoxListViewTextAlternate.TabIndex = 33;
this.textBoxListViewTextAlternate.Visible = false;
this.textBoxListViewTextAlternate.TextChanged += new System.EventHandler(this.textBoxListViewTextAlternate_TextChanged);
this.textBoxListViewTextAlternate.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxListViewTextAlternate_KeyDown);
//
// labelSingleLine
//
this.labelSingleLine.AutoSize = true;
this.labelSingleLine.Location = new System.Drawing.Point(310, 86);
this.labelSingleLine.Name = "labelSingleLine";
this.labelSingleLine.Size = new System.Drawing.Size(76, 13);
this.labelSingleLine.TabIndex = 32;
this.labelSingleLine.Text = "labelSingleLine";
//
// buttonAutoBreak
//
this.buttonAutoBreak.Location = new System.Drawing.Point(139, 75);
@ -2862,15 +2999,6 @@
this.buttonAutoBreak.UseVisualStyleBackColor = true;
this.buttonAutoBreak.Click += new System.EventHandler(this.ButtonAutoBreakClick);
//
// panelSingleLine
//
this.panelSingleLine.AutoSize = true;
this.panelSingleLine.Location = new System.Drawing.Point(314, 86);
this.panelSingleLine.Margin = new System.Windows.Forms.Padding(0);
this.panelSingleLine.Name = "panelSingleLine";
this.panelSingleLine.Size = new System.Drawing.Size(52, 16);
this.panelSingleLine.TabIndex = 7;
//
// labelTextLineLengths
//
this.labelTextLineLengths.AutoSize = true;
@ -2883,22 +3011,22 @@
// labelTextLineTotal
//
this.labelTextLineTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelTextLineTotal.Location = new System.Drawing.Point(625, 84);
this.labelTextLineTotal.AutoSize = true;
this.labelTextLineTotal.Location = new System.Drawing.Point(625, 86);
this.labelTextLineTotal.Name = "labelTextLineTotal";
this.labelTextLineTotal.Size = new System.Drawing.Size(177, 18);
this.labelTextLineTotal.Size = new System.Drawing.Size(94, 13);
this.labelTextLineTotal.TabIndex = 21;
this.labelTextLineTotal.Text = "labelTextLineTotal";
this.labelTextLineTotal.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// labelCharactersPerSecond
//
this.labelCharactersPerSecond.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelCharactersPerSecond.Location = new System.Drawing.Point(625, 10);
this.labelCharactersPerSecond.AutoSize = true;
this.labelCharactersPerSecond.Location = new System.Drawing.Point(634, 11);
this.labelCharactersPerSecond.Name = "labelCharactersPerSecond";
this.labelCharactersPerSecond.Size = new System.Drawing.Size(177, 17);
this.labelCharactersPerSecond.Size = new System.Drawing.Size(133, 13);
this.labelCharactersPerSecond.TabIndex = 31;
this.labelCharactersPerSecond.Text = "labelCharactersPerSecond";
this.labelCharactersPerSecond.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// buttonUnBreak
//
@ -2996,15 +3124,6 @@
this.buttonNext.UseVisualStyleBackColor = true;
this.buttonNext.Click += new System.EventHandler(this.ButtonNextClick);
//
// labelText
//
this.labelText.AutoSize = true;
this.labelText.Location = new System.Drawing.Point(203, 11);
this.labelText.Name = "labelText";
this.labelText.Size = new System.Drawing.Size(29, 13);
this.labelText.TabIndex = 5;
this.labelText.Text = "Text";
//
// labelStartTime
//
this.labelStartTime.AutoSize = true;
@ -3339,7 +3458,6 @@
private System.Windows.Forms.ToolStripMenuItem changeLanguageToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator12;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemCompare;
private System.Windows.Forms.Panel panelSingleLine;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemUnbreakLines;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAutoBreakLines;
private System.Windows.Forms.ToolStripSeparator toolStripSeparatorBreakLines;
@ -3516,6 +3634,18 @@
private System.Windows.Forms.ContextMenuStrip contextMenuStripEmpty;
private System.Windows.Forms.ToolStripMenuItem insertLineToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem closeVideoToolStripMenuItem;
private System.Windows.Forms.Label labelSingleLine;
private System.Windows.Forms.TextBox textBoxListViewTextAlternate;
private System.Windows.Forms.Label labelAlternateText;
private System.Windows.Forms.Label labelAlternateCharactersPerSecond;
private System.Windows.Forms.Label labelTextAlternateLineTotal;
private System.Windows.Forms.Label labelAlternateSingleLine;
private System.Windows.Forms.Label labelTextAlternateLineLengths;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator20;
private System.Windows.Forms.ToolStripMenuItem saveOriginalToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveOriginalAstoolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openOriginalToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeOriginalToolStripMenuItem;
}
}

View File

@ -50,6 +50,7 @@ namespace Nikse.SubtitleEdit.Forms
int _replaceStartLineIndex = 0;
bool _sourceViewChange;
bool _change;
bool _changeAlternate;
int _subtitleListViewIndex = -1;
Paragraph _oldSelectedParagraph;
bool _converted;
@ -104,7 +105,7 @@ namespace Nikse.SubtitleEdit.Forms
if (versionInfo.Length >= 3 && versionInfo[2] != "0")
_title += "." + versionInfo[2];
}
return _title + " Beta 7";
return _title + " Beta 8";
}
}
@ -933,7 +934,7 @@ namespace Nikse.SubtitleEdit.Forms
OpenSubtitle(fileName, encoding, null, null);
}
private void OpenSubtitle(string fileName, Encoding encoding, string videoFileName, string orginalFileName)
private void OpenSubtitle(string fileName, Encoding encoding, string videoFileName, string originalFileName)
{
if (File.Exists(fileName))
{
@ -941,7 +942,7 @@ namespace Nikse.SubtitleEdit.Forms
// save last first visible index + first selected index from listview
if (!string.IsNullOrEmpty(_fileName))
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, orginalFileName);
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, originalFileName);
openFileDialog1.InitialDirectory = Path.GetDirectoryName(fileName);
@ -1005,8 +1006,8 @@ namespace Nikse.SubtitleEdit.Forms
SetCurrentFormat(format);
_subtitleAlternateFileName = null;
if (LoadAlternateSubtitleFile(orginalFileName))
_subtitleAlternateFileName = orginalFileName;
if (LoadAlternateSubtitleFile(originalFileName))
_subtitleAlternateFileName = originalFileName;
textBoxSource.Text = _subtitle.ToText(format);
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
@ -1406,6 +1407,7 @@ namespace Nikse.SubtitleEdit.Forms
_subtitleListViewIndex = -1;
textBoxListViewText.Text = string.Empty;
textBoxListViewTextAlternate.Text = string.Empty;
textBoxListViewText.Enabled = false;
labelTextLineLengths.Text = string.Empty;
labelCharactersPerSecond.Text = string.Empty;
@ -2765,6 +2767,7 @@ namespace Nikse.SubtitleEdit.Forms
{
_subtitleListViewIndex = -1;
textBoxListViewText.Text = string.Empty;
textBoxListViewTextAlternate.Text = string.Empty;
MakeHistoryForUndo(_language.BeforeUndo);
string subtitleFormatFriendlyName;
@ -3237,6 +3240,19 @@ namespace Nikse.SubtitleEdit.Forms
newParagraph.EndTime.TotalMilliseconds = 3000;
}
if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
if (next != null)
{
Paragraph original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(next), next, _subtitleAlternate.Paragraphs);
if (original != null)
{
int originalInsertIndex = _subtitleAlternate.GetIndex(original);
_subtitleAlternate.Paragraphs.Insert(originalInsertIndex, new Paragraph(newParagraph));
}
}
}
if (_networkSession != null)
{
_networkSession.TimerStop();
@ -3298,6 +3314,22 @@ namespace Nikse.SubtitleEdit.Forms
newParagraph.EndTime.TotalMilliseconds = 3000;
}
if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
if (prev != null)
{
Paragraph original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(prev), prev, _subtitleAlternate.Paragraphs);
if (original != null)
{
int originalInsertIndex = _subtitleAlternate.GetIndex(original);
if (originalInsertIndex >= 0)
{
_subtitleAlternate.Paragraphs.Insert(originalInsertIndex+1, new Paragraph(newParagraph));
}
}
}
}
if (_networkSession != null)
{
_networkSession.TimerStop();
@ -3371,14 +3403,14 @@ namespace Nikse.SubtitleEdit.Forms
Paragraph p = _subtitle.GetParagraphOrDefault(firstSelectedIndex);
if (p != null)
{
textBoxListViewText.TextChanged -= TextBoxListViewTextTextChanged;
InitializeListViewEditBox(p);
textBoxListViewText.TextChanged += TextBoxListViewTextTextChanged;
_subtitleListViewIndex = firstSelectedIndex;
_oldSelectedParagraph = new Paragraph(p);
UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelTextLineTotal, labelCharactersPerSecond, p);
UpdateListViewTextInfo(p);
InitializeListViewEditBoxAlternate(p, firstSelectedIndex);
labelAlternateCharactersPerSecond.Left = textBoxListViewTextAlternate.Left + (textBoxListViewTextAlternate.Width - labelAlternateCharactersPerSecond.Width);
labelTextAlternateLineTotal.Left = textBoxListViewTextAlternate.Left + (textBoxListViewTextAlternate.Width - labelTextAlternateLineTotal.Width);
}
}
}
@ -3396,7 +3428,7 @@ namespace Nikse.SubtitleEdit.Forms
toolStripSelected.Text = string.Format(_language.XLinesSelected, SubtitleListview1.SelectedItems.Count);
}
private void UpdateListViewTextCharactersPerSeconds(Paragraph paragraph)
private void UpdateListViewTextCharactersPerSeconds(Label charsPerSecond, Paragraph paragraph)
{
const string zeroWhiteSpace = "\u200B";
const string zeroWidthNoBreakSpace = "\uFEFF";
@ -3406,47 +3438,47 @@ namespace Nikse.SubtitleEdit.Forms
{
double charactersPerSecond = s.Length / paragraph.Duration.TotalSeconds;
if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds + 7)
labelCharactersPerSecond.ForeColor = System.Drawing.Color.Red;
charsPerSecond.ForeColor = System.Drawing.Color.Red;
else if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds)
labelCharactersPerSecond.ForeColor = System.Drawing.Color.Orange;
charsPerSecond.ForeColor = System.Drawing.Color.Orange;
else
labelCharactersPerSecond.ForeColor = System.Drawing.Color.Black;
labelCharactersPerSecond.Text = string.Format(_language.CharactersPerSecond, charactersPerSecond);
charsPerSecond.ForeColor = System.Drawing.Color.Black;
charsPerSecond.Text = string.Format(_language.CharactersPerSecond, charactersPerSecond);
}
else
{
labelCharactersPerSecond.ForeColor = System.Drawing.Color.Red;
labelCharactersPerSecond.Text = string.Format(_language.CharactersPerSecond, _languageGeneral.NotAvailable);
charsPerSecond.ForeColor = System.Drawing.Color.Red;
charsPerSecond.Text = string.Format(_language.CharactersPerSecond, _languageGeneral.NotAvailable);
}
}
private void UpdateListViewTextInfo(Paragraph paragraph)
private void UpdateListViewTextInfo(Label lineLengths, Label singleLine, Label lineTotal, Label charactersPerSecond, Paragraph paragraph)
{
if (paragraph == null)
return;
string text = paragraph.Text;
labelTextLineLengths.Text = _languageGeneral.SingleLineLengths;
panelSingleLine.Left = labelTextLineLengths.Left + labelTextLineLengths.Width - 6;
Utilities.DisplayLineLengths(panelSingleLine, text);
lineLengths.Text = _languageGeneral.SingleLineLengths;
singleLine.Left = lineLengths.Left + lineLengths.Width - 6;
Utilities.GetLineLengths(singleLine, text);
string s = Utilities.RemoveHtmlTags(text).Replace(Environment.NewLine, " ");
if (s.Length < Configuration.Settings.General.SubtitleLineMaximumLength * 1.9)
{
labelTextLineTotal.ForeColor = System.Drawing.Color.Black;
labelTextLineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length);
lineTotal.ForeColor = System.Drawing.Color.Black;
lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length);
}
else if (s.Length < Configuration.Settings.General.SubtitleLineMaximumLength * 2.1)
{
labelTextLineTotal.ForeColor = System.Drawing.Color.Orange;
labelTextLineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length);
lineTotal.ForeColor = System.Drawing.Color.Orange;
lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length);
}
else
{
labelTextLineTotal.ForeColor = System.Drawing.Color.Red;
labelTextLineTotal.Text = string.Format(_languageGeneral.TotalLengthXSplitLine, s.Length);
lineTotal.ForeColor = System.Drawing.Color.Red;
lineTotal.Text = string.Format(_languageGeneral.TotalLengthXSplitLine, s.Length);
}
UpdateListViewTextCharactersPerSeconds(paragraph);
UpdateListViewTextCharactersPerSeconds(charactersPerSecond, paragraph);
}
private void ButtonNextClick(object sender, EventArgs e)
@ -3521,12 +3553,37 @@ namespace Nikse.SubtitleEdit.Forms
// update _subtitle + listview
_subtitle.Paragraphs[_subtitleListViewIndex].Text = text;
UpdateListViewTextInfo(_subtitle.Paragraphs[_subtitleListViewIndex]);
UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelTextLineTotal, labelCharactersPerSecond, _subtitle.Paragraphs[_subtitleListViewIndex]);
SubtitleListview1.SetText(_subtitleListViewIndex, text);
_change = true;
}
}
private void TextBoxListViewTextAlternateTextChanged(object sender, EventArgs e)
{
if (_subtitleListViewIndex >= 0)
{
Paragraph p = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex);
if (p == null)
return;
Paragraph original = Utilities.GetOriginalParagraph(_subtitleListViewIndex, p, _subtitleAlternate.Paragraphs);
if (original != null)
{
string text = textBoxListViewTextAlternate.Text.TrimEnd();
// update _subtitle + listview
original.Text = text;
UpdateListViewTextInfo(labelTextAlternateLineLengths, labelAlternateSingleLine, labelTextAlternateLineTotal, labelAlternateCharactersPerSecond, original);
SubtitleListview1.SetAlternateText(_subtitleListViewIndex, text);
_changeAlternate = true;
}
else
{
}
}
}
private void TextBoxListViewTextKeyDown(object sender, KeyEventArgs e)
{
int numberOfNewLines = textBoxListViewText.Text.Length - textBoxListViewText.Text.Replace(Environment.NewLine, " ").Length;
@ -3539,7 +3596,7 @@ namespace Nikse.SubtitleEdit.Forms
ButtonAutoBreakClick(null, null);
e.SuppressKeyPress = true;
}
else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.R)
else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.U)
{
ButtonUnBreakClick(null, null);
e.SuppressKeyPress = true;
@ -3571,7 +3628,6 @@ namespace Nikse.SubtitleEdit.Forms
e.SuppressKeyPress = true;
}
// last key down in text
_lastTextKeyDownTicks = DateTime.Now.Ticks;
}
@ -3878,7 +3934,7 @@ namespace Nikse.SubtitleEdit.Forms
if (currentParagraph != null)
{
UpdateOverlapErrors(timeUpDownStartTime.TimeCode);
UpdateListViewTextCharactersPerSeconds(currentParagraph);
UpdateListViewTextCharactersPerSeconds(labelCharactersPerSecond, currentParagraph);
// update _subtitle + listview
string oldDuration = currentParagraph.Duration.ToString();
@ -3886,6 +3942,16 @@ namespace Nikse.SubtitleEdit.Forms
SubtitleListview1.SetDuration(firstSelectedIndex, currentParagraph);
_change = true;
if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
Paragraph original = Utilities.GetOriginalParagraph(firstSelectedIndex, currentParagraph, _subtitleAlternate.Paragraphs);
if (original != null)
{
original.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds;
_changeAlternate = true;
}
}
MakeHistoryForUndoWhenNoMoreChanges(string.Format(_language.DisplayTimeAdjustedX, "#" + currentParagraph.Number + ": " + oldDuration + " -> " + currentParagraph.Duration.ToString()));
}
}
@ -3906,6 +3972,30 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void InitializeListViewEditBoxAlternate(Paragraph p, int firstSelectedIndex)
{
if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
Paragraph original = Utilities.GetOriginalParagraph(firstSelectedIndex, p, _subtitleAlternate.Paragraphs);
if (original == null)
{
textBoxListViewTextAlternate.Enabled = false;
textBoxListViewTextAlternate.Text = string.Empty;
labelAlternateCharactersPerSecond.Text = string.Empty;
}
else
{
textBoxListViewTextAlternate.Enabled = true;
textBoxListViewTextAlternate.TextChanged -= TextBoxListViewTextAlternateTextChanged;
textBoxListViewTextAlternate.Text = original.Text;
textBoxListViewTextAlternate.TextChanged += TextBoxListViewTextAlternateTextChanged;
//UpdateOverlapErrors(timeUpDownStartTime.TimeCode);
UpdateListViewTextCharactersPerSeconds(labelAlternateCharactersPerSecond, p);
}
}
}
private void InitializeListViewEditBox(Paragraph p)
{
textBoxListViewText.TextChanged -= TextBoxListViewTextTextChanged;
@ -3921,7 +4011,7 @@ namespace Nikse.SubtitleEdit.Forms
numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged;
UpdateOverlapErrors(timeUpDownStartTime.TimeCode);
UpdateListViewTextCharactersPerSeconds(p);
UpdateListViewTextCharactersPerSeconds(labelCharactersPerSecond, p);
if (_subtitle != null && _subtitle.Paragraphs.Count > 0)
textBoxListViewText.Enabled = true;
}
@ -3932,6 +4022,23 @@ namespace Nikse.SubtitleEdit.Forms
{
UpdateStartTimeInfo(timeUpDownStartTime.TimeCode);
_change = true;
if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
int firstSelectedIndex = FirstSelectedIndex;
Paragraph p = _subtitle.GetParagraphOrDefault(firstSelectedIndex);
if (p != null)
{
Paragraph original = Utilities.GetOriginalParagraph(firstSelectedIndex, p, _subtitleAlternate.Paragraphs);
if (original != null)
{
original.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds;
original.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds;
_changeAlternate = true;
}
}
}
MakeHistoryForUndoWhenNoMoreChanges(string.Format(_language.StarTimeAdjustedX, "#" + (_subtitleListViewIndex+1).ToString() + ": " + timeUpDownStartTime.TimeCode.ToString()));
}
}
@ -5232,6 +5339,10 @@ namespace Nikse.SubtitleEdit.Forms
_fileName = _subtitleAlternateFileName;
_subtitleAlternateFileName = tempName;
bool tempChange = _change;
_change = _changeAlternate;
_changeAlternate = tempChange;
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
RefreshSelectedParagraph();
}
@ -5672,6 +5783,7 @@ namespace Nikse.SubtitleEdit.Forms
{
toolStripMenuItemTranslationMode.Text = _language.Menu.Edit.ShowOriginalText;
}
toolStripMenuItemTranslationMode.Visible = false; //TODO: Remove this (now in file menu)
}
private void InsertUnicodeSymbol(object sender, EventArgs e)
@ -5869,6 +5981,20 @@ namespace Nikse.SubtitleEdit.Forms
SubtitleListview1.HideAlternateTextColumn();
_subtitleAlternate = new Subtitle();
_subtitleAlternateFileName = null;
buttonUnBreak.Visible = true;
buttonUndoListViewChanges.Visible = true;
textBoxListViewTextAlternate.Visible = false;
labelAlternateText.Visible = false;
labelAlternateCharactersPerSecond.Visible = false;
labelTextAlternateLineLengths.Visible = false;
labelAlternateSingleLine.Visible = false;
labelTextAlternateLineTotal.Visible = false;
textBoxListViewText.Width = (groupBoxEdit.Width - (textBoxListViewText.Left + 8 + buttonUnBreak.Width));
textBoxListViewText.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
labelCharactersPerSecond.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelCharactersPerSecond.Width);
labelTextLineTotal.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelTextLineTotal.Width);
}
else
{
@ -5878,6 +6004,7 @@ namespace Nikse.SubtitleEdit.Forms
private void OpenAlternateSubtitle()
{
SaveSubtitleListviewIndexes();
openFileDialog1.Title = Configuration.Settings.Language.General.OpenOriginalSubtitleFile;
openFileDialog1.FileName = string.Empty;
openFileDialog1.Filter = Utilities.GetOpenDialogFiler();
@ -5888,6 +6015,7 @@ namespace Nikse.SubtitleEdit.Forms
return;
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
RestoreSubtitleListviewIndexes();
}
private bool LoadAlternateSubtitleFile(string fileName)
@ -5921,12 +6049,35 @@ namespace Nikse.SubtitleEdit.Forms
else
_subtitleAlternate.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
if (_subtitleAlternate.Paragraphs.Count > 1)
{
buttonUnBreak.Visible = false;
buttonUndoListViewChanges.Visible = false;
textBoxListViewText.Anchor = AnchorStyles.Left | AnchorStyles.Top;
textBoxListViewText.Width = (groupBoxEdit.Width - (textBoxListViewText.Left + 10)) / 2;
textBoxListViewTextAlternate.Anchor = AnchorStyles.Left | AnchorStyles.Top;
textBoxListViewTextAlternate.Left = textBoxListViewText.Left + textBoxListViewText.Width + 3;
textBoxListViewTextAlternate.Width = textBoxListViewText.Width;
textBoxListViewTextAlternate.Visible = true;
labelAlternateText.Text = Configuration.Settings.Language.General.OriginalText;
labelAlternateText.Visible = true;
labelAlternateCharactersPerSecond.Visible = true;
labelTextAlternateLineLengths.Visible = true;
labelAlternateSingleLine.Visible = true;
labelTextAlternateLineTotal.Visible = true;
labelCharactersPerSecond.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelCharactersPerSecond.Width);
labelTextLineTotal.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelTextLineTotal.Width);
Main_Resize(null, null);
_changeAlternate = false;
}
SubtitleListview1.ShowAlternateTextColumn(Configuration.Settings.Language.General.OriginalText);
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -6272,6 +6423,23 @@ namespace Nikse.SubtitleEdit.Forms
private void Main_Resize(object sender, EventArgs e)
{
panelVideoPlayer.Invalidate();
if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
textBoxListViewText.Width = (groupBoxEdit.Width - (textBoxListViewText.Left + 10)) / 2;
textBoxListViewTextAlternate.Left = textBoxListViewText.Left + textBoxListViewText.Width + 3;
labelAlternateText.Left = textBoxListViewTextAlternate.Left;
textBoxListViewTextAlternate.Width = textBoxListViewText.Width;
labelAlternateCharactersPerSecond.Left = textBoxListViewTextAlternate.Left + (textBoxListViewTextAlternate.Width - labelAlternateCharactersPerSecond.Width);
labelTextAlternateLineLengths.Left = textBoxListViewTextAlternate.Left;
labelAlternateSingleLine.Left = labelTextAlternateLineLengths.Left + labelTextAlternateLineLengths.Width;
labelTextAlternateLineTotal.Left = textBoxListViewTextAlternate.Left + (textBoxListViewTextAlternate.Width - labelTextAlternateLineTotal.Width);
}
labelCharactersPerSecond.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelCharactersPerSecond.Width);
labelTextLineTotal.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelTextLineTotal.Width);
}
private void PlayCurrent()
@ -6838,6 +7006,26 @@ namespace Nikse.SubtitleEdit.Forms
private void fileToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
toolStripMenuItemOpenContainingFolder.Visible = !string.IsNullOrEmpty(_fileName) && File.Exists(_fileName);
if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
saveOriginalToolStripMenuItem.Visible = true;
saveOriginalAstoolStripMenuItem.Visible = true;
removeOriginalToolStripMenuItem.Visible = true;
}
else
{
saveOriginalToolStripMenuItem.Visible = false;
saveOriginalAstoolStripMenuItem.Visible = false;
removeOriginalToolStripMenuItem.Visible = false;
if (_subtitle == null || _subtitle.Paragraphs.Count < 1)
{
openOriginalToolStripMenuItem.Visible = false;
toolStripSeparator20.Visible = false;
}
}
}
private void toolStripMenuItemOpenContainingFolder_Click(object sender, EventArgs e)
@ -6976,6 +7164,7 @@ namespace Nikse.SubtitleEdit.Forms
_timerAutoSave.Interval = 1000 * Configuration.Settings.General.AutoBackupSeconds; // take backup every x second if changes were made
_timerAutoSave.Start();
}
Main_Resize(null, null);
}
void TimerAutoSaveTick(object sender, EventArgs e)
@ -8295,5 +8484,187 @@ namespace Nikse.SubtitleEdit.Forms
closeVideoToolStripMenuItem.Visible = !string.IsNullOrEmpty(_videoFileName);
}
private void textBoxListViewTextAlternate_TextChanged(object sender, EventArgs e)
{
if (_subtitleAlternate == null || _subtitleAlternate.Paragraphs.Count < 1)
return;
if (_subtitleListViewIndex >= 0)
{
Paragraph original = Utilities.GetOriginalParagraph(_subtitleListViewIndex, _subtitle.Paragraphs[_subtitleListViewIndex], _subtitleAlternate.Paragraphs);
if (original != null)
{
string text = textBoxListViewTextAlternate.Text.TrimEnd();
// update _subtitle + listview
original.Text = text;
UpdateListViewTextInfo(labelTextAlternateLineLengths, labelAlternateSingleLine, labelTextAlternateLineTotal, labelAlternateCharactersPerSecond, original);
SubtitleListview1.SetAlternateText(_subtitleListViewIndex, text);
_changeAlternate = true;
}
}
}
private void textBoxListViewTextAlternate_KeyDown(object sender, KeyEventArgs e)
{
if (_subtitleAlternate == null || _subtitleAlternate.Paragraphs.Count < 1)
return;
int numberOfNewLines = textBoxListViewTextAlternate.Text.Length - textBoxListViewTextAlternate.Text.Replace(Environment.NewLine, " ").Length;
if (e.KeyCode == Keys.Enter && numberOfNewLines > 1)
{
e.SuppressKeyPress = true;
}
else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.R)
{
if (textBoxListViewTextAlternate.Text.Length > 0)
textBoxListViewTextAlternate.Text = Utilities.AutoBreakLine(textBoxListViewTextAlternate.Text);
e.SuppressKeyPress = true;
}
else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.U)
{
textBoxListViewTextAlternate.Text = Utilities.UnbreakLine(textBoxListViewTextAlternate.Text);
e.SuppressKeyPress = true;
}
else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.I)
{
if (textBoxListViewTextAlternate.SelectionLength == 0)
{
string tag = "i";
if (textBoxListViewTextAlternate.Text.Contains("<" + tag + ">"))
{
textBoxListViewTextAlternate.Text = textBoxListViewTextAlternate.Text.Replace("<" + tag + ">", string.Empty);
textBoxListViewTextAlternate.Text = textBoxListViewTextAlternate.Text.Replace("</" + tag + ">", string.Empty);
}
else
{
textBoxListViewTextAlternate.Text = string.Format("<{0}>{1}</{0}>", tag, textBoxListViewTextAlternate.Text);
}
}
else
{
//NIO:TODO: TextBoxListViewToogleTag("i");
}
}
if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D)
{
textBoxListViewTextAlternate.SelectionLength = 0;
e.SuppressKeyPress = true;
}
// last key down in text
_lastTextKeyDownTicks = DateTime.Now.Ticks;
}
private void openOriginalToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenAlternateSubtitle();
}
private void saveOriginalAstoolStripMenuItem_Click(object sender, EventArgs e)
{
SubtitleFormat currentFormat = GetCurrentSubtitleFormat();
Utilities.SetSaveDialogFilter(saveFileDialog1, currentFormat);
saveFileDialog1.Title = _language.SaveOriginalSubtitleAs;
saveFileDialog1.DefaultExt = "*" + currentFormat.Extension;
saveFileDialog1.AddExtension = true;
if (!string.IsNullOrEmpty(_videoFileName))
saveFileDialog1.FileName = Path.GetFileNameWithoutExtension(_videoFileName);
else
saveFileDialog1.FileName = Path.GetFileNameWithoutExtension(_subtitleAlternateFileName);
if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory))
saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory;
DialogResult result = saveFileDialog1.ShowDialog(this);
if (result == DialogResult.OK)
{
//TODO!!!!
}
}
private void saveOriginalToolStripMenuItem_Click(object sender, EventArgs e)
{
SubtitleFormat format = GetCurrentSubtitleFormat();
if (string.IsNullOrEmpty(_subtitleAlternateFileName))
{
saveOriginalAstoolStripMenuItem_Click(null, null);
return;
}
try
{
string allText = _subtitleAlternate.ToText(format).Trim();
var currentEncoding = GetCurrentEncoding();
if (currentEncoding == Encoding.Default && (allText.Contains("♪") || allText.Contains("♫") | allText.Contains("♥"))) // ANSI & music/unicode symbols
{
if (MessageBox.Show(string.Format(_language.UnicodeMusicSymbolsAnsiWarning), Title, MessageBoxButtons.YesNo) == DialogResult.No)
return;
}
bool containsNegativeTime = false;
foreach (var p in _subtitleAlternate.Paragraphs)
{
if (p.StartTime.TotalMilliseconds < 0 || p.EndTime.TotalMilliseconds < 0)
{
containsNegativeTime = true;
break;
}
}
if (containsNegativeTime && !string.IsNullOrEmpty(_language.NegativeTimeWarning))
{
if (MessageBox.Show(_language.NegativeTimeWarning, Title, MessageBoxButtons.YesNo) == DialogResult.No)
return;
}
if (File.Exists(_subtitleAlternateFileName))
{
DateTime fileOnDisk = File.GetLastWriteTime(_subtitleAlternateFileName);
if (_fileDateTime != fileOnDisk && _fileDateTime != new DateTime())
{
if (MessageBox.Show(string.Format(_language.OverwriteModifiedFile,
_fileName, fileOnDisk.ToShortDateString(), fileOnDisk.ToString("HH:mm:ss"),
Environment.NewLine, _fileDateTime.ToShortDateString(), _fileDateTime.ToString("HH:mm:ss")),
Title + " - " + _language.FileOnDiskModified, MessageBoxButtons.YesNo) == DialogResult.No)
return;
}
File.Delete(_subtitleAlternateFileName);
}
File.WriteAllText(_subtitleAlternateFileName, allText, currentEncoding);
_fileDateTime = File.GetLastWriteTime(_subtitleAlternateFileName);
ShowStatus(string.Format(_language.SavedSubtitleX, _subtitleAlternateFileName));
_changeAlternate = false;
}
catch
{
MessageBox.Show(string.Format(_language.UnableToSaveSubtitleX, _subtitleAlternateFileName));
}
}
private void removeOriginalToolStripMenuItem_Click(object sender, EventArgs e)
{
SubtitleListview1.HideAlternateTextColumn();
_subtitleAlternate = new Subtitle();
_subtitleAlternateFileName = null;
buttonUnBreak.Visible = true;
buttonUndoListViewChanges.Visible = true;
textBoxListViewTextAlternate.Visible = false;
labelAlternateText.Visible = false;
labelAlternateCharactersPerSecond.Visible = false;
labelTextAlternateLineLengths.Visible = false;
labelAlternateSingleLine.Visible = false;
labelTextAlternateLineTotal.Visible = false;
textBoxListViewText.Width = (groupBoxEdit.Width - (textBoxListViewText.Left + 8 + buttonUnBreak.Width));
textBoxListViewText.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
labelCharactersPerSecond.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelCharactersPerSecond.Width);
labelTextLineTotal.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelTextLineTotal.Width);
}
}
}

View File

@ -481,7 +481,10 @@ namespace Nikse.SubtitleEdit.Logic
{
SaveChangesToUntitled = "Save changes to untitled?",
SaveChangesToX = "Save changes to {0}?",
SaveChangesToUntitledOriginal = "Save changes to untitled original?",
SaveChangesToOriginalX = "Save changes to original {0}?",
SaveSubtitleAs = "Save subtitle as...",
SaveOriginalSubtitleAs = "Save original subtitle as...",
NoSubtitleLoaded = "No subtitle loaded",
VisualSyncSelectedLines = "Visual sync - selected lines",
VisualSyncTitle = "Visual sync",
@ -497,6 +500,7 @@ namespace Nikse.SubtitleEdit.Logic
FileIsEmptyOrShort = "File is empty or very short!",
FileNotFound = "File not found: {0}",
SavedSubtitleX = "Saved subtitle {0}",
SavedOriginalSubtitleX = "Saved original subtitle {0}",
FileOnDiskModified = "file on disk modified",
OverwriteModifiedFile = "Overwrite the file {0} modified at {1} {2}{3} with current file loaded from disk at {4} {5}?",
UnableToSaveSubtitleX = "Unable to save subtitle file {0}",

View File

@ -413,7 +413,10 @@
public MainVideoControls VideoControls { get; set; }
public string SaveChangesToUntitled { get; set; }
public string SaveChangesToX { get; set; }
public string SaveChangesToUntitledOriginal { get; set; }
public string SaveChangesToOriginalX { get; set; }
public string SaveSubtitleAs { get; set; }
public string SaveOriginalSubtitleAs { get; set; }
public string NoSubtitleLoaded { get; set; }
public string VisualSyncSelectedLines { get; set; }
public string VisualSyncTitle { get; set; }
@ -429,6 +432,7 @@
public string FileIsEmptyOrShort { get; set; }
public string FileNotFound { get; set; }
public string SavedSubtitleX { get; set; }
public string SavedOriginalSubtitleX { get; set; }
public string FileOnDiskModified { get; set; }
public string OverwriteModifiedFile { get; set; }
public string UnableToSaveSubtitleX { get; set; }

View File

@ -240,6 +240,7 @@ namespace Nikse.SubtitleEdit.Logic
public bool SyncListViewWithVideoWhilePlaying { get; set; }
public int AutoBackupSeconds { get; set; }
public string SpellChecker { get; set; }
public bool AllowEditOfOriginalSubtitle { get; set; }
public GeneralSettings()
{
@ -287,6 +288,7 @@ namespace Nikse.SubtitleEdit.Logic
SyncListViewWithVideoWhilePlaying = false;
AutoBackupSeconds = 0;
SpellChecker = "hunspell";
AllowEditOfOriginalSubtitle = false;
}
}
@ -642,6 +644,9 @@ namespace Nikse.SubtitleEdit.Logic
subNode = node.SelectSingleNode("SpellChecker");
if (subNode != null)
settings.General.SpellChecker = subNode.InnerText;
subNode = node.SelectSingleNode("AllowEditOfOriginalSubtitle");
if (subNode != null)
settings.General.AllowEditOfOriginalSubtitle = Convert.ToBoolean(subNode.InnerText);
settings.Tools = new Nikse.SubtitleEdit.Logic.ToolsSettings();
node = doc.DocumentElement.SelectSingleNode("Tools");
@ -951,6 +956,7 @@ namespace Nikse.SubtitleEdit.Logic
textWriter.WriteElementString("SyncListViewWithVideoWhilePlaying", settings.General.SyncListViewWithVideoWhilePlaying.ToString());
textWriter.WriteElementString("AutoBackupSeconds", settings.General.AutoBackupSeconds.ToString());
textWriter.WriteElementString("SpellChecker", settings.General.SpellChecker);
textWriter.WriteElementString("AllowEditOfOriginalSubtitle", settings.General.AllowEditOfOriginalSubtitle.ToString());
textWriter.WriteEndElement();
textWriter.WriteStartElement("Tools", "");

View File

@ -1168,47 +1168,80 @@ namespace Nikse.SubtitleEdit.Logic
}
}
internal static void DisplayLineLengths(Panel panelSingleLine, string text)
internal static void GetLineLengths(Label label, string text)
{
string cleanText = RemoveHtmlTags(text).Replace(Environment.NewLine, "|");
label.ForeColor = Color.Black;
string cleanText = Utilities.RemoveHtmlTags(text).Replace(Environment.NewLine, "|");
string[] lines = cleanText.Split('|');
int position = 0;
// we must dispose before clearing controls (or this will occur: "Error creating window handle")
foreach (Control ctrl in panelSingleLine.Controls)
ctrl.Dispose();
panelSingleLine.Controls.Clear();
const int max = 3;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < lines.Length; i++)
{
string line = lines[i];
if (i > 0)
{
var labelSlash = new Label {AutoSize = true, Margin = new Padding(0)};
panelSingleLine.Controls.Add(labelSlash);
labelSlash.Text = "/";
labelSlash.Top = 0;
labelSlash.Left = position;
position += labelSlash.Width - 4;
sb.Append("/");
}
if (i > max)
{
label.ForeColor = Color.Red;
sb.Append("...");
label.Text = sb.ToString();
return;
}
var labelLength = new Label();
labelLength.AutoSize = true;
labelLength.Margin = new Padding(0);
panelSingleLine.Controls.Add(labelLength);
labelLength.Text = line.Length.ToString();
labelLength.Top = 0;
labelLength.Left = position;
position += labelLength.Width - 4;
sb.Append(line.Length.ToString());
if (line.Length > Configuration.Settings.General.SubtitleLineMaximumLength)
labelLength.ForeColor = Color.Red;
label.ForeColor = Color.Red;
else if (line.Length > Configuration.Settings.General.SubtitleLineMaximumLength - 5)
labelLength.ForeColor = Color.Orange;
label.ForeColor = Color.Orange;
}
label.Text = sb.ToString();
}
//internal static void DisplayLineLengths(Panel panelSingleLine, string text)
//{
// string cleanText = RemoveHtmlTags(text).Replace(Environment.NewLine, "|");
// string[] lines = cleanText.Split('|');
// int position = 0;
// // we must dispose before clearing controls (or this will occur: "Error creating window handle")
// foreach (Control ctrl in panelSingleLine.Controls)
// ctrl.Dispose();
// panelSingleLine.Controls.Clear();
// for (int i = 0; i < lines.Length; i++)
// {
// string line = lines[i];
// if (i > 0)
// {
// var labelSlash = new Label {AutoSize = true, Margin = new Padding(0)};
// panelSingleLine.Controls.Add(labelSlash);
// labelSlash.Text = "/";
// labelSlash.Top = 0;
// labelSlash.Left = position;
// position += labelSlash.Width - 4;
// }
// var labelLength = new Label();
// labelLength.AutoSize = true;
// labelLength.Margin = new Padding(0);
// panelSingleLine.Controls.Add(labelLength);
// labelLength.Text = line.Length.ToString();
// labelLength.Top = 0;
// labelLength.Left = position;
// position += labelLength.Width - 4;
// if (line.Length > Configuration.Settings.General.SubtitleLineMaximumLength)
// labelLength.ForeColor = Color.Red;
// else if (line.Length > Configuration.Settings.General.SubtitleLineMaximumLength - 5)
// labelLength.ForeColor = Color.Orange;
// }
//}
public static bool IsValidRegex(string testPattern)
{
if (!string.IsNullOrEmpty(testPattern))
@ -1644,5 +1677,25 @@ namespace Nikse.SubtitleEdit.Logic
return text;
}
internal static Paragraph GetOriginalParagraph(int index, Paragraph paragraph, List<Paragraph> originalParagraphs)
{
if (index < originalParagraphs.Count && Math.Abs(originalParagraphs[index].StartTime.TotalMilliseconds - paragraph.StartTime.TotalMilliseconds) < 50)
return originalParagraphs[index];
foreach (Paragraph p in originalParagraphs)
{
if (p.StartTime.TotalMilliseconds == paragraph.StartTime.TotalMilliseconds)
return p;
}
foreach (Paragraph p in originalParagraphs)
{
if (p.StartTime.TotalMilliseconds > paragraph.StartTime.TotalMilliseconds - 200 &&
p.StartTime.TotalMilliseconds < paragraph.StartTime.TotalMilliseconds + 1000)
return p;
}
return null;
}
}
}