Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 2355 → Rev 2356

/MKLiveView/v1.0/Source/MainWindow.xaml.cs
1697,9 → 1697,6
}
}
 
// lblNCGPSLat.Invoke((Action)(() => lblNCGPSLat.Text = d.ToString("0.######°"))); //GPS-Position: Latitude in decimal degree
//lblNCGPSLat.Invoke((Action)(() => lblNCGPSLat.Text = _convertDegree(d))); //GPS-Position: Latitude in minutes, seconds
 
i_16 = data[28];
i_16 = (Int16)(i_16 << 8);
iVal = data[27] + i_16;
1756,38 → 1753,6
}
}
 
if(wpList.Count > 0 && ((data[67] & 2) == 2))
{
//if (_wpIndex > -1)
//{
// row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
// row.Background = new SolidColorBrush(Colors.Transparent);
// row.BorderBrush = new SolidColorBrush(Colors.Transparent);
// row.BorderThickness = new Thickness(0);
//}
//_wpIndex = dgvWP.SelectedIndex;
//row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
//row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 100, 255));
//row.BorderBrush = new SolidColorBrush(Colors.Aqua);
//row.BorderThickness = new Thickness(2);
//dgvWP.UpdateLayout();
 
 
// Dispatcher.Invoke(() =>
// {
// if(data[48] < wpList.Count)
// {
// DataGridRow row;
// if (data[48] > 0)
// {
// row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(data[48] - 1);
// row.Background = new SolidColorBrush(Colors.Transparent);
// }
// row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(data[48]);
// row.Background = new SolidColorBrush(Color.FromArgb(50, 0, 100, 255));
// }
// });
}
Dispatcher.Invoke((Action)(() => tbWPCount.Text = data[49].ToString())); //Waypoints count
Dispatcher.Invoke((Action)(() => lblWPCountNC.Content = data[49].ToString())); //Waypoints count
_wpCount = data[49];
1917,22 → 1882,17
{
if (data[1] == 1)
{
if(mRouteWP != null)
Dispatcher.Invoke(() => MainMap.Markers.Remove(mRouteWP));
wpList.Clear();
Dispatcher.Invoke(() => lblWPRouteDistance.Content = "0 m");
dtWaypoints.Rows.Clear();
Dispatcher.Invoke(() =>
{
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++;
}
wpList.Clear();
_clearMapMarkers(typeof(CustomMarkerWP));
if (mRouteWP != null)
MainMap.Markers.Remove(mRouteWP);
if (wpActiveMarker != null)
MainMap.Markers.Remove(wpActiveMarker);
lblWPRouteDistance.Content = "0 m";
dtWaypoints.Rows.Clear();
_wpEdit = -1;
});
}
DataRow dr = dtWaypoints.NewRow();
2264,7 → 2224,7
{
for (int i = 0; i < dtWaypoints.Rows.Count; i++)
{
_sendWayPoint(dtWaypoints.Rows[i],-1);
_sendWayPoint(dtWaypoints.Rows[i],-1,'w');
 
_iWPCount = -1;
iTimeout = 0;
2286,7 → 2246,7
Log(LogMsgType.Error, "NOT CONNECTED!");
 
}
bool _sendWayPoint(DataRow dr, int index)
bool _sendWayPoint(DataRow dr, int index, char command)
{
 
if (serialPortCtrl.Port.IsOpen)
2355,7 → 2315,7
//Autotrigger
bData[28] = Convert.ToByte(dr[11]);
 
bytes = FlightControllerMessage.CreateMessage('w', 2, bData);
bytes = FlightControllerMessage.CreateMessage(command, 2, bData);
serialStream.Write(bytes, 0, bytes.Length);
 
return true;
3200,14 → 3160,7
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++;
//}
_wpEdit = -1;
_clearMapMarkers(typeof(CustomMarkerWP));
wpList.Clear();
if (mRouteWP != null)
3557,6 → 3510,7
//if (wpActiveMarker != null)
// MainMap.Markers.Remove(wpActiveMarker);
dtWaypoints.Rows.Clear();
_wpEdit = -1;
Dispatcher.Invoke(() => dgvWP.Items.Refresh());
Dispatcher.Invoke(() => lblWPIndex.Content = 0);
Dispatcher.Invoke(() => lblWPCount.Content = 0);
3572,13 → 3526,13
if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
{
if (_wpCount > 0)
_sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], -1);
_sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], -1,'s');
else
_sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], 1);
_sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], 1,'s');
 
