Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 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 WindowsFormsApp4
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18.  
  19. }
  20.  
  21. private void Form1_Load(object sender, EventArgs e)
  22. {
  23. Kino kn = new Kino();
  24. kn.KataskeuiKoumpiou();
  25.  
  26.  
  27. Controls.AddRange(kn.pinakas);
  28. Controls.Add(kn.Koumpi());
  29. }
  30.  
  31.  
  32. class Kino : Form1
  33. {
  34. public Button[] pinakas { get; set; } = new Button[80];
  35. private Random tixaios = new Random();
  36.  
  37. public void KataskeuiKoumpiou()
  38. {
  39. int x = 0;
  40. int y = 0;
  41.  
  42.  
  43. for (int i = 0; i < 80; i++, x++)
  44. {
  45. if (i % 10 == 0 && i != 0)
  46. {
  47. y = y + 50;
  48. x = 0;
  49. }
  50. Button btn = new Button();
  51. btn.Width = btn.Height = 50;
  52. btn.Location = new Point(x * 50 + 50, y + 50);
  53.  
  54. btn.Text = (i + 1).ToString();
  55. btn.Font = new Font(new FontFamily("Arial"), 16);
  56. pinakas[i] = btn;
  57.  
  58. }
  59.  
  60. }
  61.  
  62. public Button Koumpi()
  63. {
  64. Button btn = new Button();
  65. btn.AutoSize = true;
  66. btn.Location = new Point(600, 100);
  67. btn.Text = "klirosi";
  68. btn.Font = new Font(new FontFamily("Arial"), 16);
  69. btn.Click += OnKlirosi;
  70. return btn;
  71. }
  72. private void OnKlirosi(object sender, EventArgs e)
  73. {
  74.  
  75. Timer timer = new Timer();
  76.  
  77. timer.Interval = 1000;
  78. timer.Start();
  79. timer.Tick += animate;
  80. }
  81.  
  82. private void animate(object sender, EventArgs e)
  83. {
  84. pinakas[tixaios.Next(0, 80)].Enabled = false;
  85.  
  86. }
  87.  
  88. }
  89.  
  90.  
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement