level 5
CLOSURING
楼主
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;
using System.IO;
using System.Drawing.Drawing2D;
namespace Drum
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//实现画图功能
private Graphics g = null;
private Point oldpoint = new Point(0, 0);
Point ptstart, ptend;
private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
{
g = pictureBox3.CreateGraphics();
oldpoint = e.Location;
ptstart = e.Location;
this.pictureBox3.MouseMove += new
System.Windows.Forms.MouseEventHandler(this.pictureBox3_MouseMove);
}
private void pictureBox3_MouseMove(object sender, MouseEventArgs e)
{
if (g != null)
{
//异常处理
try
{
g.DrawLine(Pens.Black, oldpoint, e.Location);
oldpoint = e.Location;
ptend = e.Location;
}
catch (Exception ex)
{
}
//异常处理
}
}
private void pictureBox3_MouseUp(object sender, MouseEventArgs e)
{
g.Dispose();
this.pictureBox3.MouseMove -= new System.Windows.Forms.MouseEventHandler(this.pictureBox3_MouseMove);
/*if ((ptstart.X-ptend.X)*(ptstart.X-ptend.X)+(ptstart.Y-ptend.Y)*(ptstart.Y-ptend.Y)<=100)
{
}*/
//保存图片
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox3.Height);
pictureBox3.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
bmp.Save("F:\\1.bmp");
//保存图片
}
2014年12月20日 16点12分
1
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Drawing2D;
namespace Drum
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//实现画图功能
private Graphics g = null;
private Point oldpoint = new Point(0, 0);
Point ptstart, ptend;
private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
{
g = pictureBox3.CreateGraphics();
oldpoint = e.Location;
ptstart = e.Location;
this.pictureBox3.MouseMove += new
System.Windows.Forms.MouseEventHandler(this.pictureBox3_MouseMove);
}
private void pictureBox3_MouseMove(object sender, MouseEventArgs e)
{
if (g != null)
{
//异常处理
try
{
g.DrawLine(Pens.Black, oldpoint, e.Location);
oldpoint = e.Location;
ptend = e.Location;
}
catch (Exception ex)
{
}
//异常处理
}
}
private void pictureBox3_MouseUp(object sender, MouseEventArgs e)
{
g.Dispose();
this.pictureBox3.MouseMove -= new System.Windows.Forms.MouseEventHandler(this.pictureBox3_MouseMove);
/*if ((ptstart.X-ptend.X)*(ptstart.X-ptend.X)+(ptstart.Y-ptend.Y)*(ptstart.Y-ptend.Y)<=100)
{
}*/
//保存图片
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox3.Height);
pictureBox3.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
bmp.Save("F:\\1.bmp");
//保存图片
}