FrmConfig.cs
(开头部分) 10KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
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 Tetris
{
public partial class FrmConfig : Form
{
public FrmConfig()
{
InitializeComponent();
}
private bool[,] struArr = new bool[5, 5];
private Color blockColor = Color.Red;
private Config config = new Config();
private void lblMode_Paint(object sender, PaintEventArgs e)
{
Graphics gp = e.Graphics;
gp.Clear(Color.Black);
Pen p = new Pen(Color.White);
//SolidBrush s = new SolidBrush(Color.White);
for (int i = 31; i < 155; i = i + 31)
gp.DrawLine(p, 1, i, 155, i); //划横白线
for (int i = 31; i < 155; i = i + 31)
gp.DrawLine(p, i, 1, i, 155); //画竖白线
//填充矩阵中的方块
SolidBrush s = new SolidBrush(blockColor);
for(int x=0;x<5;x++)
{
for(int y=0;y<5;y++)
{
if(struArr[x,y])
{
gp.FillRectangle(s, 31 * x + 1, 31 * y + 1, 30, 30);
}
}
}
}
private void lblMode_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left) //判断是否点击了鼠标左键
return; //如果点击的不是鼠标左键就退出
int xPos, yPos; //xPos表示数组第一个下标,yPos表示数组第二个下标
xPos = e.X / 31; //把屏幕像素值转换为数组下标值
yPos = e.Y / 31;
struArr[xPos, yPos] = !struArr[xPos, yPos];
bool b = struArr[xPos, yPos];
Graphics gp = lblMode.CreateGraphics(); //得到lblMode的Graphics
SolidBrush s = new SolidBrush(b ? blockColor : Color.Black); //创建一个刷子,并确定它的颜色
gp.FillRectangle(s, 31 * xPos + 1, 31 * yPos + 1, 30, 30); //给鼠标点击的方块上色
gp.Dispose(); //释放Graphics
后面还有 202 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。