Ejemplo n.º 1
0
        private void FindText_Click(object sender, RoutedEventArgs e)
        {   //FileContent and Word are xaml elements
            setCurrentText(FileContent.Text.ToLower());
            setSearchWord(Word.Text.ToLower());
            StringBuilder occurrences = new StringBuilder();
            bool          NotFound    = true;
            int           index       = 0;

            do
            {
                index = GetCurrentText().IndexOf(SearchWord, index);
                if (index != -1)
                {
                    NotFound = false;
                    occurrences.Append(" " + index + ", ");
                    index++;
                }
            } while (index != -1);

            Indexes.Clear();

            if (NotFound)
            {
                Indexes.AppendText("No Match!");
            }
            else
            {
                string repeats = occurrences.ToString();
                Indexes.AppendText(repeats);
            }


            index = 0;
        }