Exemplo n.º 1
0
 void DrawBoard(Board board)
 {
     try
     {
         MainCanvas.Children.Clear();
         _imageToPieceMap.Clear();
         foreach (var kvp in board.playedPieces)
         {
             HexagonDrawing hexWithImage = HexagonDrawing.GetHexagonDrawing(kvp.Value, _drawSize, kvp.Key, _mainCanvasOffsetPoint);
             MainCanvas.Children.Add(hexWithImage.image);
             MainCanvas.Children.Add(hexWithImage.polygon);
             _imageToPieceMap[hexWithImage.polygon]    = kvp.Key;
             hexWithImage.polygon.MouseLeftButtonDown += polygon_MouseLeftButtonDown;
         }
         UnplayedPiecesCanvas.Children.Clear();
         _unplayedImageToPieceMap.Clear();
         HashSet <Tuple <PieceColor, string> > shown = new HashSet <Tuple <PieceColor, string> >();
         foreach (Piece unplayedPiece in board.unplayedPieces.OrderBy(p => p.number))
         {
             var pieceTypeTuple = new Tuple <PieceColor, string>(unplayedPiece.color, unplayedPiece.GetPieceNotation());
             if (shown.Contains(pieceTypeTuple))
             {
                 continue;
             }
             AddUnplayedPieceToCanvas(unplayedPiece);
             shown.Add(pieceTypeTuple);
         }
         DrawGameInfo(board);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemplo n.º 2
0
        private void AddUnplayedPieceToCanvas(Piece piece)
        {
            Hex            hex          = GetHexForUnplayedPiece(piece);
            HexagonDrawing hexWithImage = HexagonDrawing.GetHexagonDrawing(hex, _drawSize, piece, _unplayedCanvasOffsetPoint);

            UnplayedPiecesCanvas.Children.Add(hexWithImage.image);
            _unplayedImageToPieceMap[hexWithImage.image] = piece;
            hexWithImage.image.MouseLeftButtonDown      += unplayedPieceImage_MouseLeftButtonDown;
        }