Пример #1
0
 public void UpdateSpellCheck()
 {
     if (Variables.SpellCheck && this.SpellCheck)
     {
         SpellCheckTextBox.SpellCheck.IsEnabled = false;
         SpellCheckTextBox.Text = this.Text;
         SpellCheckTextBox.SpellCheck.IsEnabled = true;
         VelerSoftware.SZC35.Services.TextMarkerService markerService = ((VelerSoftware.SZC35.Services.TextMarkerService) this.textArea.TextView.Services.GetService(typeof(VelerSoftware.SZC35.Services.ITextMarkerService)));
         VelerSoftware.SZC35.Services.ITextMarker       marker        = null;
         int length = 0;
         markerService.RemoveAll();
         for (int i = 0; i < this.Text.Length - 1; i++)
         {
             i = SpellCheckTextBox.GetNextSpellingErrorCharacterIndex(i, System.Windows.Documents.LogicalDirection.Forward);
             if (i == -1)
             {
                 break;
             }
             length = SpellCheckTextBox.GetSpellingErrorLength(i);
             if (this.Text.Length >= (i + length + 2))
             {
                 if (this.Text.Substring(i + length, 2) != ")%" && this.Text.Substring(i + length, 1) != "[")
                 {
                     if ((i >= 2 && this.Text.Substring(i - 2, 2) == "%(") || (i >= 1 && this.Text.Substring(i - 1, 1) == "="))
                     {
                         SpellCheckTextBox.GetSpellingError(i).IgnoreAll();
                     }
                     else
                     {
                         marker             = markerService.Create(i, length);
                         marker.MarkerColor = System.Windows.Media.Colors.Red;
                         marker.MarkerType  = Services.TextMarkerType.SquigglyUnderline;
                     }
                 }
                 else
                 {
                     SpellCheckTextBox.GetSpellingError(i).IgnoreAll();
                 }
             }
             else
             {
                 marker             = markerService.Create(i, length);
                 marker.MarkerColor = System.Windows.Media.Colors.Red;
                 marker.MarkerType  = Services.TextMarkerType.SquigglyUnderline;
             }
             i += length;
         }
     }
     else
     {
         if (SpellCheckTextBox.SpellCheck.IsEnabled)
         {
             SpellCheckTextBox.SpellCheck.IsEnabled = false;
             SpellCheckTextBox.Text = "";
             ((VelerSoftware.SZC35.Services.TextMarkerService) this.textArea.TextView.Services.GetService(typeof(VelerSoftware.SZC35.Services.ITextMarkerService))).RemoveAll();
         }
     }
 }
Пример #2
0
        private static List <string> getSuggestions(List <string> alltext)
        {
            System.Windows.Controls.TextBox wpfTextBox = new System.Windows.Controls.TextBox();
            wpfTextBox.AcceptsReturn        = true;
            wpfTextBox.AcceptsTab           = true;
            wpfTextBox.SpellCheck.IsEnabled = true;


            List <string> suggestions = new List <string>();

            foreach (var ttt in alltext)
            {
                int index = 0;
                wpfTextBox.Text = ttt;

                Dictionary <int, string> spellingErrors = new Dictionary <int, string>();


                while ((index = wpfTextBox.GetNextSpellingErrorCharacterIndex(index, System.Windows.Documents.LogicalDirection.Forward)) != -1)
                {
                    string currentError = wpfTextBox.Text.Substring(index,
                                                                    wpfTextBox.GetSpellingErrorLength(index));
                    spellingErrors.Add(index, currentError);
                    index += currentError.Length;
                }



                int           caretIndex = wpfTextBox.CaretIndex;
                SpellingError spellingError;



                spellingError = wpfTextBox.GetSpellingError(caretIndex);



                if (spellingError == null)
                {
                    suggestions.Add(ttt);
                }
            }



            //while ((index =wpfTextBox.GetNextSpellingErrorCharacterIndex(index, System.Windows.Documents.LogicalDirection.Forward)) !=-1)
            //{
            //    string currentError = wpfTextBox.Text.Substring(index, wpfTextBox.GetSpellingErrorLength(index));
            //    suggestions.Add(currentError);

            //    foreach (string suggestion in wpfTextBox.GetSpellingError(index).Suggestions)
            //    {
            //        suggestions.Add(suggestion);
            //    }
            //})
            return(suggestions);
        }
