예제 #1
0
        public static IDominoShape[] AddRowColumn(IRowColumnAddableDeletable reference,
                                                  bool column, int position, bool southeast, int count, int color, out int[] inserted_positions)
        {
            int[][] shapes = new int[count][];
            for (int i = 0; i < count; i++)
            {
                shapes[i] = new int[reference.getLengthOfTypicalRowColumn(column)];
                for (int j = 0; j < shapes[i].Length; j++)
                {
                    shapes[i][j] = color;
                }
            }
            var pos   = reference.getPositionFromIndex(position);
            var res_y = southeast ? (pos.Y + (!column ? 1 : 0)) : pos.Y;
            var res_x = southeast ? (pos.X + (column ? 1 : 0)) : pos.X;

            if (!column && (res_y == -1 || res_y == reference.current_height + (column ? 0 : count)) ||
                column && (res_x == -1 || res_x == reference.current_width + (column ? count : 0)))
            {
                throw new InvalidOperationException("Can't insert row/column here, borders must remain borders");
            }
            return(AddRowColumn(reference, column, Enumerable.Repeat(new PositionWrapper()
            {
                X = res_x, Y = res_y, CountInsideCell = 0
            },
                                                                     count).ToArray(), shapes, out inserted_positions));
        }
예제 #2
0
 public static PositionWrapper[] IndicesToPositions(IRowColumnAddableDeletable reference, int[] positions)
 {
     PositionWrapper[] wrapper = new PositionWrapper[positions.Length];
     for (int i = 0; i < positions.Length; i++)
     {
         wrapper[i] = reference.getPositionFromIndex(positions[i]);
     }
     return(wrapper);
 }