Пример #1
0
        private void findNextButton_Click(object sender, EventArgs e)
        {
            TypingArea currentTextArea = TabControlMethods.CurrentTextArea;

            //Check if the current string hasn't been search last turns
            if (previousText != currentTextArea.Text)
            {
                previousText = currentTextArea.Text;

                textsFound.Clear();
                textsFound = currentTextArea.FindAll(searchTextbox.Text);
            }

            if (textsFound.Count != 0)
            {
                if (searchTextbox.Text.Length == 0)
                {
                    return;
                }

                indexOfSearchText++;
                if (indexOfSearchText == textsFound.Count)
                {
                    indexOfSearchText = 0;
                }

                //Each every text found next will be highlighted
                currentTextArea.Select(textsFound[indexOfSearchText], searchTextbox.Text.Length);
            }

            currentTextArea.Focus();
        }
Пример #2
0
        private void findPreviousButton_Click(object sender, EventArgs e)
        {
            TypingArea currentTextArea = TabControlMethods.CurrentTextArea;

            if (previousText != currentTextArea.Text)
            {
                previousText = currentTextArea.Text;

                textsFound.Clear();
                textsFound = currentTextArea.FindAll(searchTextbox.Text);
            }

            if (textsFound.Count != 0)
            {
                if (searchTextbox.Text.Length == 0)
                {
                    return;
                }

                indexOfSearchText--;
                if (indexOfSearchText <= -1)
                {
                    indexOfSearchText = textsFound.Count - 1;
                }

                //Each every text found privous will be highlighted
                currentTextArea.Select(textsFound[indexOfSearchText], searchTextbox.Text.Length);
            }

            currentTextArea.Focus();
        }
Пример #3
0
        private void replaceButton_Click(object sender, EventArgs e)
        {
            TypingArea currentTextArea = TabControlMethods.CurrentTextArea;

            currentTextArea.Focus();

            //Check if this string has been replaced or this string has nothing
            if (indexOfSearchText == -1 || searchTextbox.Text.Equals(replacementTextbox.Text) || currentTextArea.SelectionLength == 0)
            {
                return;
            }

            //We might changed or do something with the text so we need to get this again
            textsFound.Clear();
            textsFound = currentTextArea.FindAll(searchTextbox.Text);

            currentTextArea.Select(textsFound[indexOfSearchText], searchTextbox.Text.Length);

            //Make it be replaced
            currentTextArea.SelectedText = replacementTextbox.Text;

            //just select for nothing much
            currentTextArea.Select(textsFound[indexOfSearchText], replacementTextbox.Text.Length);
        }
Пример #4
0
        private void replaceAllButton_Click(object sender, EventArgs e)
        {
            //Check if this string has been replaced or this string has nothing
            if (searchTextbox.Text.Equals(replacementTextbox.Text))
            {
                return;
            }

            TypingArea currentTextArea = TabControlMethods.CurrentTextArea;

            //Replace all the selected found text by replacement text
            string textToReplace = currentTextArea.Text.Replace(searchTextbox.Text, replacementTextbox.Text);

            currentTextArea.Select(0, currentTextArea.TextLength);
            currentTextArea.Text = currentTextArea.Text.Replace(searchTextbox.Text, replacementTextbox.Text);
        }