Exemplo n.º 1
0
        private string OfficeWordImlaDuzeltme(string Cumle)
        {
            var wordApplication = new Microsoft.Office.Interop.Word.Application()
            {
                Visible = false
            };
            string retVal = "";

            var myDocument = wordApplication.Documents.Open(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\myDoc.docx");

            List <string> temp     = new List <string>();
            var           language = wordApplication.Languages[WdLanguageID.wdTurkish];

            // http://support.microsoft.com/kb/292108
            // http://www.delphigroups.info/2/c2/261707.html
            const string custDict = "custom.dic";

            var suggestions = wordApplication.GetSpellingSuggestions(Cumle, custDict, MainDictionary: language.Name);

            foreach (SpellingSuggestion spellingSuggestion in suggestions)
            {
                temp.Add(spellingSuggestion.Name);
            }
            object obj = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;

            myDocument.Close(ref obj);
            wordApplication.Quit(ref obj);

            if (temp.Count <= 0)
            {
                retVal = "Unspelled";
            }
            else
            {
                retVal = temp[0].ToString();
            }
            return(retVal);
        }
Exemplo n.º 2
0
        private void ShowNextSpellingError()
        {
            listBoxSuggestions.Items.Clear();
            if (_currentSpellCollection != null && _currentSpellCollection.Count > 0)
            {
                _currentSpellCollectionIndex++;
                if (_currentSpellCollectionIndex < _currentSpellCollection.Count)
                {
                    var spell = _currentSpellCollection[_currentSpellCollectionIndex + 1];
                    if (_useAlwaysList.ContainsKey(spell.Text))
                    {
                        FixWord(spell.Text, _useAlwaysList[spell.Text]);
                    }
                    else if (checkBoxUseNamesEtc.Checked && _namesEtcList.Contains(spell.Text))
                    {
                        labelActionInfo.Text = "Skipping name/noise word '" + spell.Text + "'...";
                    }
                    else if (!_skipAllList.Contains(spell.Text))
                    {
                        _currentErrorText    = spell.Text;
                        _currentErrorStart   = spell.Start;
                        textBoxWord.Text     = spell.Text;
                        _currentStartIndex   = spell.Start;
                        labelActionInfo.Text = string.Empty;
                        if (spell.SpellingErrors.Count > 0)
                        {
                            labelActionInfo.Text = "Found error regarding '" + spell.Text + "'...";
                        }
                        else if (spell.GrammaticalErrors.Count > 0)
                        {
                            labelActionInfo.Text = "Found gramitical error regarding '" + spell.Text + "'...";
                        }

                        foreach (Word.SpellingSuggestion suggestion in _wordApp.GetSpellingSuggestions(spell.Text, "custom.dic", string.Empty, comboBoxDictionaries.SelectedItem))
                        {
                            listBoxSuggestions.Items.Add(suggestion.Name);
                        }

                        if (listBoxSuggestions.Items.Count > 0)
                        {
                            listBoxSuggestions.SelectedIndex = 0;
                        }

                        textBoxWord.Focus();
                        textBoxWord.SelectAll();
                        ShowActiveWordWithColor(spell.Text, spell.Start);
                        return;
                    }
                }
            }

            int index = 0;

            if (listViewSubtitle.SelectedIndices.Count > 0)
            {
                index = listViewSubtitle.SelectedIndices[0];
            }

            listViewSubtitle.Items[index].Selected = false;
            index++;
            if (index >= listViewSubtitle.Items.Count)
            {
                SpellCheckDone();
                return;
            }
            listViewSubtitle.Items[index].Selected = true;
            listViewSubtitle.EnsureVisible(index);
            DoStartSpellCheck();
        }