forked from AdamMil/Maneubo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBackgroundScaleForm.cs
54 lines (48 loc) · 1.35 KB
/
BackgroundScaleForm.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
using System.Windows.Forms;
namespace Maneubo
{
partial class BackgroundScaleForm : DataForm
{
public BackgroundScaleForm()
{
InitializeComponent();
}
public BackgroundScaleForm(double pixels, double meters, UnitSystem unitSystem) : this()
{
lblPixels.Text = pixels.ToString("0.##") + " pixels represents...";
txtLength.Text = ManeuveringBoard.GetDistanceString(meters, unitSystem);
txtLength.Tag = meters;
txtLength.WasChanged = false;
this.unitSystem = unitSystem;
}
public double Distance
{
get
{
double distance;
if(txtLength.WasChanged) TryParseLength(txtLength.Text, unitSystem, out distance);
else distance = (double)txtLength.Tag;
return distance;
}
}
void btnOK_Click(object sender, System.EventArgs e)
{
double length;
if(txtLength.WasChanged)
{
if(TryParseLength(txtLength.Text, unitSystem, out length))
{
txtLength.Tag = length;
}
else
{
if(string.IsNullOrEmpty(txtLength.Text.Trim())) ShowRequiredMessage("Distance");
else ShowInvalidLength(txtLength.Text);
return;
}
}
DialogResult = DialogResult.OK;
}
readonly UnitSystem unitSystem;
}
}