Browse Source

APM Planner

fix CAPM update firmware error
mission-4.1.18
Hazy 13 years ago
parent
commit
71b73a669c
  1. 1
      Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj
  2. 19
      Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs
  3. 42
      Tools/ArdupilotMegaPlanner/MainV2.cs
  4. 64
      Tools/ArdupilotMegaPlanner/Utility.cs

1
Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj

@ -445,6 +445,7 @@ @@ -445,6 +445,7 @@
<DependentUpon>temp.cs</DependentUpon>
</Compile>
<Compile Include="Radio\Uploader.cs" />
<Compile Include="Utility.cs" />
<EmbeddedResource Include="Controls\ProgressReporterDialogue.resx">
<DependentUpon>ProgressReporterDialogue.cs</DependentUpon>
</EmbeddedResource>

19
Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs

@ -173,27 +173,21 @@ namespace ArdupilotMega.GCSViews @@ -173,27 +173,21 @@ namespace ArdupilotMega.GCSViews
CultureInfo ci = null;
foreach (string name in new string[] { "en-US", "zh-Hans", "zh-TW", "ru-RU", "Fr", "Pl", "it-IT", "es-ES" })
{
ci = MainV2.getcultureinfo(name);
ci = CultureInfoEx.GetCultureInfo(name);
if (ci != null)
languages.Add(ci);
}
CMB_language.DisplayMember = "DisplayName";
CMB_language.DataSource = languages;
bool match = false;
for (int i = 0; i < languages.Count && !match; i++)
{
ci = Thread.CurrentThread.CurrentUICulture;
while (!ci.Equals(CultureInfo.InvariantCulture))
for (int i = 0; i < languages.Count; i++)
{
if (ci.Equals(languages[i]))
if (ci.IsChildOf(languages[i]))
{
CMB_language.SelectedIndex = i;
match = true;
break;
}
ci = ci.Parent;
}
}
CMB_language.SelectedIndexChanged += CMB_language_SelectedIndexChanged;
@ -599,12 +593,12 @@ namespace ArdupilotMega.GCSViews @@ -599,12 +593,12 @@ namespace ArdupilotMega.GCSViews
continue;
if (index2 != -1)
line = line.Replace(',','.');
line = line.Replace(',', '.');
string name = line.Substring(0, index);
float value = float.Parse(line.Substring(index + 1), new System.Globalization.CultureInfo("en-US"));
MAVLink.modifyParamForDisplay(true,name,ref value);
MAVLink.modifyParamForDisplay(true, name, ref value);
// set param table as well
foreach (DataGridViewRow row in Params.Rows)
@ -813,7 +807,8 @@ namespace ArdupilotMega.GCSViews @@ -813,7 +807,8 @@ namespace ArdupilotMega.GCSViews
{
DsError.ThrowExceptionForHR(hr);
}
catch (Exception ex) {
catch (Exception ex)
{
MessageBox.Show("Can not add video source\n" + ex.ToString());
return;
}

42
Tools/ArdupilotMegaPlanner/MainV2.cs

@ -138,7 +138,7 @@ namespace ArdupilotMega @@ -138,7 +138,7 @@ namespace ArdupilotMega
xmlconfig(false);
if (config.ContainsKey("language") && !string.IsNullOrEmpty((string)config["language"]))
changelanguage(getcultureinfo((string)config["language"]));
changelanguage(CultureInfoEx.GetCultureInfo((string)config["language"]));
if (!MONO) // windows only
{
@ -2011,51 +2011,13 @@ namespace ArdupilotMega @@ -2011,51 +2011,13 @@ namespace ArdupilotMega
{
ComponentResourceManager rm = new ComponentResourceManager(view.GetType());
foreach (Control ctrl in view.Controls)
applyresource(rm, ctrl);
rm.ApplyResource(ctrl);
rm.ApplyResources(view, "$this");
}
}
}
}
private void applyresource(ComponentResourceManager rm, Control ctrl)
{
rm.ApplyResources(ctrl, ctrl.Name);
foreach (Control subctrl in ctrl.Controls)
applyresource(rm, subctrl);
if (ctrl.ContextMenu != null)
applyresource(rm, ctrl.ContextMenu);
if (ctrl is DataGridView)
{
foreach (DataGridViewColumn col in (ctrl as DataGridView).Columns)
rm.ApplyResources(col, col.Name);
}
}
private void applyresource(ComponentResourceManager rm, Menu menu)
{
rm.ApplyResources(menu, menu.Name);
foreach (MenuItem submenu in menu.MenuItems)
applyresource(rm, submenu);
}
public static CultureInfo getcultureinfo(string name)
{
try
{
return new CultureInfo(name);
}
catch (Exception)
{
return null;
}
}
private void MainV2_FormClosing(object sender, FormClosingEventArgs e)
{
config["MainHeight"] = this.Height;

64
Tools/ArdupilotMegaPlanner/Utility.cs

@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
//this file contains some simple extension methods
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.ComponentModel;
using System.Windows.Forms;
namespace ArdupilotMega
{
static class CultureInfoEx
{
public static CultureInfo GetCultureInfo(string name)
{
try { return new CultureInfo(name); }
catch (Exception) { return null; }
}
public static bool IsChildOf(this CultureInfo cX, CultureInfo cY)
{
if (cX == null || cY == null)
return false;
CultureInfo c = cX;
while (!c.Equals(CultureInfo.InvariantCulture))
{
if (c.Equals(cY))
return true;
c = c.Parent;
}
return false;
}
}
static class ComponentResourceManagerEx
{
public static void ApplyResource(this ComponentResourceManager rm, Control ctrl)
{
rm.ApplyResources(ctrl, ctrl.Name);
foreach (Control subctrl in ctrl.Controls)
ApplyResource(rm, subctrl);
if (ctrl.ContextMenu != null)
ApplyResource(rm, ctrl.ContextMenu);
if (ctrl is DataGridView)
{
foreach (DataGridViewColumn col in (ctrl as DataGridView).Columns)
rm.ApplyResources(col, col.Name);
}
}
public static void ApplyResource(this ComponentResourceManager rm, Menu menu)
{
rm.ApplyResources(menu, menu.Name);
foreach (MenuItem submenu in menu.MenuItems)
ApplyResource(rm, submenu);
}
}
}
Loading…
Cancel
Save