Kyaria

GhettoPAint

Jan 8th, 2018
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace malen
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Point neu = new Point();
  16.         public Point alt = new Point();
  17.         public Pen p = new Pen(Color.Black, 5);
  18.         public Graphics g;
  19.         public Bitmap bittymap;
  20.  
  21.         public Form1()
  22.         {
  23.             InitializeComponent();
  24.  
  25.             bittymap = new Bitmap(500, 500);
  26.             g = Graphics.FromImage(bittymap);
  27.             g.Clear(SystemColors.Control);
  28.  
  29.             p.SetLineCap(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.DashCap.Round);
  30.         }
  31.  
  32.         private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
  33.         {
  34.             if (e.Button == MouseButtons.Left)
  35.             {
  36.                 neu = e.Location;
  37.                 g.DrawLine(p, neu, alt);
  38.                 alt = neu;
  39.  
  40.                 pictureBox1.Image = bittymap;
  41.             }
  42.         }
  43.  
  44.         private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
  45.         {
  46.             alt = e.Location;
  47.  
  48.             if (e.Button == MouseButtons.Right)
  49.             {
  50.                 g.Clear(SystemColors.Control);
  51.  
  52.                 pictureBox1.Image = bittymap;
  53.             }
  54.         }
  55.  
  56.         private void button1_Click(object sender, EventArgs e)
  57.         {
  58.             string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\bittymap.bmp";
  59.             bittymap.Save(path, System.Drawing.Imaging.ImageFormat.Bmp);
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment