260,7 → 260,7 |
/// <summary> |
/// datatable for motordata (current,temp) |
/// </summary> |
DataTable dtMotors1 = new DataTable(); |
DataTable dtMotors = new DataTable(); |
|
DataTable dtWaypoints = new DataTable(); |
static volatile int _iWPCount = -1; |
350,13 → 350,13 |
/// </summary> |
void _dataTablesInit() |
{ |
dtMotors1.Columns.Add("#"); |
dtMotors.Columns.Add("#"); |
if (Thread.CurrentThread.CurrentUICulture.Name == "de-DE") |
dtMotors1.Columns.Add("Strom"); |
dtMotors.Columns.Add("Strom"); |
else |
dtMotors1.Columns.Add("Current"); |
dtMotors1.Columns.Add("Temp"); |
dgvMotors1.DataContext = dtMotors1.DefaultView; |
dtMotors.Columns.Add("Current"); |
dtMotors.Columns.Add("Temp"); |
dgvMotors1.DataContext = dtMotors.DefaultView; |
_initDTMotors(); |
|
Setter setter = new Setter(ContentControl.PaddingProperty, new Thickness(5,0,5,0)); |
368,10 → 368,10 |
style.Setters.Add(setter); |
|
dtWaypoints.Columns.Add("Index",typeof(int)); |
dtWaypoints.Columns.Add("Type",typeof(string)); |
dtWaypoints.Columns.Add("Type", typeof(int)); |
dtWaypoints.Columns.Add("Name",typeof(string)); |
dtWaypoints.Columns.Add("Latitude",typeof(string)); |
dtWaypoints.Columns.Add("Longitude",typeof(string)); |
dtWaypoints.Columns.Add("Latitude",typeof(double)); |
dtWaypoints.Columns.Add("Longitude",typeof(double)); |
dtWaypoints.Columns.Add("Altitude",typeof(string)); |
dtWaypoints.Columns.Add("Heading",typeof(string)); |
dtWaypoints.Columns.Add("Speed",typeof(string)); |
391,7 → 391,7 |
|
} |
/// <summary> |
/// initialize the datatable dtMotors1 for motor values |
/// initialize the datatable dtMotors for motor values |
/// DataGridView dgvMotors1 is bound to dtMotors1 |
/// </summary> |
void _initDTMotors() |
398,12 → 398,12 |
{ |
for (int i = 0; i < 12; i++) |
{ |
if (dtMotors1.Rows.Count < 12) |
dtMotors1.Rows.Add((i + 1).ToString(), "NA", "NA"); |
if (dtMotors.Rows.Count < 12) |
dtMotors.Rows.Add((i + 1).ToString(), "NA", "NA"); |
else |
{ |
dtMotors1.Rows[i].SetField(1, "NA"); |
dtMotors1.Rows[i].SetField(2, "NA"); |
dtMotors.Rows[i].SetField(1, "NA"); |
dtMotors.Rows[i].SetField(2, "NA"); |
} |
} |
} |
1508,13 → 1508,13 |
{ |
if (bAvailable) |
{ |
dtMotors1.Rows[data[i]].SetField(1, ((double)data[i + 1] / (double)10).ToString("0.0 A")); |
dtMotors1.Rows[data[i]].SetField(2, data[i + 2].ToString("0 °C")); |
dtMotors.Rows[data[i]].SetField(1, ((double)data[i + 1] / (double)10).ToString("0.0 A")); |
dtMotors.Rows[data[i]].SetField(2, data[i + 2].ToString("0 °C")); |
} |
else |
{ |
dtMotors1.Rows[data[i]].SetField(1, "NA"); |
dtMotors1.Rows[data[i]].SetField(2, "NA"); |
dtMotors.Rows[data[i]].SetField(1, "NA"); |
dtMotors.Rows[data[i]].SetField(2, "NA"); |
} |
} |
//if (data[i] > 3 && data[i] < 8) |
1769,10 → 1769,21 |
if (_bGetWP) |
{ |
if (data[1] == 1) |
{ |
dtWaypoints.Rows.Clear(); |
foreach (GMapMarker p in MainMap.Markers) |
{ |
if (p.Shape.GetType() == typeof(CustomMarkerWP)) |
MainMap.Markers.Remove(p); |
} |
} |
DataRow dr = dtWaypoints.NewRow(); |
dr = Waypoints.toDataRow(data, dr); |
dtWaypoints.Rows.Add(dr); |
GMapMarker wp = new GMapMarker(new PointLatLng((double)dr[3], (double)dr[4])); |
wp.Shape = new CustomMarkerWP(this, wp, (string)dr[2],(int)dr[1]); |
_setMarkerColor(wp, (int)dr[1]); |
MainMap.Markers.Add(wp); |
Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
Dispatcher.Invoke(() => _iWPIndex = data[1]); |
if (data[1] == data[0]) |
2005,22 → 2016,12 |
} |
void _getWP() |
{ |
//if (_iWP > 0) |
//{ |
// _getWPList(); |
//} |
//else |
//{ |
// if (_iWP == -1) |
// { |
_bGetWPCount = true; |
_getpWP(1); |
_getpWP(1); //get the itemscount of wp |
while (_bGetWPCount) |
Thread.Sleep(100); |
if (_iWPCount > 0) |
_getWPList(); |
// } |
//} |
} |
void _getWPList() |
{ |
2558,6 → 2559,7 |
} |
} |
|
#region WP |
void _readWPLFile() |
{ |
Microsoft.Win32.OpenFileDialog fd = new Microsoft.Win32.OpenFileDialog(); |
2591,6 → 2593,14 |
NumberFormatInfo nfi = new NumberFormatInfo(); |
nfi.NumberDecimalSeparator = "."; |
dtWaypoints.Rows.Clear(); |
for(int k = 0; k < MainMap.Markers.Count;) |
{ |
GMapMarker p = MainMap.Markers[k]; |
if (p.Shape.GetType() == typeof(CustomMarkerWP)) |
MainMap.Markers.Remove(p); |
else |
k++; |
} |
for (int k = 1; k <= wpnum; k++) |
{ |
DataRow dr = dtWaypoints.NewRow(); |
2602,7 → 2612,7 |
i++; |
sVal = ini.IniReadValue(wp, "Type"); |
if (sVal != "") |
o[i] = Convert.ToInt16(sVal) -1; |
o[i] = Convert.ToInt16(sVal) - 1; |
i++; |
sVal = ini.IniReadValue(wp, "Prefix"); |
if (sVal != "") |
2626,7 → 2636,7 |
i++; |
sVal = ini.IniReadValue(wp, "Speed"); |
if (sVal != "") |
o[i] =Convert.ToInt16(sVal); |
o[i] = Convert.ToInt16(sVal); |
i++; |
sVal = ini.IniReadValue(wp, "ClimbRate"); |
if (sVal != "") |
2657,8 → 2667,12 |
o[i] = "New"; |
|
dr.ItemArray = o; |
// dtWaypoints.Rows.Add(dr); |
dtWaypoints.Rows.Add(dr); |
GMapMarker wpMarker = new GMapMarker(new PointLatLng((double)o[3], (double)o[4])); |
wpMarker.Shape = new CustomMarkerWP(this, wpMarker, (string)dr[2], (int)o[1]); |
_setMarkerColor(wpMarker, (int)o[1]); |
MainMap.Markers.Add(wpMarker); |
|
Dispatcher.Invoke(() => lblWPIndex.Content = k.ToString()); |
Dispatcher.Invoke(() => lblWPCount.Content = k.ToString()); |
Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
2677,27 → 2691,121 |
|
} |
} |
void _setMarkerColor(GMapMarker wpMarker,int iType) |
{ |
Dispatcher.Invoke(() => |
{ |
switch (iType) |
{ |
case 0: |
if (comboBoxWPColor.SelectionBoxItem != null) |
{ |
string s = comboBoxWPColor.SelectionBoxItem.ToString(); |
((CustomMarkerWP)(wpMarker.Shape)).setColor(s); |
} |
else |
((CustomMarkerWP)(wpMarker.Shape)).setColor("red"); |
break; |
case 1: |
if (comboBoxPOIColor.SelectionBoxItem != null) |
{ |
string s = comboBoxPOIColor.SelectionBoxItem.ToString(); |
((CustomMarkerWP)(wpMarker.Shape)).setColor(s); |
} |
else |
((CustomMarkerWP)(wpMarker.Shape)).setColor("red"); |
break; |
case 2: |
if (comboBoxFSColor.SelectionBoxItem != null) |
{ |
string s = comboBoxFSColor.SelectionBoxItem.ToString(); |
((CustomMarkerWP)(wpMarker.Shape)).setColor(s); |
} |
else |
((CustomMarkerWP)(wpMarker.Shape)).setColor("red"); |
break; |
default: |
((CustomMarkerWP)(wpMarker.Shape)).setColor("red"); |
break; |
} |
}); |
|
private void btnLoadWPLFile_Click(object sender, RoutedEventArgs e) |
} |
private void comboBoxWPColor_DropDownClosed(object sender, EventArgs e) |
{ |
_readWPLFile(); |
Dispatcher.Invoke(() => |
{ |
if (comboBoxWPColor.SelectionBoxItem != null) |
{ |
for (int k = 0; k < MainMap.Markers.Count;k++) |
{ |
GMapMarker p = MainMap.Markers[k]; |
if (p.Shape.GetType() == typeof(CustomMarkerWP)) |
{ |
if (((CustomMarkerWP)p.Shape).WPType == 0) |
{ |
string s = comboBoxWPColor.SelectionBoxItem.ToString(); |
((CustomMarkerWP)(p.Shape)).setColor(s); |
} |
} |
} |
} |
}); |
} |
#endregion functions |
} |
public class BooleanToVisibilityConverter : IValueConverter |
{ |
private void comboBoxPOIColor_DropDownClosed(object sender, EventArgs e) |
{ |
Dispatcher.Invoke(() => |
{ |
if (comboBoxPOIColor.SelectionBoxItem != null) |
{ |
for (int k = 0; k < MainMap.Markers.Count; k++) |
{ |
GMapMarker p = MainMap.Markers[k]; |
if (p.Shape.GetType() == typeof(CustomMarkerWP)) |
{ |
if (((CustomMarkerWP)p.Shape).WPType == 1) |
{ |
string s = comboBoxPOIColor.SelectionBoxItem.ToString(); |
((CustomMarkerWP)(p.Shape)).setColor(s); |
} |
} |
} |
} |
}); |
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
} |
private void comboBoxFSColor_DropDownClosed(object sender, EventArgs e) |
{ |
return (bool)value ? Visibility.Visible : Visibility.Collapsed; |
Dispatcher.Invoke(() => |
{ |
if (comboBoxFSColor.SelectionBoxItem != null) |
{ |
for (int k = 0; k < MainMap.Markers.Count; k++) |
{ |
GMapMarker p = MainMap.Markers[k]; |
if (p.Shape.GetType() == typeof(CustomMarkerWP)) |
{ |
if (((CustomMarkerWP)p.Shape).WPType == 2) |
{ |
string s = comboBoxFSColor.SelectionBoxItem.ToString(); |
((CustomMarkerWP)(p.Shape)).setColor(s); |
} |
} |
} |
} |
}); |
} |
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
private void btnLoadWPLFile_Click(object sender, RoutedEventArgs e) |
{ |
throw new NotImplementedException(); |
_readWPLFile(); |
} |
#endregion WP |
|
#endregion functions |
} |
|
/// <summary> |
/// formats the wp datatable values for display in datagrid - this is bound in the datagrid as a converter |
/// </summary> |
public class waypointsConverter : IValueConverter |
{ |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |