Exemplo n.º 1
0
 public WinFormsTripled(
     ControlToForm[] controls) : base ("WinFormsTripled", "WinFormsTripled", controls)
 {
     base.ChildForm = this;
     
     this.neededControls = controls;
 }
Exemplo n.º 2
0
        private void loadControl <T>(T control, ControlToForm controlToForm)
        {
            try {
                //            if (this.ControlName != string.Empty){
                //                (control as System.Windows.Forms.Control).GetType().GetProperty("Text").SetValue(control, this.ControlName, null);
                //            } else {
                //                (control as System.Windows.Forms.Control).GetType().GetProperty("Text").SetValue(control, _controlType, null);
                //            }
                (control as Control).GetType()
                .GetProperty("Text")
                .SetValue(control,
                          controlToForm.ControlName != string.Empty
                            ? controlToForm.ControlName
                            : controlToForm.ControlTypeAsString, null);

                /*
                 * if (controlToForm.ControlName != string.Empty){
                 *  (control as System.Windows.Forms.Control).GetType().GetProperty("Text").SetValue(control, controlToForm.ControlName, null);
                 * } else {
                 *  (control as System.Windows.Forms.Control).GetType().GetProperty("Text").SetValue(control, controlToForm.ControlTypeAsString, null);
                 * }
                 */
                //            if (this.ControlAutomationId != string.Empty){
                //                (control as System.Windows.Forms.Control).GetType().GetProperty("Name").SetValue(control, this.ControlAutomationId, null);
                //            } else {
                //                (control as System.Windows.Forms.Control).GetType().GetProperty("Name").SetValue(control, _controlType, null);
                //            }
                (control as Control).GetType()
                .GetProperty("Name")
                .SetValue(control,
                          controlToForm.ControlAutomationId != string.Empty
                            ? controlToForm.ControlAutomationId
                            : controlToForm.ControlTypeAsString, null);

                /*
                 * if (controlToForm.ControlAutomationId != string.Empty) {
                 *  (control as System.Windows.Forms.Control).GetType().GetProperty("Name").SetValue(control, controlToForm.ControlAutomationId, null);
                 * } else {
                 *  (control as System.Windows.Forms.Control).GetType().GetProperty("Name").SetValue(control, controlToForm.ControlTypeAsString, null);
                 * }
                 */
                (control as Control).Visible = false;
                var r = new Random();
                (control as Control).Left =
                    // 20130110
                    //r.Next(0, this.Width - 20);
                    r.Next(0, this.Width - 50);
                (control as Control).Top =
                    // 20130110
                    //r.Next(0, this.Height - 20);
                    r.Next(0, this.Height - 50);
                // this.Controls.Add(b);
                ChildForm.Controls.Add(control as Control);

                var showControlDelegate = new ShowControl(runTimeout);
                // WriteVerbose(this, "runScriptBlocks 5 fired");
                //showControlDelegate(this.ControlDelay, control as System.Windows.Forms.Control);
                showControlDelegate(controlToForm.ControlDelayEn, control as Control);
            } catch {
            }
        }
Exemplo n.º 3
0
        void WinFormsFormShown(object sender, EventArgs e)
        {
            if ((null == ControlType) &&
                (null == controlsArray ||
                 controlsArray.Length == 0))
            {
                return;
            }

            ControlToForm[] arr;
            if (null == controlsArray &&
                null != ControlType)
            {
                var ctf = new ControlToForm();
                ctf.ControlType         = ControlType;
                ctf.ControlName         = ControlName;
                ctf.ControlAutomationId = ControlAutomationId;
                ctf.ControlDelayEn      = ControlDelay;
                var arrList = new ArrayList();
                arrList.Add(ctf);
                arr = (ControlToForm[])arrList.ToArray(typeof(ControlToForm));
            }
            else
            {
                arr = controlsArray;
            }

            for (int i = 0; i < arr.Length; i++)
            {
                string _controlType = arr[i].ControlType.ProgrammaticName.Substring(
                    arr[i].ControlType.ProgrammaticName.IndexOf(".") + 1);
                arr[i].ControlTypeAsString = _controlType;
                switch (_controlType)
                {
                case "Button":
                    var b = new Button();
                    loadControl(b, arr[i]);
                    break;

                case "MonthCalendar":
                case "Calendar":
                    var mc = new MonthCalendar();
                    loadControl(mc, arr[i]);
                    break;

                case "CheckBox":
                    var chk = new CheckBox();
                    loadControl(chk, arr[i]);
                    break;

                case "ComboBox":
                    var cmb = new ComboBox();
                    loadControl(cmb, arr[i]);
                    break;

                case "GroupBox":
                case "Group":
                    var gb = new GroupBox();
                    loadControl(gb, arr[i]);
                    break;

                case "Label":
                case "Text":
                    var l = new Label();
                    loadControl(l, arr[i]);
                    break;

                case "ListBox":
                case "List":
                    var lb = new ListBox();
                    loadControl(lb, arr[i]);
                    break;

                case "ListView":
                    //case "Table":
                    var lv = new ListView();
                    loadControl(lv, arr[i]);
                    break;

                case "MenuBar":
                    var ms = new MenuStrip();
                    loadControl(ms, arr[i]);
                    break;

                case "ProgressBar":
                    var pb = new ProgressBar();
                    loadControl(pb, arr[i]);
                    break;

                case "RadioButton":
                    var rb = new RadioButton();
                    loadControl(rb, arr[i]);
                    break;

                case "RichTextBox":
                case "Document":
                    var rtb = new RichTextBox();
                    loadControl(rtb, arr[i]);
                    break;

                case "StatusBar":
                    var sb = new StatusBar();
                    loadControl(sb, arr[i]);
                    break;

                case "Table":
                    var pg = new PropertyGrid();
                    loadControl(pg, arr[i]);
                    break;

                case "TextBox":
                case "Edit":
                    var tb = new TextBox();
                    loadControl(tb, arr[i]);
                    break;

                case "TreeView":
                case "Tree":
                    var tv = new TreeView();
                    loadControl(tv, arr[i]);
                    break;

                default:
                    //System.Windows.Forms.DataGridTextBox
                    //System.Windows.Forms.DataGridView
                    //System.Windows.Forms.GridItem
                    //System.Windows.Forms.DomainUpDown
                    //System.Windows.Forms.RichTextBox
                    //System.Windows.Automation.ControlType.Document
                    break;
                } // switch (_controlType)

                Application.DoEvents();
            } // for (int i = 0; i < arr.Length; i++)

            //Application.DoEvents();
        }
Exemplo n.º 4
0
 public WinFormsMaximized(
     ControlToForm[] controls) : base ("WinFormsMaximized", "WinFormsMaximized", controls)
 {
     base.ChildForm = this;
 }        
Exemplo n.º 5
0
 public WinFormsEmpty(
     ControlToForm[] controls) : base ("WinFormsEmpty", "WinFormsEmpty", controls)
 {
     base.ChildForm = this;
 }
Exemplo n.º 6
0
 public WinFormsSecond(
     ControlToForm[] controls) : base ("WinFormsSecond", "WinFormsSecond", controls)
 {
     base.ChildForm = this;
 }
Exemplo n.º 7
0
        private static void Main(string[] args)
        {
            
            // Console.WriteLine(System.Windows.Automation.ControlType.Button.ToString());
            // Console.WriteLine(System.Windows.Automation.ControlType.Button.ProgrammaticName.ToString());
            // Console.WriteLine(System.Windows.Automation.ControlType.Button.GetType().Name);
      

// Dumping types for further investigation

//            Console.WriteLine("Dumping the types...");
//            dumpTypes(System.Environment.GetEnvironmentVariable("TEMP",
//                                                                EnvironmentVariableTarget.User) + 
//                      @"\types.txt");
//            Console.WriteLine("...completed");
//                      return;

            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
            
            // the second command-line argument FormDelay
            if (args.Length > 1 && args[1] != null && args[1] != string.Empty)
            {
                try {
                    if ((Convert.ToInt32(args[0]) != 0) &&
                        (Convert.ToInt32(args[1]) != 0))
                    {
                        int sleepTime = 
                            Convert.ToInt32(args[1]);
                        System.Threading.Thread.Sleep(sleepTime);
                    }
                } catch {
                    // Console.WriteLine("Wrong arguments!Use numbers:");
                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
                    return; // 1;
                }
            }
            
// if (Delay > 0) {
// System.Threading.Thread.Sleep(Delay);
// }
            // the first command-line argument FormType
            if (args.Length > 0 && args[0] != null && args[0] != "")
            {
                Forms formCode;
                try {
                    formCode = (Forms)(Convert.ToInt32(args[0]));
                } catch {
                    // Console.WriteLine("Wrong arguments!Use numbers:");
                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
                    return; // 2;
                }

                // System.Windows.Forms.Application.Run(new MainForm());
                
#region reserved code
//                System.Windows.Automation.ControlType ctrlType = null;
//                
//                // the third command-line argument ControlType
//                if (args.Length > 2 && args[2] != null && args[2] != "") {
//                    // string _controlType = String.Empty;
//                    //_controlType = args[2].ToUpper();
//                    ctrlType = 
//                        UiaHelper.GetControlTypeByTypeName(args[2]);
//                }
//                
//                int controlDelay = 0;
//                
//                // the fourth command-line argument ControlDelay
//                if (args.Length > 3 && args[3] != null && args[3] != string.Empty) {
//                    try {
//                        controlDelay = System.Convert.ToInt32(args[3]);
//                    } catch { }
//                }
//                
//                string controlName = string.Empty;
//                
//                // the fifth command-line argument ControlName
//                if (args.Length > 4 && args[4] != null && args[4] != string.Empty) {
//                    try {
//                        controlName = args[4];
//                    } catch { }
//                }
//                
//                string controlAutomationId = string.Empty;
//                
//                // the sixth command-line argument ControlAutomationId
//                if (args.Length > 5 && args[5] != null && args[5] != string.Empty) {
//                    try {
//                        controlAutomationId = args[5];
//                    } catch { }
//                }
//                
//                switch (formCode)
//                {
//                    case Forms.WinFormsEmpty:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsEmpty(ctrlType, controlName, controlAutomationId, controlDelay));
//                        // WinFormsEmpty frmWFE = new WinFormsEmpty();
//                        // frmWFE.ShowDialog();
//                        break;
//                    case Forms.WinFormsEmptyX2:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsEmpty(ctrlType, controlName, controlAutomationId, controlDelay));
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsEmpty(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsAnonymous:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsAnonymous(
//                                ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsMinimized:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsMinimized(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsMaximized:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsMaximized(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsNoTaskBar:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsNoTaskBar(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsRich:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsRich(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    
//                        
//                    case Forms.WPFEmpty:
//                        WPFEmpty frmWPFE = new WPFEmpty();
//                        frmWPFE.ShowDialog();
//                        //Application.Run(new MainForm());
//                        break;
//                    case Forms.WPFEmptyX2:
//                        WPFEmpty frmWPFE1 = new WPFEmpty();
//                        frmWPFE1.ShowDialog();
//                        WPFEmpty frmWPFE2 = new WPFEmpty();
//                        frmWPFE2.ShowDialog();
//                        break;
//                    case Forms.WPFAnonymous:
//                        WPFAnonymous frmWPFA = new WPFAnonymous();
//                        frmWPFA.ShowDialog();
//                        break;
//                    case Forms.WPFMinimized:
//                        WPFMinimized frmWPFMi = new WPFMinimized();
//                        frmWPFMi.ShowDialog();
//                        break;
//                    case Forms.WPFMaximized:
//                        WPFMaximized frmWPFMa = new WPFMaximized();
//                        frmWPFMa.ShowDialog();
//                        break;
//                    case Forms.WPFCollapsed:
//                        WPFCollapsed frmWPFCo = new WPFCollapsed();
//                        frmWPFCo.ShowDialog();
//                        break;
//                        
//                }
//            }
#endregion reserved code

            System.Windows.Automation.ControlType ctrlType = null;
            int controlDelay = 0;
            string controlName = string.Empty;
            string controlAutomationId = string.Empty;
            ControlToForm[] controls = null;

            if (args.Length > 2) {
            //    ControlToForm controlToForm = new ControlToForm();
            //    for (int i = 2; i < args.Length; i++) {
            //        controlto
            //    }
            
                System.Collections.ArrayList arrList = 
                    new System.Collections.ArrayList();
                
                for (int i = 2; i < args.Length; i = i + 4) {
                    
                    ControlToForm controlToForm = 
                        new ControlToForm();
                
                    //System.Windows.Automation.ControlType ctrlType = null;
                    ctrlType = null;
                    
                    // the third command-line argument ControlType
                    if (args[i] != null && args[i] != "") {
                        ctrlType = 
                            UiaHelper.GetControlTypeByTypeName(args[i]);
                        controlToForm.ControlType = ctrlType;
                    }
                
                    //int controlDelay = 0;
                    controlDelay = 0;
                    
                    // the fourth command-line argument ControlDelay
                    if (args[i + 1] != null && args[i + 1] != string.Empty) {
                        try {
                            controlDelay = Convert.ToInt32(args[i + 1]);
                            controlToForm.ControlDelayEn = controlDelay;
                        } catch { }
                    }
                    
                    //string controlName = string.Empty;
                    controlName = string.Empty;
                    
                    // the fifth command-line argument ControlName
                    if (args[i + 2] != null && args[i + 2] != string.Empty) {
                        try {
                            controlName = args[i + 2];
                            controlToForm.ControlName = controlName;
                        } catch { }
                    }
                
                    //string controlAutomationId = string.Empty;
                    controlAutomationId = string.Empty;
                    
                    // the sixth command-line argument ControlAutomationId
                    if (args[i + 3] != null && args[i + 3] != string.Empty) {
                        try {
                            controlAutomationId = args[i + 3];
                            controlToForm.ControlAutomationId = controlAutomationId;
                        } catch { }
                    }
                    
                    arrList.Add(controlToForm);
                    
                } // for (int i = 2; i < args.Length; i = i + 4)
                
                controls =
                    (ControlToForm[])arrList.ToArray(typeof(ControlToForm));
            }
            
            switch (formCode)
            {
                case Forms.WinFormsEmpty:
                    System.Windows.Forms.Application.Run(
                        new WinFormsEmpty(controls));
                    break;
                case Forms.WinFormsEmptyX2:
                    System.Windows.Forms.Application.Run(
                        new WinFormsEmpty(controls));
                    System.Windows.Forms.Application.Run(
                        new WinFormsEmpty(controls));
                    break;
                case Forms.WinFormsAnonymous:
                    System.Windows.Forms.Application.Run(
                        new WinFormsAnonymous(
                            ctrlType, controlName, controlAutomationId, controlDelay));
                    break;
                case Forms.WinFormsMinimized:
                    System.Windows.Forms.Application.Run(
                        new WinFormsMinimized(ctrlType, controlName, controlAutomationId, controlDelay));
                    break;
                case Forms.WinFormsMaximized:
                    System.Windows.Forms.Application.Run(
                        new WinFormsMaximized(ctrlType, controlName, controlAutomationId, controlDelay));
                    break;
                case Forms.WinFormsNoTaskBar:
                    System.Windows.Forms.Application.Run(
                        new WinFormsNoTaskBar(ctrlType, controlName, controlAutomationId, controlDelay));
                    break;
                case Forms.WinFormsTripled:
                    System.Windows.Forms.Application.Run(
                        new WinFormsTripled(controls));
                    break;
                case Forms.WinFormsThreeSet:
                    System.Windows.Forms.Application.Run(
                        new WinFormsOuter()); //(controls));
                    break;
                case Forms.WinFormsWithMenus:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWithMenus());
                    break;
                case Forms.WinFormsRich:
                    System.Windows.Forms.Application.Run(
                        new WinFormsRich()); //ctrlType, controlName, controlAutomationId, controlDelay));
                    break;
                case Forms.WinFormsFull:
                    System.Windows.Forms.Application.Run(
                        new WinFormsFull()); //ctrlType, controlName, controlAutomationId, controlDelay));
                    break;
                case Forms.WinFormsWizard:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWizard()); //ctrlType, controlName, controlAutomationId, controlDelay));
                    break;
                case Forms.WinFormsWithGrid:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWithGrid());
                    break;
                case Forms.WinFormsWithLists:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWithLists());
                    break;
                    
                case Forms.WPFEmpty:
                    WPFEmpty frmWPFE = new WPFEmpty();
                    frmWPFE.ShowDialog();
                    //Application.Run(new MainForm());
                    break;
                case Forms.WPFEmptyX2:
                    WPFEmpty frmWPFE1 = new WPFEmpty();
                    frmWPFE1.ShowDialog();
                    WPFEmpty frmWPFE2 = new WPFEmpty();
                    frmWPFE2.ShowDialog();
                    break;
                case Forms.WPFAnonymous:
                    WPFAnonymous frmWPFA = new WPFAnonymous();
                    frmWPFA.ShowDialog();
                    break;
                case Forms.WPFMinimized:
                    WPFMinimized frmWPFMi = new WPFMinimized();
                    frmWPFMi.ShowDialog();
                    break;
                case Forms.WPFMaximized:
                    WPFMaximized frmWPFMa = new WPFMaximized();
                    frmWPFMa.ShowDialog();
                    break;
                case Forms.WPFCollapsed:
                    WPFCollapsed frmWPFCo = new WPFCollapsed();
                    frmWPFCo.ShowDialog();
                    break;
                case Forms.WPFFull:
                    WPFFull frmWPFFull = new WPFFull();
                    frmWPFFull.ShowDialog();
                    break;
//                case Forms.WPFWizard:
//                    WPFWizard frmWPFWizard = new WPFWizard();
//                    frmWPFWizard.ShowDialog();
//                    break;
            }
            
