Exemplo n.º 1
0
 /// <summary>
 /// Numerate rows in ascending order, from 0
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NumerateRows_OnLoadRows(object sender, ExtendedGrid.Microsoft.Windows.Controls.DataGridRowEventArgs e)
 {
     e.Row.Header = e.Row.GetIndex();
 }
Exemplo n.º 2
0
    /// <summary>
    /// Calculates one of the surface distances (not the necessarily the shortest one) for 2 points on opposing cube faces.
    /// </summary>
    private static int CalculateDistanceOnExtendedGrid(ExtendedGrid extendedGrid, GridPoint startPoint, GridPoint endPoint)
    {
        GridPoint start = new GridPoint(startPoint.face, startPoint.x, startPoint.y);
        GridPoint end   = new GridPoint(endPoint.face, endPoint.x, endPoint.y);

        switch (extendedGrid)
        {
        case ExtendedGrid.TopLeft:
            end.MirrorGridHorizontal();
            end.RotateGrid90CW();
            start.x += gridSize;
            end.y   += (gridSize * 2);
            break;

        case ExtendedGrid.TopMiddle:
            end.MirrorGridVertical();
            end.y += (gridSize * 2);
            break;

        case ExtendedGrid.TopRight:
            end.MirrorGridVertical();
            end.RotateGrid90CW();
            end.x += gridSize;
            end.y += (gridSize * 2);
            break;


        case ExtendedGrid.RightTop:
            end.MirrorGridVertical();
            end.RotateGrid90CW();
            end.x += (gridSize * 2);
            end.y += gridSize;
            break;

        case ExtendedGrid.RightMiddle:
            end.MirrorGridHorizontal();
            end.x += (gridSize * 2);
            break;

        case ExtendedGrid.RightBot:
            end.MirrorGridHorizontal();
            end.RotateGrid90CW();
            start.y += gridSize;
            end.x   += gridSize * 2;
            break;


        case ExtendedGrid.BotRight:
            end.MirrorGridHorizontal();
            end.RotateGrid90CW();
            start.y += gridSize * 2;
            end.x   += gridSize;
            break;

        case ExtendedGrid.BotMiddle:
            end.MirrorGridVertical();
            start.y += (gridSize * 2);
            break;

        case ExtendedGrid.BotLeft:
            end.MirrorGridVertical();
            end.RotateGrid90CW();
            start.x += gridSize;
            start.y += gridSize * 2;
            break;


        case ExtendedGrid.LeftBot:
            end.MirrorGridVertical();
            end.RotateGrid90CW();
            start.y += gridSize;
            start.x += (gridSize * 2);
            break;

        case ExtendedGrid.LeftMiddle:
            end.MirrorGridHorizontal();
            start.x += gridSize * 2;
            break;

        case ExtendedGrid.LeftTop:
            end.MirrorGridHorizontal();
            end.RotateGrid90CW();
            start.x += gridSize * 2;
            end.y   += gridSize;
            break;

        default:
            throw new Exception("huh?");
        }

        return(CalculateShortestDistance(start, end));
    }