Nya ResultatRutor

This commit is contained in:
2022-06-30 23:23:16 +02:00
parent 8b722b024e
commit d39a372b3a
2 changed files with 55 additions and 10 deletions

View File

@ -37,6 +37,8 @@
this.btnDiceTmpl6 = new System.Windows.Forms.Button();
this.btnDiceTmpl5 = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.txtMaxValue = new System.Windows.Forms.TextBox();
this.txtChosenValue = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
@ -135,11 +137,31 @@
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// txtMaxValue
//
this.txtMaxValue.Location = new System.Drawing.Point(669, 82);
this.txtMaxValue.Multiline = true;
this.txtMaxValue.Name = "txtMaxValue";
this.txtMaxValue.Size = new System.Drawing.Size(42, 44);
this.txtMaxValue.TabIndex = 9;
this.txtMaxValue.Visible = false;
//
// txtChosenValue
//
this.txtChosenValue.Location = new System.Drawing.Point(669, 126);
this.txtChosenValue.Multiline = true;
this.txtChosenValue.Name = "txtChosenValue";
this.txtChosenValue.Size = new System.Drawing.Size(42, 44);
this.txtChosenValue.TabIndex = 10;
this.txtChosenValue.Visible = false;
//
// frmPersonRound
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.txtChosenValue);
this.Controls.Add(this.txtMaxValue);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnDiceTmpl6);
this.Controls.Add(this.btnDiceTmpl5);
@ -168,5 +190,7 @@
private Button btnDiceTmpl6;
private Button btnDiceTmpl5;
private Button btnClose;
private TextBox txtMaxValue;
private TextBox txtChosenValue;
}
}

View File

@ -12,7 +12,7 @@ using System.Diagnostics;
namespace WinGreed
{
public partial class frmPersonRound : Form
{
{
int y = 79;
int x = 0;
int row = 0;
@ -33,13 +33,13 @@ namespace WinGreed
private void btnThrow_Click(object sender, EventArgs e)
{
x = 0;
y = y + btnDiceTmpl1.Height+5;
y = y + btnDiceTmpl1.Height + 5;
var no = 0;
var result = _ht.Throw();
Button btn = null;
MarkGrayAndDisable(row);
@ -56,7 +56,7 @@ namespace WinGreed
{
btn = btnDiceTmpl1.Clone<Button>();
btn.Name = $"btnDice{row}1";
break;
break;
}
case 2:
{
@ -91,7 +91,7 @@ namespace WinGreed
default:
break;
}
_dice.Add(btn);
btn.Location = new Point(x + (btn.Width + 5) * no, y);
btn.Visible = true;
@ -110,7 +110,7 @@ namespace WinGreed
List<int> Numbers = new List<int>();
foreach (var item in result)
{
Numbers.Add(item.Number);
Numbers.Add(item.Number);
}
AnalyseNumbers(Numbers);
@ -134,19 +134,40 @@ namespace WinGreed
}
}
}
AnalyseNumbers(Numbers);
AnalyseNumbers(Numbers, false);
}
}
private void AnalyseNumbers(List<int> numbers)
private void AnalyseNumbers(List<int> numbers, bool before = true)
{
if (before)
{
TextBox txt = null;
TextBox txtRes = null;
txt = txtMaxValue.Clone<TextBox>();
txt.Name = $"txtMaxValue{row}";
txt.Location = new Point(x + 350, y);
txt.Visible = true;
this.Controls.Add(txt);
this.Refresh();
txtRes = txtChosenValue.Clone<TextBox>();
txtRes.Name = $"txtChosenValue{row}";
txtRes.Location = new Point(x + 350 + (txtRes.Width + 5), y);
txtRes.Visible = true;
this.Controls.Add(txtRes);
this.Refresh();
}
numbers.ForEach(x => Debug.Write($"{x}, "));
Debug.WriteLine(" -");
}
private void btnDiceTmpl_Click(object sender, EventArgs e)
{
if (((Dice)((Button)sender).Tag).Chosen) {
if (((Dice)((Button)sender).Tag).Chosen)
{
((Button)sender).BackColor = Color.Green;
((Dice)((Button)sender).Tag).Chosen = false;
}