Пример #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 void richTextBox1_MouseUp(object sender, MouseEventArgs e)
 {
     //MessageBox.Show("test");
     if (e.Button != System.Windows.Forms.MouseButtons.Right)
     {
         return;
     }
     //if ((e.Button & System.Windows.Forms.MouseButtons.Right) != System.Windows.Forms.MouseButtons.None)
     try
     {
         int i = 1;
         //int i = richTextBox1.Text.LastIndexOf(' ', 0, richTextBox1.SelectionStart);
         i = findprevspace(richTextBox1.Text, richTextBox1.SelectionStart);
         if (i == -1)
         {
             i = 0;
         }
         i++;
         //if (i > 0)
         {
             //SpellingError SE = T.GetSpellingError(richTextBox1.SelectionStart);
             SpellingError SE    = T.GetSpellingError(i);
             bool          error = T.GetSpellingErrorStart(i) >= 0;
             if (error)
             {
                 //MessageBox.Show(SE.Suggestions.ToArray()[0]);
                 string   S  = "";
                 string[] SG = SE.Suggestions.ToArray();
                 contextMenuStrip1.Items.Clear();
                 if (SG.Length > 0)
                 {
                     S = SG[0];
                     for (int j = 1; j < SG.Length; j++)
                     {
                         //S = S + "\n" + SG[j];
                         contextMenuStrip1.Items.Add(SG[j]);
                     }
                 }
                 contextMenuStrip1.Show(Cursor.Position);
                 //toolTip1.Show("Spelling suggestions:"+S,this,2000);
                 //toolTip1.AutomaticDelay = 1000000;
                 //toolTip1.SetToolTip(richTextBox1, "Spelling suggestions:\n" + S);
                 //toolTip1.Show("Spelling suggestions:" + S, this, 10000);
             }
             else
             {
                 //toolTip1.SetToolTip(richTextBox1, null);
             }
         }
     }
     catch
     {
     }
 }
Пример #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 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;
            }
        }
Пример #6
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;
        }