forked from ArduPilot/MissionPlanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoftwareConfig.cs
134 lines (113 loc) · 5.08 KB
/
SoftwareConfig.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using System;
using System.Reflection;
using System.Windows.Forms;
using log4net;
using MissionPlanner.Controls;
using MissionPlanner.Controls.BackstageView;
using MissionPlanner.GCSViews.ConfigurationView;
using MissionPlanner.Utilities;
namespace MissionPlanner.GCSViews
{
public partial class SoftwareConfig : MyUserControl, IActivate
{
internal static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static string lastpagename = "";
public SoftwareConfig()
{
InitializeComponent();
}
public void Activate()
{
}
private BackstageViewPage AddBackstageViewPage(Type userControl, string headerText,
BackstageViewPage Parent = null, bool advanced = false)
{
try
{
return backstageView.AddPage(userControl, headerText, Parent, advanced);
}
catch (Exception ex)
{
log.Error(ex);
return null;
}
}
private void SoftwareConfig_Load(object sender, EventArgs e)
{
try
{
BackstageViewPage start = null;
if (MainV2.comPort.BaseStream.IsOpen)
{
start = AddBackstageViewPage(typeof(ConfigFlightModes), Strings.FlightModes);
if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduCopter2)
AddBackstageViewPage(typeof( ConfigAC_Fence), Strings.GeoFence);
if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduCopter2)
{
start = AddBackstageViewPage(typeof( ConfigSimplePids), Strings.BasicTuning);
AddBackstageViewPage(typeof( ConfigArducopter), Strings.ExtendedTuning);
}
if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduPlane)
{
start = AddBackstageViewPage(typeof( ConfigArduplane), Strings.BasicTuning);
}
if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduRover)
{
start = AddBackstageViewPage(typeof( ConfigArdurover), Strings.BasicTuning);
}
if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduTracker)
{
start = AddBackstageViewPage(typeof( ConfigAntennaTracker), Strings.ExtendedTuning);
}
AddBackstageViewPage(typeof (ConfigFriendlyParams), Strings.StandardParams);
if (MainV2.DisplayConfiguration.displayAdvancedParams)
{
AddBackstageViewPage(typeof (ConfigFriendlyParamsAdv), Strings.AdvancedParams, null, true);
}
if (MainV2.DisplayConfiguration.displayFullParamList)
{
AddBackstageViewPage(typeof (ConfigRawParams), Strings.FullParameterList, null, true);
}
if (MainV2.DisplayConfiguration.displayFullParamTree)
{
AddBackstageViewPage(typeof (ConfigRawParamsTree), Strings.FullParameterTree, null, true);
}
if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.Ateryx)
{
start = AddBackstageViewPage(typeof( ConfigFlightModes), Strings.FlightModes);
AddBackstageViewPage(typeof( ConfigAteryxSensors), "Ateryx Zero Sensors");
AddBackstageViewPage(typeof( ConfigAteryx), "Ateryx Pids");
}
AddBackstageViewPage(typeof( ConfigPlanner), "Planner");
}
else
{
start = AddBackstageViewPage(typeof( ConfigPlanner), "Planner");
}
// apply theme before trying to display it
ThemeManager.ApplyThemeTo(this);
// remeber last page accessed
foreach (BackstageViewPage page in backstageView.Pages)
{
if (page.LinkText == lastpagename)
{
backstageView.ActivatePage(page);
break;
}
}
if (backstageView.SelectedPage == null && start != null)
backstageView.ActivatePage(start);
}
catch (Exception ex)
{
log.Error(ex);
}
}
private void SoftwareConfig_FormClosing(object sender, FormClosingEventArgs e)
{
if (backstageView.SelectedPage != null)
lastpagename = backstageView.SelectedPage.LinkText;
backstageView.Close();
}
}
}