//            } // if (args.Length > 2)
//            else {
//                System.Windows.Forms.Application.Run(
//                    new WinFormsEmpty(ctrlType, 0));
//            }

                

                

                

                

            }

            
//            // the third command-line argument ControlType
//            if (args.Length > 2 && args[2] != null && args[2] != string.Empty)
//            {
//                
//                
//                FormControls controls;
//                try {
//                    controls = (FormControls)(System.Convert.ToInt32(args[2]));
//                } catch {
//                    // Console.WriteLine("Wrong arguments!Use numbers:");
//                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
//                    return; // 2;
//                }
//    
//                System.Windows.Forms.Application.EnableVisualStyles();
//                System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
//                // System.Windows.Forms.Application.Run(new MainForm());
//                
//                
//                System.Windows.Automation.ControlType ctrlType = null;
//                if (args.Length > 2 && args[2] != null && args[2] != "") {
//                    // string _controlType = String.Empty;
//                    //_controlType = args[2].ToUpper();
//                    ctrlType = 
//                        UiaHelper.GetControlTypeByTypeName(args[2]);
//                
//                
//                try {
//                    if ((System.Convert.ToInt32(args[0]) != 0) &&
//                        (System.Convert.ToInt32(args[1]) != 0))
//                    {
//                        int sleepTime = 
//                            System.Convert.ToInt32(args[1]);
//                        System.Threading.Thread.Sleep(sleepTime);
//                    }
//                } catch {
//                    // Console.WriteLine("Wrong arguments!Use numbers:");
//                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
//                    return; // 1;
//                }
//            }
        }
