Пример #1
0
 private void FormSpellCheck_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         _action      = SpellCheckAction.Abort;
         DialogResult = DialogResult.Cancel;
     }
     else if (e.KeyCode == Keys.F1)
     {
         Utilities.ShowHelp("#spellcheck");
         e.SuppressKeyPress = true;
     }
     else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.G)
     {
         e.SuppressKeyPress = true;
         System.Diagnostics.Process.Start("https://www.google.com/search?q=" + Utilities.UrlEncode(textBoxWord.Text));
     }
     else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Z)
     {
         if (buttonUndo.Visible)
         {
             buttonUndo_Click(null, null);
             e.SuppressKeyPress = true;
         }
     }
 }
Пример #2
0
        public void DoAction(SpellCheckAction action)
        {
            if (_currentWord != null)
            {
                switch (action)
                {
                case SpellCheckAction.Skip:
                    string key = CurrentLineIndex + "-" + _currentWord.Text + "-" + _currentWord.Index;
                    _skipOnceList.Add(key);
                    break;

                case SpellCheckAction.SkipAll:
                    _skipAllList.Add(_currentWord.Text);
                    break;

                case SpellCheckAction.AddToDictionary:
                    _spellCheckWordLists.AddUserWord(_currentWord.Text);
                    break;

                case SpellCheckAction.AddToNames:
                    _spellCheckWordLists.AddName(_currentWord.Text);
                    break;
                }

                if (_wrongWords.Contains(_currentWord))
                {
                    IsWrongWord = false;
                    _wrongWords.Remove(_currentWord);
                    IsSpellCheckRequested = true;
                    TextChangedHighlight(this, EventArgs.Empty);
                }
            }
        }
Пример #3
0
        public void Initialize(string languageName, SpellCheckWord word, List <string> suggestions, string paragraph, string progress)
        {
            _originalWord = word.Text;
            _suggestions  = suggestions;
            groupBoxWordNotFound.Visible  = true;
            groupBoxEditWholeText.Visible = false;
            buttonEditWholeText.Text      = Configuration.Settings.Language.SpellCheck.EditWholeText;
            Text                  = Configuration.Settings.Language.SpellCheck.Title + " [" + languageName + "] - " + progress;
            textBoxWord.Text      = word.Text;
            textBoxWholeText.Text = paragraph;
            listBoxSuggestions.Items.Clear();
            foreach (string suggestion in suggestions)
            {
                listBoxSuggestions.Items.Add(suggestion);
            }
            if (listBoxSuggestions.Items.Count > 0)
            {
                listBoxSuggestions.SelectedIndex = 0;
            }

            richTextBoxParagraph.Text = paragraph;

            FillSpellCheckDictionaries(languageName);
            ShowActiveWordWithColor(word);
            _action      = SpellCheckAction.Skip;
            DialogResult = DialogResult.None;
        }
        private void PushUndo(string text, SpellCheckAction action, string word)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            if (action == SpellCheckAction.ChangeAll && _changeAllDictionary.ContainsKey(_currentWord))
                return;

            string format = Configuration.Settings.Language.SpellCheck.UndoX;
            if (string.IsNullOrEmpty(format))
                format = "Undo: {0}";
            string undoText = string.Format(format, text);

            _undoList.Add(new UndoObject
                {
                    CurrentIndex = _currentParagraphIndex,
                    UndoText = undoText,
                    UndoWord = word,
                    Action = action,
                    CurrentWord = _currentWord,
                    Subtitle = new Subtitle(_subtitle),
                    NoOfChangedWords = _noOfChangedWords,
                    NoOfAddedWords = _noOfAddedWords,
                });
            Window.SetUndoButton(false, undoText);
        }
Пример #5
0
        private void PushUndo(string text, SpellCheckAction action)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            if (action == SpellCheckAction.ChangeAll && _changeAllDictionary.ContainsKey(_currentWord))
            {
                return;
            }

            string format = Configuration.Settings.Language.SpellCheck.UndoX;

            if (string.IsNullOrEmpty(format))
            {
                format = "Undo: {0}";
            }
            string undoText = string.Format(format, text);

            _undoList.Add(new UndoObject
            {
                CurrentIndex     = _currentIndex,
                UndoText         = undoText,
                UndoWord         = textBoxWord.Text.Trim(),
                Action           = action,
                CurrentWord      = _currentWord,
                Subtitle         = new Subtitle(_subtitle),
                NoOfSkippedWords = _noOfSkippedWords,
                NoOfChangedWords = _noOfChangedWords,
                NoOfCorrectWords = _noOfCorrectWords,
                NoOfNamesEtc     = _noOfNamesEtc,
                NoOfAddedWords   = _noOfAddedWords,
            });
            buttonUndo.Text    = undoText;
            buttonUndo.Visible = true;
        }
