Add project files.
This commit is contained in:
217
WindowsFormsCore/Form1.cs
Normal file
217
WindowsFormsCore/Form1.cs
Normal file
@ -0,0 +1,217 @@
|
||||
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<string> clicked;
|
||||
private byte numClicks = 0;
|
||||
private bool clearing;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
lotto = new Lotto(rnd);
|
||||
ClearChks();
|
||||
}
|
||||
|
||||
private void btnGenerate_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var ansver = lotto.RandomRad();
|
||||
txtNr1.Text = ansver[0];
|
||||
txtNr2.Text = ansver[1];
|
||||
txtNr3.Text = ansver[2];
|
||||
txtNr4.Text = ansver[3];
|
||||
txtNr5.Text = ansver[4];
|
||||
txtNr6.Text = ansver[5];
|
||||
txtNr7.Text = ansver[6];
|
||||
}
|
||||
|
||||
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<string> jmfList = new List<string>();
|
||||
txtNr21.Text = string.IsNullOrEmpty(txtNr1.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtNr1.Text)).ToString();
|
||||
jmfList.Add(txtNr21.Text);
|
||||
txtNr22.Text = string.IsNullOrEmpty(txtNr2.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtNr2.Text)).ToString();
|
||||
jmfList.Add(txtNr22.Text);
|
||||
txtNr23.Text = string.IsNullOrEmpty(txtNr3.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtNr3.Text)).ToString();
|
||||
jmfList.Add(txtNr23.Text);
|
||||
txtNr24.Text = string.IsNullOrEmpty(txtNr4.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtNr4.Text)).ToString();
|
||||
jmfList.Add(txtNr24.Text);
|
||||
txtNr25.Text = string.IsNullOrEmpty(txtNr5.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtNr5.Text)).ToString();
|
||||
jmfList.Add(txtNr25.Text);
|
||||
txtNr26.Text = string.IsNullOrEmpty(txtNr6.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtNr6.Text)).ToString();
|
||||
jmfList.Add(txtNr26.Text);
|
||||
txtNr27.Text = string.IsNullOrEmpty(txtNr7.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtNr7.Text)).ToString();
|
||||
jmfList.Add(txtNr27.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++)
|
||||
{
|
||||
switch (i + 1)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
txtNr1.Text = clicked[i];
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
txtNr2.Text = clicked[i];
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
txtNr3.Text = clicked[i];
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
txtNr4.Text = clicked[i];
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
txtNr5.Text = clicked[i];
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
txtNr6.Text = clicked[i];
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
txtNr7.Text = clicked[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ClearChks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearChks()
|
||||
{
|
||||
clearing = true;
|
||||
foreach (var chk in gpbInmata.Controls)
|
||||
{
|
||||
if (chk.GetType() == typeof(CheckBox))
|
||||
{
|
||||
((CheckBox)chk).Checked = false;
|
||||
}
|
||||
}
|
||||
clicked = new List<string>();
|
||||
numClicks = 0;
|
||||
clearing = false;
|
||||
}
|
||||
|
||||
private void btnClear_Click(object sender, EventArgs e)
|
||||
{
|
||||
ClearChks();
|
||||
gpbInmata.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user