/// <summary> /// Sets the <see cref="ToggleState"/>. /// </summary> /// <param name="extension">The extended interface.</param> /// <param name="control">The UI Automation element</param> /// <param name="checkstate">The <see cref="ToggleState"/>.</param> public static void SetToggleStateHook(this ToggleAdapter extension, BaseProdControl control, ToggleState checkstate) { try { UiaSetToggleState(control, checkstate); } catch (ArgumentNullException err) { throw new ProdOperationException(err); } catch (ElementNotAvailableException err) { throw new ProdOperationException(err); } catch (InvalidOperationException) { NativeSetToggleState(control, checkstate); } }
/// <summary> /// Gets the current <see cref="ToggleState"/>. /// </summary> /// <param name="extension">The extended interface.</param> /// <param name="control">The UI Automation element</param> /// <returns>The current <see cref="ToggleState"/></returns> public static ToggleState GetToggleStateHook(this ToggleAdapter extension, BaseProdControl control) { try { return(UiaGetToggleState(control)); } catch (ArgumentNullException err) { throw new ProdOperationException(err); } catch (ElementNotAvailableException err) { throw new ProdOperationException(err); } catch (InvalidOperationException) { return(NativeGetToggleState(control)); } }