Пример #6
0
        public void DoAction(SpellCheckAction action)
        {
            switch (action)
            {
                case SpellCheckAction.Change:
                    _noOfChangedWords++;
                    _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange);
                    break;
                case SpellCheckAction.ChangeAll:
                    _noOfChangedWords++;
                    if (!_changeAllDictionary.ContainsKey(_currentWord))
                        _changeAllDictionary.Add(_currentWord, ChangeWord);
                    _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange);
                    break;
                case SpellCheckAction.Skip:
                    _noOfSkippedWords++;
                    break;
                case SpellCheckAction.SkipAll:
                    _noOfSkippedWords++;
                    _skipAllList.Add(ChangeWord.ToUpper());
                    if (ChangeWord.EndsWith("'") || ChangeWord.StartsWith("'"))
                        _skipAllList.Add(ChangeWord.ToUpper().Trim("'".ToCharArray()));
                    break;
                case SpellCheckAction.AddToDictionary:
                    if (_userWordList.IndexOf(ChangeWord) < 0)
                    {
                        _noOfAddedWords++;
                        string s = ChangeWord.Trim().ToLower();
                        if (s.Contains(" "))
                            _userPhraseList.Add(s);
                        else
                            _userWordList.Add(s);
                        Utilities.AddToUserDictionary(s, _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;
            }
            labelActionInfo.Text = string.Empty;
            PrepareNextWord();
            CheckActions();
        }
Пример #7
0
 private void FormSpellCheck_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         _action = SpellCheckAction.Abort;
         DialogResult = DialogResult.Cancel;
     }
     else if (e.KeyCode == Keys.F1)
     {
         Utilities.ShowHelp("#spellcheck");
         e.SuppressKeyPress = true;
     }
     else 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));
     }
     else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Z)
     {
         if (buttonUndo.Visible)
         {
             buttonUndo_Click(null, null);
             e.SuppressKeyPress = true;
         }
     }
 }
Пример #8
0
        public void Initialize(string languageName, SpellCheckWord word, List<string> suggestions, string paragraph, string progress)
        {
            _originalWord = word.Text;
            _suggestions = suggestions;
            groupBoxWordNotFound.Visible = true;
            groupBoxEditWholeText.Visible = false;
            buttonEditWholeText.Text = Configuration.Settings.Language.SpellCheck.EditWholeText;
            Text = Configuration.Settings.Language.SpellCheck.Title + " [" + languageName + "] - " + progress;
            textBoxWord.Text = word.Text;
            textBoxWholeText.Text = paragraph;
            listBoxSuggestions.Items.Clear();
            foreach (string suggestion in suggestions)
            {
                listBoxSuggestions.Items.Add(suggestion);
            }
            if (listBoxSuggestions.Items.Count > 0)
                listBoxSuggestions.SelectedIndex = 0;

            richTextBoxParagraph.Text = paragraph;

            FillSpellCheckDictionaries(languageName);
            ShowActiveWordWithColor(word);
            _action = SpellCheckAction.Skip;
            DialogResult = DialogResult.None;
        }
Пример #9
0
        private void PushUndo(string text, SpellCheckAction action)
        {
            if (text.Trim().Length > 0)
            {
                if (action == SpellCheckAction.ChangeAll && _changeAllDictionary.ContainsKey(_currentWord))
                    return;

                string format = Configuration.Settings.Language.SpellCheck.UndoX;
                if (string.IsNullOrEmpty(format))
                    format = "Undo: {0}";
                string undoText = string.Format(format, text);

                _undoList.Add(new UndoObject()
                {
                    CurrentIndex = _currentIndex,
                    UndoText = undoText,
                    UndoWord = textBoxWord.Text.Trim(),
                    Action = action,
                    CurrentWord = _currentWord,
                    Subtitle = new Subtitle(_subtitle),
                    NoOfSkippedWords = _noOfSkippedWords,
                    NoOfChangedWords = _noOfChangedWords,
                    NoOfCorrectWords = _noOfCorrectWords,
                    NoOfNamesEtc = _noOfNamesEtc,
                    NoOfAddedWords = _noOfAddedWords,
                });
                buttonUndo.Text = undoText;
                buttonUndo.Visible = true;
            }
        }
