/// <summary>
        /// Find TextRange via TextRangeFinder
        /// </summary>
        /// <param name="backward"></param>
        private void FindTextRange(bool backward)
        {
            //turn off hilighter
            this.Hilighter.HilightBoundingRectangles(false);

            Axe.Windows.Desktop.UIAutomation.Patterns.TextRange range = null;

            try
            {
                var attributeId = GetAttributeId();

                range = attributeId == SearchForText
                    ? this.Finder.FindText(GetAttributeValue() as string, backward, chbIgnoreCase.IsChecked ?? false)
                    : this.Finder.Find(attributeId, GetAttributeValue(), backward);

                if (range != null)
                {
                    this.Hilighter.SetBoundingRectangles(range.GetBoundingRectangles());
                    this.Hilighter.HilightBoundingRectangles(true);
                }
                else
                {
                    MessageDialog.Show(Properties.Resources.TextRangeFindDialog_FindTextRange_No_matched_range_is_found);
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception ex)
            {
                ex.ReportException();
                MessageDialog.Show(Properties.Resources.TextRangeFindDialog_FindTextRange_Please_check_value__it_may_not_be_matched_with_expected);
            }
#pragma warning restore CA1031 // Do not catch general exception types
        }
Exemple #2
0
        /// <summary>
        /// Find TextRange via TextRangeFinder
        /// </summary>
        /// <param name="backward"></param>
        private void FindTextRange(bool backward)
        {
            //turn off hilighter
            this.Hilighter.HilightBoundingRectangles(false);

            Axe.Windows.Desktop.UIAutomation.Patterns.TextRange range = null;

            try
            {
                range = this.Finder.Find(GetAttributeId(), GetAttributeValue(), backward, this.chbIgnoreCase.IsChecked.Value);

                if (range != null)
                {
                    this.Hilighter.SetBoundingRectangles(range.GetBoundingRectangles());
                    this.Hilighter.HilightBoundingRectangles(true);
                }
                else
                {
                    MessageDialog.Show(Properties.Resources.TextRangeFindDialog_FindTextRange_No_matched_range_is_found);
                }
            }
            catch (Exception ex)
            {
                ex.ReportException();
                MessageDialog.Show(Properties.Resources.TextRangeFindDialog_FindTextRange_Please_check_value__it_may_not_be_matched_with_expected);
            }
        }