/// <summary> /// Sets the state of the window /// </summary> /// <param name="state">The <see cref="WindowVisualState"/> of the current window</param> /// <param name="wp">The WindowPattern of the target window.</param> private static void SetState(WindowVisualState state, WindowPattern wp) { switch (state) { case WindowVisualState.Maximized: // Confirm that the element can be maximized if ((wp.Current.CanMaximize) && !(wp.Current.IsModal)) { wp.SetWindowVisualState(WindowVisualState.Maximized); } break; case WindowVisualState.Minimized: // Confirm that the element can be minimized if ((wp.Current.CanMinimize) && !(wp.Current.IsModal)) { wp.SetWindowVisualState(WindowVisualState.Minimized); } break; case WindowVisualState.Normal: wp.SetWindowVisualState(WindowVisualState.Normal); break; default: wp.SetWindowVisualState(WindowVisualState.Normal); break; } }
private bool HookProcess() { logger.Information($"Hooking on to {ApplicationName}..."); if (mainWindowHandle != IntPtr.Zero) { logger.Information($"Already hooked {ApplicationName}!"); // Already hooked return(true); } mainWindowHandle = FindMainProcessWindow(); if (mainWindowHandle == IntPtr.Zero) { logger.Error($"Cannot find {ApplicationName}'s main window."); // Main window is lost return(false); } else { logger.Debug($"Hooked on to window handle {mainWindowHandle}"); } try { process.EnableRaisingEvents = true; process.Exited += Process_Exited; automationElement = AutomationElement.FromHandle(mainWindowHandle); Automation.AddAutomationPropertyChangedEventHandler( automationElement, TreeScope.Element, Process_VisualStateChanged, new AutomationProperty[] { WindowPattern.WindowVisualStateProperty }); logger.Debug($"Attached event handlers for {ApplicationName} window."); // If not already hidden and is currently minimised, hide immediately var isIconic = User32.IsIconic(mainWindowHandle); if (windowShown && isIconic) { logger.Information($"{ApplicationName} is already minimised, hiding now."); HideMainWindow(); } else { lastWindowVisualState = (WindowVisualState)automationElement.GetCurrentPropertyValue(WindowPattern.WindowVisualStateProperty); } logger.Debug($"Set {ApplicationName} visual state as {lastWindowVisualState}."); icon.SetMenuEnabled(true); return(true); } catch (Win32Exception) { mainWindowHandle = IntPtr.Zero; logger.Error($"No privillages to hook to {ApplicationName}."); return(false); } }
public ActionResult SetWindowState(AutomationElement window, WindowVisualState windowVisualState) { ActionResult actionResult = new ActionResult(); Object windowPattern; try { window.TryGetCurrentPattern(WindowPattern.Pattern, out windowPattern); if (windowPattern != null) { ((WindowPattern)windowPattern).SetWindowVisualState(windowVisualState); actionResult.executionInfo = "Window is " + windowVisualState; } else { actionResult.errorMessage = "Unable to " + windowVisualState + " the window"; } } catch (Exception ex) { Reporter.ToLog(eLogLevel.DEBUG, "SetWindowState", ex); actionResult.errorMessage = "Unable to " + windowVisualState + " the window"; } return(actionResult); }
private void Thunderbird_VisualStateChanged(object sender, AutomationPropertyChangedEventArgs e) { WindowVisualState visualState = WindowVisualState.Normal; try { visualState = (WindowVisualState)e.NewValue; } catch (InvalidCastException) { // ignore } log.Debug("Detected visual state change to {@visualState}.", visualState); if (visualState == WindowVisualState.Minimized) { HideThunderbird(); } else { thunderbirdShown = true; lastVisualState = visualState; } }
private static WindowVisualState UiaGetWindowVisualState(ProdWindow control) { WindowVisualState retVal = WindowPatternHelper.GetVisualState(control.UIAElement); LogController.ReceiveLogMessage(new LogMessage(retVal.ToString())); return(retVal); }
public static void SetWindowVisualState(AutomationElement window, WindowVisualState TargetState) { WindowPattern pattern = window.GetCurrentPattern(WindowPattern.Pattern) as WindowPattern; //pattern.SetWindowVisualState(WindowVisualState.Normal); pattern.SetWindowVisualState(TargetState); }
private void Process_VisualStateChanged(object sender, AutomationPropertyChangedEventArgs e) { WindowVisualState visualState = WindowVisualState.Normal; try { visualState = (WindowVisualState)e.NewValue; } catch (InvalidCastException) { // ignore } logger.Debug($"Detected {ApplicationName} visual state change to {visualState}."); if (visualState == WindowVisualState.Minimized) { HideMainWindow(); } else { windowShown = true; lastWindowVisualState = visualState; } }
private bool HookThunderbird() { log.Information("Hooking on to Thunderbird..."); if (thunderbirdProcess != null && thunderbirdMainWindowHandle != IntPtr.Zero) { log.Information("Already hooked!"); // Already hooked return(true); } thunderbirdProcess = Process.GetProcessesByName("thunderbird").FirstOrDefault(); if (thunderbirdProcess == null) { log.Error("Cannot find the Thunderbird process to hook to."); // Hook failure, process does not exist return(false); } thunderbirdMainWindowHandle = FindMainThunderbirdWindow(thunderbirdProcess); if (thunderbirdMainWindowHandle == IntPtr.Zero) { log.Error("Cannot find Thunderbird's main window."); // Main window is lost (hidden) return(false); } else { log.Debug("Hooked on to window handle {@thunderbirdMainWindowHandle}", thunderbirdMainWindowHandle); } thunderbirdProcess.EnableRaisingEvents = true; thunderbirdProcess.Exited += Thunderbird_Exited; thunderbirdAutomationElement = AutomationElement.FromHandle(thunderbirdMainWindowHandle); Automation.AddAutomationPropertyChangedEventHandler( thunderbirdAutomationElement, TreeScope.Element, Thunderbird_VisualStateChanged, new AutomationProperty[] { WindowPattern.WindowVisualStateProperty }); log.Debug("Attached event handlers for window."); // If not already hidden and is currently minimised, hide immediately var isIconic = User32.IsIconic(thunderbirdMainWindowHandle); if (thunderbirdShown && isIconic) { log.Information("Thunderbird is already minimised, hiding now. {@thunderbirdShown}, {@isIconic}.", thunderbirdShown, isIconic); HideThunderbird(); } else { lastVisualState = (WindowVisualState)thunderbirdAutomationElement.GetCurrentPropertyValue(WindowPattern.WindowVisualStateProperty); } log.Debug("Setting visual state as {@lastVisualState}.", lastVisualState); return(true); }
public void SetWindowVisualState(WindowVisualState state) { try { pattern.SetVisualState(state); } catch (Exception ex) { throw DbusExceptionTranslator.Translate(ex); } }
public void SetWindowVisualState (WindowVisualState state) { try { pattern.SetVisualState (state); } catch (Exception ex) { throw DbusExceptionTranslator.Translate (ex); } }
private void SetState(WindowVisualState state) { if (WindowManager == null) { WindowManager = DozeObject.FindObjectOfType <WindowsObject>(); } WindowManager.SetState("window-general:login", state); }
// /// ------------------------------------------------------------------- // void TS_Minimizable(bool ShouldBeMinimized, CheckType checkType) // { // if (!pattern_getCanMinimize.Equals(ShouldBeMinimized)) // ThrowMe("CanMinimize == " + pattern_getCanMinimize, checkType); // // m_TestStep++; // } /// ------------------------------------------------------------------- void TS_VerifyVisualState(WindowVisualState WindowVisualState, bool shouldBe, CheckType checkType) { if (!pattern_getVisualState.Equals(WindowVisualState).Equals(shouldBe)) { ThrowMe(checkType, TestCaseCurrentStep + ": WindowVisualState = " + pattern_getVisualState); } Comment("WindowVisualState = " + pattern_getWindowInteractionState); m_TestStep++; }
private static void HandleCanMaximizeProperty(ProxySimple el, IntPtr hwnd, int eventId) { if (eventId == NativeMethods.EventObjectLocationChange) { WindowVisualState wvs = GetWindowVisualState(hwnd); bool canMaximize = wvs != WindowVisualState.Maximized; RaisePropertyChangedEvent(el, WindowPattern.CanMaximizeProperty, canMaximize); } }
private bool SetWindowVisualState(WindowVisualState state) { _windowPattern = _window?.GetCurrentPattern(UIA_PatternIds.UIA_WindowPatternId) as IUIAutomationWindowPattern; if (_windowPattern == null) { return(false); } _windowPattern.SetWindowVisualState(state); _windowPattern.WaitWithTimeoutTill(x => x.CurrentWindowVisualState == state); return(_windowPattern.CurrentWindowVisualState == state); }
/// <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)); }
public void SetWindowVisualState(WindowVisualState state) { var num1 = (int)ActionHandler.Invoke(sender: UIObject, actionInfo: ActionEventArgs.GetDefault(action: "WaitForReady")); var num2 = (int)ActionHandler.Invoke(sender: UIObject, actionInfo: ActionEventArgs.GetDefault(action: "MakeVisible")); if (ActionHandler.Invoke(sender: UIObject, actionInfo: new ActionEventArgs(action: nameof(SetWindowVisualState), state)) != ActionResult.Unhandled) { return; } Pattern.SetWindowVisualState(state: state); }
public void SetWindowVisualState(WindowVisualState state) { try { this._pattern.SetWindowVisualState((UIAutomationClient.WindowVisualState)state); } catch (System.Runtime.InteropServices.COMException e) { Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; } } }
public void SetWindowVisualState(WindowVisualState state, bool log) { if (log) { procedureLogger.Action(string.Format("Set {0} to be {1}.", this.NameAndType, state)); } WindowPattern wp = (WindowPattern)element.GetCurrentPattern(WindowPattern.Pattern); wp.SetWindowVisualState(state); }
private void RestoreOnShow(object sender, WindowInfoEventArgs e) { WindowPlacement windowplacement = WindowPlacement.Load(this.Handle); WindowPattern windowPattern = (WindowPattern)this.AutomationElement.GetCurrentPattern(WindowPattern.Pattern); WindowVisualState visualState = ((windowplacement.Flags & WindowPlacementFlags.RestoreToMaximize) > 0) ? WindowVisualState.Maximized : WindowVisualState.Normal; windowPattern.SetWindowVisualState(visualState); this.Restored?.Invoke(sender, new WindowInfoEventArgs(this)); }
// </Snippet102> // <Snippet103> ///-------------------------------------------------------------------- /// <summary> /// Calls the WindowPattern.SetVisualState() method for an associated /// automation element. /// </summary> /// <param name="windowPattern"> /// The WindowPattern control pattern obtained from /// an automation element. /// </param> /// <param name="visualState"> /// The specified WindowVisualState enumeration value. /// </param> ///-------------------------------------------------------------------- private void SetVisualState(WindowPattern windowPattern, WindowVisualState visualState) { try { if (windowPattern.Current.WindowInteractionState == WindowInteractionState.ReadyForUserInteraction) { switch (visualState) { case WindowVisualState.Maximized: // Confirm that the element can be maximized if ((windowPattern.Current.CanMaximize) && !(windowPattern.Current.IsModal)) { windowPattern.SetWindowVisualState( WindowVisualState.Maximized); // TODO: additional processing } break; case WindowVisualState.Minimized: // Confirm that the element can be minimized if ((windowPattern.Current.CanMinimize) && !(windowPattern.Current.IsModal)) { windowPattern.SetWindowVisualState( WindowVisualState.Minimized); // TODO: additional processing } break; case WindowVisualState.Normal: windowPattern.SetWindowVisualState( WindowVisualState.Normal); break; default: windowPattern.SetWindowVisualState( WindowVisualState.Normal); // TODO: additional processing break; } } } catch (InvalidOperationException) { // object is not able to perform the requested action return; } }
internal void pattern_SetWindowVisualState(WindowVisualState state, Type expectedException, CheckType checkType) { string call = "SetWindowVisualState(" + state + ")"; try { m_pattern.SetWindowVisualState(state); } catch (Exception actualException) { TestException(expectedException, actualException, call, checkType); return; } TestNoException(expectedException, call, checkType); }
private void OnVisualStateChange(object sender, AutomationPropertyChangedEventArgs e) { WindowVisualState visualState = WindowVisualState.Normal; try { visualState = (WindowVisualState)e.NewValue; } catch (InvalidCastException) { // ignore } WindowStateChange?.Invoke(this, new WindowStateChangeEventArgs((WindowState)visualState)); }
public static bool IsMinimized(IntPtr ptr) { AutomationElement ae = AutomationElement.FromHandle(ptr); object windowPattern = null; if (ae.TryGetCurrentPattern(WindowPattern.Pattern, out windowPattern)) { WindowVisualState state = ((WindowPattern)windowPattern).Current.WindowVisualState; if (state == WindowVisualState.Minimized) { return(true); } } return(false); }
public override void RaiseAutomationPropertyChangedEvent(AutomationPropertyChangedEventArgs e) { if (fakeLabel != null && balloonWindow && e.Property == AutomationElementIdentifiers.NameProperty) { fakeLabel.RaiseAutomationPropertyChangedEvent(e); } else if (e.Property == TransformPatternIdentifiers.CanResizeProperty) { NotifyStateChange(Atk.StateType.Resizable, (bool)e.NewValue); } else if (e.Property == WindowPatternIdentifiers.WindowVisualStateProperty) { WindowVisualState newValue = (WindowVisualState)e.NewValue; if (newValue == WindowVisualState.Maximized) { EmitSignal("maximize"); } else if (newValue == WindowVisualState.Minimized) { EmitSignal("minimize"); } else // Back to Normal, so is Restored { EmitSignal("restore"); } } else if (e.Property == AutomationElementIdentifiers.BoundingRectangleProperty) { Rect oldValue = (Rect)e.OldValue; Rect newValue = (Rect)e.NewValue; if (oldValue.X != newValue.X || oldValue.Y != newValue.Y) { EmitSignal("move"); } if (oldValue.Width != newValue.Width || oldValue.Height != newValue.Height) { EmitSignal("resize"); } base.RaiseAutomationPropertyChangedEvent(e); } else { base.RaiseAutomationPropertyChangedEvent(e); } }
//------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods private void OnStateChange(IntPtr hwnd, int idObject, int idChild) { NativeMethods.HWND nativeHwnd = NativeMethods.HWND.Cast(hwnd); // Ignore windows that have been destroyed if (!SafeNativeMethods.IsWindow(nativeHwnd)) { return; } AutomationElement rawEl = AutomationElement.FromHandle(hwnd); // Raise this event only for elements with the WindowPattern. object patternObject; if (!rawEl.TryGetCurrentPattern(WindowPattern.Pattern, out patternObject)) { return; } Object windowVisualState = rawEl.GetPatternPropertyValue(WindowPattern.WindowVisualStateProperty, false); // if has no state value just return if (!(windowVisualState is WindowVisualState)) { return; } WindowVisualState state = (WindowVisualState)windowVisualState; // Filter... avoid duplicate events if (hwnd == _lastHwnd && state == _lastState) { return; } AutomationPropertyChangedEventArgs e = new AutomationPropertyChangedEventArgs( WindowPattern.WindowVisualStateProperty, null, state); ClientEventManager.RaiseEventInThisClientOnly(AutomationElement.AutomationPropertyChangedEvent, rawEl, e); // save the last hwnd/rect for filtering out duplicates _lastHwnd = hwnd; _lastState = state; }
/// <summary> /// IWindowProvider implementation. /// </summary> /// <param name="state">The visual state of the window to change to.</param> public void SetVisualState(WindowVisualState state) { switch (state) { case WindowVisualState.Maximized: this.OwnerAsRadWindow().WindowState = System.Windows.WindowState.Maximized; break; case WindowVisualState.Minimized: this.OwnerAsRadWindow().WindowState = System.Windows.WindowState.Minimized; break; default: this.OwnerAsRadWindow().WindowState = System.Windows.WindowState.Normal; break; } }
public void SetWindowVisualState(WindowVisualState state) { try { this._pattern.SetWindowVisualState((UIAutomationClient.WindowVisualState)state); } catch (System.Runtime.InteropServices.COMException e) { Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; } } }
public void SetVisualState(WindowVisualState state) { SWF.FormWindowState newState = form.WindowState; switch (state) { case WindowVisualState.Maximized: newState = SWF.FormWindowState.Maximized; break; case WindowVisualState.Minimized: newState = SWF.FormWindowState.Minimized; break; case WindowVisualState.Normal: newState = SWF.FormWindowState.Normal; break; } PerformSetVisualState(form, newState); }
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods /// <summary> /// Changes the State of the window based on the passed enum. /// </summary> /// <param name="state">The requested state of the window.</param> /// /// <outside_see conditional="false"> /// This API does not work inside the secure execution environment. /// <exception cref="System.Security.Permissions.SecurityPermission"/> /// </outside_see> public void SetWindowVisualState( WindowVisualState state ) { UiaCoreApi.WindowPattern_SetWindowVisualState(_hPattern, state); }
//------------------------------------------------------ // // Interface IWindowProvider // //------------------------------------------------------ #region Interface IWindowProvider void IWindowProvider.SetVisualState( WindowVisualState state ) { if ( !SafeNativeMethods.IsWindow( _hwnd ) ) throw new ElementNotAvailableException(); switch ( state ) { case WindowVisualState.Normal: { // you can't really do anything to a disabled window if ( IsBitSet(GetWindowStyle(), SafeNativeMethods.WS_DISABLED) ) throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed)); // If already in the normal state, do not need to do anything. if (((IWindowProvider)this).VisualState == WindowVisualState.Normal) { return; } ClearMenuMode(); UnsafeNativeMethods.WINDOWPLACEMENT wp = new UnsafeNativeMethods.WINDOWPLACEMENT(); wp.length = Marshal.SizeOf(typeof(UnsafeNativeMethods.WINDOWPLACEMENT)); // get the WINDOWPLACEMENT information if (!Misc.GetWindowPlacement(_hwnd, ref wp)) { throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed)); } wp.showCmd = UnsafeNativeMethods.SW_RESTORE; // Use SetWindowPlacement to set state to normal because if the window is maximized then minimized // sending SC_RESTORE puts it back to maximized instead of normal. if (!Misc.SetWindowPlacement(_hwnd, ref wp)) { throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed)); } return; } case WindowVisualState.Minimized: { if (!((IWindowProvider)this).Minimizable) throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed)); // If already minimzed, do not need to do anything. if (((IWindowProvider)this).VisualState == WindowVisualState.Minimized) { return; } ClearMenuMode(); if (!Misc.PostMessage(_hwnd, UnsafeNativeMethods.WM_SYSCOMMAND, (IntPtr)UnsafeNativeMethods.SC_MINIMIZE, IntPtr.Zero)) { throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed)); } return; } case WindowVisualState.Maximized: { if ( ! ((IWindowProvider)this).Maximizable ) throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed)); // If already maximized, do not need to do anything. if (((IWindowProvider)this).VisualState == WindowVisualState.Maximized) { return; } ClearMenuMode(); if (!Misc.PostMessage(_hwnd, UnsafeNativeMethods.WM_SYSCOMMAND, (IntPtr)UnsafeNativeMethods.SC_MAXIMIZE, IntPtr.Zero)) { throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed)); } return; } default: { Debug.Assert(false,"unexpected switch() case:"); throw new ArgumentException(SR.Get(SRID.UnexpectedWindowState),"state"); } } }
public void SetVisualState (WindowVisualState state) { provider.SetVisualState (state); }
//------------------------------------------------------ // // Interface IWindowProvider // //------------------------------------------------------ #region Interface IWindowProvider public void SetVisualState(WindowVisualState state) { ElementUtil.Invoke(_peer, new DispatcherOperationCallback(SetVisualState), state); }
// ---------------------------------------------------------------------------- /// <summary> /// /// </summary> /// <param name="element"></param> /// <param name="wvs"></param> /// <param name="checkType"></param> // ---------------------------------------------------------------------------- internal void TS_VerifyWindowVisualState(AutomationElement element, WindowVisualState wvs, CheckType checkType) { WindowPattern wp = ObtainWindowPattern(m_le, checkType); if (wp.Current.WindowVisualState != wvs) ThrowMe(checkType, "Element's WindowVisualState(" + wp.Current.WindowVisualState + ") != " + wvs); m_TestStep++; }
//------------------------------------------------------ // // Interface IWindowProvider // //------------------------------------------------------ #region Interface IWindowProvider public void SetVisualState( WindowVisualState state ) { ElementUtil.Invoke( _peer, new DispatcherOperationCallback( SetVisualState ), state ); }
/// ------------------------------------------------------------------- void TS_VerifySetVisualState(WindowVisualState WindowVisualState, Type expectedException, CheckType checkType) { pattern_SetWindowVisualState(WindowVisualState, expectedException, checkType); m_TestStep++; }
/// ------------------------------------------------------------------- /// <summary> /// Test that one can set the VisualState /// </summary> /// ------------------------------------------------------------------- internal void TS_SetWindowVisualState(AutomationElement element, WindowVisualState wvs, CheckType checkType) { AutomationPropertyChangedEventHandler handler; WindowPattern wp = ObtainWindowPattern(m_le, checkType); if (wp.Current.WindowVisualState != wvs) { // Want to wait till the BoundingRectangle changes to determine if the window changed Visual State handler = new AutomationPropertyChangedEventHandler(OnEvent); Automation.AddAutomationPropertyChangedEventHandler(element, TreeScope.Element, handler, new AutomationProperty[] { AutomationElement.BoundingRectangleProperty }); _gotNotifiedEvent.Reset(); // Set the new visual state wp.SetWindowVisualState(wvs); // Wait up to 5 seconds or until we get the event. If WaitOne returns false, the event was not fired. bool eventHappened = _gotNotifiedEvent.WaitOne(5000, true); // We don't need the event handler anymore, remove it Automation.RemoveAutomationPropertyChangedEventHandler(element, handler); // If the event did not happen, then log error if (!eventHappened) { ThrowMe(checkType, "BoundingRectangle property change event was not fired and should have. WindowState is set to {0}", wp.Current.WindowVisualState); } } m_TestStep++; }
/// ------------------------------------------------------------------- void TS_VerifySetVisualState(WindowVisualState WindowVisualState, Type expectedException, CheckType checkType) { pattern_SetWindowVisualState(WindowVisualState, expectedException, checkType); m_TestStep++; }
public void SetWindowVisualState (WindowVisualState state) { Source.SetWindowVisualState (state); }
// /// ------------------------------------------------------------------- // void TS_Minimizable(bool ShouldBeMinimized, CheckType checkType) // { // if (!pattern_getCanMinimize.Equals(ShouldBeMinimized)) // ThrowMe("CanMinimize == " + pattern_getCanMinimize, checkType); // // m_TestStep++; // } /// ------------------------------------------------------------------- void TS_VerifyVisualState(WindowVisualState WindowVisualState, bool shouldBe, CheckType checkType) { if (!pattern_getVisualState.Equals(WindowVisualState).Equals(shouldBe)) ThrowMe(checkType, TestCaseCurrentStep + ": WindowVisualState = " + pattern_getVisualState); Comment("WindowVisualState = " + pattern_getWindowInteractionState); m_TestStep++; }
internal void pattern_SetWindowVisualState(WindowVisualState state, Type expectedException, CheckType checkType) { string call = "SetWindowVisualState(" + state + ")"; try { m_pattern.SetWindowVisualState(state); } catch (Exception actualException) { TestException(expectedException, actualException, call, checkType); return; } TestNoException(expectedException, call, checkType); }
// Sets the current window state // private void SetWindowState(WindowVisualState state) { object windowPattern; // Check if main window form supports WindowPattern // if (this.window.TryGetCurrentPattern(WindowPattern.Pattern, out windowPattern)) { // Bring window to front // ((WindowPattern)windowPattern).SetWindowVisualState(state); } }
/// ------------------------------------------------------------------- /// <summary>Test step: Start Narrator</summary> /// ------------------------------------------------------------------- void TS_NarratorStart(WindowVisualState windowState, bool dismissLanguageDialog, CheckType checkType) { AutomationElement element; string pathNarrator; object caption; HelperGetNarratorIdentifiers(out pathNarrator, out caption, checkType); // Set up the thread to handle the language mismatch error dialog NarratorErrorDialogs narratorErrorDialogs = null; if (dismissLanguageDialog) { narratorErrorDialogs = new NarratorErrorDialogs(); narratorErrorDialogs.HandleVoiceLanguageWarningForm(); } // Start up Narrator Comment("Starting {0} at \"{1}:{2}:{3}:{4}\" ...", pathNarrator, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); Comment("Seach for window with \"{0}\" title", caption.ToString()); Library.StartApplicationShellExecute(pathNarrator, caption.ToString(), null, out element, _WAIT_STARTUP_MILLISECONDS); Wait(WaitForNarratorToBeVisible, _WAIT_NORMAL_MILLISECONDS, checkType); Wait(WaitForNarratorUserInteractiveState, _WAIT_NORMAL_MILLISECONDS, checkType); HelperNarratorRestoreWindow(checkType); if (null == MainForm.AutomationElement) ThrowMe(checkType, "Could not find Narrator dialog"); m_TestStep++; }
public override void SetWindowVisualState(WindowVisualState state) { Com.Call(() => NativePattern.SetWindowVisualState((UIA.WindowVisualState)state)); }
void IWindowProvider.SetVisualState(WindowVisualState state) { // Not supported. }
public void SetVisualState (WindowVisualState state) { SWF.FormWindowState newState = form.WindowState; switch (state) { case WindowVisualState.Maximized: newState = SWF.FormWindowState.Maximized; break; case WindowVisualState.Minimized: newState = SWF.FormWindowState.Minimized; break; case WindowVisualState.Normal: newState = SWF.FormWindowState.Normal; break; } PerformSetVisualState (form, newState); }
/// ------------------------------------------------------------------- /// <summary>Test step: Start Narrator</summary> /// ------------------------------------------------------------------- void TS_NarratorStart(WindowVisualState windowState, CheckType checkType) { TS_NarratorStart(windowState, true, checkType); //m_TestStep++; let the overloaded method increment the value }
/// <summary> /// Changes the visual state of the window (such as minimizing or /// maximizing it). /// </summary> /// <param name="state"> /// The visual state of the window to change to, as a value of the /// enumeration. /// </param> void IWindowProvider.SetVisualState(WindowVisualState state) { }
// The methods and properties of WindowPattern public void SetWindowVisualState(WindowVisualState state) { SetWindowVisualState (state, true); }
public void SetWindowVisualState(WindowVisualState state, bool log) { if (log == true) procedureLogger.Action (string.Format ("Set {0} to be {1}.", this.Name, state)); WindowPattern wp = (WindowPattern) element.GetCurrentPattern (WindowPattern.Pattern); wp.SetWindowVisualState (state); }
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods /// <summary> /// Changes the State of the window based on the passed enum. /// </summary> /// <param name="state">The requested state of the window.</param> public void SetWindowVisualState(WindowVisualState state) { UiaCoreApi.WindowPattern_SetWindowVisualState(_hPattern, state); }
//the WindowPattern's method public void SetWindowVisualState(WindowVisualState state) { procedureLogger.Action (string.Format ("Set \"{0}\" to be \"{1}\".", this.Name, state)); WindowPattern wp = (WindowPattern) element.GetCurrentPattern (WindowPattern.Pattern); wp.SetWindowVisualState (state); }