Skip to content

Commit

Permalink
Completed the Speed, Time, Fuel.
Browse files Browse the repository at this point in the history
  • Loading branch information
zizwiz committed Jul 13, 2024
1 parent 6884c14 commit abbefe5
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 52 deletions.
35 changes: 19 additions & 16 deletions myFlightInfo/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions myFlightInfo/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,19 @@ private void btn_gransden_lodge_photo_update_Click(object sender, EventArgs e)
}
}
















//private void tabcnt_utils_Leave(object sender, EventArgs e)
//{
// btn_navigation_calculations.Visible = false;
Expand Down
8 changes: 8 additions & 0 deletions myFlightInfo/KeyDowns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ private void Navigation_Keydown(object sender, KeyEventArgs e)
}
}

private void SpeedTimeFuel_Keydown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == Keys.Enter) && ((tabcnt_toplevel.SelectedTab == tab_utils) && (tabcnt_utils.SelectedTab == tab_crosswind)))
{
btn_calc_speed_time_fuel.PerformClick();
}
}

private void txtbx_navigate_to_url_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
Expand Down
117 changes: 83 additions & 34 deletions myFlightInfo/SpeedTimeFuel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,22 @@ public partial class Form1

private void btn_calc_speed_time_fuel_Click(object sender, EventArgs e)
{
bool TimeFuelFlag = true;
rchtxbx_speed_time_fuel_output.Text = "";

try
{
if ((txtbx_speed_distance.Text == "")||(txtbx_speed_fuel_consumption.Text == "")||
(txtbx_min_landing_fuel.Text == "") || (txtbx_speed_fuel_specific_gravity.Text == ""))

//&& TimeFuelCheck(txtbx_speed_fuel_consumption.Text,txtbx_min_landing_fuel.Text, txtbx_speed_fuel_specific_gravity.Text))
{
TimeFuelFlag = false;
}


if (SpeedDataCheck(txtbx_speed_wind_speed.Text, txtbx_speed_wind_direction.Text,
txtbx_speed_course.Text, txtbx_speed_true_airspeed.Text))
txtbx_speed_course.Text, txtbx_speed_true_airspeed.Text))
{
bool TimeFuelFlag = TimeFuelCheck(txtbx_speed_distance.Text, txtbx_speed_fuel_consumption.Text,
txtbx_min_landing_fuel.Text, txtbx_speed_fuel_specific_gravity.Text);

var results = Speed_Time_Fuel.Calculate_Speed_Time_fuel(txtbx_speed_true_airspeed,
txtbx_speed_wind_speed,
txtbx_speed_course, txtbx_speed_wind_direction, txtbx_speed_distance,
txtbx_speed_fuel_consumption,
txtbx_min_landing_fuel, TimeFuelFlag);


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

Expand Down Expand Up @@ -70,13 +64,6 @@ private void btn_calc_speed_time_fuel_Click(object sender, EventArgs e)
Double.Parse(txtbx_speed_fuel_specific_gravity.Text) +
"kg");
}

}
else
{
//It did not work instead of crashing just put up hint and return gracefully
MsgBox.Show("Something has gone wrong.\rPlease check data and try again", "Something is Wrong",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch
Expand All @@ -91,28 +78,50 @@ private void btn_calc_speed_time_fuel_Click(object sender, EventArgs e)
private bool SpeedDataCheck(string myWindStrength, string myDirection, string myCourse, string myAirspeed)
{
//catch for incomplete data
if ((myWindStrength == "") || (myDirection == "") || (myCourse == "") || (myAirspeed == ""))
if (myCourse == "")
{
MsgBox.Show("Please fill in all the data", "Incomplete Data", MessageBoxButtons.OK,
MsgBox.Show("Please check Course has correct data", "Incomplete Course Data", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}

if (myAirspeed == "")
{
MsgBox.Show("Please check True Airspeed has correct data", "Incomplete True Airspeed Data", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}

if (myDirection == "")
{
MsgBox.Show("Please check Wind Direction has correct data", "Incomplete Wind Direction Data", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}

if (myWindStrength == "")
{
MsgBox.Show("Please check Wind Speed has correct data", "Incomplete Wind Speed Data", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}


//Check data is in fact doubles.
if (!CheckData.IsItADouble(myWindStrength))
{
MsgBox.Show("Check Wind speed is a valid number.", "Incorrect Data", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}

if (double.Parse(myWindStrength) < 0)
{
MsgBox.Show("Check Wind speed is valid number (0 - 999)", "Data out of scope", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}

if (double.Parse(myWindStrength) > 253)
{
if (MsgBox.Show("Are you really sure that is the wind speed?", "New World Record for Wind Speed",
Expand Down Expand Up @@ -154,37 +163,77 @@ private bool SpeedDataCheck(string myWindStrength, string myDirection, string my
}
else if ((double.Parse(myAirspeed) < 0) || (double.Parse(myAirspeed) > 999))
{
MsgBox.Show("Check True Air Speed Data is a valid number)", "Data out of scope",
MsgBox.Show("Check True Air Speed Data is a valid number >0 and <999)", "Data out of scope",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}

return true;
}


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

return true;
}
if (myFuelConsumption == "")
{
MsgBox.Show("Please check data is correct for Fuel Consumption", "Incomplete Fuel Consumption Data", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}

if (myMinLandingFuel == "")
{
MsgBox.Show("Please check data is correct for Min Landing Fuel", "Incomplete Min Landing Fuel Data", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}


if (myFuelSpecificGravity == "")
{
MsgBox.Show("Please check data is correct for Fuel Specific Gravity", "Incomplete Fuel Specific Gravity Data", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}


private bool TimeFuelCheck(string myFuelConsumption, string myMinLandingFuel, string myFuelSpecificGravity)
{
//catch for incomplete data
if ((myFuelConsumption == "") || (myMinLandingFuel == "") || (myFuelSpecificGravity == ""))
//Check data is in fact doubles.
if (!CheckData.IsItADouble(myDistance))
{
MsgBox.Show("Please data is correct for Fuel Consumption, Min Landing Fuel and Fuel Specific Gravity", "Incomplete Data", MessageBoxButtons.OK,
MsgBox.Show("Check Distance is a valid number.", "Incorrect Data", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}

if (!CheckData.IsItADouble(myFuelConsumption))
{
MsgBox.Show("Check Fuel Consumption is a valid number.", "Incorrect Data", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}

if (!CheckData.IsItADouble(myMinLandingFuel))
{
MsgBox.Show("Check Minimum Landing Fuel is a valid number.", "Incorrect Data", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}

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

return true;
}


}
}

0 comments on commit abbefe5

Please sign in to comment.