Ctrl+G will Google word in spell check dialogs

This commit is contained in:
niksedk 2014-06-18 14:06:03 +02:00
parent 7f5af11424
commit e99fae3efc
6 changed files with 148 additions and 10 deletions

View File

@ -366,6 +366,7 @@
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "OCR spellcheck";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OcrSpellCheck_KeyDown);
this.groupBoxSuggestions.ResumeLayout(false);
this.GroupBoxEditWord.ResumeLayout(false);
this.GroupBoxEditWord.PerformLayout();

View File

@ -280,5 +280,14 @@ namespace Nikse.SubtitleEdit.Forms
System.Diagnostics.Process.Start("http://www.google.com/search?q=" + Utilities.UrlEncode(text));
}
private void OcrSpellCheck_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers == Keys.Control && e.KeyCode == Keys.G)
{
e.SuppressKeyPress = true;
buttonGoogleIt_Click(null, null);
}
}
}
}

View File

@ -112,9 +112,9 @@
<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>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.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>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -56,6 +56,7 @@
this.textBoxWholeText = new System.Windows.Forms.TextBox();
this.labelActionInfo = new System.Windows.Forms.Label();
this.buttonSpellCheckDownload = new System.Windows.Forms.Button();
this.buttonUndo = new System.Windows.Forms.Button();
this.contextMenuStrip1.SuspendLayout();
this.groupBoxWordNotFound.SuspendLayout();
this.groupBoxSuggestions.SuspendLayout();
@ -121,13 +122,13 @@
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addXToNamesnoiseListToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(211, 26);
this.contextMenuStrip1.Size = new System.Drawing.Size(208, 26);
this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStrip1Opening);
//
// addXToNamesnoiseListToolStripMenuItem
//
this.addXToNamesnoiseListToolStripMenuItem.Name = "addXToNamesnoiseListToolStripMenuItem";
this.addXToNamesnoiseListToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
this.addXToNamesnoiseListToolStripMenuItem.Size = new System.Drawing.Size(207, 22);
this.addXToNamesnoiseListToolStripMenuItem.Text = "Add x to names/noise list";
this.addXToNamesnoiseListToolStripMenuItem.Click += new System.EventHandler(this.AddXToNamesnoiseListToolStripMenuItemClick);
//
@ -237,6 +238,7 @@
//
// groupBoxWordNotFound
//
this.groupBoxWordNotFound.Controls.Add(this.buttonUndo);
this.groupBoxWordNotFound.Controls.Add(this.buttonAddToNames);
this.groupBoxWordNotFound.Controls.Add(this.buttonAddToDictionary);
this.groupBoxWordNotFound.Controls.Add(this.buttonSkipOnce);
@ -269,7 +271,7 @@
this.checkBoxAutoChangeNames.AutoSize = true;
this.checkBoxAutoChangeNames.Location = new System.Drawing.Point(8, 157);
this.checkBoxAutoChangeNames.Name = "checkBoxAutoChangeNames";
this.checkBoxAutoChangeNames.Size = new System.Drawing.Size(209, 17);
this.checkBoxAutoChangeNames.Size = new System.Drawing.Size(216, 17);
this.checkBoxAutoChangeNames.TabIndex = 3;
this.checkBoxAutoChangeNames.Text = "Auto fix names where only casing differ";
this.checkBoxAutoChangeNames.UseVisualStyleBackColor = true;
@ -347,6 +349,17 @@
this.buttonSpellCheckDownload.UseVisualStyleBackColor = true;
this.buttonSpellCheckDownload.Click += new System.EventHandler(this.buttonSpellCheckDownload_Click);
//
// buttonUndo
//
this.buttonUndo.Location = new System.Drawing.Point(20, 158);
this.buttonUndo.Name = "buttonUndo";
this.buttonUndo.Size = new System.Drawing.Size(250, 21);
this.buttonUndo.TabIndex = 7;
this.buttonUndo.Text = "Undo: skip all \'A\'";
this.buttonUndo.UseVisualStyleBackColor = true;
this.buttonUndo.Visible = false;
this.buttonUndo.Click += new System.EventHandler(this.buttonUndo_Click);
//
// SpellCheck
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -415,5 +428,6 @@
private System.Windows.Forms.CheckBox checkBoxAutoChangeNames;
private System.Windows.Forms.Label labelActionInfo;
private System.Windows.Forms.Button buttonSpellCheckDownload;
private System.Windows.Forms.Button buttonUndo;
}
}