Пример #3
0
        private static string checkone(string text)
        {
            System.Windows.Controls.TextBox wpfTextBox = new System.Windows.Controls.TextBox();
            wpfTextBox.AcceptsReturn        = true;
            wpfTextBox.AcceptsTab           = true;
            wpfTextBox.SpellCheck.IsEnabled = true;


            List <string> suggestions = new List <string>();


            wpfTextBox.Text = text;

            int index = 0;

            Dictionary <int, string> spellingErrors = new Dictionary <int, string>();

            while ((index = wpfTextBox.GetNextSpellingErrorCharacterIndex(index, System.Windows.Documents.LogicalDirection.Forward)) != -1)
            {
                string currentError = wpfTextBox.Text.Substring(index,
                                                                wpfTextBox.GetSpellingErrorLength(index));

                spellingErrors.Add(index, currentError);
                index += currentError.Length;
            }



            int           caretIndex = wpfTextBox.CaretIndex;
            SpellingError spellingError;

            spellingError = wpfTextBox.GetSpellingError(caretIndex);

            if (spellingError == null)
            {
                return(text);
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        private static string checkone(string text)
        {
            System.Windows.Controls.TextBox wpfTextBox = new System.Windows.Controls.TextBox();
            wpfTextBox.AcceptsReturn = true;
            wpfTextBox.AcceptsTab = true;
            wpfTextBox.SpellCheck.IsEnabled = true;

            List<string> suggestions = new List<string>();

            wpfTextBox.Text = text;

            int index = 0;

            Dictionary<int, string> spellingErrors = new Dictionary<int, string>();

            while ((index = wpfTextBox.GetNextSpellingErrorCharacterIndex(index, System.Windows.Documents.LogicalDirection.Forward)) != -1)
            {
                string currentError = wpfTextBox.Text.Substring(index,
                wpfTextBox.GetSpellingErrorLength(index));

                spellingErrors.Add(index, currentError);
                index += currentError.Length;
            }

            int caretIndex = wpfTextBox.CaretIndex;
            SpellingError spellingError;

            spellingError = wpfTextBox.GetSpellingError(caretIndex);

            if (spellingError == null)
            {
                return text;
            }
            else
            {
                return null;
            }
        }
Пример #5
0
        private static List<string> getSuggestions(List<string> alltext)
        {
            System.Windows.Controls.TextBox wpfTextBox = new System.Windows.Controls.TextBox();
            wpfTextBox.AcceptsReturn = true;
            wpfTextBox.AcceptsTab = true;
            wpfTextBox.SpellCheck.IsEnabled = true;

            List<string> suggestions = new List<string>();

            foreach (var ttt in alltext)
            {

                 int index = 0;
                 wpfTextBox.Text = ttt;

                Dictionary<int,string> spellingErrors = new Dictionary<int, string>();

                while ((index = wpfTextBox.GetNextSpellingErrorCharacterIndex(index, System.Windows.Documents.LogicalDirection.Forward)) != -1)
                {
                    string currentError = wpfTextBox.Text.Substring(index,
                    wpfTextBox.GetSpellingErrorLength(index));
                    spellingErrors.Add(index, currentError);
                    index += currentError.Length;
                }

                int caretIndex = wpfTextBox.CaretIndex;
                SpellingError spellingError;

                spellingError = wpfTextBox.GetSpellingError(caretIndex);

                if (spellingError == null)
                {
                    suggestions.Add(ttt);
                }
            }

            //while ((index =wpfTextBox.GetNextSpellingErrorCharacterIndex(index, System.Windows.Documents.LogicalDirection.Forward)) !=-1)
            //{
            //    string currentError = wpfTextBox.Text.Substring(index, wpfTextBox.GetSpellingErrorLength(index));
            //    suggestions.Add(currentError);

            //    foreach (string suggestion in wpfTextBox.GetSpellingError(index).Suggestions)
            //    {
            //        suggestions.Add(suggestion);
            //    }
            //})
            return suggestions;
        }