Example #1
0
        /// <summary>
        ///Una prueba de GetPositionOnMatrixFromIndex
        ///</summary>
        public void GetPositionOnMatrixFromIndexTestHelper <T>(int rowCount, int columnCount)
        {
            var matrix = new MatrixRotation.Matrix <int>(rowCount, columnCount);

            for (int r = 0; r < matrix.RowCount; r++)
            {
                for (int c = 0; c < matrix.ColumnCount; c++)
                {
                    matrix[r, c] = r * 10 + c;
                }
            }

            int frameCount = Math.Min(matrix.RowCount, matrix.ColumnCount) / 2;

            for (int frameIndex = 0; frameIndex < frameCount; frameIndex++)
            {
                var frame = Frame <int> .FromMatrix(matrix, frameIndex, 0);

                var frameAccesor = new PrivateObject(frame);
                var enumerable   = new MatrixRotation.PositionOnMatrixFrameStyleEnumerable(matrix.RowCount, matrix.ColumnCount, frameIndex);
                var i            = 0;

                foreach (MatrixRotation.PositionOnMatrix pos in enumerable)
                {
                    MatrixRotation.PositionOnMatrix newPos = (MatrixRotation.PositionOnMatrix)frameAccesor.Invoke("GetPositionOnMatrixFromIndex", i);
                    Assert.AreEqual(pos.Row, newPos.Row, String.Format("Row.FrameIndex={1} Index={0}", i, frameIndex));
                    Assert.AreEqual(pos.Column, newPos.Column, String.Format("Column.FrameIndex={1}  Index={0}", i, frameIndex));
                    i++;
                }
            }
        }
Example #2
0
 private int GetIndexFromPositionOnMatrix(PositionOnMatrix pos)
 {
     if (IsOnFrameTop(pos))
     {
         return(pos.Column - _frameIndex);
     }
     if (IsOnFrameRight(pos))
     {
         return(_frameColumnCount - 1 + (pos.Row - _frameIndex));
     }
     if (IsOnFrameBottom(pos))
     {
         return((_frameColumnCount - 1) + (_frameRowCount - 1) + (_frameColumnCount - 1 + _frameIndex - pos.Column));
     }
     if (IsOnFrameLeft(pos))
     {
         return(2 * (_frameColumnCount - 1) + (_frameRowCount - 1) + (_frameRowCount - 1 + _frameIndex - pos.Row));
     }
     throw new ArgumentOutOfRangeException("Position", "La posición no está en el frame");
 }
Example #3
0
 private bool IsOnFrameLeft(PositionOnMatrix pos)
 {
     return(pos.Column == _frameIndex);
 }
Example #4
0
 private bool IsOnFrameBottom(PositionOnMatrix pos)
 {
     return(pos.Row == _rowCount - 1 - _frameIndex);
 }
Example #5
0
 private bool IsOnFrameRight(PositionOnMatrix pos)
 {
     return(pos.Column == _columnCount - 1 - _frameIndex);
 }
Example #6
0
 private bool IsOnFrameTop(PositionOnMatrix pos)
 {
     return(pos.Row == _frameIndex);
 }