Пример #1
0
        public Piece(PieceType type, PieceColor color, int col, int row, Board board)
        {
            this.Col = col;
            this.Row = row;
            this.X = col * Game.TILESIZE;
            this.Y =  row * Game.TILESIZE;
            this.Color = color;
            this.Board = board;
            FirstMove = true;
            SetType(type);

            this.MouseDown += delegate(object s, MouseButtonEventArgs ev) {
                if (!Game.GameOver && ((!Game.IsConnected && Game.MyTurn(Color)) ||
                    (Game.IsConnected && Game.MainColor == Color && Game.MyTurn())))
                {
                    dragging = true;
                    this.Cursor = Cursors.Hand;
                    System.Windows.Controls.Canvas.SetZIndex(this, 1000);
                }
            };

            this.MouseUp += new MouseButtonEventHandler(image_MouseUp);

            this.MouseMove += new MouseEventHandler(image_MouseMove);

            this.MouseLeave += new MouseEventHandler(image_MouseMove);
        }