-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDelayDialog.cs
65 lines (50 loc) · 1.49 KB
/
DelayDialog.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
63
64
65
using System;
using System.Windows.Forms;
namespace LangontsAntSimulator
{
public partial class DelayDialog : BaseForm
{
#region Private Member Declarations
private ISimulation _simulation;
#endregion Private Member Declarations
#region Public Constructors
public DelayDialog()
{
InitializeComponent();
}
public DelayDialog(ISimulation simulation)
: this()
{
_simulation = simulation;
}
#endregion Public Constructors
#region Protected Overridden Methods
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (_simulation != null)
delayNumericUpDown.Value = _simulation.Speed;
}
#endregion Protected Overridden Methods
#region Event Handlers
private void cancelButton_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void okButton_Click(object sender, EventArgs e)
{
if (delayNumericUpDown.Value < 1 || delayNumericUpDown.Value > delayNumericUpDown.Maximum)
{
MessageBox.Show("Please enter a valid delay.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
delayNumericUpDown.Focus();
this.DialogResult = DialogResult.None;
}
else
{
_simulation.Speed = (int)delayNumericUpDown.Value;
this.DialogResult = DialogResult.OK;
}
}
#endregion Event Handlers
}
}