/// <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;
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 4
0
        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;
            }
        }
Exemplo n.º 5
0
        private static WindowVisualState UiaGetWindowVisualState(ProdWindow control)
        {
            WindowVisualState retVal = WindowPatternHelper.GetVisualState(control.UIAElement);

            LogController.ReceiveLogMessage(new LogMessage(retVal.ToString()));
            return(retVal);
        }
Exemplo n.º 6
0
        public static void SetWindowVisualState(AutomationElement window, WindowVisualState TargetState)
        {
            WindowPattern pattern = window.GetCurrentPattern(WindowPattern.Pattern) as WindowPattern;

            //pattern.SetWindowVisualState(WindowVisualState.Normal);
            pattern.SetWindowVisualState(TargetState);
        }
Exemplo n.º 7
0
        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;
            }
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
 public void SetWindowVisualState(WindowVisualState state)
 {
     try {
         pattern.SetVisualState(state);
     } catch (Exception ex) {
         throw DbusExceptionTranslator.Translate(ex);
     }
 }
Exemplo n.º 10
0
		public void SetWindowVisualState (WindowVisualState state)
		{
			try {
				pattern.SetVisualState (state);
			} catch (Exception ex) {
				throw DbusExceptionTranslator.Translate (ex);
			}
		}
Exemplo n.º 11
0
        private void SetState(WindowVisualState state)
        {
            if (WindowManager == null)
            {
                WindowManager = DozeObject.FindObjectOfType <WindowsObject>();
            }

            WindowManager.SetState("window-general:login", state);
        }
Exemplo n.º 12
0
        //        /// -------------------------------------------------------------------
        //        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++;
        }
Exemplo n.º 13
0
        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);
            }
        }
Exemplo n.º 14
0
 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));
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
 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; }
     }
 }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        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));
        }
Exemplo n.º 20
0
        // </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;
            }
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
        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));
        }
Exemplo n.º 23
0
        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);
        }
Exemplo n.º 24
0
        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);
            }
        }
Exemplo n.º 25
0
        //------------------------------------------------------
        //
        //  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;
            }
        }
Exemplo n.º 27
0
 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;
         }
     }
 }
Exemplo n.º 28
0
        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);
        }
Exemplo n.º 29
0
        //------------------------------------------------------
        //
        //  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");
                }

            }

        }
Exemplo n.º 31
0
		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);
        }
Exemplo n.º 33
0
        // ----------------------------------------------------------------------------
        /// <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 );
        }
Exemplo n.º 35
0
 /// -------------------------------------------------------------------
 void TS_VerifySetVisualState(WindowVisualState WindowVisualState, Type expectedException, CheckType checkType)
 {
     pattern_SetWindowVisualState(WindowVisualState, expectedException, checkType);
     m_TestStep++;
 }
Exemplo n.º 36
0
        /// -------------------------------------------------------------------
        /// <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++;
        }
Exemplo n.º 37
0
 /// -------------------------------------------------------------------
 void TS_VerifySetVisualState(WindowVisualState WindowVisualState, Type expectedException, CheckType checkType)
 {
     pattern_SetWindowVisualState(WindowVisualState, expectedException, checkType);
     m_TestStep++;
 }
Exemplo n.º 38
0
		public void SetWindowVisualState (WindowVisualState state)
		{
			Source.SetWindowVisualState (state);
		}
Exemplo n.º 39
0
        //        /// -------------------------------------------------------------------
        //        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++;
        }
Exemplo n.º 40
0
 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);
 }
Exemplo n.º 41
0
 // 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);
     }
 }
Exemplo n.º 42
0
        /// -------------------------------------------------------------------
        /// <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++;

        }
Exemplo n.º 43
0
 public override void SetWindowVisualState(WindowVisualState state)
 {
     Com.Call(() => NativePattern.SetWindowVisualState((UIA.WindowVisualState)state));
 }
Exemplo n.º 44
0
 void IWindowProvider.SetVisualState(WindowVisualState state)
 {
     // Not supported.
 }
Exemplo n.º 45
0
		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);
		}
Exemplo n.º 46
0
 /// -------------------------------------------------------------------
 /// <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)
 {
 }
Exemplo n.º 48
0
 // The methods and properties of WindowPattern
 public void SetWindowVisualState(WindowVisualState state)
 {
     SetWindowVisualState (state, true);
 }
Exemplo n.º 49
0
        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);
        }
Exemplo n.º 50
0
        //------------------------------------------------------
        //
        //  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);
        }
Exemplo n.º 51
0
 //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);
 }