Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- using System.IO;
- namespace lottos_feladat
- {
- public partial class Szelveny : Form
- {
- public int valaszt = 0;
- private int tippek = 0;
- public Szelveny()
- {
- InitializeComponent();
- }
- private void Szelveny_Load(object sender, EventArgs e)
- {
- felado.Enabled = false;
- feladas.Enabled = false;
- int db = 0;
- if (valaszt == 5) { db = 90; }
- if (valaszt == 6) { db = 45; }
- if (valaszt == 7) { db = 35; }
- int balrol = -25;
- int fentrol = 20;
- if (valaszt == 5)
- {
- int oszloponkent = 10;
- this.Height = 290;
- for (int i = 1; i <= db; i++)
- {
- oszloponkent++;
- if ((i % 10) == 1)
- {
- balrol = balrol + 45;
- oszloponkent = oszloponkent - 10;
- }
- CheckBox tipp = new CheckBox();
- tipp.Left = balrol;
- tipp.Top = fentrol + oszloponkent * 20;
- tipp.Text = i.ToString();
- tipp.Width = 40;
- tipp.CheckedChanged += mintagomb_CheckedChanged;
- this.Controls.Add(tipp);
- }
- }
- else if (valaszt == 6)
- {
- int sorsz = 5;
- this.Height = 190;
- for (int i = 1; i <= db; i++)
- {
- sorsz++;
- if ((i % 5) == 1)
- {
- balrol = balrol + 45;
- sorsz = sorsz - 5;
- }
- CheckBox tipp = new CheckBox();
- tipp.Left = balrol;
- tipp.Top = fentrol + sorsz * 20;
- tipp.Text = i.ToString();
- tipp.Width = 40;
- tipp.CheckedChanged += mintagomb_CheckedChanged;
- this.Controls.Add(tipp);
- }
- }
- else {
- int sorsz = 4;
- this.Height = 170;
- for (int i = 1; i <= db; i++)
- {
- sorsz++;
- if ((i % 4) == 1)
- {
- balrol = balrol + 45;
- sorsz = sorsz - 4;
- }
- CheckBox tipp = new CheckBox();
- tipp.Left = balrol;
- tipp.Top = fentrol + sorsz * 20;
- tipp.Text = i.ToString();
- tipp.Width = 40;
- tipp.CheckedChanged += mintagomb_CheckedChanged;
- this.Controls.Add(tipp);
- }
- }
- }
- private void felado_TextChanged(object sender, EventArgs e)
- {
- if (felado.Text.Trim().Split(' ').Length >= 2) { feladas.Enabled = true; }
- else { feladas.Enabled = false; }
- }
- private void feladas_Click(object sender, EventArgs e)
- {
- string mentes = "" + Environment.NewLine;
- if (valaszt == 5) { mentes = "5-ös"+Environment.NewLine; }
- if (valaszt == 6) { mentes = "6-os" + Environment.NewLine; }
- if (valaszt == 7) { mentes = "Skandinav" + Environment.NewLine; }
- mentes += "Ekkor: " + System.DateTime.Now.ToString() + Environment.NewLine; ;
- mentes += "Feladó: " + felado.Text + Environment.NewLine + "Tippek: ";
- foreach (Control x in this.Controls)
- {
- if (x is CheckBox)
- {
- CheckBox tippekmentes = (CheckBox)x;
- if (tippekmentes.Checked) mentes += tippekmentes.Text + ",";
- }
- }
- StreamWriter fileba = new StreamWriter("tippek.txt", true, Encoding.GetEncoding("ISO-8859-2"));
- fileba.WriteLine(mentes);
- fileba.Close();
- this.Close();
- }
- private void mintagomb_CheckedChanged(object sender, EventArgs e)
- {
- CheckBox Box = (CheckBox)sender;
- if (Box.Checked) { tippek++; }
- else { tippek--; }
- if (tippek == valaszt)
- {
- felado.Enabled = true;
- foreach (Control x in this.Controls)
- {
- if (x is CheckBox)
- {
- CheckBox tippgomb = (CheckBox)x;
- if (!(tippgomb.Checked)) tippgomb.Enabled = false;
- }
- }
- }
- else
- {
- felado.Enabled = false;
- foreach (Control x in this.Controls)
- {
- if (x is CheckBox)
- {
- CheckBox tippgomb = (CheckBox)x;
- tippgomb.Enabled = true;
- }
- }
- }
- }
- private void megse_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement