mirror of https://github.com/ArduPilot/ardupilot
parent
f27e9f9ca1
commit
71b73a669c
|
@ -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>
|
||||
|
|
|
@ -173,26 +173,20 @@ 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;
|
||||
for (int i = 0; i < languages.Count; i++)
|
||||
{
|
||||
ci = Thread.CurrentThread.CurrentUICulture;
|
||||
while (!ci.Equals(CultureInfo.InvariantCulture))
|
||||
if (ci.IsChildOf(languages[i]))
|
||||
{
|
||||
if (ci.Equals(languages[i]))
|
||||
{
|
||||
CMB_language.SelectedIndex = i;
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
ci = ci.Parent;
|
||||
CMB_language.SelectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CMB_language.SelectedIndexChanged += CMB_language_SelectedIndexChanged;
|
||||
|
@ -555,23 +549,23 @@ namespace ArdupilotMega.GCSViews
|
|||
if (text.Length > 0)
|
||||
{
|
||||
if (text[0].GetType() == typeof(NumericUpDown))
|
||||
{
|
||||
decimal option = (decimal)(float.Parse(Params[e.ColumnIndex, e.RowIndex].Value.ToString()));
|
||||
((NumericUpDown)text[0]).Value = option;
|
||||
((NumericUpDown)text[0]).BackColor = Color.Green;
|
||||
}
|
||||
{
|
||||
decimal option = (decimal)(float.Parse(Params[e.ColumnIndex, e.RowIndex].Value.ToString()));
|
||||
((NumericUpDown)text[0]).Value = option;
|
||||
((NumericUpDown)text[0]).BackColor = Color.Green;
|
||||
}
|
||||
else if (text[0].GetType() == typeof(ComboBox))
|
||||
{
|
||||
int option = (int)(float.Parse(Params[e.ColumnIndex, e.RowIndex].Value.ToString()));
|
||||
((ComboBox)text[0]).SelectedIndex = option;
|
||||
((ComboBox)text[0]).BackColor = Color.Green;
|
||||
}
|
||||
{
|
||||
int option = (int)(float.Parse(Params[e.ColumnIndex, e.RowIndex].Value.ToString()));
|
||||
((ComboBox)text[0]).SelectedIndex = option;
|
||||
((ComboBox)text[0]).BackColor = Color.Green;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { ((Control)text[0]).BackColor = Color.Red; }
|
||||
|
||||
Params.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void BUT_load_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -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,9 +807,10 @@ namespace ArdupilotMega.GCSViews
|
|||
{
|
||||
DsError.ThrowExceptionForHR(hr);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
MessageBox.Show("Can not add video source\n" + ex.ToString());
|
||||
return;
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Can not add video source\n" + ex.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the stream config interface
|
||||
|
@ -940,7 +935,7 @@ namespace ArdupilotMega.GCSViews
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch { MessageBox.Show("Error: getting param list"); }
|
||||
|
||||
|
|
|
@ -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
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -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…
Reference in New Issue