中国像棋/Form1.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 中国像棋
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
            
        }
        private void picMain_Paint(object sender, PaintEventArgs e)
        {
            ChessBoard.DreawAllChess(e.Graphics);
        }

        private void picMain_Click(object sender, EventArgs e)
        {
            MouseEventArgs mea = e as MouseEventArgs;
            Point p = GetClickPoint(mea.X, mea.Y);
            ChessBoard.ClickPoint(p);            
            picMain.Invalidate();
        }
        public Point GetClickPoint(int x, int y)
        {
            for (int i = 1; i <= 9; i++) {
                for (int j = 1; j <= 10; j++) {
                    int x1 = 50 + (i - 1) * 61;
                    int y1 = 50 + (j - 1) * 61;
                    if (Math.Abs(x - x1) <= 25 && Math.Abs(y - y1) <= 25)
                        return new Point(i, j);
                }
            }
            return new Point(-1, -1);            
        }

        public void ReDraw()
        {
            picMain.Invalidate();
        }

        private void btnDrawImage_Click(object sender, EventArgs e)
        {
            ChessBoard.ChessBack();
            picMain.Invalidate();
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。