122 List<ReadOnlyCollection<GPALAutomationElement>> rowsOfColumns =
new List<ReadOnlyCollection<GPALAutomationElement>>();
123 List<ReadOnlyCollection<GPALAutomationElement>> rowsOfElements =
new List<ReadOnlyCollection<GPALAutomationElement>>();
126 List<SmallSelectorNode> interactionInfo =
new List<SmallSelectorNode>();
132 rowsOfElements.Clear();
133 rowsOfColumns.Clear();
134 application.CurrentUOW.MatchedRowIndexes.Clear();
135 application.CurrentUOW.ColCount = 0;
136 application.CurrentUOW.RowCount = 0;
137 application.CurrentUOW.PartialMatch =
false;
139 foreach (
Selector sel
in application.CurrentUOW.WithSelectorList)
142 List<GPALAutomationElement> matchedElems;
143 ReadOnlyCollection<GPALAutomationElement> tmpElems = ElementHelper.FindElements(application, application.CurrentUOW, sel, out
bool matchedAll, out matchedElems);
144 rowsOfElements.Add(tmpElems);
145 application.CurrentUOW.ColCount++;
147 if (
false == matchedAll)
148 application.CurrentUOW.PartialMatch |=
true;
150 if (0 < tmpElems?.Count &&
true == matchedAll)
153 application.CurrentUOW.RowCount = Math.Max(application.CurrentUOW.RowCount, (
int.MaxValue == application.CurrentUOW.WithAllThatMatch ? tmpElems.Count : application.CurrentUOW.WithAllThatMatch));
155 else if (0 < matchedElems?.Count &&
false == matchedAll)
164 if (-1 != (tmpIdx = tmpElems.IndexOf(webElement)))
165 if (
false == application.CurrentUOW.MatchedRowIndexes.Contains(
new KeyValuePair<int, string>(tmpIdx, sel.AttributeName)))
166 application.CurrentUOW.MatchedRowIndexes.Add(tmpIdx, sel.AttributeName);
170 application.CurrentUOW.RowCount = (int.MaxValue == application.CurrentUOW.WithAllThatMatch ? application.CurrentUOW.MatchedRowIndexes.Count : application.CurrentUOW.WithAllThatMatch);
174 if (0 < matchedElems?.Count || 0 < tmpElems?.Count)
175 interactionInfo.Add(
new SmallSelectorNode() { InteractionType = sel.
InteractionType, OffsetX = sel.
DeltaX, OffsetY = sel.
DeltaY, DeltaX = sel.
DeltaY, DeltaY = sel.DeltaY });
179 if (
true == application.CurrentUOW.PartialMatch)
181 List<GPALAutomationElement> newColumn =
new List<GPALAutomationElement>();
183 application.CurrentUOW.RowCount = application.CurrentUOW.MatchedRowIndexes.Count;
187 foreach (ReadOnlyCollection<GPALAutomationElement> rowOfElements
in rowsOfElements)
191 foreach (KeyValuePair<int, string> idx
in application.CurrentUOW.MatchedRowIndexes)
192 newColumn.Add(rowOfElements[idx.Key]);
193 rowsOfColumns.Add(
new ReadOnlyCollection<GPALAutomationElement>(newColumn));
194 newColumn =
new List<GPALAutomationElement>();
199 foreach (ReadOnlyCollection<GPALAutomationElement> rowOfElements
in rowsOfElements)
200 rowsOfColumns.Add(rowOfElements);
204 application.CurrentUOW.ElementGrid.Clear();
207 if (0 != application.CurrentUOW.ColCount)
209 for (
int cnt = 0; cnt < application.CurrentUOW.RowCount; cnt++)
210 application.CurrentUOW.ElementGrid.AddRow(
new List<UnitOfWork.ElementNode>(application.CurrentUOW.ColCount));
217 foreach (ReadOnlyCollection<GPALAutomationElement> rowOfColumns
in rowsOfColumns)
223 switch (elem.
Ae.Current.LocalizedControlType.ToLower())
229 application.CurrentUOW.ElementGrid[rowCnt++].Add(
232 AutomationElement = elem.Ae,
233 InteractionType = interactionInfo[columnIdx].InteractionType,
234 OffsetX = interactionInfo[columnIdx].OffsetX,
235 OffsetY = interactionInfo[columnIdx].OffsetY
245 if (rowCnt >= application.CurrentUOW.WithAllThatMatch)
256 if (tokenIdx < tokens.Count())
260 foreach (List<UnitOfWork.ElementNode> elementNode
in application.CurrentUOW.ElementGrid)
262 List<T> currentRow = tokens[tokenIdx++];
264 foreach (T token
in currentRow)
266 if (elementIdx < elementNode.Count &&
null != elementNode[elementIdx])
268 if (InteractionType.Hardware == elementNode[elementIdx].InteractionType)
269 ElementHelper.HardwareFillInFrom(application,
new GPALAutomationElement(elementNode[elementIdx].AutomationElement), elementNode[elementIdx].OffsetX, elementNode[elementIdx].OffsetY, token.ToString(), writeMode);
271 ElementHelper.FillInFrom(application, elementNode[elementIdx].AutomationElement, elementNode[elementIdx], token.ToString(), writeMode);
275 GPAL.
PublishSimpleEvent(GPALEventType.WARNING, $
"Unused token [{token}] from tokens [{string.Join(",
", currentRow)}]", application, GPALObjectType.Application);
281 while (elementIdx < elementNode.Count &&
null != elementNode[elementIdx++])
282 GPAL.
PublishSimpleEvent(GPALEventType.WARNING, $
"No token for control: [{elementNode[elementIdx++].AutomationElement.Current.LocalizedControlType}]", application, GPALObjectType.Application);
286 CallIfStatus handled = CallIfStatus.NotHandled;
290 if (
null != application.CurrentUOW.AppCallAfterFillIn)
291 handled = application.CurrentUOW.AppCallAfterFillIn(application, (IGPALGrid<string>)tokens, tokenIdx);
295 application.CurrentUOW = safeUOW;
297 if (CallIfStatus.Terminate == handled)
299 GPAL.
PublishSimpleEvent(GPALEventType.INFO, $
"CallAfterFillIn handler requested program termination.", application, GPALObjectType.Application);
300 throw new GPALException($
"{GPAL.MyMethodName()}: CallAfterFillIn handler requested program termination.");
306 lastRowCnt += rowCnt;
313 if (tokenIdx == tokens.Count())