Advertisement
itocska

lottos_kod

May 16th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.45 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. using System.IO;
  11.  
  12. namespace lottos_feladat
  13. {
  14. public partial class Szelveny : Form
  15. {
  16. public int valaszt = 0;
  17. private int tippek = 0;
  18. public Szelveny()
  19. {
  20. InitializeComponent();
  21. }
  22. private void Szelveny_Load(object sender, EventArgs e)
  23. {
  24. felado.Enabled = false;
  25. feladas.Enabled = false;
  26. int db = 0;
  27. if (valaszt == 5) { db = 90; }
  28. if (valaszt == 6) { db = 45; }
  29. if (valaszt == 7) { db = 35; }
  30. int balrol = -25;
  31. int fentrol = 20;
  32. if (valaszt == 5)
  33. {
  34. int oszloponkent = 10;
  35. this.Height = 290;
  36. for (int i = 1; i <= db; i++)
  37. {
  38. oszloponkent++;
  39. if ((i % 10) == 1)
  40. {
  41. balrol = balrol + 45;
  42. oszloponkent = oszloponkent - 10;
  43. }
  44. CheckBox tipp = new CheckBox();
  45. tipp.Left = balrol;
  46. tipp.Top = fentrol + oszloponkent * 20;
  47. tipp.Text = i.ToString();
  48. tipp.Width = 40;
  49. tipp.CheckedChanged += mintagomb_CheckedChanged;
  50. this.Controls.Add(tipp);
  51. }
  52. }
  53. else if (valaszt == 6)
  54. {
  55. int sorsz = 5;
  56. this.Height = 190;
  57. for (int i = 1; i <= db; i++)
  58. {
  59. sorsz++;
  60. if ((i % 5) == 1)
  61. {
  62. balrol = balrol + 45;
  63. sorsz = sorsz - 5;
  64. }
  65. CheckBox tipp = new CheckBox();
  66. tipp.Left = balrol;
  67. tipp.Top = fentrol + sorsz * 20;
  68. tipp.Text = i.ToString();
  69. tipp.Width = 40;
  70. tipp.CheckedChanged += mintagomb_CheckedChanged;
  71. this.Controls.Add(tipp);
  72. }
  73. }
  74. else {
  75. int sorsz = 4;
  76. this.Height = 170;
  77. for (int i = 1; i <= db; i++)
  78. {
  79. sorsz++;
  80. if ((i % 4) == 1)
  81. {
  82. balrol = balrol + 45;
  83. sorsz = sorsz - 4;
  84. }
  85. CheckBox tipp = new CheckBox();
  86. tipp.Left = balrol;
  87. tipp.Top = fentrol + sorsz * 20;
  88. tipp.Text = i.ToString();
  89. tipp.Width = 40;
  90. tipp.CheckedChanged += mintagomb_CheckedChanged;
  91. this.Controls.Add(tipp);
  92. }
  93. }
  94. }
  95. private void felado_TextChanged(object sender, EventArgs e)
  96. {
  97. if (felado.Text.Trim().Split(' ').Length >= 2) { feladas.Enabled = true; }
  98. else { feladas.Enabled = false; }
  99. }
  100. private void feladas_Click(object sender, EventArgs e)
  101. {
  102. string mentes = "" + Environment.NewLine;
  103. if (valaszt == 5) { mentes = "5-ös"+Environment.NewLine; }
  104. if (valaszt == 6) { mentes = "6-os" + Environment.NewLine; }
  105. if (valaszt == 7) { mentes = "Skandinav" + Environment.NewLine; }
  106. mentes += "Ekkor: " + System.DateTime.Now.ToString() + Environment.NewLine; ;
  107.  
  108. mentes += "Feladó: " + felado.Text + Environment.NewLine + "Tippek: ";
  109. foreach (Control x in this.Controls)
  110. {
  111. if (x is CheckBox)
  112. {
  113. CheckBox tippekmentes = (CheckBox)x;
  114. if (tippekmentes.Checked) mentes += tippekmentes.Text + ",";
  115. }
  116. }
  117. StreamWriter fileba = new StreamWriter("tippek.txt", true, Encoding.GetEncoding("ISO-8859-2"));
  118. fileba.WriteLine(mentes);
  119. fileba.Close();
  120. this.Close();
  121. }
  122. private void mintagomb_CheckedChanged(object sender, EventArgs e)
  123. {
  124. CheckBox Box = (CheckBox)sender;
  125. if (Box.Checked) { tippek++; }
  126. else { tippek--; }
  127. if (tippek == valaszt)
  128. {
  129. felado.Enabled = true;
  130. foreach (Control x in this.Controls)
  131. {
  132. if (x is CheckBox)
  133. {
  134. CheckBox tippgomb = (CheckBox)x;
  135. if (!(tippgomb.Checked)) tippgomb.Enabled = false;
  136. }
  137. }
  138. }
  139. else
  140. {
  141. felado.Enabled = false;
  142. foreach (Control x in this.Controls)
  143. {
  144. if (x is CheckBox)
  145. {
  146. CheckBox tippgomb = (CheckBox)x;
  147. tippgomb.Enabled = true;
  148. }
  149. }
  150. }
  151. }
  152. private void megse_Click(object sender, EventArgs e)
  153. {
  154. this.Close();
  155. }
  156. }
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement