private static string UiaGetText(BaseProdControl control) { string ret = ValuePatternHelper.GetValue(control.UIAElement); LogController.ReceiveLogMessage(new LogMessage("String: " + ret)); return(ret); }
public void Clear() { LogText = "Cleared"; try { RegisterEvent(ValuePattern.ValueProperty); if (ReadOnly) { throw new ProdOperationException("Text Control is Read Only"); } if (ValuePatternHelper.SetValue(UIAElement, "") == 0) { return; } if (NativeWindowHandle != IntPtr.Zero) { NativeTextProds.ClearTextNative(NativeWindowHandle); return; } /* If it doesn't have one, send keys, then */ //TODO: convert ValuePatternHelper.SendKeysSetText(UIAElement, string.Empty); } catch (ProdOperationException err) { throw; } }
private static int UiaGetLength(BaseProdControl control) { string txt = ValuePatternHelper.GetValue(control.UIAElement); int retVal = txt.Length; LogController.ReceiveLogMessage(new LogMessage("Length: " + retVal)); return(retVal); }
private static void UiaClearText(BaseProdControl control) { if (ValuePatternHelper.GetIsReadOnly(control.UIAElement)) { throw new ProdOperationException("Control is Read Only"); } //currently the verification is done in pattern helper ValuePatternHelper.SetValue(control.UIAElement, ""); LogController.ReceiveLogMessage(new LogMessage("Clear Text")); }
private static void UiaAppendText(BaseProdControl control, string newText) { if (ValuePatternHelper.GetIsReadOnly(control.UIAElement)) { throw new ProdOperationException("Control is Read Only"); } AutomationEventVerifier.Register(new EventRegistrationMessage(control, ValuePattern.ValueProperty)); LogController.ReceiveLogMessage(new LogMessage("Appending: " + newText)); ValuePatternHelper.AppendValue(control.UIAElement, newText); }
public string GetText() { string ret = ValuePatternHelper.GetValue(UIAElement); if (ret == null && UIAElement.Current.NativeWindowHandle != 0) { ret = NativeTextProds.GetTextNative(NativeWindowHandle); } LogText = "Text: " + ret; LogMessage(); return(ret); }
/// <summary> /// Gets the read only state of the control. /// </summary> /// <param name="extension">The extension.</param> /// <param name="control">The control.</param> /// <returns> /// <c>true</c> if in a ReadOnly state; otherwise, <c>false</c>. /// </returns> public static bool GetReadOnlyHook(this ValueAdapter extension, BaseProdControl control) { try { return(ValuePatternHelper.GetIsReadOnly(control.UIAElement)); } catch (ArgumentNullException err) { throw new ProdOperationException(err); } catch (ElementNotAvailableException err) { throw new ProdOperationException(err); } catch (InvalidOperationException err) { //Note: Native throw new ProdOperationException(err); } }
/// <summary> /// Gets the text currently contained in a text area /// </summary> /// <param name="controlHandle">NativeWindowHandle to the target control</param> /// <returns> /// Text contained in text area /// </returns> /// <exception cref="ProdOperationException">Examine inner exception</exception> /// <remarks> /// This overload is invalid for WPF controls /// </remarks> public static string GetText(IntPtr controlHandle) { try { AutomationElement control = AutomationElement.FromHandle(controlHandle); control.GetCurrentPattern(ValuePattern.Pattern); string ret = ValuePatternHelper.GetValue(control); return(ret ?? NativeTextProds.GetTextNative(controlHandle)); } catch (InvalidOperationException err) { throw new ProdOperationException(err.Message, err); } catch (ElementNotAvailableException err) { throw new ProdOperationException(err.Message, err); } catch (ArgumentException err) { throw new ProdOperationException(err.Message, err); } }
public void SetText(string text) { LogText = "Text: " + text; try { RegisterEvent(ValuePattern.ValueProperty); if (ReadOnly) { throw new ProdOperationException("Text Control is Read Only"); } if (ValuePatternHelper.SetValue(UIAElement, text) == 0) { return; } /* If control has a handle, use native method */ if (UIAElement.Current.NativeWindowHandle != 0) { if (NativeTextProds.SetTextNative(NativeWindowHandle, text)) { return; } } /* If it doesn't have one, send keys, then */ //TODO: convert ValuePatternHelper.SendKeysSetText(UIAElement, text); } catch (ProdOperationException err) { throw; } }
/// <summary> /// Set text area value to an empty string /// </summary> /// <param name="controlHandle">NativeWindowHandle to the target control</param> /// <exception cref="ProdOperationException">Examine inner exception</exception> public static void ClearText(IntPtr controlHandle) { if (GetReadOnly(controlHandle)) { throw new ProdOperationException("TextBox is Read Only"); } try { ValuePatternHelper.SetValue(AutomationElement.FromHandle(controlHandle), string.Empty); } catch (InvalidOperationException err) { throw new ProdOperationException(err.Message, err); } catch (ElementNotAvailableException err) { throw new ProdOperationException(err.Message, err); } catch (ArgumentException err) { throw new ProdOperationException(err.Message, err); } }
private static void UiaSetText(BaseProdControl control, string text) { LogController.ReceiveLogMessage(new LogMessage(text)); AutomationEventVerifier.Register(new EventRegistrationMessage(control, ValuePattern.ValueProperty)); ValuePatternHelper.SetValue(control.UIAElement, text); }
private static void UiaInsertText(BaseProdControl control, string newText, int index) { LogController.ReceiveLogMessage(new LogMessage("inserting " + newText)); AutomationEventVerifier.Register(new EventRegistrationMessage(control, ValuePattern.ValueProperty)); ValuePatternHelper.InsertValue(control.UIAElement, newText, index); }