49,6 → 49,7 |
GMapRoute mRouteWP; |
GMapMarker wpActiveMarker; |
List<PointLatLng> wpList = new List<PointLatLng>(); |
List<int> wpOffset = new List<int>(); |
Circle cWPBound = new Circle(); |
double dWPMaxRange = 0; |
|
1929,25 → 1930,26 |
Dispatcher.Invoke((Action)(() => lblWPStatusIndexNC.Content = data[48].ToString())); |
if(data[48] > 0 && _wpIndex != data[48] -1 && wpList.Count >= data[48] -1) |
{ |
_setActiveWP(data[48]-1); |
_setActiveWP(data[48]- 1); |
if((data[67] & 2) == 2) |
Dispatcher.Invoke(() => { |
DataGridRow row; |
if (_wpIndex > -1) |
{ |
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex); |
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(wpOffset[_wpIndex]); |
row.Background = new SolidColorBrush(Colors.Transparent); |
row.BorderBrush = new SolidColorBrush(Colors.Transparent); |
row.BorderThickness = new Thickness(0); |
} |
|
_wpIndex = data[48] - 1; |
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex); |
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(wpOffset[_wpIndex]); |
row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 255, 100)); |
row.BorderBrush = new SolidColorBrush(Colors.SpringGreen); |
row.BorderThickness = new Thickness(2); |
dgvWP.UpdateLayout(); |
}); |
_wpIndex = data[48]-1; |
_wpIndex = data[48]- 1; |
} |
else |
{ |
1959,7 → 1961,7 |
DataGridRow row; |
if (_wpIndex > -1 && data[48] == 0 && wpList.Count > _wpIndex) |
{ |
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex); |
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(wpOffset[_wpIndex]); |
row.Background = new SolidColorBrush(Colors.Transparent); |
row.BorderBrush = new SolidColorBrush(Colors.Transparent); |
row.BorderThickness = new Thickness(0); |
2161,12 → 2163,13 |
lblWPRouteDistance.Content = "0 m"; |
dtWaypoints.Rows.Clear(); |
_wpEdit = -1;_wpIndex = -1; |
wpOffset.Clear(); |
}); |
} |
DataRow dr = dtWaypoints.NewRow(); |
dr = Waypoints.toDataRow(data, dr); |
dtWaypoints.Rows.Add(dr); |
_createWP(new PointLatLng((double)dr[3], (double)dr[4]), (string)dr[2], (int)dr[1]); |
_createWP(new PointLatLng((double)dr[3], (double)dr[4]), (string)dr[2], (int)dr[1],(int)data[1]-1); |
Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
Dispatcher.Invoke(() => _iWPIndex = data[1]); |
if (data[1] == data[0]) |
3487,6 → 3490,7 |
nfi.NumberDecimalSeparator = "."; |
dtWaypoints.Rows.Clear(); |
_wpEdit = -1;_wpIndex = -1; |
wpOffset.Clear(); |
_clearMapMarkers(typeof(CustomMarkerWP)); |
_clearMapMarkers(typeof(CustomMarkerWPActive)); |
wpList.Clear(); |
3564,7 → 3568,7 |
|
dr.ItemArray = o; |
dtWaypoints.Rows.Add(dr); |
_createWP(new PointLatLng((double)o[3], (double)o[4]), (string)dr[2], (int)o[1]); |
_createWP(new PointLatLng((double)o[3], (double)o[4]), (string)dr[2], (int)o[1], (int)o[0]-1); |
|
Dispatcher.Invoke(() => lblWPIndex.Content = k.ToString()); |
Dispatcher.Invoke(() => lblWPCount.Content = k.ToString()); |
3678,7 → 3682,7 |
MapRoute mr = new MapRoute(wpList, "WPList"); |
Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance * 1000).ToString("0 m")); |
} |
GMapMarker _createWP(PointLatLng p, string name, int type) |
GMapMarker _createWP(PointLatLng p, string name, int type, int index) |
{ |
GMapMarker wpMarker = new GMapMarker(p); |
Dispatcher.Invoke(()=> |
3690,7 → 3694,10 |
_setMarkerColor(wpMarker, type); |
MainMap.Markers.Add(wpMarker); |
if (type == 0 || type == 3) |
{ |
wpList.Add(p); |
wpOffset.Add(index); |
} |
((CustomMarkerWP)wpMarker.Shape).positionChanged += _updateDTWPPos; |
((CustomMarkerWP)wpMarker.Shape).newPosition += _updateDTWPPosFin; |
((CustomMarkerWP)wpMarker.Shape).mouseCaptured += _WPMouseCaptured; |
3745,7 → 3752,45 |
} |
|
} |
/// <summary> |
/// find the index of of a wp from datatable in the waypointlist wpList |
/// </summary> |
/// <param name="dtIndex">the index of wp in datatable (0-based)</param> |
/// <returns></returns> |
int _getWPIndexfromList(int dtIndex) |
{ |
if ((int)dtWaypoints.Rows[dtIndex][1] == 0 || (int)dtWaypoints.Rows[dtIndex][1] == 3) |
{ |
GMapMarker wp = _findWPMarker((string)dtWaypoints.Rows[dtIndex][2]); |
if (wp != null) |
return wpList.IndexOf(wp.Position); |
} |
return -1; |
} |
/// <summary> |
/// find the index of of a wp from datatable in the waypointlist wpList |
/// </summary> |
/// <param name="name">the name of the wp</param> |
/// <returns></returns> |
int _getWPIndexfromList(string name) |
{ |
GMapMarker wp = _findWPMarker(name); |
if ((wp != null && wp.Shape != null) && ((CustomMarkerWP)wp.Shape).WPType == 0 | ((CustomMarkerWP)wp.Shape).WPType == 3) |
return wpList.IndexOf(wp.Position); |
else |
return -1; |
} |
int _getWPListOffset(int index) |
{ |
int k = 0; |
for(int i = 0; i < wpOffset.Count;i++) |
{ |
if (wpOffset[i] <= index) |
k++; |
} |
|
return k; |
} |
void _setMarkerColor(GMapMarker wpMarker,int iType) |
{ |
if(wpMarker != null) |
3921,6 → 3966,7 |
dtWaypoints.Rows.Clear(); |
_wpEdit = -1; |
_wpIndex = -1; |
wpOffset.Clear(); |
Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
Dispatcher.Invoke(() => lblWPIndex.Content = 0); |
Dispatcher.Invoke(() => lblWPCount.Content = 0); |
4173,6 → 4219,18 |
if (dgvWP.SelectedIndex > 0 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count) |
{ |
int index = dgvWP.SelectedIndex; |
if (((int)dtWaypoints.Rows[index][1] == 0 | (int)dtWaypoints.Rows[index][1] == 3) && ((int)dtWaypoints.Rows[index - 1][1] == 0 | (int)dtWaypoints.Rows[index - 1][1] == 3))// && wpList.Count > index) |
{ |
PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]); |
int wpListIndex = wpList.IndexOf(x); |
if (wpListIndex > 0) |
{ |
wpList.RemoveAt(wpListIndex); |
wpList.Insert(wpListIndex - 1, x); |
MainMap.Markers.Remove(mRouteWP); |
_routeUpdate(); |
} |
} |
DataRow dr = dtWaypoints.Rows[index]; |
DataRow newRow = dtWaypoints.NewRow(); |
newRow.ItemArray = dr.ItemArray; |
4190,18 → 4248,26 |
dgvWP.Items.Refresh(); |
dgvWP.SelectedIndex = index - 1; |
_dgvWPselectEditRow(); |
if (((int)dtWaypoints.Rows[index][1] == 0 | (int)dtWaypoints.Rows[index][1] == 3) && ((int)dtWaypoints.Rows[index - 1][1] == 0 | (int)dtWaypoints.Rows[index - 1][1] == 3))// && wpList.Count > index) |
if (wpOffset.Contains(index)) // calculating offset for wpList (index is 0-based - offset starts with index 1) |
{ |
PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]); |
int wpListIndex = wpList.IndexOf(x); |
if (wpListIndex > 0) |
int iOffset = wpOffset.IndexOf(index); |
if (iOffset > 0) // if not first element |
{ |
wpList.RemoveAt(wpListIndex); |
wpList.Insert(wpListIndex - 1, x); |
MainMap.Markers.Remove(mRouteWP); |
_routeUpdate(); |
if (wpOffset[iOffset - 1] < index-1) //if previous element is not immediately before actual offset |
wpOffset[iOffset] = index-1; //then decrease offset value by one |
} |
else |
wpOffset[iOffset] = index-1; //if first element, decrease offset by one |
} |
else //selected line is POI |
{ |
if (wpOffset.Contains(index - 1)) // if next point is WP |
{ |
int iOffset = wpOffset.IndexOf(index - 1); |
wpOffset[iOffset] = index; //decrease linenumber of following WP |
} |
} |
|
} |
} |
|
4210,6 → 4276,21 |
if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count - 1) |
{ |
int index = dgvWP.SelectedIndex; |
if (((int)dtWaypoints.Rows[index][1] == 0 | (int)dtWaypoints.Rows[index][1] == 3) && ((int)dtWaypoints.Rows[index+1][1] == 0 | (int)dtWaypoints.Rows[index+1][1] == 3))// && wpList.Count > index) |
{ |
PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]); |
int wpListIndex = wpList.IndexOf(x); |
if (wpListIndex > -1) |
{ |
wpList.RemoveAt(wpListIndex); |
if (wpList.Count > wpListIndex) |
wpList.Insert(wpListIndex + 1, x); |
else |
wpList.Add(x); |
MainMap.Markers.Remove(mRouteWP); |
_routeUpdate(); |
} |
} |
DataRow dr = dtWaypoints.Rows[index]; |
DataRow newRow = dtWaypoints.NewRow(); |
newRow.ItemArray = dr.ItemArray; |
4227,21 → 4308,25 |
dgvWP.Items.Refresh(); |
dgvWP.SelectedIndex = index + 1; |
_dgvWPselectEditRow(); |
if (((int)dtWaypoints.Rows[index][1] == 0 | (int)dtWaypoints.Rows[index][1] == 3) && ((int)dtWaypoints.Rows[index+1][1] == 0 | (int)dtWaypoints.Rows[index+1][1] == 3))// && wpList.Count > index) |
if(wpOffset.Contains(index)) // If selected line is WP |
{ |
PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]); |
int wpListIndex = wpList.IndexOf(x); |
if (wpListIndex > -1) |
int iOffset = wpOffset.IndexOf(index); |
if(iOffset < wpOffset.Count -1) // if not last element |
{ |
wpList.RemoveAt(wpListIndex); |
if (wpList.Count > wpListIndex) |
wpList.Insert(wpListIndex + 1, x); |
else |
wpList.Add(x); |
MainMap.Markers.Remove(mRouteWP); |
_routeUpdate(); |
if (wpOffset[iOffset + 1] > index + 1) //if next element is not immediately after actual offset |
wpOffset[iOffset] = index + 1; //then increase offset value by one |
} |
else |
wpOffset[iOffset] = index + 1; //if last element increase offset by one |
} |
else //selected line is POI |
{ |
if (wpOffset.Contains(index + 1)) // if next point is WP |
{ |
int iOffset = wpOffset.IndexOf(index + 1); |
wpOffset[iOffset] = index; //decrease linenumber of following WP |
} |
} |
} |
|
} |
4260,10 → 4345,13 |
dtWaypoints.Rows[dgvWP.SelectedIndex][4] = Convert.ToDouble(tbWPEditLon.Text.Replace('.', ',')); |
if (i > -1) |
{ |
if((int)dtWaypoints.Rows[dgvWP.SelectedIndex][1] == 0 || (int)dtWaypoints.Rows[dgvWP.SelectedIndex][1] == 3) |
if ((int)dtWaypoints.Rows[dgvWP.SelectedIndex][1] == 0 || (int)dtWaypoints.Rows[dgvWP.SelectedIndex][1] == 3) |
wpList[i] = (new PointLatLng((double)dtWaypoints.Rows[dgvWP.SelectedIndex][3], (double)dtWaypoints.Rows[dgvWP.SelectedIndex][4])); |
else |
{ |
wpList.Remove(pOld); |
wpOffset.Remove(wpOffset[i]); |
} |
} |
else |
{ |
4271,9 → 4359,14 |
{ |
int found = 0; |
for (int k = 0; k < dgvWP.SelectedIndex; k++) |
if ((int)dtWaypoints.Rows[k][1] == 0) |
{ |
if ((int)dtWaypoints.Rows[k][1] == 0 || (int)dtWaypoints.Rows[k][1] == 3) |
{ |
found++; |
} |
} |
wpList.Insert(found, new PointLatLng((double)dtWaypoints.Rows[dgvWP.SelectedIndex][3], (double)dtWaypoints.Rows[dgvWP.SelectedIndex][4])); |
wpOffset.Insert(found, dgvWP.SelectedIndex); |
} |
} |
dtWaypoints.Rows[dgvWP.SelectedIndex][5] = tbWPEditAlt.Text; |
4363,6 → 4456,8 |
} |
if ((int)dtWaypoints.Rows[index][1] == 0 || (int)dtWaypoints.Rows[index][1] == 3) |
wpList.Remove(new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4])); |
else |
wpOffset.Remove((int)dtWaypoints.Rows[index][0] + 1); |
_clearWPMarker((string)dtWaypoints.Rows[index][2]); |
if (wpActiveMarker != null) |
MainMap.Markers.Remove(wpActiveMarker); |
4525,7 → 4620,7 |
o[15] = "0"; |
|
dtWaypoints.Rows.Add(o); |
_createWP(new PointLatLng((double)o[3], (double)o[4]), (string)o[2], (int)o[1]); |
_createWP(new PointLatLng((double)o[3], (double)o[4]), (string)o[2], (int)o[1],(int)o[0]-1); |
Dispatcher.Invoke(() => lblWPCount.Content = o[0].ToString()); |
if (mRouteWP != null) |
MainMap.Markers.Remove(mRouteWP); |
4631,6 → 4726,12 |
} |
} |
} |
|
private void Grid_TouchDown(object sender, TouchEventArgs e) |
{ |
|
} |
|
private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
{ |
_loadGPXLog(); |
4713,7 → 4814,8 |
#endregion GPX |
#endregion functions |
} |
/// <summary> |
|
/// <summary> |
/// formats the wp datatable values for display in datagrid - this is bound in the datagrid as a converter |
/// </summary> |
public class waypointsConverter : IValueConverter |
4760,7 → 4862,6 |
throw new NotImplementedException(); |
} |
} |
|
public class IniFile |
{ |
public string path; |
4815,7 → 4916,6 |
|
} |
} |
|
/// <summary> |
/// Selected Win AI Function Calls |
/// </summary> |