Indexerat textboxarna
This commit is contained in:
@ -56,27 +56,31 @@ namespace WindowsFormsCore
|
|||||||
Random rnd = new CryptoRandom(DateTime.Now.DayOfYear);
|
Random rnd = new CryptoRandom(DateTime.Now.DayOfYear);
|
||||||
private Lotto lotto;
|
private Lotto lotto;
|
||||||
private List<string> clicked;
|
private List<string> clicked;
|
||||||
private byte numClicks = 0;
|
|
||||||
private bool clearing;
|
private bool clearing;
|
||||||
|
private TextBox[] txtBGrp1 = new TextBox[7];
|
||||||
|
private TextBox[] txtBGrp2 = new TextBox[7];
|
||||||
|
|
||||||
public Form1()
|
public Form1()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
lotto = new Lotto(rnd);
|
lotto = new Lotto(rnd);
|
||||||
ClearChks();
|
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)
|
private void btnGenerate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
var ansver = lotto.RandomRad();
|
var ansver = lotto.RandomRad();
|
||||||
txtNr1.Text = ansver[0];
|
for (int i = 0; i < txtBGrp1.Count(); i++)
|
||||||
txtNr2.Text = ansver[1];
|
{
|
||||||
txtNr3.Text = ansver[2];
|
txtBGrp1[i].Text = ansver[i];
|
||||||
txtNr4.Text = ansver[3];
|
}
|
||||||
txtNr5.Text = ansver[4];
|
|
||||||
txtNr6.Text = ansver[5];
|
|
||||||
txtNr7.Text = ansver[6];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string randomNum()
|
private string randomNum()
|
||||||
@ -89,20 +93,12 @@ namespace WindowsFormsCore
|
|||||||
lblIndicator.BackColor = SystemColors.Control;
|
lblIndicator.BackColor = SystemColors.Control;
|
||||||
lblIndicator.Text = " ";
|
lblIndicator.Text = " ";
|
||||||
List<string> jmfList = new List<string>();
|
List<string> jmfList = new List<string>();
|
||||||
txtNr21.Text = string.IsNullOrEmpty(txtNr1.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtNr1.Text)).ToString();
|
|
||||||
jmfList.Add(txtNr21.Text);
|
for (int i = 0; i < txtBGrp1.Count(); i++)
|
||||||
txtNr22.Text = string.IsNullOrEmpty(txtNr2.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtNr2.Text)).ToString();
|
{
|
||||||
jmfList.Add(txtNr22.Text);
|
txtBGrp2[i].Text = string.IsNullOrEmpty(txtNr1.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtBGrp1[i].Text)).ToString();
|
||||||
txtNr23.Text = string.IsNullOrEmpty(txtNr3.Text) ? "" : lotto.AntiCircularValue(int.Parse(txtNr3.Text)).ToString();
|
jmfList.Add(txtBGrp2[i].Text);
|
||||||
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();
|
jmfList.Sort();
|
||||||
var prev = string.Empty;
|
var prev = string.Empty;
|
||||||
@ -145,48 +141,9 @@ namespace WindowsFormsCore
|
|||||||
|
|
||||||
if (clicked.Count() > 6)
|
if (clicked.Count() > 6)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++)
|
for (int i = 0; i < 7; i++)
|
||||||
{
|
{
|
||||||
switch (i + 1)
|
txtBGrp1[i].Text = clicked[i];
|
||||||
{
|
|
||||||
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();
|
ClearChks();
|
||||||
}
|
}
|
||||||
@ -204,7 +161,6 @@ namespace WindowsFormsCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
clicked = new List<string>();
|
clicked = new List<string>();
|
||||||
numClicks = 0;
|
|
||||||
clearing = false;
|
clearing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user