Advertisement
Skylighty

zeruwa

May 16th, 2019
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 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 kolos_0_termin
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         List<Kulka> kulki = new List<Kulka>();
  16.         Pen pioro = new Pen(Color.Black, 10);
  17.         Pen first = new Pen(Color.Red, 10);
  18.         public bool hold = false;
  19.    
  20.         public Form1()
  21.         {
  22.             InitializeComponent();
  23.         }
  24.  
  25.         private void panel1_MouseMove(object sender, MouseEventArgs e)
  26.         {
  27.             Kulka nowa = new Kulka(e.X, e.Y);
  28.             kulki.Add(nowa);
  29.             if (kulki.Count >= 20 && hold == false)
  30.             {
  31.                 kulki.RemoveAt(0);
  32.                 panel1.Refresh();
  33.             }
  34.             panel1.Refresh();
  35.         }
  36.  
  37.         class Kulka
  38.         {
  39.             public int kx;
  40.             public int ky;
  41.  
  42.             public Kulka(int x, int y)
  43.             {
  44.                 kx = x;
  45.                 ky = y;
  46.             }
  47.         }
  48.  
  49.         private void panel1_Paint(object sender, PaintEventArgs e)
  50.         {
  51.             Graphics g = e.Graphics;
  52.             g.DrawEllipse(first, kulki[0].kx, kulki[0].ky, 5, 5);
  53.             for (int i = 1; i < kulki.Count; i++)
  54.             {
  55.                 g.DrawEllipse(pioro, kulki[i].kx,kulki[i].ky,5, 5);
  56.             }
  57.         }
  58.  
  59.         private void panel1_MouseDown(object sender, MouseEventArgs e)
  60.         {
  61.             hold = true;
  62.         }
  63.  
  64.         private void panel1_MouseUp(object sender, MouseEventArgs e)
  65.         {
  66.             hold = false;
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement