Chess类里的pointlist中的点为什么传不到form类里的paint函数中,画不出来图形啊?有谁可以解答下吗
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 C_例_69_五子棋_窗体应用
{
public enum ChessState
{
BLANK,
BLACK,
WHITE
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public int start = 0;
public const int forever = 10;
public bool fupan = false;
public int count = forever;
private void Form1_Paint(object sender, PaintEventArgs e)
{
Chess c1 = new Chess();
Graphics g = e.Graphics;
SolidBrush w = new SolidBrush(Color.White);
SolidBrush b = new SolidBrush(Color.Black);
for (int i = 0; i < c1.pointlist.Count; i++)
{
if (i % 2 == 0)
{
g.FillEllipse(w, x - 15, y - 15, 28, 28);
if (i % 2 == 1)
{
g.FillEllipse(b, x - 15, y - 15, 28, 28);
}
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
Chess c2 = new Chess();
if (start == 1)
{
if (e.Location.X > 55 && e.Location.X < 505 && e.Location.Y > 65 && e.Location.Y < 515)
{
Point p1 = new Point();
p1.X = e.Location.X; p1.Y = e.Location.Y;
c2.pointlist.Add(p1);
Invalidate();
}
}
}
private void rrstart_Click(object sender, EventArgs e)
{
Chess c = new Chess();
c.pointlist.Clear();
Invalidate();
start = 1;
}
}
public struct Point
{
public int X;
public int Y;
}
class Chess
{
public int width = 640;
public int height = 600;
public ChessState[,] qipan = new ChessState[15, 15];
public List<Point> pointlist = new List<Point>(500);
}
}