Exemplo n.º 8
0
 public WinFormsNoTaskBar(
     ControlToForm[] controls) : base ("WinFormsNoTaskBar", "WinFormsNoTaskBar", controls)
 {
     base.ChildForm = this;
 }
Exemplo n.º 9
0
 public WinFormsAnonymous(
     ControlToForm[] controls) : base ("WinFormsAnonymous", "WinFormsAnonymous", controls)
 {
     base.ChildForm = this;
 }
Exemplo n.º 10
0
        private static void Main(string[] args)
        {
            // Console.WriteLine(System.Windows.Automation.ControlType.Button.ToString());
            // Console.WriteLine(System.Windows.Automation.ControlType.Button.ProgrammaticName.ToString());
            // Console.WriteLine(System.Windows.Automation.ControlType.Button.GetType().Name);


// Dumping types for further investigation

//            Console.WriteLine("Dumping the types...");
//            dumpTypes(System.Environment.GetEnvironmentVariable("TEMP",
//                                                                EnvironmentVariableTarget.User) +
//                      @"\types.txt");
//            Console.WriteLine("...completed");
//                      return;

            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            // the second command-line argument FormDelay
            if (args.Length > 1 && args[1] != null && args[1] != string.Empty)
            {
                try {
                    if ((Convert.ToInt32(args[0]) != 0) &&
                        (Convert.ToInt32(args[1]) != 0))
                    {
                        int sleepTime =
                            Convert.ToInt32(args[1]);
                        System.Threading.Thread.Sleep(sleepTime);
                    }
                } catch {
                    // Console.WriteLine("Wrong arguments!Use numbers:");
                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
                    return; // 1;
                }
            }

// if (Delay > 0) {
// System.Threading.Thread.Sleep(Delay);
// }
            // the first command-line argument FormType
            if (args.Length > 0 && args[0] != null && args[0] != "")
            {
                Forms formCode;
                try {
                    formCode = (Forms)(Convert.ToInt32(args[0]));
                } catch {
                    // Console.WriteLine("Wrong arguments!Use numbers:");
                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
                    return; // 2;
                }

                // System.Windows.Forms.Application.Run(new MainForm());

                #region reserved code
//                System.Windows.Automation.ControlType ctrlType = null;
//
//                // the third command-line argument ControlType
//                if (args.Length > 2 && args[2] != null && args[2] != "") {
//                    // string _controlType = String.Empty;
//                    //_controlType = args[2].ToUpper();
//                    ctrlType =
//                        UiaHelper.GetControlTypeByTypeName(args[2]);
//                }
//
//                int controlDelay = 0;
//
//                // the fourth command-line argument ControlDelay
//                if (args.Length > 3 && args[3] != null && args[3] != string.Empty) {
//                    try {
//                        controlDelay = System.Convert.ToInt32(args[3]);
//                    } catch { }
//                }
//
//                string controlName = string.Empty;
//
//                // the fifth command-line argument ControlName
//                if (args.Length > 4 && args[4] != null && args[4] != string.Empty) {
//                    try {
//                        controlName = args[4];
//                    } catch { }
//                }
//
//                string controlAutomationId = string.Empty;
//
//                // the sixth command-line argument ControlAutomationId
//                if (args.Length > 5 && args[5] != null && args[5] != string.Empty) {
//                    try {
//                        controlAutomationId = args[5];
//                    } catch { }
//                }
//
//                switch (formCode)
//                {
//                    case Forms.WinFormsEmpty:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsEmpty(ctrlType, controlName, controlAutomationId, controlDelay));
//                        // WinFormsEmpty frmWFE = new WinFormsEmpty();
//                        // frmWFE.ShowDialog();
//                        break;
//                    case Forms.WinFormsEmptyX2:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsEmpty(ctrlType, controlName, controlAutomationId, controlDelay));
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsEmpty(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsAnonymous:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsAnonymous(
//                                ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsMinimized:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsMinimized(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsMaximized:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsMaximized(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsNoTaskBar:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsNoTaskBar(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsRich:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsRich(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//
//
//                    case Forms.WPFEmpty:
//                        WPFEmpty frmWPFE = new WPFEmpty();
//                        frmWPFE.ShowDialog();
//                        //Application.Run(new MainForm());
//                        break;
//                    case Forms.WPFEmptyX2:
//                        WPFEmpty frmWPFE1 = new WPFEmpty();
//                        frmWPFE1.ShowDialog();
//                        WPFEmpty frmWPFE2 = new WPFEmpty();
//                        frmWPFE2.ShowDialog();
//                        break;
//                    case Forms.WPFAnonymous:
//                        WPFAnonymous frmWPFA = new WPFAnonymous();
//                        frmWPFA.ShowDialog();
//                        break;
//                    case Forms.WPFMinimized:
//                        WPFMinimized frmWPFMi = new WPFMinimized();
//                        frmWPFMi.ShowDialog();
//                        break;
//                    case Forms.WPFMaximized:
//                        WPFMaximized frmWPFMa = new WPFMaximized();
//                        frmWPFMa.ShowDialog();
//                        break;
//                    case Forms.WPFCollapsed:
//                        WPFCollapsed frmWPFCo = new WPFCollapsed();
//                        frmWPFCo.ShowDialog();
//                        break;
//
//                }
//            }
                #endregion reserved code

                System.Windows.Automation.ControlType ctrlType = null;
                int             controlDelay        = 0;
                string          controlName         = string.Empty;
                string          controlAutomationId = string.Empty;
                ControlToForm[] controls            = null;

                if (args.Length > 2)
                {
                    //    ControlToForm controlToForm = new ControlToForm();
                    //    for (int i = 2; i < args.Length; i++) {
                    //        controlto
                    //    }

                    System.Collections.ArrayList arrList =
                        new System.Collections.ArrayList();

                    for (int i = 2; i < args.Length; i = i + 4)
                    {
                        ControlToForm controlToForm =
                            new ControlToForm();

                        //System.Windows.Automation.ControlType ctrlType = null;
                        ctrlType = null;

                        // the third command-line argument ControlType
                        if (args[i] != null && args[i] != "")
                        {
                            ctrlType =
                                UiaHelper.GetControlTypeByTypeName(args[i]);
                            controlToForm.ControlType = ctrlType;
                        }

                        //int controlDelay = 0;
                        controlDelay = 0;

                        // the fourth command-line argument ControlDelay
                        if (args[i + 1] != null && args[i + 1] != string.Empty)
                        {
                            try {
                                controlDelay = Convert.ToInt32(args[i + 1]);
                                controlToForm.ControlDelayEn = controlDelay;
                            } catch { }
                        }

                        //string controlName = string.Empty;
                        controlName = string.Empty;

                        // the fifth command-line argument ControlName
                        if (args[i + 2] != null && args[i + 2] != string.Empty)
                        {
                            try {
                                controlName = args[i + 2];
                                controlToForm.ControlName = controlName;
                            } catch { }
                        }

                        //string controlAutomationId = string.Empty;
                        controlAutomationId = string.Empty;

                        // the sixth command-line argument ControlAutomationId
                        if (args[i + 3] != null && args[i + 3] != string.Empty)
                        {
                            try {
                                controlAutomationId = args[i + 3];
                                controlToForm.ControlAutomationId = controlAutomationId;
                            } catch { }
                        }

                        arrList.Add(controlToForm);
                    } // for (int i = 2; i < args.Length; i = i + 4)

                    controls =
                        (ControlToForm[])arrList.ToArray(typeof(ControlToForm));
                }

                switch (formCode)
                {
                case Forms.WinFormsEmpty:
                    System.Windows.Forms.Application.Run(
                        new WinFormsEmpty(controls));
                    break;

                case Forms.WinFormsEmptyX2:
                    System.Windows.Forms.Application.Run(
                        new WinFormsEmpty(controls));
                    System.Windows.Forms.Application.Run(
                        new WinFormsEmpty(controls));
                    break;

                case Forms.WinFormsAnonymous:
                    System.Windows.Forms.Application.Run(
                        new WinFormsAnonymous(
                            ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsMinimized:
                    System.Windows.Forms.Application.Run(
                        new WinFormsMinimized(ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsMaximized:
                    System.Windows.Forms.Application.Run(
                        new WinFormsMaximized(ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsNoTaskBar:
                    System.Windows.Forms.Application.Run(
                        new WinFormsNoTaskBar(ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsTripled:
                    System.Windows.Forms.Application.Run(
                        new WinFormsTripled(controls));
                    break;

                case Forms.WinFormsThreeSet:
                    System.Windows.Forms.Application.Run(
                        new WinFormsOuter()); //(controls));
                    break;

                case Forms.WinFormsWithMenus:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWithMenus());
                    break;

                case Forms.WinFormsRich:
                    System.Windows.Forms.Application.Run(
                        new WinFormsRich()); //ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsFull:
                    System.Windows.Forms.Application.Run(
                        new WinFormsFull()); //ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsWizard:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWizard()); //ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsWithGrid:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWithGrid());
                    break;

                case Forms.WinFormsWithLists:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWithLists());
                    break;

                case Forms.WPFEmpty:
                    WPFEmpty frmWPFE = new WPFEmpty();
                    frmWPFE.ShowDialog();
                    //Application.Run(new MainForm());
                    break;

                case Forms.WPFEmptyX2:
                    WPFEmpty frmWPFE1 = new WPFEmpty();
                    frmWPFE1.ShowDialog();
                    WPFEmpty frmWPFE2 = new WPFEmpty();
                    frmWPFE2.ShowDialog();
                    break;

                case Forms.WPFAnonymous:
                    WPFAnonymous frmWPFA = new WPFAnonymous();
                    frmWPFA.ShowDialog();
                    break;

                case Forms.WPFMinimized:
                    WPFMinimized frmWPFMi = new WPFMinimized();
                    frmWPFMi.ShowDialog();
                    break;

                case Forms.WPFMaximized:
                    WPFMaximized frmWPFMa = new WPFMaximized();
                    frmWPFMa.ShowDialog();
                    break;

                case Forms.WPFCollapsed:
                    WPFCollapsed frmWPFCo = new WPFCollapsed();
                    frmWPFCo.ShowDialog();
                    break;

                case Forms.WPFFull:
                    WPFFull frmWPFFull = new WPFFull();
                    frmWPFFull.ShowDialog();
                    break;
//                case Forms.WPFWizard:
//                    WPFWizard frmWPFWizard = new WPFWizard();
//                    frmWPFWizard.ShowDialog();
//                    break;
                }

//            } // if (args.Length > 2)
//            else {
//                System.Windows.Forms.Application.Run(
//                    new WinFormsEmpty(ctrlType, 0));
//            }
            }


//            // the third command-line argument ControlType
//            if (args.Length > 2 && args[2] != null && args[2] != string.Empty)
//            {
//
//
//                FormControls controls;
//                try {
//                    controls = (FormControls)(System.Convert.ToInt32(args[2]));
//                } catch {
//                    // Console.WriteLine("Wrong arguments!Use numbers:");
//                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
//                    return; // 2;
//                }
//
//                System.Windows.Forms.Application.EnableVisualStyles();
//                System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
//                // System.Windows.Forms.Application.Run(new MainForm());
//
//
//                System.Windows.Automation.ControlType ctrlType = null;
//                if (args.Length > 2 && args[2] != null && args[2] != "") {
//                    // string _controlType = String.Empty;
//                    //_controlType = args[2].ToUpper();
//                    ctrlType =
//                        UiaHelper.GetControlTypeByTypeName(args[2]);
//
//
//                try {
//                    if ((System.Convert.ToInt32(args[0]) != 0) &&
//                        (System.Convert.ToInt32(args[1]) != 0))
//                    {
//                        int sleepTime =
//                            System.Convert.ToInt32(args[1]);
//                        System.Threading.Thread.Sleep(sleepTime);
//                    }
//                } catch {
//                    // Console.WriteLine("Wrong arguments!Use numbers:");
//                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
//                    return; // 1;
//                }
//            }
        }