Add French letters in OCR char inspect - thx tormento :)

This commit is contained in:
Nikolaj Olsson 2021-05-13 12:50:05 +02:00
parent 571413d1fc
commit 018ae17d58
14 changed files with 118 additions and 5436 deletions

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{
UiUtil.PreInitialize(this);
InitializeComponent();
MakeToolStripLetters(contextMenuStripLetters, InsertLanguageCharacter);
UiUtil.FixFonts(this);
labelExpandCount.Text = string.Empty;
@ -57,23 +58,58 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
UiUtil.FixLargeFonts(this, buttonOK);
buttonImport.Visible = binOcrDb != null;
}
foreach (ToolStripItem toolStripItem in contextMenuStripLetters.Items)
public static void MakeToolStripLetters(ContextMenuStrip contextMenu, EventHandler clickAction)
{
contextMenu.Items.Clear();
var l = LanguageSettings.Current.VobSubOcrCharacter;
MakeToolStripLetterItem(contextMenu, "Catalan", "àÀéÉèÈíÍïÏóÓòÒúÚüÜçÇ");
MakeToolStripLetterItem(contextMenu, "French", "àâèéêëîïôœŒùûçÇ");
MakeToolStripLetterItem(contextMenu, l.German, "äÄöÖüÜß");
MakeToolStripLetterItem(contextMenu, "Italian", "àÀèÈéÉìÌòÒùÙ");
MakeToolStripLetterItem(contextMenu, l.Nordic, "æÆøØåÅäÄöÖ");
MakeToolStripLetterItem(contextMenu, "Polish", "ąĄćĆęĘłŁńŃóÓśŚźŹżŻ");
MakeToolStripLetterItem(contextMenu, "Portuguese", "ãÃõÕáÁéÉíÍóÓúÚâÂêÊôÔàÀçÇ");
MakeToolStripLetterItem(contextMenu, l.Spanish, "áÁéÉíÍóÓúÚüÜñÑ¿¡");
MakeToolStripLetterItem(contextMenu, string.Empty, "♪♫");
foreach (ToolStripItem toolStripItem in contextMenu.Items)
{
if (toolStripItem is ToolStripDropDownItem i && i.HasDropDownItems)
{
foreach (ToolStripItem item in i.DropDownItems)
{
item.Click += InsertLanguageCharacter;
item.Click += clickAction;
}
}
else
{
toolStripItem.Click += InsertLanguageCharacter;
toolStripItem.Click += clickAction;
}
}
}
private static void MakeToolStripLetterItem(ToolStrip contextMenu, string text, string letters)
{
if (string.IsNullOrEmpty(text))
{
foreach (var letter in letters)
{
contextMenu.Items.Add(letter.ToString());
}
return;
}
var menuItem = new ToolStripMenuItem(text);
contextMenu.Items.Add(menuItem);
foreach (var letter in letters)
{
menuItem.DropDownItems.Add(letter.ToString());
}
}
private void Refill(List<VobSubOcr.ImageCompareAddition> additions)
{
if (additions != null && additions.Count > 0)

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{
UiUtil.PreInitialize(this);
InitializeComponent();
VobSubEditCharacters.MakeToolStripLetters(contextMenuStripLetters, InsertLanguageCharacter);
UiUtil.FixFonts(this);
labelImageSize.Text = string.Empty;
labelStatus.Text = string.Empty;
@ -32,21 +33,6 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
buttonAddBetterMatch.Text = LanguageSettings.Current.VobSubOcrCharacterInspect.AddBetterMatch;
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
foreach (ToolStripItem toolStripItem in contextMenuStripLetters.Items)
{
if (toolStripItem is ToolStripDropDownItem i && i.HasDropDownItems)
{
foreach (ToolStripItem item in i.DropDownItems)
{
item.Click += InsertLanguageCharacter;
}
}
else
{
toolStripItem.Click += InsertLanguageCharacter;
}
}
}
private void InsertLanguageCharacter(object sender, EventArgs e)

View File

@ -61,6 +61,7 @@
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonImport = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.contextMenuStripLetters = new System.Windows.Forms.ContextMenuStrip(this.components);
this.groupBoxCurrentCompareImage.SuspendLayout();
this.groupBox2.SuspendLayout();
this.contextMenuStripLinesBackground.SuspendLayout();
@ -335,6 +336,7 @@
//
// textBoxText
//
this.textBoxText.ContextMenuStrip = this.contextMenuStripLetters;
this.textBoxText.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBoxText.Location = new System.Drawing.Point(14, 35);
this.textBoxText.Name = "textBoxText";
@ -390,6 +392,11 @@
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// contextMenuStripLetters
//
this.contextMenuStripLetters.Name = "contextMenuStripLetters";
this.contextMenuStripLetters.Size = new System.Drawing.Size(61, 4);
//
// VobSubNOcrEdit
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -458,5 +465,6 @@
private System.Windows.Forms.Label labelNOcrCharInfo;
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem1;
private System.Windows.Forms.ContextMenuStrip contextMenuStripLetters;
}
}

