Select() public method

public Select ( ) : void
return void
Ejemplo n.º 1
0
        /// --------------------------------------------------------------------
        /// <summary>
        ///     Gets the enclosing element of the target selection.
        /// </summary>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">Event arguments.</param>
        /// --------------------------------------------------------------------
        private void GetEnclosingElement_Click(object sender, RoutedEventArgs e)
        {
            // Obtain the enclosing element.
            AutomationElement enclosingElement;
            try
            {
                enclosingElement = _searchRange.GetEnclosingElement();
            }
            catch (ElementNotAvailableException)
            {
                // TODO: error handling.
                return;
            }

            // Assemble the information about the enclosing element.
            var enclosingElementInformation = new StringBuilder();
            enclosingElementInformation.Append(
                "Enclosing element:\t").AppendLine(
                    enclosingElement.Current.ControlType.ProgrammaticName);

            // The WPF target doesn't show selected text as highlighted unless
            // the window has focus.
            _targetWindow.SetFocus();

            // Display the enclosing element information in the client.
            _targetSelectionDetails.Text = enclosingElementInformation.ToString();

            // Is the enclosing element the entire document?
            // If so, select the document.
            if (enclosingElement == _targetDocument)
            {
                _documentRange = _targetTextPattern.DocumentRange;
                _documentRange.Select();
                return;
            }
            // Otherwise, select the range from the child element.
            var childRange =
                _documentRange.TextPattern.RangeFromChild(enclosingElement);
            childRange.Select();
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------------
        // Wrapper for TextPatternRange.Select Method
        //---------------------------------------------------------------------------
        internal void Range_Select(TextPatternRange callingRange, Type expectedException, CheckType checkType)
        {
            string call = "TextPatternRange.Select()";
            Comment("---Calling " + call);

            if (callingRange == null)
                throw new ArgumentNullException(call + " requires non-NULL TextPatterncallingRange");

            try
            {
                callingRange.Select();
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(expectedException, actualException, call, checkType);
                return;
            }
            TestNoExceptionQuiet(expectedException, call, checkType);
        }