Пример #10
0
        public void DoAction(SpellCheckAction action)
        {
            switch (action)
            {
            case SpellCheckAction.Change:
                _noOfChangedWords++;
                _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, _wordsIndex);
                break;

            case SpellCheckAction.ChangeAll:
                _noOfChangedWords++;
                if (!_changeAllDictionary.ContainsKey(_currentWord))
                {
                    _changeAllDictionary.Add(_currentWord, ChangeWord);
                }
                _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, -1);
                break;

            case SpellCheckAction.Skip:
                _noOfSkippedWords++;
                break;

            case SpellCheckAction.SkipAll:
                _noOfSkippedWords++;
                _skipAllList.Add(ChangeWord.ToUpper());
                if (ChangeWord.EndsWith('\'') || ChangeWord.StartsWith('\''))
                {
                    _skipAllList.Add(ChangeWord.ToUpper().Trim('\''));
                }
                break;

            case SpellCheckAction.AddToDictionary:
                if (_spellCheckWordLists.AddUserWord(ChangeWord))
                {
                    _noOfAddedWords++;
                }
                break;

            case SpellCheckAction.AddToNamesEtc:
                _spellCheckWordLists.AddName(ChangeWord);
                if (string.Compare(ChangeWord, _currentWord, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    return;     // don't prepare next word if change was more than just casing
                }
                if (ChangeWord != _currentWord)
                {
                    _changeAllDictionary.Add(_currentWord, ChangeWord);
                    _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, -1);
                }
                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;
            }
            labelActionInfo.Text = string.Empty;
            PrepareNextWord();
            CheckActions();
        }
Пример #11
0
        public void DoAction(SpellCheckAction action)
        {
            switch (action)
            {
                case SpellCheckAction.Change:
                    _noOfChangedWords++;
                    _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, _wordsIndex);
                    break;
                case SpellCheckAction.ChangeAll:
                    _noOfChangedWords++;
                    if (!_changeAllDictionary.ContainsKey(_currentWord))
                        _changeAllDictionary.Add(_currentWord, ChangeWord);
                    _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, -1);
                    break;
                case SpellCheckAction.Skip:
                    _noOfSkippedWords++;
                    break;
                case SpellCheckAction.SkipAll:
                    _noOfSkippedWords++;
                    _skipAllList.Add(ChangeWord.ToUpper());
                    if (ChangeWord.EndsWith('\'') || ChangeWord.StartsWith('\''))
                        _skipAllList.Add(ChangeWord.ToUpper().Trim('\''));
                    break;
                case SpellCheckAction.AddToDictionary:
                    if (_spellCheckWordLists.AddUserWord(ChangeWord))
                        _noOfAddedWords++;
                    break;
                case SpellCheckAction.AddToNamesEtc:
                    _spellCheckWordLists.AddName(ChangeWord);
                    if (string.Compare(ChangeWord, _currentWord, StringComparison.OrdinalIgnoreCase) != 0)
                        return; // don't prepare next word if change was more than just casing
                    if (ChangeWord != _currentWord)
                    {
                        _changeAllDictionary.Add(_currentWord, ChangeWord);
                        _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, -1);
                    }
                    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;
            }
            labelActionInfo.Text = string.Empty;
            PrepareNextWord();
            CheckActions();
        }
