Skip to content

Commit abbefe5

Browse files
committed
Completed the Speed, Time, Fuel.
1 parent 6884c14 commit abbefe5

File tree

4 files changed

+116
-52
lines changed

4 files changed

+116
-52
lines changed

myFlightInfo/Form1.Designer.cs

+19-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

myFlightInfo/Form1.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -552,15 +552,19 @@ private void btn_gransden_lodge_photo_update_Click(object sender, EventArgs e)
552552
}
553553
}
554554

555-
556-
557555

558556

559557

560558

561559

562560

563561

562+
563+
564+
565+
566+
567+
564568
//private void tabcnt_utils_Leave(object sender, EventArgs e)
565569
//{
566570
// btn_navigation_calculations.Visible = false;

myFlightInfo/KeyDowns.cs

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ private void Navigation_Keydown(object sender, KeyEventArgs e)
3333
}
3434
}
3535

36+
private void SpeedTimeFuel_Keydown(object sender, KeyEventArgs e)
37+
{
38+
if ((e.KeyCode == Keys.Enter) && ((tabcnt_toplevel.SelectedTab == tab_utils) && (tabcnt_utils.SelectedTab == tab_crosswind)))
39+
{
40+
btn_calc_speed_time_fuel.PerformClick();
41+
}
42+
}
43+
3644
private void txtbx_navigate_to_url_KeyPress(object sender, KeyPressEventArgs e)
3745
{
3846
if (e.KeyChar == (char)13)

myFlightInfo/SpeedTimeFuel.cs

+83-34
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,22 @@ public partial class Form1
1212

1313
private void btn_calc_speed_time_fuel_Click(object sender, EventArgs e)
1414
{
15-
bool TimeFuelFlag = true;
15+
rchtxbx_speed_time_fuel_output.Text = "";
1616

1717
try
1818
{
19-
if ((txtbx_speed_distance.Text == "")||(txtbx_speed_fuel_consumption.Text == "")||
20-
(txtbx_min_landing_fuel.Text == "") || (txtbx_speed_fuel_specific_gravity.Text == ""))
21-
22-
//&& TimeFuelCheck(txtbx_speed_fuel_consumption.Text,txtbx_min_landing_fuel.Text, txtbx_speed_fuel_specific_gravity.Text))
23-
{
24-
TimeFuelFlag = false;
25-
}
26-
27-
2819
if (SpeedDataCheck(txtbx_speed_wind_speed.Text, txtbx_speed_wind_direction.Text,
29-
txtbx_speed_course.Text, txtbx_speed_true_airspeed.Text))
20+
txtbx_speed_course.Text, txtbx_speed_true_airspeed.Text))
3021
{
22+
bool TimeFuelFlag = TimeFuelCheck(txtbx_speed_distance.Text, txtbx_speed_fuel_consumption.Text,
23+
txtbx_min_landing_fuel.Text, txtbx_speed_fuel_specific_gravity.Text);
24+
3125
var results = Speed_Time_Fuel.Calculate_Speed_Time_fuel(txtbx_speed_true_airspeed,
3226
txtbx_speed_wind_speed,
3327
txtbx_speed_course, txtbx_speed_wind_direction, txtbx_speed_distance,
3428
txtbx_speed_fuel_consumption,
3529
txtbx_min_landing_fuel, TimeFuelFlag);
36-
30+
3731

3832
//results = WindCorrection, GroundSpeed, FlightTime, JourneyFuelLoad, FuelLoad
3933

@@ -70,13 +64,6 @@ private void btn_calc_speed_time_fuel_Click(object sender, EventArgs e)
7064
Double.Parse(txtbx_speed_fuel_specific_gravity.Text) +
7165
"kg");
7266
}
73-
74-
}
75-
else
76-
{
77-
//It did not work instead of crashing just put up hint and return gracefully
78-
MsgBox.Show("Something has gone wrong.\rPlease check data and try again", "Something is Wrong",
79-
MessageBoxButtons.OK, MessageBoxIcon.Error);
8067
}
8168
}
8269
catch
@@ -91,28 +78,50 @@ private void btn_calc_speed_time_fuel_Click(object sender, EventArgs e)
9178
private bool SpeedDataCheck(string myWindStrength, string myDirection, string myCourse, string myAirspeed)
9279
{
9380
//catch for incomplete data
94-
if ((myWindStrength == "") || (myDirection == "") || (myCourse == "") || (myAirspeed == ""))
81+
if (myCourse == "")
9582
{
96-
MsgBox.Show("Please fill in all the data", "Incomplete Data", MessageBoxButtons.OK,
83+
MsgBox.Show("Please check Course has correct data", "Incomplete Course Data", MessageBoxButtons.OK,
9784
MessageBoxIcon.Error);
9885
return false;
9986
}
10087

88+
if (myAirspeed == "")
89+
{
90+
MsgBox.Show("Please check True Airspeed has correct data", "Incomplete True Airspeed Data", MessageBoxButtons.OK,
91+
MessageBoxIcon.Error);
92+
return false;
93+
}
94+
95+
if (myDirection == "")
96+
{
97+
MsgBox.Show("Please check Wind Direction has correct data", "Incomplete Wind Direction Data", MessageBoxButtons.OK,
98+
MessageBoxIcon.Error);
99+
return false;
100+
}
101+
102+
if (myWindStrength == "")
103+
{
104+
MsgBox.Show("Please check Wind Speed has correct data", "Incomplete Wind Speed Data", MessageBoxButtons.OK,
105+
MessageBoxIcon.Error);
106+
return false;
107+
}
108+
109+
101110
//Check data is in fact doubles.
102111
if (!CheckData.IsItADouble(myWindStrength))
103112
{
104113
MsgBox.Show("Check Wind speed is a valid number.", "Incorrect Data", MessageBoxButtons.OK,
105114
MessageBoxIcon.Error);
106115
return false;
107116
}
108-
117+
109118
if (double.Parse(myWindStrength) < 0)
110119
{
111120
MsgBox.Show("Check Wind speed is valid number (0 - 999)", "Data out of scope", MessageBoxButtons.OK,
112121
MessageBoxIcon.Error);
113122
return false;
114123
}
115-
124+
116125
if (double.Parse(myWindStrength) > 253)
117126
{
118127
if (MsgBox.Show("Are you really sure that is the wind speed?", "New World Record for Wind Speed",
@@ -154,37 +163,77 @@ private bool SpeedDataCheck(string myWindStrength, string myDirection, string my
154163
}
155164
else if ((double.Parse(myAirspeed) < 0) || (double.Parse(myAirspeed) > 999))
156165
{
157-
MsgBox.Show("Check True Air Speed Data is a valid number)", "Data out of scope",
166+
MsgBox.Show("Check True Air Speed Data is a valid number >0 and <999)", "Data out of scope",
158167
MessageBoxButtons.OK, MessageBoxIcon.Error);
159168
return false;
160169
}
161170

171+
return true;
172+
}
162173

163174

175+
private bool TimeFuelCheck(string myDistance, string myFuelConsumption, string myMinLandingFuel, string myFuelSpecificGravity)
176+
{
177+
//catch for incomplete data
178+
if (myDistance == "")
179+
{
180+
MsgBox.Show("Please add Distance and try again if you want Time and Fuel Calculations", "Incomplete Distance Data", MessageBoxButtons.OK,
181+
MessageBoxIcon.Error);
182+
return false;
183+
}
164184

165-
return true;
166-
}
185+
if (myFuelConsumption == "")
186+
{
187+
MsgBox.Show("Please check data is correct for Fuel Consumption", "Incomplete Fuel Consumption Data", MessageBoxButtons.OK,
188+
MessageBoxIcon.Error);
189+
return false;
190+
}
167191

192+
if (myMinLandingFuel == "")
193+
{
194+
MsgBox.Show("Please check data is correct for Min Landing Fuel", "Incomplete Min Landing Fuel Data", MessageBoxButtons.OK,
195+
MessageBoxIcon.Error);
196+
return false;
197+
}
168198

169-
199+
if (myFuelSpecificGravity == "")
200+
{
201+
MsgBox.Show("Please check data is correct for Fuel Specific Gravity", "Incomplete Fuel Specific Gravity Data", MessageBoxButtons.OK,
202+
MessageBoxIcon.Error);
203+
return false;
204+
}
170205

171206

172-
private bool TimeFuelCheck(string myFuelConsumption, string myMinLandingFuel, string myFuelSpecificGravity)
173-
{
174-
//catch for incomplete data
175-
if ((myFuelConsumption == "") || (myMinLandingFuel == "") || (myFuelSpecificGravity == ""))
207+
//Check data is in fact doubles.
208+
if (!CheckData.IsItADouble(myDistance))
176209
{
177-
MsgBox.Show("Please data is correct for Fuel Consumption, Min Landing Fuel and Fuel Specific Gravity", "Incomplete Data", MessageBoxButtons.OK,
210+
MsgBox.Show("Check Distance is a valid number.", "Incorrect Data", MessageBoxButtons.OK,
178211
MessageBoxIcon.Error);
179212
return false;
180213
}
181214

215+
if (!CheckData.IsItADouble(myFuelConsumption))
216+
{
217+
MsgBox.Show("Check Fuel Consumption is a valid number.", "Incorrect Data", MessageBoxButtons.OK,
218+
MessageBoxIcon.Error);
219+
return false;
220+
}
182221

222+
if (!CheckData.IsItADouble(myMinLandingFuel))
223+
{
224+
MsgBox.Show("Check Minimum Landing Fuel is a valid number.", "Incorrect Data", MessageBoxButtons.OK,
225+
MessageBoxIcon.Error);
226+
return false;
227+
}
183228

229+
if (!CheckData.IsItADouble(myFuelSpecificGravity))
230+
{
231+
MsgBox.Show("Check Specific Gravity of Fuel is a valid number.", "Incorrect Data", MessageBoxButtons.OK,
232+
MessageBoxIcon.Error);
233+
return false;
234+
}
184235

185236
return true;
186237
}
187-
188-
189238
}
190239
}

0 commit comments

Comments
 (0)