Exemplo n.º 1
0
 void mouseUp(ChessPieces cp, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (cp.pic.Parent == pic_chessboard)
         {
             cp.canmove = false;
             pic_chessboard.Cursor = Cursors.Default;
             if (cp.deadPanel.Name == "pnl_RedDied")
             {
                 if (whichside == 0)//是否轮到黑棋
                 {
                     if (cp.move())
                     {
                         btn_TakeBack.Enabled = true;
                         悔棋ToolStripMenuItem.Enabled = true;
                         turnToRed();//调用移动规则 移动成功则轮到红棋
                     }
                 }
                 else
                 {
                     cp.goBack();//若不是轮到黑棋 则返回初始位置
                 }
             }
             else
             {
                 if (whichside == 1)//是否轮到红棋
                 {
                     if (cp.move())
                     {
                         btn_TakeBack.Enabled = true;
                         悔棋ToolStripMenuItem.Enabled = true;
                         turnToBlack(); //调用移动规则 移动成功则轮到黑棋
                     }
                 }
                 else
                 {
                     cp.goBack();//若不是轮到红棋 则返回初始位置
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 void mouseDown(ChessPieces cp, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         stackPoint.Push(new Point(cp.getX(), cp.getY()));
         stackPictureBox.Push(cp.pic.Name);
         if (cp.canmove == false)
         {
             if (cp.pic.Parent == pic_chessboard)
             {
                 cp.canmove = true;
                 x1 = MousePosition.X;
                 y1 = MousePosition.Y;
                 cp.getTemp();//纪录起始位置
             }
         }
     }
     else if (e.Button == MouseButtons.Right)
     {
         if (cp.canmove)
         {
             //MessageBox.Show("red");
             cp.goBack();
             pic_chessboard.Cursor = Cursors.Default;
             cp.canmove = false;
         }
     }
 }