/// <summary>
        /// Sets the current value of the UI Automation element
        /// </summary>
        /// <param name="control">The UI Automation element.</param>
        /// <param name="value">The value to set the control to.</param>
        internal static void SetValue(AutomationElement control, double value)
        {
            RangeValuePattern pattern = (RangeValuePattern)CommonUIAPatternHelpers.CheckPatternSupport(RangeValuePattern.Pattern, control);

            pattern.SetValue(value);
            ValueVerifier <double, double> .Verify(value, GetValue(control));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the TextBox value to the supplied value, overwriting any existing text
        /// </summary>
        /// <param name="control">The UI Automation element</param>
        /// <param name="text">Text to set Textbox value to</param>
        internal static void SetValue(AutomationElement control, string text)
        {
            ValuePattern pattern = (ValuePattern)CommonUIAPatternHelpers.CheckPatternSupport(ValuePattern.Pattern, control);

            pattern.SetValue(text);

            ValueVerifier <string, string> .Verify(text, GetValue(control));
        }
 /// <summary>
 /// Sets state of toggle control
 /// </summary>
 /// <param name="control">The UI Automation element</param>
 /// <param name="toggleState">The current <see cref="System.Windows.Automation.ToggleState"/>ToggleState</param>
 internal static void SetToggleState(AutomationElement control, ToggleState toggleState)
 {
     /* Only need to change it if it needs-a-changin' */
     if (GetToggleState(control) != toggleState)
     {
         TogglePattern pattern = (TogglePattern)control.GetCurrentPattern(TogglePattern.Pattern);
         pattern.Toggle();
     }
     ValueVerifier <ToggleState, ToggleState> .Verify(toggleState, GetToggleState(control));
 }
Ejemplo n.º 4
0
        /* These are for text based controls */
        /// <summary>
        /// Appends the supplied string to the existing textBox text
        /// </summary>
        /// <param name="control">The UI Automation element</param>
        /// <param name="text">Text to append to TextBox value</param>
        internal static void AppendValue(AutomationElement control, string text)
        {
            ValuePattern pattern      = (ValuePattern)CommonUIAPatternHelpers.CheckPatternSupport(ValuePattern.Pattern, control);
            string       originalText = pattern.Current.Value;
            string       appText      = originalText + text;

            pattern.SetValue(appText);

            ValueVerifier <string, string> .Verify(appText, pattern.Current.Value);
        }
        /// <summary>
        /// Sets the visual state of the window
        /// </summary>
        /// <param name="control">The UI Automation element</param>
        /// <param name="state">The <see cref="WindowVisualState"/> of the current window</param>
        internal static void SetVisualState(AutomationElement control, WindowVisualState state)
        {
            WindowPattern pattern = (WindowPattern)CommonUIAPatternHelpers.CheckPatternSupport(WindowPattern.Pattern, control);

            if (pattern.Current.WindowInteractionState != WindowInteractionState.ReadyForUserInteraction)
            {
                return;
            }
            SetState(state, pattern);
            ValueVerifier <WindowVisualState, WindowVisualState> .Verify(state, GetVisualState(control));
        }