private void SetCellPosition(object control, int row, int column, bool rowSpecified, bool colSpecified) { if (IsStub) { if (colSpecified) { _stub.SetColumn(control, column); } if (rowSpecified) { _stub.SetRow(control, row); } } else { IArrangedElement element = LayoutEngine.CastToArrangedElement(control); if (element.Container != null) { TableLayout.ClearCachedAssignments(TableLayout.GetContainerInfo(element.Container)); } TableLayout.LayoutInfo layoutInfo = TableLayout.GetLayoutInfo(element); if (colSpecified) { layoutInfo.ColumnPosition = column; } if (rowSpecified) { layoutInfo.RowPosition = row; } LayoutTransaction.DoLayout(element.Container, element, PropertyNames.TableIndex); Debug.Assert(!colSpecified || GetColumn(element) == column, "column position shoule equal to what we set"); Debug.Assert(!rowSpecified || GetRow(element) == row, "row position shoule equal to what we set"); } }
public int GetColumn(object control) { ArgumentNullException.ThrowIfNull(control); if (IsStub) { return(_stub.GetColumn(control)); } else { IArrangedElement element = LayoutEngine.CastToArrangedElement(control); TableLayout.LayoutInfo layoutInfo = TableLayout.GetLayoutInfo(element); return(layoutInfo.ColumnPosition); } }
public int GetRow(object control) { if (control == null) { throw new ArgumentNullException(nameof(control)); } if (IsStub) { return(_stub.GetRow(control)); } else { IArrangedElement element = LayoutEngine.CastToArrangedElement(control); TableLayout.LayoutInfo layoutInfo = TableLayout.GetLayoutInfo(element); return(layoutInfo.RowPosition); } }