Exemplo n.º 1
0
        /// <summary>
        /// Highlights words in the exmaple DecoratortextBox.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The key event arguments</param>
        private void ExampleDecoratorTextBox_EnterPressed(object sender, KeyEventArgs e)
        {
            List <HighlightSection> terms = new List <HighlightSection>();

            string[] words        = this.ExampleDecoratorTextBox.Text.Split(' ');
            int      wordTicker   = 0;
            int      charPosition = 0;

            for (int i = 1; i <= words.Length; i++)
            {
                wordTicker = wordTicker >= 4 == true ? 1 : wordTicker + 1;

                HighlightSection t;

                if (wordTicker == 1)
                {
                    t = new HighlightSection(charPosition, true, words[i - 1].Length);
                    terms.Add(t);
                }
                else if (wordTicker == 3)
                {
                    t = new HighlightSection(charPosition, false, words[i - 1].Length);
                    terms.Add(t);
                }

                charPosition = charPosition + words[i - 1].Length + 1;
            }

            this.ExampleDecoratorTextBox.MatchingTermItemsSource = terms;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Highlights words in the exmaple DecoratortextBox.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The key event arguments</param>
        private void ExampleDecoratorTextBox_EnterPressed(object sender, KeyEventArgs e)
        {
            List<HighlightSection> terms = new List<HighlightSection>();
            string[] words = this.ExampleDecoratorTextBox.Text.Split(' ');
            int wordTicker = 0;
            int charPosition = 0;
            for (int i = 1; i <= words.Length; i++)
            {
                wordTicker = wordTicker >= 4 == true ? 1 : wordTicker + 1;

                HighlightSection t;

                if (wordTicker == 1)
                {
                    t = new HighlightSection(charPosition, true, words[i - 1].Length);
                    terms.Add(t);
                }
                else if (wordTicker == 3)
                {
                    t = new HighlightSection(charPosition, false, words[i - 1].Length);
                    terms.Add(t);
                }

                charPosition = charPosition + words[i - 1].Length + 1;
            }

            this.ExampleDecoratorTextBox.MatchingTermItemsSource = terms;
        }