Пример #12
0
 private void FormSpellCheck_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         _action = SpellCheckAction.Abort;
         DialogResult = DialogResult.Cancel;
     }
     else if (e.KeyCode == Keys.F1)
     {
         Utilities.ShowHelp("#spellcheck");
         e.SuppressKeyPress = true;
     }
 }
        /// <summary>
        /// The do action.
        /// </summary>
        /// <param name="action">
        /// The action.
        /// </param>
        public void DoAction(SpellCheckAction action)
        {
            switch (action)
            {
                case SpellCheckAction.Change:
                    this._noOfChangedWords++;
                    this._mainWindow.CorrectWord(this._prefix + this.ChangeWord + this._postfix, this._currentParagraph, this._prefix + this._currentWord + this._postfix, ref this._firstChange);
                    break;
                case SpellCheckAction.ChangeAll:
                    this._noOfChangedWords++;
                    if (!this._changeAllDictionary.ContainsKey(this._currentWord))
                    {
                        this._changeAllDictionary.Add(this._currentWord, this.ChangeWord);
                    }

                    this._mainWindow.CorrectWord(this._prefix + this.ChangeWord + this._postfix, this._currentParagraph, this._prefix + this._currentWord + this._postfix, ref this._firstChange);
                    break;
                case SpellCheckAction.Skip:
                    this._noOfSkippedWords++;
                    break;
                case SpellCheckAction.SkipAll:
                    this._noOfSkippedWords++;
                    this._skipAllList.Add(this.ChangeWord.ToUpper());
                    if (this.ChangeWord.EndsWith('\'') || this.ChangeWord.StartsWith('\''))
                    {
                        this._skipAllList.Add(this.ChangeWord.ToUpper().Trim('\''));
                    }

                    break;
                case SpellCheckAction.AddToDictionary:
                    if (this._userWordList.IndexOf(this.ChangeWord) < 0)
                    {
                        this._noOfAddedWords++;
                        string s = this.ChangeWord.Trim().ToLower();
                        if (s.Contains(' '))
                        {
                            this._userPhraseList.Add(s);
                        }
                        else
                        {
                            this._userWordList.Add(s);
                        }

                        Utilities.AddToUserDictionary(s, this._languageName);
                    }

                    break;
                case SpellCheckAction.AddToNamesEtc:
                    if (this.ChangeWord.Length > 1 && !this._namesEtcList.Contains(this.ChangeWord))
                    {
                        this._namesEtcList.Add(this.ChangeWord);
                        this._namesEtcListUppercase.Add(this.ChangeWord.ToUpper());
                        if (this._languageName.StartsWith("en_") && !this.ChangeWord.EndsWith('s'))
                        {
                            this._namesEtcList.Add(this.ChangeWord + "s");
                            this._namesEtcListUppercase.Add(this.ChangeWord.ToUpper() + "S");
                        }

                        if (!this.ChangeWord.EndsWith('s'))
                        {
                            this._namesEtcListWithApostrophe.Add(this.ChangeWord + "'s");
                            this._namesEtcListUppercase.Add(this.ChangeWord.ToUpper() + "'S");
                        }

                        if (!this.ChangeWord.EndsWith('\''))
                        {
                            this._namesEtcListWithApostrophe.Add(this.ChangeWord + "'");
                        }

                        var namesList = new NamesList(Configuration.DictionariesFolder, this._languageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
                        namesList.Add(this.ChangeWord);
                    }

                    break;
                case SpellCheckAction.ChangeWholeText:
                    this._mainWindow.ShowStatus(string.Format(Configuration.Settings.Language.Main.SpellCheckChangedXToY, this._currentParagraph.Text.Replace(Environment.NewLine, " "), this.ChangeWholeText.Replace(Environment.NewLine, " ")));
                    this._currentParagraph.Text = this.ChangeWholeText;
                    this._mainWindow.ChangeWholeTextMainPart(ref this._noOfChangedWords, ref this._firstChange, this._currentIndex, this._currentParagraph);

                    break;
            }

            this.labelActionInfo.Text = string.Empty;
            this.PrepareNextWord();
            this.CheckActions();
        }
        /// <summary>
        /// The push undo.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="action">
        /// The action.
        /// </param>
        private void PushUndo(string text, SpellCheckAction action)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            if (action == SpellCheckAction.ChangeAll && this._changeAllDictionary.ContainsKey(this._currentWord))
            {
                return;
            }

            string format = Configuration.Settings.Language.SpellCheck.UndoX;
            if (string.IsNullOrEmpty(format))
            {
                format = "Undo: {0}";
            }

            string undoText = string.Format(format, text);

            this._undoList.Add(new UndoObject { CurrentIndex = this._currentIndex, UndoText = undoText, UndoWord = this.textBoxWord.Text.Trim(), Action = action, CurrentWord = this._currentWord, Subtitle = new Subtitle(this._subtitle), NoOfSkippedWords = this._noOfSkippedWords, NoOfChangedWords = this._noOfChangedWords, NoOfCorrectWords = this._noOfCorrectWords, NoOfNamesEtc = this._noOfNamesEtc, NoOfAddedWords = this._noOfAddedWords, });
            this.buttonUndo.Text = undoText;
            this.buttonUndo.Visible = true;
        }