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;
using System.Drawing.Drawing2D;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
timer1.Start();
}
private Point[] a = new Point[0];
private Point c=new Point();
private int num = 0, picnum =0;
private GraphicsPath myPath;
private void Form1_Load(object sender, EventArgs e)
{
this.Cursor = Cursors.Hand;
}
private void label1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
label1.Text = "left";
}
if (e.Button == MouseButtons.Right)
{
label1.Text = "right";
}
}
private void Form1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
for (int i = 0; i < files.Length; i++)
{
listBox1.Items.Add(files[i]);
}
}
}
private void Form1_DoubleClick(object sender, EventArgs e)
{
SendKeys.Send("{Tab}");
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point[] b = new Point[num];
b = a;
num++;
Array.Resize(ref a, num);
for (int i = 0; i < num - 1; i++)
{
a[i] = b[i];
}
a[num - 1] = new Point(e.X, e.Y);
}
if (e.Button == MouseButtons.Right)
{
num = 0;
Array.Resize(ref a, 0);
}
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
c = new Point(e.X, e.Y);
this.Refresh();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Pen blackpen = new Pen(Color.Black, 2);
myPath = new GraphicsPath();
if (num>0)
{
for (int i = 0; i < num-1; i++)
{
myPath.AddLine(a[i],a[i+1]);
}
e.Graphics.DrawPath(blackpen, myPath);
e.Graphics.DrawLine(blackpen, a[num-1], c);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
Rectangle bounds = this.Bounds;
Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height);
Graphics g = Graphics.FromImage(bitmap);
g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
bitmap.Save("test" + picnum + ".jpg");
picnum++;
this.Refresh();
}
}
}
No comments:
Post a Comment