private int GetMyIndexAmongSiblings() { int i = -1; foreach (UITestControl uitestcontrol in SourceControl.GetParent().GetChildren()) { i++; if (uitestcontrol == SourceControl) { break; } } return(i); }
/// <summary> /// Moves the property expressions with property name /// <see cref="CUITControls.WinControl.PropertyNames.ControlName"/>. from the control to /// search for to its parent. /// </summary> /// <remarks> /// Searching for WinForms controls differs slightly from searching for WPF controls. /// When searching for WPF controls using e.g. their automation id, the automation id /// search property is added to the WPF control. /// When searching for WinForms controls using their control name, the control name search /// property is added to the parent WinForms control, not the actual control itself. /// </remarks> private void MoveControlNames(PropertyExpressionCollection searchProperties) { PropertyExpression[] controlNameExpressions = searchProperties .Where(searchProperty => searchProperty.PropertyName == CUITControls.WinControl.PropertyNames.ControlName) .ToArray(); if (!controlNameExpressions.Any()) { return; } foreach (PropertyExpression controlNameExpression in controlNameExpressions) { searchProperties.Remove(controlNameExpression); } SourceControl.GetParent().SearchProperties.AddRange(controlNameExpressions); }