Dispatcher.Invoke(() => {
DataGridRow row;
if (_wpIndex > -1)
if (_wpIndex > -1 && _wpIndex < dgvWP.ItemContainerGenerator.Items.Count)
{
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
row.Background = new SolidColorBrush(Colors.Transparent);
3594,6 → 3548,33
});
}
}
private void btnSendActiveWP2_Click(object sender, RoutedEventArgs e)
{
if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
{
if (_wpCount > 0)
_sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], _wpCount,'s');
else
_sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], 1,'s');
 
Dispatcher.Invoke(() => {
DataGridRow row;
if (_wpIndex > -1 && _wpIndex < dgvWP.ItemContainerGenerator.Items.Count)
{
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
row.Background = new SolidColorBrush(Colors.Transparent);
row.BorderBrush = new SolidColorBrush(Colors.Transparent);
row.BorderThickness = new Thickness(0);
}
_wpIndex = dgvWP.SelectedIndex;
row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 100, 255));
row.BorderBrush = new SolidColorBrush(Colors.Aqua);
row.BorderThickness = new Thickness(2);
dgvWP.UpdateLayout();
});
}
}
private void dgvWP_MouseUp(object sender, MouseButtonEventArgs e)
{
if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
3710,6 → 3691,54
 
}
 
private void tbWPEditHeading_KeyDown(object sender, KeyEventArgs e)
{
if(!tbWPEditHeading.IsReadOnly)
{
//var x = KeyInterop.VirtualKeyFromKey(e.Key);
KeyConverter x = new KeyConverter();
string s = x.ConvertToString(e.Key);
 
if ("1234567890,\b".IndexOf(s) < 0) //general check for valid chars(0-9) and backspace (\b)
e.Handled = true;
else
if ("\b".IndexOf(s) < 0)
if (Convert.ToInt16(((TextBox)sender).Text + s) > 360) //if valid and not backspace, check for upper limit of the resulting number
e.Handled = true;
 
}
}
private void btnWPEditAddCurrentPos_Click(object sender, RoutedEventArgs e)
{
cbWPEditType.SelectedIndex = dgvWP.ItemContainerGenerator.Items.Count;
tbWPEditPrefix.Text = "P";
tbWPEditLat.Text = copter.Position.Lat.ToString();
tbWPEditLon.Text = copter.Position.Lng.ToString();
tbWPEditAlt.Text = ((double)iAnalogData[4] / (double)10).ToString();
 
cbWPEditHeading.SelectedIndex = 2;
tbWPEditHeading.Text = iAnalogData[10].ToString();
tbWPEditHeading.IsReadOnly = false;
 
cbWPEditSpeed.SelectedIndex = 1;
tbWPEditSpeed.Text = "5.0";
tbWPEditSpeed.IsReadOnly = false;
 
cbWPEditClimbrate.SelectedIndex = 1;
tbWPEditClimbrate.Text = "5.0";
tbWPEditClimbrate.IsReadOnly = false;
 
tbWPEditRadius.Text = "10";
tbWPEditHoldtime.Text = "5";
tbWPEditAutoTrigger.Text = "0";
 
cbWPEditCamAngle.SelectedIndex = 1;
tbWPEditCamAngle.Text = "AUTO";
tbWPEditCamAngle.IsReadOnly = true;
 
tbWPEditOut1.Text = "0";
}
 
#endregion WP
#region GPX
private void checkBoxGPXLog_Click(object sender, RoutedEventArgs e)
3779,6 → 3808,8
}
}
}
 
 
private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e)
{
_loadGPXLog();