mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-23 03:33:18 +01:00
Added some improvements to ocr (mostly italic) + two new subtitle formats
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1607 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
f3595e460d
commit
6bf8829764
@ -1,9 +1,26 @@
|
||||
Subtitle Edit Changelog
|
||||
Subtitle Edit Changelog
|
||||
|
||||
3.3.2 (x February 2013)
|
||||
* NEW:
|
||||
* Added a few new subtitle formats
|
||||
* Italian language - thx Johnny B. Goode
|
||||
* Turkish language - thx Çağdaş
|
||||
* IMPROVED:
|
||||
* OCR: MUCH better ocr of italics when using Tesseract
|
||||
* Waveform now performs better when many lines are selected
|
||||
* Waveform now has focused rectangle
|
||||
* Network mode more stable (auto-restart)
|
||||
* Updated Czech language file - thx Trottel
|
||||
* Updated German language file - thx Christoph Kitsche
|
||||
* FIXED:
|
||||
* Possible crash in 'Fix common errors' on selected lines - thx Dan
|
||||
* Drag'n'drop of large bluray sup files - thx AT
|
||||
|
||||
|
||||
3.3.1 (3rd February 2013)
|
||||
* NEW:
|
||||
* Added a few new subtitle formats (now 150 formats!)
|
||||
* French language - thx thx JM GBT
|
||||
* French language - thx JM GBT
|
||||
* German language - thx Christoph Kitsche
|
||||
* Greek language - thx Menes
|
||||
* IMPROVED:
|
||||
@ -107,7 +124,7 @@ Subtitle Edit Changelog
|
||||
* Added "Delete line(s)" context menu to ocr - thx Mario
|
||||
* IMPROVED:
|
||||
* Updated Chinese language file - thx FeiXJ
|
||||
* Updated Brazilian Portuguese - thx Igor Rückert
|
||||
* Updated Brazilian Portuguese - thx Igor Rückert
|
||||
* Updated Polish language file - thx Adam Malich
|
||||
* Updated Romanian language file - thx dr. Jackson
|
||||
* Better reading of Cavena 890 format - thx Victor
|
||||
@ -227,14 +244,14 @@ Subtitle Edit Changelog
|
||||
* Crash (memory leak) when exporting images from a vobsub - thx Pete
|
||||
* Bug in Fix common errors with uncheck fix quotes - thx jofafrazze
|
||||
* Bug in Import plain text when only non-English letters - thx Jasper
|
||||
* Now detects encoding when opening son files - thx Jørgen
|
||||
* Now detects encoding when opening son files - thx Jørgen
|
||||
|
||||
|
||||
3.2.3 (13th January 2012)
|
||||
* NEW:
|
||||
* Added Brazilian Portuguese - thx XXXXXXXXXX
|
||||
* Added Italian language file - thx Maff
|
||||
* Added Portuguese (Portugal) language file - thx Ricardo Perdigão
|
||||
* Added Portuguese (Portugal) language file - thx Ricardo Perdigão
|
||||
* Added Japanese language file - thx Nardog
|
||||
* Added Spanish language file - thx m2s
|
||||
* Support for subtitle format AvidCaption - thx Laszlo
|
||||
@ -335,7 +352,7 @@ Subtitle Edit Changelog
|
||||
background color
|
||||
* Fixed too much cropping for VobSub pictures
|
||||
* Now removes empty Unicode white spaces from Google translate
|
||||
* Crash when entering invalid text in source view (thx Frédéric)
|
||||
* Crash when entering invalid text in source view (thx Frédéric)
|
||||
* Fixed a few bugs in DVD Architect format + added another two
|
||||
new variants (thx Jacob)
|
||||
* Fixed incorrect line-break in Microsoft Translate in last part of
|
||||
@ -391,7 +408,7 @@ Subtitle Edit Changelog
|
||||
* Missing line break in Sony DVD Architect w line numbers (thx Rosa)
|
||||
* A minor bug in Visual Sync, if end scene was after video length (thx tsieberg)
|
||||
* OCR Fix Engine: Lines after "..." will no longer be changed to start with uppercase
|
||||
* Fixed bug in reading of SSA files (',' was removed) - thx Péter
|
||||
* Fixed bug in reading of SSA files (',' was removed) - thx Péter
|
||||
* Fixed line breaking bug in mpl format - thx Przemek
|
||||
* Fixed shortcuts for adjust commands Ctrl+Space/Shift+Space/F9/F10
|
||||
|
||||
|
@ -333,17 +333,10 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
List<Paragraph> selectedParagraphs = new List<Paragraph>();
|
||||
foreach (int index in _selectedIndices)
|
||||
{
|
||||
Paragraph p = null;
|
||||
try
|
||||
{
|
||||
p = new Paragraph(_subtitle.Paragraphs[index]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
Paragraph p = _subtitle.GetParagraphOrDefault(index);
|
||||
if (p != null)
|
||||
{
|
||||
p = new Paragraph(p);
|
||||
// not really frames... just using them as position markers for better performance
|
||||
p.StartFrame = (int)(p.StartTime.TotalSeconds * _wavePeaks.Header.SampleRate * _zoomFactor);
|
||||
p.EndFrame = (int)(p.EndTime.TotalSeconds * _wavePeaks.Header.SampleRate * _zoomFactor);
|
||||
|
39
src/Forms/About.Designer.cs
generated
39
src/Forms/About.Designer.cs
generated
@ -32,13 +32,12 @@
|
||||
this.labelProduct = new System.Windows.Forms.Label();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.richTextBoxAbout1 = new System.Windows.Forms.RichTextBox();
|
||||
this.labelFindHeight = new System.Windows.Forms.Label();
|
||||
this.buttonDonate = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.okButton.Location = new System.Drawing.Point(355, 342);
|
||||
@ -47,9 +46,9 @@
|
||||
this.okButton.TabIndex = 0;
|
||||
this.okButton.Text = "&OK";
|
||||
this.okButton.Click += new System.EventHandler(this.OkButtonClick);
|
||||
//
|
||||
//
|
||||
// labelProduct
|
||||
//
|
||||
//
|
||||
this.labelProduct.AutoSize = true;
|
||||
this.labelProduct.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.labelProduct.Location = new System.Drawing.Point(11, 16);
|
||||
@ -57,19 +56,19 @@
|
||||
this.labelProduct.Size = new System.Drawing.Size(140, 19);
|
||||
this.labelProduct.TabIndex = 26;
|
||||
this.labelProduct.Text = "Subtitle Edit 3.2";
|
||||
//
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
//
|
||||
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
|
||||
this.pictureBox1.Location = new System.Drawing.Point(368, 14);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(70, 64);
|
||||
this.pictureBox1.TabIndex = 27;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
//
|
||||
// richTextBoxAbout1
|
||||
//
|
||||
this.richTextBoxAbout1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
//
|
||||
this.richTextBoxAbout1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.richTextBoxAbout1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.richTextBoxAbout1.Location = new System.Drawing.Point(16, 43);
|
||||
@ -81,19 +80,9 @@
|
||||
this.richTextBoxAbout1.TabStop = false;
|
||||
this.richTextBoxAbout1.Text = "About...";
|
||||
this.richTextBoxAbout1.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.RichTextBoxAbout1LinkClicked);
|
||||
//
|
||||
// labelFindHeight
|
||||
//
|
||||
this.labelFindHeight.AutoSize = true;
|
||||
this.labelFindHeight.Location = new System.Drawing.Point(187, 24);
|
||||
this.labelFindHeight.Name = "labelFindHeight";
|
||||
this.labelFindHeight.Size = new System.Drawing.Size(80, 13);
|
||||
this.labelFindHeight.TabIndex = 41;
|
||||
this.labelFindHeight.Text = "labelFindHeight";
|
||||
this.labelFindHeight.Visible = false;
|
||||
//
|
||||
//
|
||||
// buttonDonate
|
||||
//
|
||||
//
|
||||
this.buttonDonate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonDonate.AutoSize = true;
|
||||
this.buttonDonate.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
@ -107,15 +96,14 @@
|
||||
this.buttonDonate.TabIndex = 42;
|
||||
this.buttonDonate.UseVisualStyleBackColor = false;
|
||||
this.buttonDonate.Click += new System.EventHandler(this.buttonDonate_Click);
|
||||
//
|
||||
//
|
||||
// About
|
||||
//
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(457, 372);
|
||||
this.Controls.Add(this.buttonDonate);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.labelFindHeight);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.richTextBoxAbout1);
|
||||
this.Controls.Add(this.labelProduct);
|
||||
@ -142,7 +130,6 @@
|
||||
private System.Windows.Forms.Label labelProduct;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.RichTextBox richTextBoxAbout1;
|
||||
private System.Windows.Forms.Label labelFindHeight;
|
||||
private System.Windows.Forms.Button buttonDonate;
|
||||
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_languageGeneral.TranslatedBy.Trim();
|
||||
okButton.Text = _languageGeneral.OK;
|
||||
|
||||
float height = TextDraw.MeasureTextHeight(richTextBoxAbout1.Font, richTextBoxAbout1.Text, false);
|
||||
|
||||
// Autosize height
|
||||
labelFindHeight.AutoSize = true;
|
||||
labelFindHeight.Text = richTextBoxAbout1.Text;
|
||||
richTextBoxAbout1.Height = labelFindHeight.Height + 25;
|
||||
richTextBoxAbout1.Height = (int)(height + 25);
|
||||
Height = richTextBoxAbout1.Top + richTextBoxAbout1.Height + 100;
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
@ -26,36 +26,36 @@
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
@ -121,7 +121,7 @@
|
||||
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAAK/INwWK6QAAAAlwSFlzAAAO
|
||||
wAAADsABataJCQAAABl0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuNUmK/OAAAA+PSURBVHhe7Zv7
|
||||
vwAADr8BOAVTJAAAABl0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuNUmK/OAAAA+PSURBVHhe7Zv7
|
||||
bxXHFcfzryBAhAIyD/MSEExwiylGGGpewnUMOBYYREHhEQQIkCHmFcJTBUMICIiKcB0ooAAtlUVCCz/Q
|
||||
gAAJHJoGNahpGgRIjQg/oOl8zvp7PXfvXl8bDFElWxrt3t3Z2XO+53seMzt+7bXOv04EOhHoRCAHAmfP
|
||||
nnVbtmyxtmnTJjtu3bo1o72/dYujJd3XvaTn7Nr70Xj0U59t27bZeXw8vQNZJI/O9+zZ4w4cOOAuXrzo
|
||||
|
36
src/Forms/Main.Designer.cs
generated
36
src/Forms/Main.Designer.cs
generated
@ -129,6 +129,8 @@
|
||||
this.toolStripMenuItemRightToLeftMode = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemReverseRightToLeftStartEnd = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator21 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.toolStripMenuItemModifySelection = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.editSelectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.adjustDisplayTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@ -172,6 +174,7 @@
|
||||
this.redockVideoControlsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemSpellCheckMain = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.spellCheckToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemSpellCheckFromCurrentLine = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.findDoubleWordsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.FindDoubleLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
|
||||
@ -1214,6 +1217,8 @@
|
||||
this.toolStripMenuItemRightToLeftMode,
|
||||
this.toolStripMenuItemReverseRightToLeftStartEnd,
|
||||
this.toolStripSeparator21,
|
||||
this.toolStripMenuItemModifySelection,
|
||||
this.toolStripMenuItemInverseSelection,
|
||||
this.editSelectAllToolStripMenuItem});
|
||||
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
|
||||
this.editToolStripMenuItem.Size = new System.Drawing.Size(40, 20);
|
||||
@ -1327,6 +1332,22 @@
|
||||
this.toolStripSeparator21.Name = "toolStripSeparator21";
|
||||
this.toolStripSeparator21.Size = new System.Drawing.Size(302, 6);
|
||||
//
|
||||
// toolStripMenuItemModifySelection
|
||||
//
|
||||
this.toolStripMenuItemModifySelection.Name = "toolStripMenuItemModifySelection";
|
||||
this.toolStripMenuItemModifySelection.Size = new System.Drawing.Size(305, 22);
|
||||
this.toolStripMenuItemModifySelection.Text = "Create/modify selection...";
|
||||
this.toolStripMenuItemModifySelection.Click += new System.EventHandler(this.toolStripMenuItemModifySelection_Click);
|
||||
//
|
||||
// toolStripMenuItemInverseSelection
|
||||
//
|
||||
this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection";
|
||||
this.toolStripMenuItemInverseSelection.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
|
||||
| System.Windows.Forms.Keys.I)));
|
||||
this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(305, 22);
|
||||
this.toolStripMenuItemInverseSelection.Text = "Inverse selection";
|
||||
this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click);
|
||||
//
|
||||
// editSelectAllToolStripMenuItem
|
||||
//
|
||||
this.editSelectAllToolStripMenuItem.Name = "editSelectAllToolStripMenuItem";
|
||||
@ -1659,6 +1680,7 @@
|
||||
//
|
||||
this.toolStripMenuItemSpellCheckMain.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.spellCheckToolStripMenuItem,
|
||||
this.toolStripMenuItemSpellCheckFromCurrentLine,
|
||||
this.findDoubleWordsToolStripMenuItem,
|
||||
this.FindDoubleLinesToolStripMenuItem,
|
||||
this.toolStripSeparator9,
|
||||
@ -1678,6 +1700,13 @@
|
||||
this.spellCheckToolStripMenuItem.Text = "Spell check...";
|
||||
this.spellCheckToolStripMenuItem.Click += new System.EventHandler(this.SpellCheckToolStripMenuItemClick);
|
||||
//
|
||||
// toolStripMenuItemSpellCheckFromCurrentLine
|
||||
//
|
||||
this.toolStripMenuItemSpellCheckFromCurrentLine.Name = "toolStripMenuItemSpellCheckFromCurrentLine";
|
||||
this.toolStripMenuItemSpellCheckFromCurrentLine.Size = new System.Drawing.Size(296, 22);
|
||||
this.toolStripMenuItemSpellCheckFromCurrentLine.Text = "Spell check from current line...";
|
||||
this.toolStripMenuItemSpellCheckFromCurrentLine.Click += new System.EventHandler(this.toolStripMenuItemSpellCheckFromCurrentLine_Click);
|
||||
//
|
||||
// findDoubleWordsToolStripMenuItem
|
||||
//
|
||||
this.findDoubleWordsToolStripMenuItem.Name = "findDoubleWordsToolStripMenuItem";
|
||||
@ -1947,7 +1976,7 @@
|
||||
this.changeCasingForSelectedLinesToolStripMenuItem,
|
||||
this.toolStripMenuItemSaveSelectedLines});
|
||||
this.contextMenuStripListview.Name = "contextMenuStripListview";
|
||||
this.contextMenuStripListview.Size = new System.Drawing.Size(285, 804);
|
||||
this.contextMenuStripListview.Size = new System.Drawing.Size(285, 782);
|
||||
this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening);
|
||||
//
|
||||
// setStylesForSelectedLinesToolStripMenuItem
|
||||
@ -3673,7 +3702,7 @@
|
||||
this.superscriptToolStripMenuItem,
|
||||
this.subscriptToolStripMenuItem});
|
||||
this.contextMenuStripTextBoxListView.Name = "contextMenuStripTextBoxListView";
|
||||
this.contextMenuStripTextBoxListView.Size = new System.Drawing.Size(215, 402);
|
||||
this.contextMenuStripTextBoxListView.Size = new System.Drawing.Size(215, 380);
|
||||
this.contextMenuStripTextBoxListView.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripTextBoxListViewOpening);
|
||||
//
|
||||
// toolStripMenuItemWebVttVoice
|
||||
@ -4538,6 +4567,9 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemWebVTT;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemWebVttVoice;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparatorWebVTT;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemModifySelection;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSpellCheckFromCurrentLine;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4263,11 +4263,26 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (onlySelectedLines)
|
||||
{ // we only update selected lines
|
||||
int i = 0;
|
||||
List<int> deletes = new List<int>();
|
||||
foreach (int index in SubtitleListview1.SelectedIndices)
|
||||
{
|
||||
_subtitle.Paragraphs[index] = fixErrors.FixedSubtitle.Paragraphs[i];
|
||||
var pOld = _subtitle.Paragraphs[index];
|
||||
var p = fixErrors.FixedSubtitle.GetParagraphOrDefaultById(pOld.ID);
|
||||
if (p == null)
|
||||
{
|
||||
deletes.Add(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
_subtitle.Paragraphs[index] = p;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
deletes.Reverse();
|
||||
foreach (int index in deletes)
|
||||
{
|
||||
_subtitle.Paragraphs.RemoveAt(index);
|
||||
}
|
||||
ShowStatus(_language.CommonErrorsFixedInSelectedLines);
|
||||
}
|
||||
else
|
||||
@ -4892,12 +4907,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void ToolStripButtonSpellCheckClick(object sender, EventArgs e)
|
||||
{
|
||||
SpellCheck(true);
|
||||
SpellCheck(true, 0);
|
||||
}
|
||||
|
||||
private void SpellCheckToolStripMenuItemClick(object sender, EventArgs e)
|
||||
{
|
||||
SpellCheck(true);
|
||||
SpellCheck(true, 0);
|
||||
}
|
||||
|
||||
private void SpellCheckViaWord()
|
||||
@ -4961,7 +4976,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_cancelWordSpellCheck = true;
|
||||
}
|
||||
|
||||
private void SpellCheck(bool autoDetect)
|
||||
private void SpellCheck(bool autoDetect, int startFromLine)
|
||||
{
|
||||
if (Configuration.Settings.General.SpellChecker.ToLower().Contains("word"))
|
||||
{
|
||||
@ -4989,7 +5004,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (result == DialogResult.No)
|
||||
{
|
||||
_spellCheckForm = new SpellCheck();
|
||||
_spellCheckForm.DoSpellCheck(autoDetect, _subtitle, dictionaryFolder, this);
|
||||
_spellCheckForm.DoSpellCheck(autoDetect, _subtitle, dictionaryFolder, this, startFromLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4999,7 +5014,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
else
|
||||
{
|
||||
_spellCheckForm = new SpellCheck();
|
||||
_spellCheckForm.DoSpellCheck(autoDetect, _subtitle, dictionaryFolder, this);
|
||||
_spellCheckForm.DoSpellCheck(autoDetect, _subtitle, dictionaryFolder, this, startFromLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8438,6 +8453,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
OpenSubtitle(fileName, null);
|
||||
}
|
||||
else if (fi.Length < 150000000 && ext == ".sup" && IsBluRaySupFile(fileName)) // max 150 mb
|
||||
{
|
||||
OpenSubtitle(fileName, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(string.Format(_language.DropFileXNotAccepted, fileName));
|
||||
@ -9115,9 +9134,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (!textBoxListViewText.Focused && !textBoxListViewTextAlternate.Focused && !textBoxSource.Focused && mediaPlayer.VideoPlayer != null)
|
||||
{
|
||||
_endSeconds = -1;
|
||||
mediaPlayer.TogglePlayPause();
|
||||
e.SuppressKeyPress = true;
|
||||
if (audioVisualizer != null && audioVisualizer.Focused || mediaPlayer != null && mediaPlayer.Focused)
|
||||
{
|
||||
_endSeconds = -1;
|
||||
mediaPlayer.TogglePlayPause();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.D1)
|
||||
@ -9942,12 +9964,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
InsertAfter();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.Modifiers == (Keys.Shift | Keys.Control) && e.KeyCode == Keys.I) //InverseSelection
|
||||
{
|
||||
foreach (ListViewItem item in SubtitleListview1.Items)
|
||||
item.Selected = !item.Selected;
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Home)
|
||||
{
|
||||
SubtitleListview1.FirstVisibleIndex = -1;
|
||||
@ -12197,6 +12213,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
generateDatetimeInfoFromVideoToolStripMenuItem.Visible = true;
|
||||
toolStripMenuItemExportCaptionInc.Visible = true;
|
||||
toolStripMenuItemExportUltech130.Visible = true;
|
||||
toolStripMenuItemModifySelection.Visible = true;
|
||||
toolStripMenuItemInverseSelection.Visible = true;
|
||||
toolStripMenuItemSpellCheckFromCurrentLine.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -12204,6 +12223,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
generateDatetimeInfoFromVideoToolStripMenuItem.Visible = false;
|
||||
toolStripMenuItemExportCaptionInc.Visible = false;
|
||||
toolStripMenuItemExportUltech130.Visible = false;
|
||||
toolStripMenuItemModifySelection.Visible = false;
|
||||
toolStripMenuItemInverseSelection.Visible = false;
|
||||
toolStripMenuItemSpellCheckFromCurrentLine.Visible = false;
|
||||
}
|
||||
|
||||
LoadPlugins();
|
||||
@ -12261,6 +12283,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
gotoLineNumberToolStripMenuItem.ShortcutKeys = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainEditGoToLineNumber);
|
||||
toolStripMenuItemRightToLeftMode.ShortcutKeys = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainEditRightToLeft);
|
||||
toolStripMenuItemShowOriginalInPreview.ShortcutKeys = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainEditToggleTranslationOriginalInPreviews);
|
||||
toolStripMenuItemInverseSelection.ShortcutKeys = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainEditInverseSelection);
|
||||
toolStripMenuItemModifySelection.ShortcutKeys = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainEditModifySelection);
|
||||
|
||||
fixToolStripMenuItem.ShortcutKeys = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainToolsFixCommonErrors);
|
||||
startNumberingFromToolStripMenuItem.ShortcutKeys = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainToolsRenumber);
|
||||
@ -13755,6 +13779,45 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
if (message == "Session not found!")
|
||||
{
|
||||
message = _networkSession.Restart();
|
||||
if (message == "Reload")
|
||||
{
|
||||
_subtitle = _networkSession.ReloadSubtitle();
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
UpdateListviewWithUserLogEntries();
|
||||
_networkSession.LastSubtitle = new Subtitle(_subtitle);
|
||||
_oldSelectedParagraph = null;
|
||||
SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged;
|
||||
_networkSession.TimerStart();
|
||||
RefreshSelectedParagraph();
|
||||
return;
|
||||
}
|
||||
if (message == "OK")
|
||||
{
|
||||
_networkSession.TimerStart();
|
||||
RefreshSelectedParagraph();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (message == "User not found!")
|
||||
{
|
||||
message = _networkSession.ReJoin();
|
||||
if (message == "Reload")
|
||||
{
|
||||
_subtitle = _networkSession.ReloadSubtitle();
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
UpdateListviewWithUserLogEntries();
|
||||
_networkSession.LastSubtitle = new Subtitle(_subtitle);
|
||||
_oldSelectedParagraph = null;
|
||||
SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged;
|
||||
_networkSession.TimerStart();
|
||||
RefreshSelectedParagraph();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MessageBox.Show(message);
|
||||
LeaveSessionToolStripMenuItemClick(null, null);
|
||||
SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged;
|
||||
@ -16517,14 +16580,35 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
MessageBox.Show(_language.NoSubtitleLoaded, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void toolStripMenuItem2_Click(object sender, EventArgs e)
|
||||
{
|
||||
var exportBdnXmlPng = new ExportPngXml();
|
||||
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "SPUMUX", _fileName, _videoInfo);
|
||||
_formPositionsAndSizes.SetPositionAndSize(exportBdnXmlPng);
|
||||
exportBdnXmlPng.ShowDialog(this);
|
||||
_formPositionsAndSizes.SavePositionAndSize(exportBdnXmlPng);
|
||||
}
|
||||
|
||||
private void toolStripMenuItemModifySelection_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = new ModifySelection(_subtitle, SubtitleListview1);
|
||||
_formPositionsAndSizes.SetPositionAndSize(form);
|
||||
form.ShowDialog(this);
|
||||
_formPositionsAndSizes.SavePositionAndSize(form);
|
||||
}
|
||||
|
||||
private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach (ListViewItem item in SubtitleListview1.Items)
|
||||
item.Selected = !item.Selected;
|
||||
}
|
||||
|
||||
private void toolStripMenuItemSpellCheckFromCurrentLine_Click(object sender, EventArgs e)
|
||||
{
|
||||
_spellCheckForm = null;
|
||||
SpellCheck(true, FirstSelectedIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
304
src/Forms/ModifySelection.Designer.cs
generated
Normal file
304
src/Forms/ModifySelection.Designer.cs
generated
Normal file
@ -0,0 +1,304 @@
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
partial class ModifySelection
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBoxWhatToDo = new System.Windows.Forms.GroupBox();
|
||||
this.radioButtonIntersect = new System.Windows.Forms.RadioButton();
|
||||
this.radioButtonSubtractFromSelection = new System.Windows.Forms.RadioButton();
|
||||
this.radioButtonAddToSelection = new System.Windows.Forms.RadioButton();
|
||||
this.radioButtonNewSelection = new System.Windows.Forms.RadioButton();
|
||||
this.groupBoxRule = new System.Windows.Forms.GroupBox();
|
||||
this.checkBoxCaseSensitive = new System.Windows.Forms.CheckBox();
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxRule = new System.Windows.Forms.ComboBox();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.buttonApply = new System.Windows.Forms.Button();
|
||||
this.groupBoxPreview = new System.Windows.Forms.GroupBox();
|
||||
this.listViewFixes = new System.Windows.Forms.ListView();
|
||||
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.labelInfo = new System.Windows.Forms.Label();
|
||||
this.groupBoxWhatToDo.SuspendLayout();
|
||||
this.groupBoxRule.SuspendLayout();
|
||||
this.groupBoxPreview.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxWhatToDo
|
||||
//
|
||||
this.groupBoxWhatToDo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBoxWhatToDo.Controls.Add(this.radioButtonIntersect);
|
||||
this.groupBoxWhatToDo.Controls.Add(this.radioButtonSubtractFromSelection);
|
||||
this.groupBoxWhatToDo.Controls.Add(this.radioButtonAddToSelection);
|
||||
this.groupBoxWhatToDo.Controls.Add(this.radioButtonNewSelection);
|
||||
this.groupBoxWhatToDo.Location = new System.Drawing.Point(343, 12);
|
||||
this.groupBoxWhatToDo.Name = "groupBoxWhatToDo";
|
||||
this.groupBoxWhatToDo.Size = new System.Drawing.Size(381, 120);
|
||||
this.groupBoxWhatToDo.TabIndex = 1;
|
||||
this.groupBoxWhatToDo.TabStop = false;
|
||||
this.groupBoxWhatToDo.Text = "What to do with matches";
|
||||
//
|
||||
// radioButtonIntersect
|
||||
//
|
||||
this.radioButtonIntersect.AutoSize = true;
|
||||
this.radioButtonIntersect.Location = new System.Drawing.Point(7, 89);
|
||||
this.radioButtonIntersect.Name = "radioButtonIntersect";
|
||||
this.radioButtonIntersect.Size = new System.Drawing.Size(172, 17);
|
||||
this.radioButtonIntersect.TabIndex = 3;
|
||||
this.radioButtonIntersect.Text = "Intersect with current selection";
|
||||
this.radioButtonIntersect.UseVisualStyleBackColor = true;
|
||||
this.radioButtonIntersect.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
|
||||
//
|
||||
// radioButtonSubtractFromSelection
|
||||
//
|
||||
this.radioButtonSubtractFromSelection.AutoSize = true;
|
||||
this.radioButtonSubtractFromSelection.Location = new System.Drawing.Point(7, 66);
|
||||
this.radioButtonSubtractFromSelection.Name = "radioButtonSubtractFromSelection";
|
||||
this.radioButtonSubtractFromSelection.Size = new System.Drawing.Size(169, 17);
|
||||
this.radioButtonSubtractFromSelection.TabIndex = 2;
|
||||
this.radioButtonSubtractFromSelection.Text = "Subtract from current selection";
|
||||
this.radioButtonSubtractFromSelection.UseVisualStyleBackColor = true;
|
||||
this.radioButtonSubtractFromSelection.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
|
||||
//
|
||||
// radioButtonAddToSelection
|
||||
//
|
||||
this.radioButtonAddToSelection.AutoSize = true;
|
||||
this.radioButtonAddToSelection.Location = new System.Drawing.Point(7, 43);
|
||||
this.radioButtonAddToSelection.Name = "radioButtonAddToSelection";
|
||||
this.radioButtonAddToSelection.Size = new System.Drawing.Size(137, 17);
|
||||
this.radioButtonAddToSelection.TabIndex = 1;
|
||||
this.radioButtonAddToSelection.Text = "Add to current selection";
|
||||
this.radioButtonAddToSelection.UseVisualStyleBackColor = true;
|
||||
this.radioButtonAddToSelection.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
|
||||
//
|
||||
// radioButtonNewSelection
|
||||
//
|
||||
this.radioButtonNewSelection.AutoSize = true;
|
||||
this.radioButtonNewSelection.Checked = true;
|
||||
this.radioButtonNewSelection.Location = new System.Drawing.Point(7, 20);
|
||||
this.radioButtonNewSelection.Name = "radioButtonNewSelection";
|
||||
this.radioButtonNewSelection.Size = new System.Drawing.Size(120, 17);
|
||||
this.radioButtonNewSelection.TabIndex = 0;
|
||||
this.radioButtonNewSelection.TabStop = true;
|
||||
this.radioButtonNewSelection.Text = "Make new selection";
|
||||
this.radioButtonNewSelection.UseVisualStyleBackColor = true;
|
||||
this.radioButtonNewSelection.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
|
||||
//
|
||||
// groupBoxRule
|
||||
//
|
||||
this.groupBoxRule.Controls.Add(this.checkBoxCaseSensitive);
|
||||
this.groupBoxRule.Controls.Add(this.textBox1);
|
||||
this.groupBoxRule.Controls.Add(this.comboBoxRule);
|
||||
this.groupBoxRule.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBoxRule.Name = "groupBoxRule";
|
||||
this.groupBoxRule.Size = new System.Drawing.Size(324, 93);
|
||||
this.groupBoxRule.TabIndex = 0;
|
||||
this.groupBoxRule.TabStop = false;
|
||||
this.groupBoxRule.Text = "Rule";
|
||||
//
|
||||
// checkBoxCaseSensitive
|
||||
//
|
||||
this.checkBoxCaseSensitive.AutoSize = true;
|
||||
this.checkBoxCaseSensitive.Location = new System.Drawing.Point(7, 54);
|
||||
this.checkBoxCaseSensitive.Name = "checkBoxCaseSensitive";
|
||||
this.checkBoxCaseSensitive.Size = new System.Drawing.Size(94, 17);
|
||||
this.checkBoxCaseSensitive.TabIndex = 2;
|
||||
this.checkBoxCaseSensitive.Text = "Case sensitive";
|
||||
this.checkBoxCaseSensitive.UseVisualStyleBackColor = true;
|
||||
this.checkBoxCaseSensitive.CheckedChanged += new System.EventHandler(this.checkBoxCaseSensitive_CheckedChanged);
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Location = new System.Drawing.Point(198, 27);
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(120, 20);
|
||||
this.textBox1.TabIndex = 1;
|
||||
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
|
||||
//
|
||||
// comboBoxRule
|
||||
//
|
||||
this.comboBoxRule.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxRule.FormattingEnabled = true;
|
||||
this.comboBoxRule.Items.AddRange(new object[] {
|
||||
"Contains",
|
||||
"Starts with",
|
||||
"Ends with",
|
||||
"Not contains",
|
||||
"RegEx"});
|
||||
this.comboBoxRule.Location = new System.Drawing.Point(7, 26);
|
||||
this.comboBoxRule.Name = "comboBoxRule";
|
||||
this.comboBoxRule.Size = new System.Drawing.Size(185, 21);
|
||||
this.comboBoxRule.TabIndex = 0;
|
||||
this.comboBoxRule.SelectedIndexChanged += new System.EventHandler(this.comboBoxRule_SelectedIndexChanged);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(649, 399);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
|
||||
this.buttonCancel.TabIndex = 6;
|
||||
this.buttonCancel.Text = "C&ancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonOK.Location = new System.Drawing.Point(568, 399);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(75, 21);
|
||||
this.buttonOK.TabIndex = 5;
|
||||
this.buttonOK.Text = "&OK";
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
|
||||
//
|
||||
// buttonApply
|
||||
//
|
||||
this.buttonApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonApply.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonApply.Location = new System.Drawing.Point(473, 399);
|
||||
this.buttonApply.Name = "buttonApply";
|
||||
this.buttonApply.Size = new System.Drawing.Size(89, 21);
|
||||
this.buttonApply.TabIndex = 4;
|
||||
this.buttonApply.Text = "&Apply";
|
||||
this.buttonApply.UseVisualStyleBackColor = true;
|
||||
this.buttonApply.Click += new System.EventHandler(this.buttonApply_Click);
|
||||
//
|
||||
// groupBoxPreview
|
||||
//
|
||||
this.groupBoxPreview.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.groupBoxPreview.Controls.Add(this.listViewFixes);
|
||||
this.groupBoxPreview.Location = new System.Drawing.Point(12, 138);
|
||||
this.groupBoxPreview.Name = "groupBoxPreview";
|
||||
this.groupBoxPreview.Size = new System.Drawing.Size(712, 255);
|
||||
this.groupBoxPreview.TabIndex = 2;
|
||||
this.groupBoxPreview.TabStop = false;
|
||||
this.groupBoxPreview.Text = "Matching lines";
|
||||
//
|
||||
// listViewFixes
|
||||
//
|
||||
this.listViewFixes.CheckBoxes = true;
|
||||
this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader4,
|
||||
this.columnHeader5,
|
||||
this.columnHeader7});
|
||||
this.listViewFixes.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.listViewFixes.FullRowSelect = true;
|
||||
this.listViewFixes.Location = new System.Drawing.Point(3, 16);
|
||||
this.listViewFixes.Name = "listViewFixes";
|
||||
this.listViewFixes.Size = new System.Drawing.Size(706, 236);
|
||||
this.listViewFixes.TabIndex = 1;
|
||||
this.listViewFixes.UseCompatibleStateImageBehavior = false;
|
||||
this.listViewFixes.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// columnHeader4
|
||||
//
|
||||
this.columnHeader4.Text = "Apply";
|
||||
this.columnHeader4.Width = 45;
|
||||
//
|
||||
// columnHeader5
|
||||
//
|
||||
this.columnHeader5.Text = "Line#";
|
||||
this.columnHeader5.Width = 122;
|
||||
//
|
||||
// columnHeader7
|
||||
//
|
||||
this.columnHeader7.Text = "Text";
|
||||
this.columnHeader7.Width = 500;
|
||||
//
|
||||
// labelInfo
|
||||
//
|
||||
this.labelInfo.AutoSize = true;
|
||||
this.labelInfo.Location = new System.Drawing.Point(12, 400);
|
||||
this.labelInfo.Name = "labelInfo";
|
||||
this.labelInfo.Size = new System.Drawing.Size(47, 13);
|
||||
this.labelInfo.TabIndex = 3;
|
||||
this.labelInfo.Text = "labelInfo";
|
||||
//
|
||||
// ModifySelection
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(736, 432);
|
||||
this.Controls.Add(this.labelInfo);
|
||||
this.Controls.Add(this.groupBoxWhatToDo);
|
||||
this.Controls.Add(this.groupBoxPreview);
|
||||
this.Controls.Add(this.buttonApply);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOK);
|
||||
this.Controls.Add(this.groupBoxRule);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.KeyPreview = true;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ModifySelection";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Create/modify selection";
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ModifySelection_KeyDown);
|
||||
this.groupBoxWhatToDo.ResumeLayout(false);
|
||||
this.groupBoxWhatToDo.PerformLayout();
|
||||
this.groupBoxRule.ResumeLayout(false);
|
||||
this.groupBoxRule.PerformLayout();
|
||||
this.groupBoxPreview.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox groupBoxWhatToDo;
|
||||
private System.Windows.Forms.RadioButton radioButtonSubtractFromSelection;
|
||||
private System.Windows.Forms.RadioButton radioButtonAddToSelection;
|
||||
private System.Windows.Forms.RadioButton radioButtonNewSelection;
|
||||
private System.Windows.Forms.GroupBox groupBoxRule;
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.ComboBox comboBoxRule;
|
||||
private System.Windows.Forms.Button buttonCancel;
|
||||
private System.Windows.Forms.Button buttonOK;
|
||||
private System.Windows.Forms.Button buttonApply;
|
||||
private System.Windows.Forms.GroupBox groupBoxPreview;
|
||||
private System.Windows.Forms.ListView listViewFixes;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader4;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader5;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader7;
|
||||
private System.Windows.Forms.Label labelInfo;
|
||||
private System.Windows.Forms.CheckBox checkBoxCaseSensitive;
|
||||
private System.Windows.Forms.RadioButton radioButtonIntersect;
|
||||
}
|
||||
}
|
223
src/Forms/ModifySelection.cs
Normal file
223
src/Forms/ModifySelection.cs
Normal file
@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Nikse.SubtitleEdit.Controls;
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
public partial class ModifySelection : Form
|
||||
{
|
||||
SubtitleListView _subtitleListView;
|
||||
Subtitle _subtitle;
|
||||
bool _loading;
|
||||
|
||||
public ModifySelection(Subtitle subtitle, SubtitleListView subtitleListView)
|
||||
{
|
||||
InitializeComponent();
|
||||
_loading = true;
|
||||
_subtitle = subtitle;
|
||||
_subtitleListView = subtitleListView;
|
||||
labelInfo.Text = string.Empty;
|
||||
comboBoxRule.SelectedIndex = 0;
|
||||
// Text = Configuration.Settings.Language.ModifySelection.Title;
|
||||
buttonOK.Text = Configuration.Settings.Language.General.OK;
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||
FixLargeFonts();
|
||||
|
||||
checkBoxCaseSensitive.Checked = Configuration.Settings.Tools.ModifySelectionCaseSensitive;
|
||||
textBox1.Text = Configuration.Settings.Tools.ModifySelectionText;
|
||||
if (Configuration.Settings.Tools.ModifySelectionRule == "Starts with")
|
||||
comboBoxRule.SelectedIndex = 1;
|
||||
else if (Configuration.Settings.Tools.ModifySelectionRule == "Ends with")
|
||||
comboBoxRule.SelectedIndex = 2;
|
||||
else if (Configuration.Settings.Tools.ModifySelectionRule == "Not contains")
|
||||
comboBoxRule.SelectedIndex = 3;
|
||||
else if (Configuration.Settings.Tools.ModifySelectionRule == "RegEx")
|
||||
comboBoxRule.SelectedIndex = 4;
|
||||
_loading = false;
|
||||
Preview();
|
||||
}
|
||||
|
||||
private void FixLargeFonts()
|
||||
{
|
||||
Graphics graphics = this.CreateGraphics();
|
||||
SizeF textSize = graphics.MeasureString(buttonOK.Text, this.Font);
|
||||
if (textSize.Height > buttonOK.Height - 4)
|
||||
{
|
||||
int newButtonHeight = (int)(textSize.Height + 7 + 0.5);
|
||||
Utilities.SetButtonHeight(this, newButtonHeight, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void ModifySelection_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Escape)
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
ApplySelection();
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
Configuration.Settings.Tools.ModifySelectionCaseSensitive = checkBoxCaseSensitive.Checked;
|
||||
Configuration.Settings.Tools.ModifySelectionText = textBox1.Text;
|
||||
if (comboBoxRule.SelectedIndex == 0)
|
||||
Configuration.Settings.Tools.ModifySelectionRule = "Contains";
|
||||
else if (comboBoxRule.SelectedIndex == 1)
|
||||
Configuration.Settings.Tools.ModifySelectionRule = "Starts with";
|
||||
else if (comboBoxRule.SelectedIndex == 2)
|
||||
Configuration.Settings.Tools.ModifySelectionRule = "Ends with";
|
||||
else if (comboBoxRule.SelectedIndex == 3)
|
||||
Configuration.Settings.Tools.ModifySelectionRule = "Not contains";
|
||||
else if (comboBoxRule.SelectedIndex == 4)
|
||||
Configuration.Settings.Tools.ModifySelectionRule = "RegEx";
|
||||
}
|
||||
|
||||
private void buttonApply_Click(object sender, EventArgs e)
|
||||
{
|
||||
ApplySelection();
|
||||
}
|
||||
|
||||
private void AddToListView(Paragraph p, int index)
|
||||
{
|
||||
var item = new ListViewItem(string.Empty) { Tag = index, Checked = true };
|
||||
var subItem = new ListViewItem.ListViewSubItem(item, p.Number.ToString());
|
||||
item.SubItems.Add(subItem);
|
||||
subItem = new ListViewItem.ListViewSubItem(item, p.Text.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString));
|
||||
item.SubItems.Add(subItem);
|
||||
|
||||
listViewFixes.Items.Add(item);
|
||||
}
|
||||
|
||||
private void Preview()
|
||||
{
|
||||
if (_loading)
|
||||
return;
|
||||
|
||||
Regex regEx = null;
|
||||
listViewFixes.BeginUpdate();
|
||||
listViewFixes.Items.Clear();
|
||||
if (textBox1.Text.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < _subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
if ((radioButtonSubtractFromSelection.Checked || radioButtonIntersect.Checked) && _subtitleListView.Items[i].Selected ||
|
||||
!radioButtonSubtractFromSelection.Checked && !radioButtonIntersect.Checked)
|
||||
{
|
||||
Paragraph p = _subtitle.Paragraphs[i];
|
||||
if (comboBoxRule.SelectedIndex == 0) // Contains
|
||||
{
|
||||
if (checkBoxCaseSensitive.Checked && p.Text.Contains(textBox1.Text) || p.Text.ToLower().Contains(textBox1.Text.ToLower()))
|
||||
AddToListView(p, i);
|
||||
}
|
||||
else if (comboBoxRule.SelectedIndex == 1) // Starts with
|
||||
{
|
||||
if (checkBoxCaseSensitive.Checked && p.Text.StartsWith(textBox1.Text) || p.Text.ToLower().StartsWith(textBox1.Text.ToLower()))
|
||||
AddToListView(p, i);
|
||||
}
|
||||
else if (comboBoxRule.SelectedIndex == 2) // Ends with
|
||||
{
|
||||
if (checkBoxCaseSensitive.Checked && p.Text.EndsWith(textBox1.Text) || p.Text.ToLower().EndsWith(textBox1.Text.ToLower()))
|
||||
AddToListView(p, i);
|
||||
}
|
||||
else if (comboBoxRule.SelectedIndex == 3) // Not contains
|
||||
{
|
||||
if (checkBoxCaseSensitive.Checked && !p.Text.Contains(textBox1.Text) || !p.Text.ToLower().Contains(textBox1.Text.ToLower()))
|
||||
AddToListView(p, i);
|
||||
}
|
||||
else if (comboBoxRule.SelectedIndex == 4) // RegEx
|
||||
{
|
||||
labelInfo.Text = string.Empty;
|
||||
if (regEx == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
regEx = new Regex(textBox1.Text, RegexOptions.Compiled);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
labelInfo.Text = e.Message;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (regEx.IsMatch(p.Text))
|
||||
AddToListView(p, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
listViewFixes.EndUpdate();
|
||||
groupBoxPreview.Text = string.Format("Matching lines: {0}", listViewFixes.Items.Count);
|
||||
}
|
||||
|
||||
private void ApplySelection()
|
||||
{
|
||||
_subtitleListView.BeginUpdate();
|
||||
if (radioButtonNewSelection.Checked || radioButtonIntersect.Checked)
|
||||
_subtitleListView.SelectNone();
|
||||
|
||||
if (radioButtonNewSelection.Checked || radioButtonAddToSelection.Checked || radioButtonIntersect.Checked)
|
||||
{
|
||||
foreach (ListViewItem item in listViewFixes.Items)
|
||||
{
|
||||
if (item.Checked)
|
||||
{
|
||||
int index = Convert.ToInt32(item.Tag);
|
||||
_subtitleListView.Items[index].Selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (radioButtonSubtractFromSelection.Checked)
|
||||
{
|
||||
foreach (ListViewItem item in listViewFixes.Items)
|
||||
{
|
||||
if (item.Checked)
|
||||
{
|
||||
int index = Convert.ToInt32(item.Tag);
|
||||
_subtitleListView.Items[index].Selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_subtitleListView.EndUpdate();
|
||||
}
|
||||
|
||||
private void textBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
Preview();
|
||||
}
|
||||
|
||||
private void comboBoxRule_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxRule.SelectedIndex == 4) // regex
|
||||
{
|
||||
textBox1.ContextMenu = FindReplaceDialogHelper.GetRegExContextMenu(textBox1);
|
||||
checkBoxCaseSensitive.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
textBox1.ContextMenuStrip = null;
|
||||
checkBoxCaseSensitive.Enabled = true;
|
||||
}
|
||||
Preview();
|
||||
}
|
||||
|
||||
private void checkBoxCaseSensitive_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Preview();
|
||||
}
|
||||
|
||||
private void radioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Preview();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
120
src/Forms/ModifySelection.resx
Normal file
120
src/Forms/ModifySelection.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
12
src/Forms/VobSubOcr.Designer.cs
generated
12
src/Forms/VobSubOcr.Designer.cs
generated
@ -114,6 +114,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.splitContainerBottom = new System.Windows.Forms.SplitContainer();
|
||||
this.textBoxCurrentText = new Nikse.SubtitleEdit.Controls.SETextBox();
|
||||
this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
|
||||
this.toolStripMenuItemSetUnItalicFactor = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.contextMenuStripListview.SuspendLayout();
|
||||
this.groupBoxOcrMethod.SuspendLayout();
|
||||
this.GroupBoxTesseractMethod.SuspendLayout();
|
||||
@ -153,10 +154,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.toolStripSeparatorImageCompare,
|
||||
this.inspectImageCompareMatchesForCurrentImageToolStripMenuItem,
|
||||
this.EditLastAdditionsToolStripMenuItem,
|
||||
this.toolStripMenuItemSetUnItalicFactor,
|
||||
this.toolStripSeparator3,
|
||||
this.deleteToolStripMenuItem});
|
||||
this.contextMenuStripListview.Name = "contextMenuStripListview";
|
||||
this.contextMenuStripListview.Size = new System.Drawing.Size(306, 226);
|
||||
this.contextMenuStripListview.Size = new System.Drawing.Size(306, 270);
|
||||
this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening);
|
||||
//
|
||||
// normalToolStripMenuItem
|
||||
@ -1054,6 +1056,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged);
|
||||
this.subtitleListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.subtitleListView1_KeyDown);
|
||||
//
|
||||
// toolStripMenuItemSetUnItalicFactor
|
||||
//
|
||||
this.toolStripMenuItemSetUnItalicFactor.Name = "toolStripMenuItemSetUnItalicFactor";
|
||||
this.toolStripMenuItemSetUnItalicFactor.Size = new System.Drawing.Size(305, 22);
|
||||
this.toolStripMenuItemSetUnItalicFactor.Text = "Set un-italic factor...";
|
||||
this.toolStripMenuItemSetUnItalicFactor.Click += new System.EventHandler(this.toolStripMenuItemSetUnItalicFactor_Click);
|
||||
//
|
||||
// VobSubOcr
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -1200,5 +1209,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private System.Windows.Forms.Button buttonUknownToNames;
|
||||
private System.Windows.Forms.Button buttonAddToOcrReplaceList;
|
||||
private System.Windows.Forms.Button buttonGoogleIt;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSetUnItalicFactor;
|
||||
}
|
||||
}
|
@ -110,6 +110,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
VobSubOcrSettings _vobSubOcrSettings;
|
||||
bool _italicCheckedLast;
|
||||
bool _useNewSubIdxCode;
|
||||
double _unItalicFactor = 0.33;
|
||||
|
||||
Type _modiType;
|
||||
Object _modiDoc;
|
||||
@ -242,6 +243,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
checkBoxUseModiInTesseractForUnknownWords.Text = language.TryModiForUnknownWords;
|
||||
checkBoxTesseractItalicsOn.Checked = Configuration.Settings.VobSubOcr.UseItalicsInTesseract;
|
||||
checkBoxTesseractItalicsOn.Text = Configuration.Settings.Language.General.Italic;
|
||||
_unItalicFactor = Configuration.Settings.VobSubOcr.ItalicFactor;
|
||||
checkBoxShowOnlyForced.Text = language.ShowOnlyForcedSubtitles;
|
||||
checkBoxUseTimeCodesFromIdx.Text = language.UseTimeCodesFromIdx;
|
||||
|
||||
@ -397,7 +399,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
_bluRaySubtitlesOriginal = subtitles;
|
||||
|
||||
groupBoxImagePalette.Visible = false;
|
||||
groupBoxImagePalette.Visible = false;
|
||||
|
||||
Text = Configuration.Settings.Language.VobSubOcr.TitleBluRay;
|
||||
if (!string.IsNullOrEmpty(fileName))
|
||||
@ -1987,43 +1989,23 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return result;
|
||||
}
|
||||
|
||||
//public void UnItalic(Bitmap bmp)
|
||||
//{
|
||||
// double xOffset = 0;
|
||||
// for (int y = 0; y < bmp.Height; y++)
|
||||
// {
|
||||
// int offset = (int)xOffset;
|
||||
// for (int x = bmp.Width - 1; x >= 0; x--)
|
||||
// {
|
||||
// if (x - offset >= 0)
|
||||
// bmp.SetPixel(x, y, bmp.GetPixel(x - offset, y));
|
||||
// else
|
||||
// bmp.SetPixel(x, y, Color.Transparent);
|
||||
// }
|
||||
// // xOffset += 0.3;
|
||||
// xOffset += 0.05;
|
||||
// }
|
||||
//}
|
||||
public static Bitmap UnItalic(Bitmap bmp, double factor)
|
||||
{
|
||||
int left = (int)(bmp.Height * factor);
|
||||
Bitmap unItaliced = new Bitmap(bmp.Width + left + 4, bmp.Height);
|
||||
|
||||
//public void UnItalic(Bitmap bmp, double factor)
|
||||
//{
|
||||
// int left = (int)(bmp.Height*factor);
|
||||
// Bitmap unItaliced = new Bitmap(bmp.Width + left, bmp.Height);
|
||||
// double xOffset = 0;
|
||||
// for (int y = 0; y < bmp.Height; y++)
|
||||
// {
|
||||
// int offset = (int)xOffset;
|
||||
// for (int x = bmp.Width - 1; x >= 0; x--)
|
||||
// {
|
||||
// if (x - offset >= 0)
|
||||
// unItaliced.SetPixel(x, y, bmp.GetPixel(x - offset, y));
|
||||
// else
|
||||
// unItaliced.SetPixel(x, y, Color.Transparent);
|
||||
// }
|
||||
// // xOffset += 0.3;
|
||||
// xOffset += 0.05;
|
||||
// }
|
||||
//}
|
||||
Point[] destinationPoints = {
|
||||
new Point(0, 0), // destination for upper-left point of original
|
||||
new Point(bmp.Width, 0), // destination for upper-right point of original
|
||||
new Point(left, bmp.Height) // destination for lower-left point of original
|
||||
};
|
||||
|
||||
using (var g = Graphics.FromImage(unItaliced))
|
||||
{
|
||||
g.DrawImage(bmp, destinationPoints);
|
||||
}
|
||||
return unItaliced;
|
||||
}
|
||||
|
||||
private string Tesseract3DoOcrViaExe(Bitmap bmp, string language, string psmMode)
|
||||
{
|
||||
@ -2265,12 +2247,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
// fix italics
|
||||
int italicStartCount = Utilities.CountTagInText(textWithOutFixes, "<i>");
|
||||
if (textWithOutFixes.Contains("<i>") && italicStartCount > 1)
|
||||
textWithOutFixes = "<i>" + textWithOutFixes.Replace("<i>", string.Empty).Replace("</i>", string.Empty) + "</i>";
|
||||
else if (italicStartCount == 1 && textWithOutFixes.Length > 20 &&
|
||||
textWithOutFixes.IndexOf("<i>") > 1 && textWithOutFixes.IndexOf("<i>") < 10 && textWithOutFixes.EndsWith("</i>"))
|
||||
textWithOutFixes = "<i>" + textWithOutFixes.Replace("<i>", string.Empty).Replace("</i>", string.Empty) + "</i>";
|
||||
textWithOutFixes = FixItalics(textWithOutFixes);
|
||||
|
||||
int numberOfWords = textWithOutFixes.ToString().Split((" " + Environment.NewLine).ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length;
|
||||
|
||||
@ -2316,7 +2293,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
newText = newText.TrimEnd() + "?";
|
||||
|
||||
textWithOutFixes = newUnfixedText;
|
||||
line = newText;
|
||||
line = FixItalics(newText);
|
||||
}
|
||||
else if (correctWords > oldCorrectWords + 1 || (correctWords > oldCorrectWords && !textWithOutFixes.Contains(" ")))
|
||||
{
|
||||
@ -2331,6 +2308,184 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (wordsNotFound > 0 || correctWords == 0 || textWithOutFixes != null && textWithOutFixes.ToString().Replace("~", string.Empty).Trim().Length < 2)
|
||||
{
|
||||
if (_bluRaySubtitles != null && !line.Contains("<i>"))
|
||||
{
|
||||
_ocrFixEngine.AutoGuessesUsed.Clear();
|
||||
_ocrFixEngine.UnknownWordsFound.Clear();
|
||||
|
||||
// which is best - normal image or one color image?
|
||||
NikseBitmap nbmp = new NikseBitmap(bitmap);
|
||||
nbmp.MakeOneColor(Color.White);
|
||||
Bitmap oneColorBitmap = nbmp.GetBitmap();
|
||||
string oneColorText = Tesseract3DoOcrViaExe(oneColorBitmap, _languageId, "-psm 6"); // 6 = Assume a single uniform block of text.
|
||||
oneColorBitmap.Dispose();
|
||||
nbmp = null;
|
||||
|
||||
if (oneColorText.Length > 1 &&
|
||||
!oneColorText.Contains("CD") &&
|
||||
(!oneColorText.Contains("0") || line.Contains("0")) &&
|
||||
(!oneColorText.Contains("2") || line.Contains("2")) &&
|
||||
(!oneColorText.Contains("3") || line.Contains("4")) &&
|
||||
(!oneColorText.Contains("5") || line.Contains("5")) &&
|
||||
(!oneColorText.Contains("9") || line.Contains("9")) &&
|
||||
(!oneColorText.Contains("•") || line.Contains("•")) &&
|
||||
(!oneColorText.Contains(")") || line.Contains(")")) &&
|
||||
Utilities.CountTagInText(oneColorText, "(") < 2 && Utilities.CountTagInText(oneColorText, ")") < 2 &&
|
||||
Utilities.CountTagInText(oneColorText, Environment.NewLine) < 3)
|
||||
{
|
||||
int modiCorrectWords;
|
||||
int modiWordsNotFound = _ocrFixEngine.CountUnknownWordsViaDictionary(oneColorText, out modiCorrectWords);
|
||||
string modiTextOcrFixed = oneColorText;
|
||||
if (checkBoxAutoFixCommonErrors.Checked)
|
||||
modiTextOcrFixed = _ocrFixEngine.FixOcrErrors(oneColorText, index, _lastLine, false, checkBoxGuessUnknownWords.Checked);
|
||||
int modiOcrCorrectedCorrectWords;
|
||||
int modiOcrCorrectedWordsNotFound = _ocrFixEngine.CountUnknownWordsViaDictionary(modiTextOcrFixed, out modiOcrCorrectedCorrectWords);
|
||||
if (modiOcrCorrectedWordsNotFound <= modiWordsNotFound)
|
||||
{
|
||||
oneColorText = modiTextOcrFixed;
|
||||
modiWordsNotFound = modiOcrCorrectedWordsNotFound;
|
||||
modiCorrectWords = modiOcrCorrectedCorrectWords;
|
||||
}
|
||||
|
||||
if (modiWordsNotFound < wordsNotFound || (textWithOutFixes.Length == 1 && modiWordsNotFound == 0))
|
||||
{
|
||||
line = FixItalics(oneColorText); // use one-color text
|
||||
wordsNotFound = modiWordsNotFound;
|
||||
correctWords = modiCorrectWords;
|
||||
if (checkBoxAutoFixCommonErrors.Checked)
|
||||
line = _ocrFixEngine.FixOcrErrors(line, index, _lastLine, true, checkBoxGuessUnknownWords.Checked);
|
||||
}
|
||||
else if (wordsNotFound == modiWordsNotFound && oneColorText.EndsWith("!") && (line.EndsWith("l") || line.EndsWith("fl")))
|
||||
{
|
||||
line = FixItalics(oneColorText);
|
||||
wordsNotFound = modiWordsNotFound;
|
||||
correctWords = modiCorrectWords;
|
||||
if (checkBoxAutoFixCommonErrors.Checked)
|
||||
line = _ocrFixEngine.FixOcrErrors(line, index, _lastLine, true, checkBoxGuessUnknownWords.Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (checkBoxTesseractItalicsOn.Checked)
|
||||
{
|
||||
if (line.Contains("<i>") || wordsNotFound > 0 || correctWords == 0 || textWithOutFixes != null && textWithOutFixes.ToString().Replace("~", string.Empty).Trim().Length < 2)
|
||||
{
|
||||
_ocrFixEngine.AutoGuessesUsed.Clear();
|
||||
_ocrFixEngine.UnknownWordsFound.Clear();
|
||||
|
||||
// which is best - normal image or de-italic'ed? We find out here
|
||||
var unItalicedBmp = UnItalic(bitmap, _unItalicFactor);
|
||||
string unItalicText = Tesseract3DoOcrViaExe(unItalicedBmp, _languageId, "-psm 6"); // 6 = Assume a single uniform block of text.
|
||||
unItalicedBmp.Dispose();
|
||||
|
||||
if (unItalicText.Length > 1)
|
||||
{
|
||||
int modiCorrectWords;
|
||||
int modiWordsNotFound = _ocrFixEngine.CountUnknownWordsViaDictionary(unItalicText, out modiCorrectWords);
|
||||
string modiTextOcrFixed = unItalicText;
|
||||
if (checkBoxAutoFixCommonErrors.Checked)
|
||||
modiTextOcrFixed = _ocrFixEngine.FixOcrErrors(unItalicText, index, _lastLine, false, checkBoxGuessUnknownWords.Checked);
|
||||
int modiOcrCorrectedCorrectWords;
|
||||
int modiOcrCorrectedWordsNotFound = _ocrFixEngine.CountUnknownWordsViaDictionary(modiTextOcrFixed, out modiOcrCorrectedCorrectWords);
|
||||
if (modiOcrCorrectedWordsNotFound <= modiWordsNotFound)
|
||||
{
|
||||
unItalicText = modiTextOcrFixed;
|
||||
modiWordsNotFound = modiOcrCorrectedWordsNotFound;
|
||||
modiCorrectWords = modiOcrCorrectedCorrectWords;
|
||||
}
|
||||
|
||||
bool ok = modiWordsNotFound < wordsNotFound || (textWithOutFixes.Length == 1 && modiWordsNotFound == 0);
|
||||
|
||||
if (!ok)
|
||||
ok = wordsNotFound == modiWordsNotFound && unItalicText.EndsWith("!") && (line.EndsWith("l") || line.EndsWith("fl"));
|
||||
|
||||
if (!ok)
|
||||
ok = wordsNotFound == modiWordsNotFound && line.StartsWith("<i>") && line.EndsWith("</i>");
|
||||
|
||||
if (ok)
|
||||
{
|
||||
wordsNotFound = modiWordsNotFound;
|
||||
correctWords = modiCorrectWords;
|
||||
|
||||
line = line.Replace("<i>", string.Empty).Replace("</i>", string.Empty).Trim();
|
||||
|
||||
if (line.Length > 7 && unItalicText.Length > 7 && unItalicText.StartsWith("I ") &&
|
||||
line.StartsWith(unItalicText.Remove(0, 2).Substring(0, 4)))
|
||||
unItalicText = unItalicText.Remove(0, 2);
|
||||
|
||||
if (unItalicText.StartsWith("[") && !line.StartsWith("["))
|
||||
{
|
||||
unItalicText = unItalicText.Remove(0, 1);
|
||||
if (unItalicText.EndsWith("]"))
|
||||
unItalicText = unItalicText.TrimEnd(']');
|
||||
}
|
||||
if (unItalicText.StartsWith("{") && !line.StartsWith("{"))
|
||||
{
|
||||
unItalicText = unItalicText.Remove(0, 1);
|
||||
if (unItalicText.EndsWith("}"))
|
||||
unItalicText = unItalicText.TrimEnd('}');
|
||||
}
|
||||
if (unItalicText.EndsWith("}") && !line.EndsWith("}"))
|
||||
unItalicText = unItalicText.TrimEnd('}');
|
||||
|
||||
if (line.EndsWith("...") && unItalicText.EndsWith("”!"))
|
||||
unItalicText = unItalicText.TrimEnd('!').TrimEnd('”') + ".";
|
||||
if (line.EndsWith("...") && unItalicText.EndsWith("\"!"))
|
||||
unItalicText = unItalicText.TrimEnd('!').TrimEnd('"') + ".";
|
||||
|
||||
if (line.EndsWith(".") && !unItalicText.EndsWith("."))
|
||||
{
|
||||
if (unItalicText.EndsWith("'") && !line.EndsWith("'."))
|
||||
unItalicText = unItalicText.TrimEnd('\'');
|
||||
unItalicText += ".";
|
||||
}
|
||||
if (unItalicText.EndsWith(".") && !unItalicText.EndsWith("...") && line.EndsWith("..."))
|
||||
unItalicText += "..";
|
||||
if (unItalicText.EndsWith("..") && !unItalicText.EndsWith("...") && line.EndsWith("..."))
|
||||
unItalicText += ".";
|
||||
|
||||
if (line.EndsWith("!") && !unItalicText.EndsWith("!"))
|
||||
{
|
||||
if (unItalicText.EndsWith("!'"))
|
||||
unItalicText = unItalicText.TrimEnd('\'');
|
||||
else
|
||||
unItalicText += "!";
|
||||
}
|
||||
if (line.EndsWith("?") && !unItalicText.EndsWith("?"))
|
||||
{
|
||||
if (unItalicText.EndsWith("?'"))
|
||||
unItalicText = unItalicText.TrimEnd('\'');
|
||||
else
|
||||
unItalicText += "?";
|
||||
}
|
||||
|
||||
line = unItalicText.Replace("<i>", string.Empty).Replace("</i>", string.Empty);
|
||||
if (checkBoxAutoFixCommonErrors.Checked)
|
||||
line = _ocrFixEngine.FixOcrErrors(line, index, _lastLine, true, checkBoxGuessUnknownWords.Checked);
|
||||
line = "<i>" + line + "</i>";
|
||||
}
|
||||
else
|
||||
{
|
||||
unItalicText = unItalicText.Replace("</i>", string.Empty);
|
||||
if (line.EndsWith("</i>") && unItalicText.EndsWith("."))
|
||||
{
|
||||
line = line.Remove(line.Length - 4, 4);
|
||||
if (line.EndsWith("-"))
|
||||
line = line.TrimEnd('-') + ".";
|
||||
if (Utilities.AllLetters.Contains(line.Substring(line.Length - 1)))
|
||||
line += ".";
|
||||
line += "</i>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (wordsNotFound > 0 || correctWords == 0 || textWithOutFixes != null && textWithOutFixes.ToString().Replace("~", string.Empty).Trim().Length < 2)
|
||||
{
|
||||
_ocrFixEngine.AutoGuessesUsed.Clear();
|
||||
@ -2384,6 +2539,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_ocrFixEngine.Abort)
|
||||
{
|
||||
ButtonStopClick(null, null);
|
||||
@ -2440,6 +2596,36 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return line;
|
||||
}
|
||||
|
||||
private static string FixItalics(string s)
|
||||
{
|
||||
int italicStartCount = Utilities.CountTagInText(s, "<i>");
|
||||
|
||||
s = s.Replace(Environment.NewLine + " ", Environment.NewLine);
|
||||
s = s.Replace(Environment.NewLine + " ", Environment.NewLine);
|
||||
s = s.Replace(" " + Environment.NewLine, Environment.NewLine);
|
||||
s = s.Replace(" " + Environment.NewLine, Environment.NewLine);
|
||||
s = s.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine);
|
||||
s = s.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine);
|
||||
|
||||
if (italicStartCount == 1 && s.Contains("<i>-</i>"))
|
||||
{
|
||||
s = s.Replace("<i>-</i>", "-");
|
||||
s = s.Replace(" ", " ");
|
||||
}
|
||||
|
||||
if (s.Contains("</i> / <i>"))
|
||||
s = s.Replace("</i> / <i>", " I ").Replace(" ", " ");
|
||||
if (s.StartsWith("/ <i>"))
|
||||
s = ("<i>I " + s.Remove(0, 5)).Replace(" ", " ");
|
||||
if (s.StartsWith("I <i>"))
|
||||
s = ("<i>I " + s.Remove(0, 5)).Replace(" ", " ");
|
||||
else if (italicStartCount == 1 && s.Length > 20 &&
|
||||
s.IndexOf("<i>") > 1 && s.IndexOf("<i>") < 10 && s.EndsWith("</i>"))
|
||||
s = "<i>" + s.Replace("<i>", string.Empty).Replace("</i>", string.Empty) + "</i>";
|
||||
s = s.Replace("</i>" + Environment.NewLine + "<i>", Environment.NewLine);
|
||||
return s;
|
||||
}
|
||||
|
||||
private void LogUnknownWords()
|
||||
{
|
||||
foreach (string unknownWord in _ocrFixEngine.UnknownWordsFound)
|
||||
@ -3605,6 +3791,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_tesseractThread.CancelAsync();
|
||||
_tesseractAsyncIndex = 10000;
|
||||
Configuration.Settings.VobSubOcr.UseItalicsInTesseract = checkBoxTesseractItalicsOn.Checked;
|
||||
Configuration.Settings.VobSubOcr.ItalicFactor = _unItalicFactor;
|
||||
Configuration.Settings.VobSubOcr.UseModiInTesseractForUnknownWords = checkBoxUseModiInTesseractForUnknownWords.Checked;
|
||||
Configuration.Settings.VobSubOcr.PromptForUnknownWords = checkBoxPromptForUnknownWords.Checked;
|
||||
}
|
||||
@ -3820,5 +4007,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void toolStripMenuItemSetUnItalicFactor_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = new VobSubOcrSetItalicFactor(GetSubtitleBitmap(_selectedIndex), _unItalicFactor);
|
||||
form.ShowDialog(this);
|
||||
_unItalicFactor = form.GetUnItalicFactor();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
144
src/Forms/VobSubOcrSetItalicFactor.Designer.cs
generated
Normal file
144
src/Forms/VobSubOcrSetItalicFactor.Designer.cs
generated
Normal file
@ -0,0 +1,144 @@
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
partial class VobSubOcrSetItalicFactor
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.pictureBoxSubtitleImage = new System.Windows.Forms.PictureBox();
|
||||
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxSubtitleImage)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(680, 312);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
|
||||
this.buttonCancel.TabIndex = 8;
|
||||
this.buttonCancel.Text = "C&ancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonOK.Location = new System.Drawing.Point(599, 312);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(75, 21);
|
||||
this.buttonOK.TabIndex = 7;
|
||||
this.buttonOK.Text = "&OK";
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
|
||||
//
|
||||
// pictureBoxSubtitleImage
|
||||
//
|
||||
this.pictureBoxSubtitleImage.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.pictureBoxSubtitleImage.Location = new System.Drawing.Point(12, 47);
|
||||
this.pictureBoxSubtitleImage.Name = "pictureBoxSubtitleImage";
|
||||
this.pictureBoxSubtitleImage.Size = new System.Drawing.Size(743, 259);
|
||||
this.pictureBoxSubtitleImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.pictureBoxSubtitleImage.TabIndex = 9;
|
||||
this.pictureBoxSubtitleImage.TabStop = false;
|
||||
//
|
||||
// numericUpDown1
|
||||
//
|
||||
this.numericUpDown1.DecimalPlaces = 2;
|
||||
this.numericUpDown1.Increment = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
131072});
|
||||
this.numericUpDown1.Location = new System.Drawing.Point(12, 19);
|
||||
this.numericUpDown1.Maximum = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
this.numericUpDown1.Name = "numericUpDown1";
|
||||
this.numericUpDown1.Size = new System.Drawing.Size(57, 20);
|
||||
this.numericUpDown1.TabIndex = 10;
|
||||
this.numericUpDown1.Value = new decimal(new int[] {
|
||||
31,
|
||||
0,
|
||||
0,
|
||||
131072});
|
||||
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(76, 21);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(431, 13);
|
||||
this.label1.TabIndex = 11;
|
||||
this.label1.Text = "Adjust value until text style is normal and not italic. Note that original image " +
|
||||
"should be italic.";
|
||||
//
|
||||
// VobSubOcrSetItalicFactor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(767, 345);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.numericUpDown1);
|
||||
this.Controls.Add(this.pictureBoxSubtitleImage);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOK);
|
||||
this.KeyPreview = true;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "VobSubOcrSetItalicFactor";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Set de-italic factor";
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VobSubOcrSetItalicFactor_KeyDown);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxSubtitleImage)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button buttonCancel;
|
||||
private System.Windows.Forms.Button buttonOK;
|
||||
private System.Windows.Forms.PictureBox pictureBoxSubtitleImage;
|
||||
private System.Windows.Forms.NumericUpDown numericUpDown1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
48
src/Forms/VobSubOcrSetItalicFactor.cs
Normal file
48
src/Forms/VobSubOcrSetItalicFactor.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
public partial class VobSubOcrSetItalicFactor : Form
|
||||
{
|
||||
Bitmap _bmp;
|
||||
double _factor;
|
||||
|
||||
public VobSubOcrSetItalicFactor(Bitmap bmp, double factor)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_bmp = bmp;
|
||||
_factor = factor;
|
||||
numericUpDown1.Value = (decimal)factor;
|
||||
}
|
||||
|
||||
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxSubtitleImage.Image = VobSubOcr.UnItalic(_bmp, (double)numericUpDown1.Value);
|
||||
}
|
||||
|
||||
internal double GetUnItalicFactor()
|
||||
{
|
||||
return _factor;
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
_factor = (double)numericUpDown1.Value;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
private void VobSubOcrSetItalicFactor_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Escape)
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
}
|
||||
}
|
120
src/Forms/VobSubOcrSetItalicFactor.resx
Normal file
120
src/Forms/VobSubOcrSetItalicFactor.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -57,11 +57,33 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
buffer[2] = 255;
|
||||
for (int i = 0; i < _bitmapData.Length; i += 4)
|
||||
{
|
||||
if (_bitmapData[i+3] > 200 && _bitmapData[i+2] > 220 && _bitmapData[i+1] > 220 && _bitmapData[i] < 40)
|
||||
if (_bitmapData[i + 3] > 200 && _bitmapData[i + 2] > 220 && _bitmapData[i + 1] > 220 && _bitmapData[i] < 40)
|
||||
Buffer.BlockCopy(buffer, 0, _bitmapData, i, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeOneColor(Color c)
|
||||
{
|
||||
byte[] buffer = new byte[4];
|
||||
buffer[0] = c.B;
|
||||
buffer[1] = c.G;
|
||||
buffer[2] = c.R;
|
||||
buffer[3] = c.A;
|
||||
|
||||
byte[] bufferTransparent = new byte[4];
|
||||
bufferTransparent[0] = 0;
|
||||
bufferTransparent[1] = 0;
|
||||
bufferTransparent[2] = 0;
|
||||
bufferTransparent[3] = 0;
|
||||
for (int i = 0; i < _bitmapData.Length; i += 4)
|
||||
{
|
||||
if (_bitmapData[i] > 20)
|
||||
Buffer.BlockCopy(buffer, 0, _bitmapData, i, 4);
|
||||
else
|
||||
Buffer.BlockCopy(bufferTransparent, 0, _bitmapData, i, 4);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a x-color image to four colors, for e.g. dvd sub pictures.
|
||||
/// Colors CAN be in any order but should not...
|
||||
|
@ -79,6 +79,17 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
return _paragraphs[index];
|
||||
}
|
||||
|
||||
public Paragraph GetParagraphOrDefaultById(string id)
|
||||
{
|
||||
foreach (Paragraph p in _paragraphs)
|
||||
{
|
||||
if (p.ID == id)
|
||||
return p;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public SubtitleFormat ReloadLoadSubtitle(List<string> lines, string fileName)
|
||||
{
|
||||
Paragraphs.Clear();
|
||||
|
@ -144,6 +144,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
new UnknownSubtitle43(),
|
||||
new UnknownSubtitle44(),
|
||||
new UnknownSubtitle45(),
|
||||
new UnknownSubtitle46(),
|
||||
new UnknownSubtitle47(),
|
||||
new UTSubtitleXml(),
|
||||
new Utx(),
|
||||
new UtxFrames(),
|
||||
|
108
src/Logic/SubtitleFormats/UnknownSubtitle46.cs
Normal file
108
src/Logic/SubtitleFormats/UnknownSubtitle46.cs
Normal file
@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
public class UnknownSubtitle46 : SubtitleFormat
|
||||
{
|
||||
//7:00:01:27AM
|
||||
static Regex regexTimeCodesAM = new Regex(@"^\d\:\d\d\:\d\d\:\d\dAM", RegexOptions.Compiled);
|
||||
static Regex regexTimeCodesPM = new Regex(@"^\d\:\d\d\:\d\d\:\d\dPM", RegexOptions.Compiled);
|
||||
public override string Extension
|
||||
{
|
||||
get { return ".pst"; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "Unknown 46"; }
|
||||
}
|
||||
|
||||
public override bool IsTimeBased
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool IsMine(List<string> lines, string fileName)
|
||||
{
|
||||
Subtitle subtitle = new Subtitle();
|
||||
LoadSubtitle(subtitle, lines, fileName);
|
||||
return subtitle.Paragraphs.Count > _errorCount;
|
||||
}
|
||||
|
||||
public override string ToText(Subtitle subtitle, string title)
|
||||
{
|
||||
//OFF THE RECORD STARTS RIGHT NOW. 7:00:01:27AM
|
||||
//HERE IS THE RUNDOWN. 7:00:05:03AM
|
||||
var sb = new StringBuilder();
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
sb.AppendLine(string.Format("{0}{1}", p.Text.Replace(Environment.NewLine, " ").PadRight(35), EncodeTimeCode(p.StartTime)));
|
||||
}
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
|
||||
private string EncodeTimeCode(TimeCode timeCode)
|
||||
{
|
||||
return string.Format("{0}:{1:00}:{2:00}:{3:00}AM", timeCode.Hours, timeCode.Minutes, timeCode.Seconds, MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds));
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
Paragraph p = null;
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.Trim();
|
||||
string[] arr = line.Split();
|
||||
var timeCode = arr[arr.Length - 1];
|
||||
if (regexTimeCodesAM.Match(timeCode).Success || regexTimeCodesPM.Match(timeCode).Success)
|
||||
{
|
||||
try
|
||||
{
|
||||
arr = timeCode.Substring(0, 10).Split(':');
|
||||
if (arr.Length == 4)
|
||||
{
|
||||
int hours = int.Parse(arr[0]);
|
||||
int minutes = int.Parse(arr[1]);
|
||||
int seconds = int.Parse(arr[2]);
|
||||
int frames = int.Parse(arr[3]);
|
||||
p = new Paragraph();
|
||||
p.StartTime = new TimeCode(hours, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
p.Text = s.Substring(0, s.IndexOf(timeCode)).Trim();
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_errorCount++;
|
||||
}
|
||||
}
|
||||
else if (s.Length > 0)
|
||||
{
|
||||
_errorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
int index = 1;
|
||||
foreach (Paragraph paragraph in subtitle.Paragraphs)
|
||||
{
|
||||
Paragraph next = subtitle.GetParagraphOrDefault(index);
|
||||
if (next != null)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
|
||||
}
|
||||
if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
subtitle.RemoveEmptyLines();
|
||||
subtitle.Renumber(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
103
src/Logic/SubtitleFormats/UnknownSubtitle47.cs
Normal file
103
src/Logic/SubtitleFormats/UnknownSubtitle47.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
public class UnknownSubtitle47 : SubtitleFormat
|
||||
{
|
||||
//7:00:01:27AM
|
||||
static Regex regexTimeCodes = new Regex(@"^\d\:\d\d\:\d\d\:\d\d\t", RegexOptions.Compiled);
|
||||
public override string Extension
|
||||
{
|
||||
get { return ".txt"; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "Unknown 47"; }
|
||||
}
|
||||
|
||||
public override bool IsTimeBased
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool IsMine(List<string> lines, string fileName)
|
||||
{
|
||||
Subtitle subtitle = new Subtitle();
|
||||
LoadSubtitle(subtitle, lines, fileName);
|
||||
return subtitle.Paragraphs.Count > _errorCount;
|
||||
}
|
||||
|
||||
public override string ToText(Subtitle subtitle, string title)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
sb.AppendLine(string.Format("{0}\t{1}", EncodeTimeCode(p.StartTime), p.Text.Replace(Environment.NewLine, " ")));
|
||||
}
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
|
||||
private string EncodeTimeCode(TimeCode timeCode)
|
||||
{
|
||||
return string.Format("{0}:{1:00}:{2:00}:{3:00}", timeCode.Hours, timeCode.Minutes, timeCode.Seconds, MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds));
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
Paragraph p = null;
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.Trim();
|
||||
if (regexTimeCodes.Match(s).Success)
|
||||
{
|
||||
try
|
||||
{
|
||||
var arr = s.Substring(0, 10).Split(':');
|
||||
if (arr.Length == 4)
|
||||
{
|
||||
int hours = int.Parse(arr[0]);
|
||||
int minutes = int.Parse(arr[1]);
|
||||
int seconds = int.Parse(arr[2]);
|
||||
int frames = int.Parse(arr[3]);
|
||||
p = new Paragraph();
|
||||
p.StartTime = new TimeCode(hours, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
p.Text = s.Remove(0,10).Trim();
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_errorCount++;
|
||||
}
|
||||
}
|
||||
else if (s.Length > 0)
|
||||
{
|
||||
_errorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
int index = 1;
|
||||
foreach (Paragraph paragraph in subtitle.Paragraphs)
|
||||
{
|
||||
Paragraph next = subtitle.GetParagraphOrDefault(index);
|
||||
if (next != null)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
|
||||
}
|
||||
if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
|
||||
{
|
||||
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
subtitle.RemoveEmptyLines();
|
||||
subtitle.Renumber(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -338,6 +338,12 @@
|
||||
<Compile Include="Forms\MergeDoubleLines.Designer.cs">
|
||||
<DependentUpon>MergeDoubleLines.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ModifySelection.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ModifySelection.Designer.cs">
|
||||
<DependentUpon>ModifySelection.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\NetworkChat.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -608,6 +614,12 @@
|
||||
<Compile Include="Forms\VobSubOcrNewFolder.Designer.cs">
|
||||
<DependentUpon>VobSubOcrNewFolder.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\VobSubOcrSetItalicFactor.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\VobSubOcrSetItalicFactor.Designer.cs">
|
||||
<DependentUpon>VobSubOcrSetItalicFactor.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Watermark.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -856,6 +868,8 @@
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle43.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle44.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle45.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle46.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle47.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle5.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\OpenDvt.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\AbcIViewer.cs" />
|
||||
@ -1083,6 +1097,9 @@
|
||||
<EmbeddedResource Include="Forms\MergeDoubleLines.resx">
|
||||
<DependentUpon>MergeDoubleLines.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\ModifySelection.resx">
|
||||
<DependentUpon>ModifySelection.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\NetworkChat.resx">
|
||||
<DependentUpon>NetworkChat.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@ -1215,6 +1232,9 @@
|
||||
<DependentUpon>VobSubOcrNewFolder.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\VobSubOcrSetItalicFactor.resx">
|
||||
<DependentUpon>VobSubOcrSetItalicFactor.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\Watermark.resx">
|
||||
<DependentUpon>Watermark.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
Loading…
Reference in New Issue
Block a user