Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- private int x, y;
- private bool rysuj;
- private void mysz_wcisnieta(Object Sender, MouseEventArgs e)
- {
- rysuj = true;
- x = e.X;
- y = e.Y;
- }
- private void mysz_niewcisnieta(Object Sender, MouseEventArgs e)
- {
- rysuj = false;
- }
- public Form1()
- {
- MouseDown += new MouseEventHandler(mysz_wcisnieta);
- MouseUp += new MouseEventHandler(mysz_niewcisnieta);
- MouseMove += new MouseEventHandler(delegate(Object Sender, MouseEventArgs e)
- {
- if (rysuj == true)
- {
- Graphics g = CreateGraphics();
- g.DrawLine(Pens.Blue, x, y, e.X, e.Y);
- x = e.X;
- y = e.Y;
- }
- });
- InitializeComponent();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment