예제 #1
0
파일: Wizard.cs 프로젝트: krukovskiy/STUPS
        public WizardStep GetActiveStep()
        {
            this.StopImmediately = false;

            WizardStep resultStep = null;

            //GetControlCmdletBase cmdletCtrl =
            //	new GetControlCmdletBase();
            UIAutomation.Commands.GetUIAControlCommand cmdletCtrl =
                new UIAutomation.Commands.GetUIAControlCommand();

            cmdletCtrl.InputObject =
                new AutomationElement[]{ CurrentData.CurrentWindow };

            cmdletCtrl.Timeout = 0;

            foreach (WizardStep step in this.Steps) {

                if (this.StopImmediately) {
                    resultStep = step;
                    break;
                }

                // 20130320
                // sleep interval
                System.Threading.Thread.Sleep(Preferences.OnSelectWizardStepDelay);

                cmdletCtrl.SearchCriteria = step.SearchCriteria;

                ArrayList controlsList = null;

                try {

                    controlsList =
                        cmdletCtrl.GetControl(cmdletCtrl);

                }
                catch {}

                if (null != controlsList && 0 < controlsList.Count) {

                    if (step == this.ActiveStep) {

                        // 20130423
                        if (Preferences.HighlightCheckedControl) {
                            foreach (AutomationElement elementChecked in controlsList) {
                                UIAHelper.HighlightCheckedControl(elementChecked);
                            }
                        }

                        continue;
                    }

                    resultStep = step;
                    this.ActiveStep = step;
                    break;
                }
            }

            // 20130515
            // moving the current step to the end of the step collection
            try {
               int currentIndex = this.Steps.IndexOf(resultStep);
               cmdletCtrl.WriteInfo(cmdletCtrl, "current index = " + currentIndex.ToString());
               this.Steps.Insert(this.Steps.Count, resultStep);
               cmdletCtrl.WriteInfo(cmdletCtrl, "inserted after the last step");
               this.Steps.RemoveAt(currentIndex);
               cmdletCtrl.WriteInfo(cmdletCtrl, "deleted from the previous position");
            }
            catch (Exception eMovingToTheEnd) {
                cmdletCtrl.WriteInfo(cmdletCtrl, eMovingToTheEnd.Message);
            }

            return resultStep;
        }
예제 #2
0
파일: Wizard.cs 프로젝트: JosefNemec/STUPS
        public WizardStep GetActiveStep()
        {
            this.StopImmediately = false;

            WizardStep resultStep = null;

            //GetControlCmdletBase cmdletCtrl =
            //	new GetControlCmdletBase();
            UIAutomation.Commands.GetUIAControlCommand cmdletCtrl =
                new UIAutomation.Commands.GetUIAControlCommand();

            cmdletCtrl.InputObject =
                new AutomationElement[]{ CurrentData.CurrentWindow };

            cmdletCtrl.Timeout = 0;

            foreach (WizardStep step in this.Steps) {

                if (this.StopImmediately) {
                    resultStep = step;
                    break;
                }

                // 20130320
                // sleep interval
                System.Threading.Thread.Sleep(Preferences.OnSelectWizardStepDelay);

                cmdletCtrl.SearchCriteria = step.SearchCriteria;

                ArrayList controlsList = null;

                try {

                    controlsList =
                        cmdletCtrl.GetControl(cmdletCtrl);

                }
                catch {}

                if (null != controlsList && 0 < controlsList.Count) {

                    if (step == this.ActiveStep) {
                        continue;
                    }

                    resultStep = step;
                    this.ActiveStep = step;
                    break;
                }
            }

            return resultStep;
        }