Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion InteractiveAutomationToolkit/Dialogs/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,8 @@ private void CheckIfVisibleWidgetOverlaps(Widget widget)

private void CheckIfOtherWidgetsAreVisibleOnPosition(Widget widget, IWidgetLayout layout, int row, int column)
{
var overlappingWidgets = new List<Widget>();

foreach (Widget otherWidget in widgetLayouts.Keys)
{
if (!otherWidget.IsVisible || widget.Equals(otherWidget))
Expand All @@ -741,9 +743,19 @@ private void CheckIfOtherWidgetsAreVisibleOnPosition(Widget widget, IWidgetLayou
IWidgetLayout otherWidgetLayout = widgetLayouts[otherWidget];
if (column >= otherWidgetLayout.Column && column < otherWidgetLayout.Column + otherWidgetLayout.ColumnSpan && row >= otherWidgetLayout.Row && row < otherWidgetLayout.Row + otherWidgetLayout.RowSpan)
{
throw new OverlappingWidgetsException(String.Format("The widget overlaps with another widget in the Dialog on Row {0}, Column {1}, RowSpan {2}, ColumnSpan {3}", layout.Row, layout.Column, layout.RowSpan, layout.ColumnSpan));
overlappingWidgets.Add(otherWidget);
}
}

if (overlappingWidgets.Count > 0)
{
string overlappingWidgetsInfo = String.Join(", ", overlappingWidgets.Select(w => FormatWidgetInfo(w, widgetLayouts[w])));

throw new OverlappingWidgetsException(String.Format(
"Widget {0} overlaps with: {1}",
FormatWidgetInfo(widget, layout),
overlappingWidgetsInfo));
}
}

private string GetRowDefinitions(SortedSet<int> rowsInUse)
Expand Down Expand Up @@ -936,5 +948,14 @@ internal void RaiseResultEvents(IUIResults uir, ILogger logger = null)
intractable.RaiseResultEvents(logger);
}
}

private string FormatWidgetInfo(Widget widget, IWidgetLayout layout)
{
string debugTagPart = String.IsNullOrEmpty(widget.DebugTag)
? String.Empty
: $" [DebugTag: '{widget.DebugTag}']";

return $"{widget.GetType().Name}{debugTagPart} (Row {layout.Row}, Column {layout.Column}, RowSpan {layout.RowSpan}, ColumnSpan {layout.ColumnSpan})";
}
}
}
Loading