-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form2.cs
69 lines (62 loc) · 1.94 KB
/
Form2.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
66
67
68
69
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication4
{
public partial class Form2 : Form
{
private Form1 form1;
public Form2(Form1 form1)
{
InitializeComponent();
this.form1 = form1;
GridBar.Value = form1.getScale();
RuleBox.Text = form1.getRule();
int speed = form1.getSpeed();
SimSpeedLabel.Text = calcFPS(speed).ToString();
SimSpeed.Value = calcFPS(speed);
wrapCheckbox.Checked = form1.getWarp();
GridCheckbox.Checked = form1.getGrid();
}
private void setValues()
{
form1.setScale(GridBar.Value);
form1.setRule(RuleBox.Text);
form1.setSpeed(calcInterval(SimSpeed.Value));
form1.setWarp(wrapCheckbox.Checked);
form1.setGrid(GridCheckbox.Checked);
}
private int calcFPS(int speed)
{
return (int)Math.Round(1000f / speed);
}
private int calcInterval(int speed)
{
return (int)Math.Round(1000f / speed);
}
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
setValues();
}
private void OKButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void GridBar_ValueChanged(object sender, EventArgs e)
{
GridSizeLabel.Text = GridBar.Value.ToString();
}
private void ApplyButton_Click(object sender, EventArgs e)
{
setValues();
}
private void SimSpeed_ValueChanged(object sender, EventArgs e)
{
SimSpeedLabel.Text = SimSpeed.Value.ToString();
}
}
}