سلام دوست من.
این همه کد چرا؟:31:
همین کافیه:
کد:
private Point pDown = new Point();
private Point pUp = new Point();
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
pDown = e.Location;
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
pUp = e.Location;
this.CreateGraphics().DrawLine(new Pen(Color.Red), pDown, pUp);
}
ولی وقتی فرم Refresh بشه خط ها پاک میشن که من کد زیر رو پیشنهاد میکنم:
کد:
public Form1()
{
InitializeComponent();
this.BackgroundImage = image;
}
private Point pDown = new Point();
private Point pUp = new Point();
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
pDown = e.Location;
}
Bitmap image = new Bitmap(500, 500);
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
pUp = e.Location;
using (Graphics eg = Graphics.FromImage(image))
{
eg.DrawLine(new Pen(Color.Red), pDown, pUp);
}
this.Invalidate();
}
موفق باشید:11:.