using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using WindowsFormsCore.Operations; namespace WindowsFormsCore { public enum LNum { x1 = 1, x2 = 2, x3 = 3, x4 = 4, x5 = 5, x6 = 6, x7 = 7, x8 = 8, x9 = 9, x10 = 10, x11 = 11, x12 = 12, x13 = 13, x14 = 14, x15 = 15, x16 = 16, x17 = 17, x18 = 18, x19 = 19, x20 = 20, x21 = 21, x22 = 22, x23 = 23, x24 = 24, x25 = 25, x26 = 26, x27 = 27, x28 = 28, x29 = 29, x30 = 30, x31 = 31, x32 = 32, x33 = 33, x34 = 34, x35 = 35 } public partial class Form1 : Form { Random rnd = new CryptoRandom(DateTime.Now.DayOfYear); private Lotto lotto; private List clicked; private bool clearing; private TextBox[] txtBGrp1 = new TextBox[7]; private TextBox[] txtBGrp2 = new TextBox[7]; public Form1() { InitializeComponent(); lotto = new Lotto(rnd); ClearChks(); for(int i = 0; i < txtBGrp1.Count(); i++) { txtBGrp1[i] = (TextBox)this.Controls["txtNr" + (i + 1).ToString()]; txtBGrp2[i] = (TextBox)this.Controls["txtNr2" + (i + 1).ToString()]; } } private void btnGenerate_Click(object sender, EventArgs e) { var ansver = lotto.RandomRad(); for (int i = 0; i < txtBGrp1.Count(); i++) { txtBGrp1[i].Text = ansver[i]; } } private string randomNum() { return Enum.GetName(typeof(LNum), rnd.Next((int)LNum.x1, (int)LNum.x35)); } private void btnGenMotNr_Click(object sender, EventArgs e) { lblIndicator.BackColor = SystemColors.Control; lblIndicator.Text = " "; List jmfList = new List(); for (int i = 0; i < txtBGrp1.Count(); i++) { txtBGrp2[i].Text = string.IsNullOrEmpty(txtNr1.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtBGrp1[i].Text)).ToString(); jmfList.Add(txtBGrp2[i].Text); } jmfList.Sort(); var prev = string.Empty; foreach (var str in jmfList) { if (str == prev) { lblIndicator.BackColor = Color.Red; lblIndicator.Text = str; break; } prev = str; } } private void btnTest_Click(object sender, EventArgs e) { var tstIn = decimal.Parse(txtTestIn.Text); txtTestOut.Text = $"number for angle {tstIn} = {lotto.GetNumberByAngle(tstIn)}"; } private void chk_CheckedChanged(object sender, EventArgs e) { if (!clearing) { var clickTxt = ((CheckBox)sender).Text; if (clicked.Any(c => c == clickTxt)) { clicked.Remove(clickTxt); clicked.ToList().ForEach(x => Debug.Write($"{x},")); Debug.WriteLine(""); } else { clicked.Add(clickTxt); } if (clicked.Count() > 6) { for (int i = 0; i < 7; i++) { txtBGrp1[i].Text = clicked[i]; } ClearChks(); } } } private void ClearChks() { clearing = true; foreach (var chk in gpbInmata.Controls) { if (chk.GetType() == typeof(CheckBox)) { ((CheckBox)chk).Checked = false; } } clicked = new List(); clearing = false; } private void btnClear_Click(object sender, EventArgs e) { ClearChks(); gpbInmata.Refresh(); } } }