Exemplo n.º 1
0
 /// <summary>
 /// 静态构造函数
 /// </summary>
 static Servicer()
 {
     Servicer.PieceImages = new Dictionary <Enums.PieceType, Image>(12);
     Servicer.InitializeBoardImage();
     Servicer.InitializeGridImages();
     Servicer.InitializePieceImages();
 }
Exemplo n.º 2
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            _isMouseDown = true;
            if (_Game == null)
            {
                return;
            }
            switch (e.Button)
            {
            case MouseButtons.Left:
                #region  择Position,并MoveIn
                for (int x = 1; x <= 8; x++)
                {
                    for (int y = 1; y <= 8; y++)
                    {
                        if (!this.Rectangles[x - 1, y - 1].Contains(e.Location))
                        {
                            continue;
                        }
                        if (_Game.TryGetPiece(Position.CalculateDot(x, y), out this.SelectedPiece))       //Pieces.TryGetPiece(position.Dot, out this.SelectedPiece))
                        {
                            if (this.SelectedPiece.GameSide != this.CurrChessSide)
                            {
                                this.SelectedPiece = null;
                                return;    //找到棋子,但棋子战方不符
                            }
                            this.SelectedPosition = new Position(x, y);
                            this.SelectedPiece.SetEnablePositions(_Game, out this.EnableMoveInPosition, out this.EnableCapturePosition);
                            this.SelectedPieceImage = Servicer.GetPieceImage(this.SelectedPiece.PieceType);
                            this.Refresh();
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                #endregion
                break;

            case MouseButtons.Middle:
            case MouseButtons.Right:
            case MouseButtons.None:
            case MouseButtons.XButton1:
            case MouseButtons.XButton2:
            default:
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>1. 用指定的棋子图片集合绘制棋子
        /// </summary>
        protected virtual void Paint_PieceImage()
        {
            Graphics g = Graphics.FromImage(this.OccImage);

            foreach (Piece piece in _Game)
            {
                if (piece.IsCaptured)
                {
                    continue;
                }
                _currManRect  = Board.GetPieceRectangle(this, piece.Position);
                _currManImage = Servicer.GetPieceImage(piece.PieceType);
                g.DrawImage(_currManImage, _currManRect);
            }
            _currManImage = null;
        }