日期:2014-05-17 浏览次数:20843 次
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Test
{
public partial class Form1 : Form
{
private Point startPoint;
private Point endPoint;
private bool isDrawing = false;
private Bitmap memoryBuffer;
public Form1()
{
InitializeComponent();
memoryBuffer = new Bitmap(pictureBox1.Width, pictureBox1.Height);
pictureBox1.MouseUp += new MouseEventHandler(pictureBox1_MouseUp);
pictureBox1.MouseDown += new MouseEventHandler(pictureBox1_MouseDown);
pictureBox1.MouseMove += new MouseEventHandler(pictureBox1_MouseMove);
}
void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
isDrawing = false;
}
void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
startPoint = new Point(e.X, e.Y);
isDrawing = true;
}
void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
endPoint = new Point(e.X, e.Y);
drawSelectedRect();
&nb