using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace KeyPress
{
public partial class Form1 : Form
{
bool shouldPaint = false;
public Form1()
{
InitializeComponent();
//事件必须在构造函数中先添加事件句柄
//声明了三个鼠标事件
this.MouseDown += new MouseEventHandler(Form1_MouseDown);
this.MouseUp += new MouseEventHandler(Form1_MouseUp);
this.MouseMove+=new MouseEventHandler(Form1_MouseMove);
}
void Form1_MouseUp(object sender, MouseEventArgs e)
{
shouldPaint = false;
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
shouldPaint = true;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (shouldPaint)
{
Graphics g = CreateGraphics();
g.FillEllipse(
new SolidBrush(Color.BlueViolet),
e.X,e.Y,4,4);
g.Dispose();
}
}
}
}
C#简单画图
最新推荐文章于 2021-06-08 17:31:52 发布
6642

被折叠的 条评论
为什么被折叠?



