-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddAntsDialog.cs
62 lines (47 loc) · 1.43 KB
/
AddAntsDialog.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace LangontsAntSimulator
{
public partial class AddAntsDialog : BaseForm
{
#region Private Member Declarations
private ISimulation _simulation;
#endregion Private Member Declarations
#region Public Constructors
public AddAntsDialog()
{
InitializeComponent();
}
public AddAntsDialog(ISimulation simulation)
: this()
{
_simulation = simulation;
}
#endregion Public Constructors
#region Event Handlers
private void cancelButton_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void okButton_Click(object sender, EventArgs e)
{
if (antsNumericUpDown.Value < 1 || antsNumericUpDown.Value > antsNumericUpDown.Maximum)
{
MessageBox.Show("Please enter a valid NUMBER.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
antsNumericUpDown.Focus();
this.DialogResult = DialogResult.None;
}
else
{
List<IActor> actors;
actors = new List<IActor>(_simulation.Actors);
for (int i = 0; i < (int)antsNumericUpDown.Value; i++)
actors.Add(new Ant());
_simulation.Actors = actors.ToArray();
this.DialogResult = DialogResult.OK;
}
}
#endregion Event Handlers
}
}