View File

@ -13,6 +13,19 @@ namespace Nikse.SubtitleEdit.Forms
{
public sealed partial class SpellCheck : Form
{
private class UndoObject
{
public int CurrentIndex { get; set; }
public string UndoText { get; set; }
public string UndoWord { get; set; }
public string CurrentWord { get; set; }
public Paragraph Paragraph { get; set; }
public string ParagraphBeforeText { get; set; }
public SpellCheckAction Action { get; set; }
public Subtitle Subtitle { get; set; }
}
List<UndoObject> _undoList = new List<UndoObject>();
SpellCheckAction _action = SpellCheckAction.Skip;
private List<string> _suggestions;
private string _currentAction = null;
@ -207,6 +220,11 @@ namespace Nikse.SubtitleEdit.Forms
Utilities.ShowHelp("#spellcheck");
e.SuppressKeyPress = true;
}
if (e.Modifiers == Keys.Control && e.KeyCode == Keys.G)
{
e.SuppressKeyPress = true;
System.Diagnostics.Process.Start("http://www.google.com/search?q=" + Utilities.UrlEncode(textBoxWord.Text));
}
}
private void ButtonAbortClick(object sender, EventArgs e)
@ -217,6 +235,7 @@ namespace Nikse.SubtitleEdit.Forms
private void ButtonChangeClick(object sender, EventArgs e)
{
PushUndo(string.Format("{0}: {1}", Configuration.Settings.Language.SpellCheck.Change, _currentWord + " > " + textBoxWord.Text), SpellCheckAction.Change);
DoAction(SpellCheckAction.Change);
}
@ -231,11 +250,13 @@ namespace Nikse.SubtitleEdit.Forms
private void ButtonSkipAllClick(object sender, EventArgs e)
{
PushUndo(string.Format("{0}: {1}", Configuration.Settings.Language.SpellCheck.SkipAll, textBoxWord.Text), SpellCheckAction.SkipAll);
DoAction(SpellCheckAction.SkipAll);
}
private void ButtonSkipOnceClick(object sender, EventArgs e)
{
PushUndo(string.Format("{0}: {1}", Configuration.Settings.Language.SpellCheck.SkipOnce, textBoxWord.Text), SpellCheckAction.Skip);
DoAction(SpellCheckAction.Skip);
}
@ -313,6 +334,7 @@ namespace Nikse.SubtitleEdit.Forms
private void ButtonChangeAllClick(object sender, EventArgs e)
{
PushUndo(string.Format("{0}: {1}", Configuration.Settings.Language.SpellCheck.ChangeAll, _currentWord + " > " + textBoxWord.Text), SpellCheckAction.ChangeAll);
DoAction(SpellCheckAction.ChangeAll);
}
@ -335,6 +357,7 @@ namespace Nikse.SubtitleEdit.Forms
private void ButtonAddToNamesClick(object sender, EventArgs e)
{
PushUndo(string.Format("{0}: {1}", Configuration.Settings.Language.SpellCheck.AddToNamesAndIgnoreList, textBoxWord.Text), SpellCheckAction.AddToNamesEtc);
DoAction(SpellCheckAction.AddToNamesEtc);
}
@ -778,8 +801,8 @@ namespace Nikse.SubtitleEdit.Forms
if (SplitChars.Contains(s.Substring(i, 1)))
{
if (sb.Length > 0)
list.Add(new SpellCheckWord() { Text = sb.ToString(), Index = i-sb.Length } );
sb = new StringBuilder ();
list.Add(new SpellCheckWord() { Text = sb.ToString(), Index = i - sb.Length });
sb = new StringBuilder();
}
else
{
@ -1133,5 +1156,96 @@ namespace Nikse.SubtitleEdit.Forms
ComboBoxDictionariesSelectedIndexChanged(null, null);
}
private void PushUndo(string text, SpellCheckAction action)
{
return;
//if (text.Trim().Length > 0)
//{
// if (action == SpellCheckAction.ChangeAll && _changeAllDictionary.ContainsKey(_currentWord))
// return;
// _undoList.Add(new UndoObject()
// {
// CurrentIndex = _currentIndex,
// UndoText = text,
// UndoWord = textBoxWord.Text.Trim(),
// Action = action,
// Paragraph = _currentParagraph,
// ParagraphBeforeText = _currentParagraph.Text,
// CurrentWord = _currentWord,
// Subtitle = new Subtitle(_subtitle),
// });
// buttonUndo.Text = string.Format("Undo: {0}", text);
// buttonUndo.Visible = true;
//}
}
private void buttonUndo_Click(object sender, EventArgs e)
{
if (_undoList.Count > 0)
{
var undo = _undoList[_undoList.Count - 1];
_currentIndex = undo.CurrentIndex - 1;
switch (undo.Action)
{
case SpellCheckAction.Change:
break;
case SpellCheckAction.ChangeAll:
_changeAllDictionary.Remove(undo.CurrentWord);
break;
case SpellCheckAction.Skip:
break;
case SpellCheckAction.SkipAll:
_skipAllList.Remove(undo.UndoWord.ToUpper());
if (undo.UndoWord.EndsWith("'") || undo.UndoWord.StartsWith("'"))
_skipAllList.Remove(undo.UndoWord.ToUpper().Trim('\''));
break;
case SpellCheckAction.AddToDictionary:
_userWordList.Remove(undo.UndoWord);
_userPhraseList.Remove(undo.UndoWord);
//Utilities.RemoveFromUserDictionary(undo.UndoWord, _languageName);
break;
case SpellCheckAction.AddToNamesEtc:
if (ChangeWord.Length > 1 && !_namesEtcList.Contains(ChangeWord))
{
_namesEtcList.Add(ChangeWord);
_namesEtcListUppercase.Add(ChangeWord.ToUpper());
if (_languageName.StartsWith("en_") && !ChangeWord.ToLower().EndsWith("s"))
{
_namesEtcList.Add(ChangeWord + "s");
_namesEtcListUppercase.Add(ChangeWord.ToUpper() + "S");
}
if (!ChangeWord.ToLower().EndsWith("s"))
{
_namesEtcListWithApostrophe.Add(ChangeWord + "'s");
_namesEtcListUppercase.Add(ChangeWord.ToUpper() + "'S");
}
if (!ChangeWord.EndsWith("'"))
_namesEtcListWithApostrophe.Add(ChangeWord + "'");
Utilities.AddWordToLocalNamesEtcList(ChangeWord, _languageName);
}
break;
case SpellCheckAction.ChangeWholeText:
_mainWindow.ShowStatus(string.Format(Configuration.Settings.Language.Main.SpellCheckChangedXToY, _currentParagraph.Text.Replace(Environment.NewLine, " "), ChangeWholeText.Replace(Environment.NewLine, " ")));
_currentParagraph.Text = ChangeWholeText;
_mainWindow.ChangeWholeTextMainPart(ref _noOfChangedWords, ref _firstChange, _currentIndex, _currentParagraph);
break;
default:
break;
}
_undoList.RemoveAt(_undoList.Count - 1);
if (_undoList.Count > 0)
{
buttonUndo.Text = _undoList[_undoList.Count - 1].UndoText;
}
else
{
buttonUndo.Visible = false;
}
}
PrepareNextWord();
}
}
}

View File

@ -112,12 +112,12 @@
<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>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.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>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>