/// <summary> /// /// </summary> /// <param name="fmName"></param> /// <param name="ctlName"></param> public void TriggerControlOnForm(string fmName, string ctlName) { if (string.IsNullOrEmpty(fmName) || string.IsNullOrEmpty(ctlName)) { throw new ApplicationException("Invalid form name and/or control name specified in test: " + this.testName + " while trying to trigger a control."); } Form curForm; if (!this.isFormValid(fmName, out curForm)) { throw new ApplicationException("Cannot trigger control in form in test: " + this.testName); } //Get control dictionary for this form Dictionary <string, TupleType <Control, ControlType, ControlTriggerType> > ctlDctToFind = this.loadFormControlTriggers[fmName]; if (CollectionUtilities.isEmpty(ctlDctToFind)) { throw new ApplicationException("Cannot find trigger control dictionary in form: " + fmName + " in test: " + this.testName); } //Find exact control entry if (!ctlDctToFind.ContainsKey(ctlName)) { throw new ApplicationException("Cannot find trigger control: " + ctlName + " in form: " + fmName + " in test: " + this.testName); } //Retrieve control entry TupleType <Control, ControlType, ControlTriggerType> ctlTuple = ctlDctToFind[ctlName]; Control ctlObj = ctlTuple.Left; ControlType ctlType = ctlTuple.Mid; ControlTriggerType ctlTrgType = ctlTuple.Right; this.internalTriggerControl(ctlObj, ctlType, ctlTrgType); }
private void internalTriggerControl(Control ctl, ControlType cType, ControlTriggerType cTrigType) { if (ctl == null) { throw new ApplicationException("internalTriggerControl cannot trigger a null control in test: " + this.testName); } Cursor.Position = new Point(ctl.Location.X + (ctl.Bounds.Width / 2), ctl.Location.Y + (ctl.Bounds.Height / 2)); SendInputWrapper.Click(); /* switch (cType) * { * case ControlType.UNKNOWN: * break; * case ControlType.UNKNOWN_XY: * Cursor.Position = * new Point(ctl.Location.X + (ctl.Bounds.Width / 2), ctl.Location.Y + (ctl.Bounds.Height / 2)); * SendInputWrapper.Click(); * break; * case ControlType.TEXTBOX: * break; * case ControlType.BUTTON: * break; * case ControlType.LISTBOX: * break; * case ControlType.COMBOBOX: * break; * case ControlType.AUTOCOMPLETE: * break; * case ControlType.DATAGRIDROW: * break; * case ControlType.DATAGRIDROWCOLUMN: * break; * default: * throw new ArgumentOutOfRangeException("cType"); * }*/ }