diff --git a/GCSViews/FlightData.cs b/GCSViews/FlightData.cs index 9ae6b7f43f..5ae32728b4 100644 --- a/GCSViews/FlightData.cs +++ b/GCSViews/FlightData.cs @@ -155,6 +155,7 @@ public partial class FlightData : MyUserControl, IActivate, IDeactivate Thread scriptthread; public readonly List TabListOriginal = new List(); + public Dictionary TabListDisplay = new Dictionary(); //List for setting colors of quick tab numbers List listQuickView = new List(); @@ -251,9 +252,6 @@ public FlightData() // populate the unmodified base list tabControlactions.TabPages.ForEach(i => { TabListOriginal.Add((TabPage) i); }); - // update tabs displayed - loadTabControlActions(); - // mymap.Manager.UseMemoryCache = false; log.Info("Tunning Graph Settings"); @@ -529,6 +527,9 @@ public void Activate() } } + // update tabs displayed + updateDisplayView(); + hud1.doResize(); } @@ -676,7 +677,40 @@ public void LoadLogFile(string file) } } - public void loadTabControlActions() + private void updateDisplayTabControlActions() + { + TabListDisplay.Clear(); + + TabListDisplay.Add(tabQuick.Name, MainV2.DisplayConfiguration.displayQuickTab); + + TabListDisplay.Add(tabPagePreFlight.Name, MainV2.DisplayConfiguration.displayPreFlightTab); + + TabListDisplay.Add(tabActions.Name, MainV2.DisplayConfiguration.displayAdvActionsTab); + + TabListDisplay.Add(tabActionsSimple.Name, MainV2.DisplayConfiguration.displaySimpleActionsTab); + + TabListDisplay.Add(tabGauges.Name, MainV2.DisplayConfiguration.displayGaugesTab); + + TabListDisplay.Add(tabStatus.Name, MainV2.DisplayConfiguration.displayStatusTab); + + TabListDisplay.Add(tabServo.Name, MainV2.DisplayConfiguration.displayServoTab); + + TabListDisplay.Add(tabScripts.Name, MainV2.DisplayConfiguration.displayScriptsTab); + + TabListDisplay.Add(tabTLogs.Name, MainV2.DisplayConfiguration.displayTelemetryTab); + + TabListDisplay.Add(tablogbrowse.Name, MainV2.DisplayConfiguration.displayDataflashTab); + + TabListDisplay.Add(tabPagemessages.Name, MainV2.DisplayConfiguration.displayMessagesTab); + + TabListDisplay.Add(tabTransponder.Name, MainV2.DisplayConfiguration.displayTransponderTab); + + TabListDisplay.Add(tabAuxFunction.Name, MainV2.DisplayConfiguration.displayAuxFunctionTab); + + TabListDisplay.Add(tabPayload.Name, MainV2.DisplayConfiguration.displayPayloadTab); + } + + private void loadTabControlActions() { string tabs = Settings.Instance["tabcontrolactions"]; @@ -692,20 +726,33 @@ public void loadTabControlActions() foreach (var tabname in tabarray) { - int a = 0; foreach (TabPage tabPage in TabListOriginal) { - if (tabPage.Name == tabname) + if (tabPage.Name == tabname && ((TabListDisplay.ContainsKey(tabname) && TabListDisplay[tabname] == true) || !TabListDisplay.ContainsKey(tabname))) { tabControlactions.TabPages.Add(tabPage); break; } - - a++; } } + } + + public void updateDisplayView() + { + updateDisplayTabControlActions(); + + loadTabControlActions(); + + //we want to at least have one tabpage + if (tabControlactions.TabPages.Count == 0) + { + tabControlactions.TabPages.Add(tabQuick); + tabControlactions.SelectedIndex = 0; + } ThemeManager.ApplyThemeTo(tabControlactions); + + saveTabControlActions(); } internal void BUT_run_script_Click(object sender, EventArgs e) @@ -2472,10 +2519,13 @@ private void customizeToolStripMenuItem_Click(object sender, EventArgs e) foreach (TabPage tabPage in TabListOriginal) { - if (tabarray.Contains(tabPage.Name)) - left.Items.Add(tabPage.Name, true); - else - left.Items.Add(tabPage.Name, false); + if((TabListDisplay.ContainsKey(tabPage.Name) && TabListDisplay[tabPage.Name] == true) || !TabListDisplay.ContainsKey(tabPage.Name)) + { + if (tabarray.Contains(tabPage.Name)) + left.Items.Add(tabPage.Name, true); + else + left.Items.Add(tabPage.Name, false); + } } ThemeManager.ApplyThemeTo(customForm); @@ -2490,7 +2540,7 @@ private void customizeToolStripMenuItem_Click(object sender, EventArgs e) Settings.Instance["tabcontrolactions"] = answer; - loadTabControlActions(); + updateDisplayView(); } } diff --git a/MainV2.cs b/MainV2.cs index 936458f95f..a8bc92b018 100644 --- a/MainV2.cs +++ b/MainV2.cs @@ -585,137 +585,8 @@ public void updateLayout(object sender, EventArgs e) //Flight data page if (MainV2.instance.FlightData != null) { - TabControl t = MainV2.instance.FlightData.tabControlactions; - if (DisplayConfiguration.displayQuickTab && !t.TabPages.Contains(FlightData.tabQuick)) - { - t.TabPages.Add(FlightData.tabQuick); - } - else if (!DisplayConfiguration.displayQuickTab && t.TabPages.Contains(FlightData.tabQuick)) - { - t.TabPages.Remove(FlightData.tabQuick); - } - - if (DisplayConfiguration.displayPreFlightTab && !t.TabPages.Contains(FlightData.tabPagePreFlight)) - { - t.TabPages.Add(FlightData.tabPagePreFlight); - } - else if (!DisplayConfiguration.displayPreFlightTab && t.TabPages.Contains(FlightData.tabPagePreFlight)) - { - t.TabPages.Remove(FlightData.tabPagePreFlight); - } - - if (DisplayConfiguration.displayAdvActionsTab && !t.TabPages.Contains(FlightData.tabActions)) - { - t.TabPages.Add(FlightData.tabActions); - } - else if (!DisplayConfiguration.displayAdvActionsTab && t.TabPages.Contains(FlightData.tabActions)) - { - t.TabPages.Remove(FlightData.tabActions); - } - - if (DisplayConfiguration.displaySimpleActionsTab && !t.TabPages.Contains(FlightData.tabActionsSimple)) - { - t.TabPages.Add(FlightData.tabActionsSimple); - } - else if (!DisplayConfiguration.displaySimpleActionsTab && - t.TabPages.Contains(FlightData.tabActionsSimple)) - { - t.TabPages.Remove(FlightData.tabActionsSimple); - } - - if (DisplayConfiguration.displayGaugesTab && !t.TabPages.Contains(FlightData.tabGauges)) - { - t.TabPages.Add(FlightData.tabGauges); - } - else if (!DisplayConfiguration.displayGaugesTab && t.TabPages.Contains(FlightData.tabGauges)) - { - t.TabPages.Remove(FlightData.tabGauges); - } - - if (DisplayConfiguration.displayStatusTab && !t.TabPages.Contains(FlightData.tabStatus)) - { - t.TabPages.Add(FlightData.tabStatus); - } - else if (!DisplayConfiguration.displayStatusTab && t.TabPages.Contains(FlightData.tabStatus)) - { - t.TabPages.Remove(FlightData.tabStatus); - } - - if (DisplayConfiguration.displayServoTab && !t.TabPages.Contains(FlightData.tabServo)) - { - t.TabPages.Add(FlightData.tabServo); - } - else if (!DisplayConfiguration.displayServoTab && t.TabPages.Contains(FlightData.tabServo)) - { - t.TabPages.Remove(FlightData.tabServo); - } - - if (DisplayConfiguration.displayScriptsTab && !t.TabPages.Contains(FlightData.tabScripts)) - { - t.TabPages.Add(FlightData.tabScripts); - } - else if (!DisplayConfiguration.displayScriptsTab && t.TabPages.Contains(FlightData.tabScripts)) - { - t.TabPages.Remove(FlightData.tabScripts); - } - - if (DisplayConfiguration.displayTelemetryTab && !t.TabPages.Contains(FlightData.tabTLogs)) - { - t.TabPages.Add(FlightData.tabTLogs); - } - else if (!DisplayConfiguration.displayTelemetryTab && t.TabPages.Contains(FlightData.tabTLogs)) - { - t.TabPages.Remove(FlightData.tabTLogs); - } - - if (DisplayConfiguration.displayDataflashTab && !t.TabPages.Contains(FlightData.tablogbrowse)) - { - t.TabPages.Add(FlightData.tablogbrowse); - } - else if (!DisplayConfiguration.displayDataflashTab && t.TabPages.Contains(FlightData.tablogbrowse)) - { - t.TabPages.Remove(FlightData.tablogbrowse); - } - - if (DisplayConfiguration.displayMessagesTab && !t.TabPages.Contains(FlightData.tabPagemessages)) - { - t.TabPages.Add(FlightData.tabPagemessages); - } - else if (!DisplayConfiguration.displayMessagesTab && t.TabPages.Contains(FlightData.tabPagemessages)) - { - t.TabPages.Remove(FlightData.tabPagemessages); - } - - if (DisplayConfiguration.displayTransponderTab && !t.TabPages.Contains(FlightData.tabTransponder)) - { - t.TabPages.Add(FlightData.tabTransponder); - } - else if (!DisplayConfiguration.displayTransponderTab && t.TabPages.Contains(FlightData.tabTransponder)) - { - t.TabPages.Remove(FlightData.tabTransponder); - } - - if (DisplayConfiguration.displayAuxFunctionTab && !t.TabPages.Contains(FlightData.tabAuxFunction)) - { - t.TabPages.Add(FlightData.tabAuxFunction); - } - else if (!DisplayConfiguration.displayAuxFunctionTab && t.TabPages.Contains(FlightData.tabAuxFunction)) - { - t.TabPages.Remove(FlightData.tabAuxFunction); - } - - if (DisplayConfiguration.displayPayloadTab && !t.TabPages.Contains(FlightData.tabPayload)) - { - t.TabPages.Add(FlightData.tabPayload); - } - else if (!DisplayConfiguration.displayPayloadTab && t.TabPages.Contains(FlightData.tabPayload)) - { - t.TabPages.Remove(FlightData.tabPayload); - } - - t.SelectedIndex = 0; - - MainV2.instance.FlightData.loadTabControlActions(); + //hide menu items + MainV2.instance.FlightData.updateDisplayView(); } if (MainV2.instance.FlightPlanner != null)