Skip to content

Commit

Permalink
Allow the enter key to work like a button in certain circumstances. F…
Browse files Browse the repository at this point in the history
…or Crosswind when we enter the tab the cursor will be directly into the wind magnitude textbox.
  • Loading branch information
zizwiz committed May 16, 2024
1 parent f6fe486 commit b460f8c
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 24 deletions.
7 changes: 7 additions & 0 deletions myFlightInfo/Form1.Designer.cs

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

20 changes: 6 additions & 14 deletions myFlightInfo/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private async void Form1_Load(object sender, EventArgs e)

webView_notams.CoreWebView2.Navigate("https://www.notaminfo.com/ukmap?destination=node%2F39");

SetMatarPages();
SetMetarPages();
SetWeatherPages();

cmbobx_gransden_lodge.SelectedIndex = 0;
Expand Down Expand Up @@ -193,7 +193,7 @@ private void btn_reset_Click(object sender, EventArgs e)
}
else if (tabcnt_toplevel.SelectedTab == tab_metar)
{
SetMatarPages();
SetMetarPages();
}
else if ((tabcnt_toplevel.SelectedTab == tab_weather) && (tabcnt_weather.SelectedTab == tab_gransden_lodge))
{
Expand Down Expand Up @@ -383,15 +383,7 @@ private void btn_navigate_to_Click(object sender, EventArgs e)
Browse.NavigateTo(txtbx_navigate_to_url.Text, webView_browser);
}

private void txtbx_navigate_to_url_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
Browse.NavigateTo(txtbx_navigate_to_url.Text, webView_browser);
}
}



private void btn_school_Click(object sender, EventArgs e)
{
//check which school is set and use it but also set button to change to other school
Expand All @@ -407,11 +399,11 @@ private void btn_school_Click(object sender, EventArgs e)
settings.Save();

grpbx_towns.Visible = false;
SetMatarPages();
SetMetarPages();
SetWeatherPages();
}

private void SetMatarPages()
private void SetMetarPages()
{
tabCnt_airfields.TabPages.Clear(); //Remove all pages associated with tab control airfields.

Expand Down Expand Up @@ -546,6 +538,6 @@ private void btn_gransden_lodge_photo_update_Click(object sender, EventArgs e)
}
}


}
}
44 changes: 44 additions & 0 deletions myFlightInfo/KeyDowns.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Windows.Forms;
using myFlightInfo.browsing;

namespace myFlightInfo
{
public partial class Form1
{
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == Keys.Enter) && ((tabcnt_toplevel.SelectedTab == tab_utils) && (tabcnt_utils.SelectedTab == tab_navigation)))
{
btn_calculate_altimiter.PerformClick();
}
else if ((e.KeyCode == Keys.Enter) && ((tabcnt_toplevel.SelectedTab == tab_utils) && (tabcnt_utils.SelectedTab == tab_crosswind)))
{
btn_calc_wind.PerformClick();
}
}

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

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

private void txtbx_navigate_to_url_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
Browse.NavigateTo(txtbx_navigate_to_url.Text, webView_browser);
}
}
}
}
1 change: 1 addition & 0 deletions myFlightInfo/Navigation/Navigate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static void SolarInfo(string airfield, ListBox myListBox, int year, int m
//Find last Sunday in March and October of year in datepicker
DateTime marchDate = CheckDate.LastSundayOfMonth("3", year.ToString());
DateTime octoberDate = CheckDate.LastSundayOfMonth("10", year.ToString());

// Construct the chosen date we are looking at
DateTime DateToCheck = DateTime.Parse(day + "/" + month + "/" + year + " 00:00:00");

Expand Down
19 changes: 9 additions & 10 deletions myFlightInfo/TabChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ private void tabcnt_utils_SelectedIndexChanged(object sender, EventArgs e)
cmbobx_airport_info.Visible = false;
grpbx_altimeter.Visible = false;
grpbx_browser_navigation.Visible = false;



if (tabcnt_utils.SelectedTab == tab_navigation)
{
//cmbobx_airport_info.SelectedIndex = 0;
Expand All @@ -203,18 +202,18 @@ private void tabcnt_utils_SelectedIndexChanged(object sender, EventArgs e)
grpbx_altimeter.Visible = false;
grpbx_browser_navigation.Visible = true;
}

SetMatarPages();
SetMetarPages();
SetWeatherPages();

grpbx_towns.Visible = false;
btn_school.Visible = false;
}


//Here we select the textbox that will be in focus.
if (tabcnt_utils.SelectedTab == tab_crosswind)
{
txtbx_magnitude.Select(); // Put cursor into Wind Magnitude Textbox"
}
}
}




}
3 changes: 3 additions & 0 deletions myFlightInfo/myFlightInfo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
<Compile Include="CrossWind.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="KeyDowns.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Navigation\Altimeter.cs" />
<Compile Include="common_data\airport_data.cs" />
<Compile Include="common_data\verification.cs" />
Expand Down

0 comments on commit b460f8c

Please sign in to comment.