UIAutomation.PatternCmdletBase.CallWindowPattern C# (CSharp) Method

CallWindowPattern() private method

private CallWindowPattern ( PatternCmdletBase cmdlet, IUiElement control, IUiElement inputObject ) : void
cmdlet PatternCmdletBase
control IUiElement
inputObject IUiElement
return void
        internal void CallWindowPattern(PatternCmdletBase cmdlet, IUiElement control, IUiElement inputObject)
        {
            try {
                // 20131208
                // WindowPattern windowPattern = control.GetCurrentPattern(classic.WindowPattern.Pattern) as WindowPattern;
                // WindowPattern windowPattern = control.GetCurrentPattern<IWindowPattern, WindowPattern>(classic.WindowPattern.Pattern) as WindowPattern;
                // IWindowPattern windowPattern = control.GetCurrentPattern<IWindowPattern, WindowPattern>(); //WindowPattern.Pattern);
                IWindowPattern windowPattern = control.GetCurrentPattern<IWindowPattern>(classic.WindowPattern.Pattern);
                if (windowPattern != null) {

                    // Close windowPattern.Close
                    // get windowPattern.Current.CanMaximize
                    // get windowPattern.Current.CanMinimize
                    // get windowPattern.Current.IsModal
                    // get windowPattern.Current.IsTopmost
                    // get windowPattern.Current.WindowInteractionState
                    // get windowPattern.Current.WindowVisualState
                    // set windowPattern.SetWindowVisualState(WindowVisualState.Maximized
                    // set windowPattern.SetWindowVisualState(WindowVisualState.Mini
                    // set windowPattern.SetWindowVisualState(WindowVisualState.Normal
                    // invoke windowPattern.WaitForInputIdle(int ms)
                    
                    windowPattern.SetWindowVisualState(classic.WindowVisualState.Minimized);
                    Thread.Sleep(1000);
                    windowPattern.SetWindowVisualState(classic.WindowVisualState.Normal);
                    windowPattern.WaitForInputIdle(1000);
                    Thread.Sleep(1000);
                    windowPattern.SetWindowVisualState(classic.WindowVisualState.Minimized);
                    Thread.Sleep(1000);
                    windowPattern.SetWindowVisualState(classic.WindowVisualState.Normal);
                    
                    if (PassThru && null != (inputObject as IUiElement)) {
                        WriteObject(this, inputObject);
                    } else {
                        WriteObject(this, true);
                    }
                } else {
                    WriteVerbose(this, "couldn't get WindowPattern");
                    WriteObject(this, false);
                }
            } catch (Exception) {
            }
        }