View File

@ -30,6 +30,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{
UiUtil.PreInitialize(this);
InitializeComponent();
VobSubEditCharacters.MakeToolStripLetters(contextMenuStripLetters, InsertLanguageCharacter);
UiUtil.FixFonts(this);
_nOcrDb = nOcrDb;
@ -56,6 +57,17 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
}
}
private void InsertLanguageCharacter(object sender, EventArgs e)
{
if (sender is ToolStripMenuItem toolStripMenuItem)
{
var start = textBoxText.SelectionStart;
textBoxText.SelectedText = toolStripMenuItem.Text;
textBoxText.SelectionLength = 0;
textBoxText.SelectionStart = start + toolStripMenuItem.Text.Length;
}
}
private void FillComboBox()
{
_nOcrChars = new List<NOcrChar>();

View File

@ -123,6 +123,9 @@
<metadata name="contextMenuLinesForeground.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>9, 17</value>
</metadata>
<metadata name="contextMenuStripLetters.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>611, 17</value>
</metadata>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>471, 17</value>
</metadata>

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{
UiUtil.PreInitialize(this);
InitializeComponent();
VobSubEditCharacters.MakeToolStripLetters(contextMenuStripLetters, InsertLanguageCharacter);
UiUtil.FixFonts(this);
var language = LanguageSettings.Current.VobSubOcrCharacter;
@ -35,9 +36,6 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
buttonAbort.Text = language.Abort;
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonSkip.Text = language.Skip;
nordicToolStripMenuItem.Text = language.Nordic;
spanishToolStripMenuItem.Text = language.Spanish;
germanToolStripMenuItem.Text = language.German;
checkBoxAutoSubmitOfFirstChar.Text = language.AutoSubmitOnFirstChar;
dataGridView1.Columns.Clear();
@ -58,22 +56,6 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
dataGridView1.Rows.Add(row2);
dataGridView1.Rows[0].Height = dataGridView1.Height / 2;
dataGridView1.Rows[1].Height = dataGridView1.Height / 2;
foreach (ToolStripItem toolStripItem in contextMenuStripLetters.Items)
{
if (toolStripItem is ToolStripDropDownItem i && i.HasDropDownItems)
{
foreach (ToolStripItem item in i.DropDownItems)
{
item.Click += InsertLanguageCharacter;
}
}
else
{
toolStripItem.Click += InsertLanguageCharacter;
}
}
UiUtil.FixLargeFonts(this, buttonSkip);
}

View File

@ -165,49 +165,4 @@
<metadata name="Column15.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column7.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column8.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column9.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column10.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column11.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column12.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column13.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column14.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column15.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{
UiUtil.PreInitialize(this);
InitializeComponent();
VobSubEditCharacters.MakeToolStripLetters(contextMenuStripLetters, InsertLanguageCharacter);
UiUtil.FixFonts(this);
labelCount.Text = string.Empty;
@ -47,24 +48,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
labelDoubleSize.Text = LanguageSettings.Current.VobSubEditCharacters.ImageDoubleSize;
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
foreach (ToolStripItem toolStripItem in contextMenuStripLetters.Items)
{
if (toolStripItem is ToolStripDropDownItem i && i.HasDropDownItems)
{
foreach (ToolStripItem item in i.DropDownItems)
{
item.Click += InsertLanguageCharacter;
}
}
else
{
toolStripItem.Click += InsertLanguageCharacter;
}
}
UiUtil.FixLargeFonts(this, buttonOK);
buttonDetectFont.Visible = Configuration.Settings.General.ShowBetaStuff;
}

File diff suppressed because it is too large Load Diff

View File

@ -28,25 +28,11 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{
UiUtil.PreInitialize(this);
InitializeComponent();
VobSubEditCharacters.MakeToolStripLetters(contextMenuStripLetters, InsertLanguageCharacter);
UiUtil.FixFonts(this);
UiUtil.FixLargeFonts(this, buttonCancel);
checkBoxAutoSubmitOfFirstChar.Text = LanguageSettings.Current.VobSubOcrCharacter.AutoSubmitOnFirstChar;
labelItalicOn.Visible = false;
foreach (ToolStripItem toolStripItem in contextMenuStripLetters.Items)
{
if (toolStripItem is ToolStripDropDownItem i && i.HasDropDownItems)
{
foreach (ToolStripItem item in i.DropDownItems)
{
item.Click += InsertLanguageCharacter;
}
}
else
{
toolStripItem.Click += InsertLanguageCharacter;
}
}
}
private void InsertLanguageCharacter(object sender, EventArgs e)
@ -153,7 +139,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
{
var c = nbmp.GetPixel(point.X, point.Y);
if (c.A > 150)
if (c.A > 150)
{
}
else
@ -837,7 +823,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
}
}
foreach (var i in indicesToDelete.OrderByDescending(p=>p))
foreach (var i in indicesToDelete.OrderByDescending(p => p))
{
lines.RemoveAt(i);
}