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; namespace malen { public partial class Form1 : Form { public Point neu = new Point(); public Point alt = new Point(); public Pen p = new Pen(Color.Black, 5); public Graphics g; public Bitmap bittymap; public Form1() { InitializeComponent(); bittymap = new Bitmap(500, 500); g = Graphics.FromImage(bittymap); g.Clear(SystemColors.Control); p.SetLineCap(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.DashCap.Round); } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { neu = e.Location; g.DrawLine(p, neu, alt); alt = neu; pictureBox1.Image = bittymap; } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { alt = e.Location; if (e.Button == MouseButtons.Right) { g.Clear(SystemColors.Control); pictureBox1.Image = bittymap; } } private void button1_Click(object sender, EventArgs e) { string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\bittymap.bmp"; bittymap.Save(path, System.Drawing.Imaging.ImageFormat.Bmp); } } }