public Rectangle(ICellPosition upperLeft, ICellPosition lowerRight) { //Дерьмо ниже на случай, если кто-то перепутает позиции. UpperLeft = new CellPosition(Math.Min(upperLeft.RowIndex, lowerRight.RowIndex), Math.Min(upperLeft.ColumnIndex, lowerRight.ColumnIndex)); LowerRight = new CellPosition(Math.Max(upperLeft.RowIndex, lowerRight.RowIndex), Math.Max(upperLeft.ColumnIndex, lowerRight.ColumnIndex)); Size = lowerRight.Subtract(upperLeft).Add(new ObjectSize(1, 1)); }
public static ICellPosition ToGlobalCoordinates(this ICellPosition relativeCoordinates, ICellPosition originCoordinates) { return(relativeCoordinates.Add(originCoordinates.Subtract(new CellPosition(1, 1)))); }
public static ICellPosition ToRelativeCoordinates(this ICellPosition globalCoordinates, ICellPosition newOrigin) { return(new CellPosition(1, 1).Add(globalCoordinates.Subtract(newOrigin))); }