Rev 2381 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2381 | Rev 2385 | ||
---|---|---|---|
Line 728... | Line 728... | ||
728 | 728 | ||
729 | copter.Shape = new CustomMarkerCopter(this, copter, MainMap.Position.Lat.ToString("0.#######°") + System.Environment.NewLine + MainMap.Position.Lng.ToString("0.#######°"),"red"); |
729 | copter.Shape = new CustomMarkerCopter(this, copter, MainMap.Position.Lat.ToString("0.#######°") + System.Environment.NewLine + MainMap.Position.Lng.ToString("0.#######°"),"red"); |
730 | if (comboBoxCopterColor.SelectionBoxItem != null) |
730 | if (comboBoxCopterColor.SelectionBoxItem != null) |
731 | { |
731 | { |
732 | string s = comboBoxCopterColor.SelectionBoxItem.ToString(); |
732 | string s = comboBoxCopterColor.SelectionBoxItem.ToString(); |
733 | ((CustomMarkerCopter)(copter.Shape)).setColor(s); |
733 | ((CustomMarkerCopter)(copter.Shape)).setCopterColor(s); |
- | 734 | } |
|
- | 735 | Dispatcher.Invoke(() => { |
|
- | 736 | if (comboBoxCopterHeadingColor.SelectionBoxItem != null) |
|
- | 737 | { |
|
- | 738 | string s = comboBoxCopterHeadingColor.SelectionBoxItem.ToString(); |
|
- | 739 | ((CustomMarkerCopter)(copter.Shape)).setHeadingColor(s); |
|
- | 740 | } |
|
734 | } |
741 | }); |
735 | copter.Offset = new System.Windows.Point(-18, -18); |
742 | copter.Offset = new System.Windows.Point(-28, -28); |
736 | copter.ZIndex = int.MaxValue; |
743 | copter.ZIndex = int.MaxValue; |
737 | MainMap.Markers.Add(copter); |
744 | MainMap.Markers.Add(copter); |
738 | copter.Position = MainMap.Position; |
745 | copter.Position = MainMap.Position; |
739 | } |
746 | } |
Line 1546... | Line 1553... | ||
1546 | Dispatcher.Invoke(() => tbTopCurrent.Text = ((double)iAnalogData[index] / (double)10).ToString("0.0 A")); |
1553 | Dispatcher.Invoke(() => tbTopCurrent.Text = ((double)iAnalogData[index] / (double)10).ToString("0.0 A")); |
1547 | break; |
1554 | break; |
1548 | case 10: //heading |
1555 | case 10: //heading |
1549 | Dispatcher.Invoke((Action)(() => tbHeading.Text = sAnalogData[index] + "°")); |
1556 | Dispatcher.Invoke((Action)(() => tbHeading.Text = sAnalogData[index] + "°")); |
1550 | Dispatcher.Invoke(() => ArtHor.rotate = iAnalogData[index]); |
1557 | Dispatcher.Invoke(() => ArtHor.rotate = iAnalogData[index]); |
- | 1558 | Dispatcher.Invoke(() => ((CustomMarkerCopter)(copter.Shape)).rotate = iAnalogData[index]); |
|
1551 | break; |
1559 | break; |
1552 | case 12: // SPI error |
1560 | case 12: // SPI error |
1553 | Dispatcher.Invoke((Action)(() => tbSPI.Text = sAnalogData[index])); |
1561 | Dispatcher.Invoke((Action)(() => tbSPI.Text = sAnalogData[index])); |
1554 | break; |
1562 | break; |
1555 | case 14: //i2c error |
1563 | case 14: //i2c error |
Line 2788... | Line 2796... | ||
2788 | if(sVal != "") comboBoxPOIColor.SelectedIndex = Convert.ToInt32(sVal); |
2796 | if(sVal != "") comboBoxPOIColor.SelectedIndex = Convert.ToInt32(sVal); |
2789 | sVal = ini.IniReadValue("waypoints", "fscolor"); |
2797 | sVal = ini.IniReadValue("waypoints", "fscolor"); |
2790 | if(sVal != "") comboBoxFSColor.SelectedIndex = Convert.ToInt32(sVal); |
2798 | if(sVal != "") comboBoxFSColor.SelectedIndex = Convert.ToInt32(sVal); |
2791 | sVal = ini.IniReadValue("waypoints", "coptercolor"); |
2799 | sVal = ini.IniReadValue("waypoints", "coptercolor"); |
2792 | if(sVal != "") comboBoxCopterColor.SelectedIndex = Convert.ToInt32(sVal); |
2800 | if(sVal != "") comboBoxCopterColor.SelectedIndex = Convert.ToInt32(sVal); |
- | 2801 | sVal = ini.IniReadValue("waypoints", "copterheadingcolor"); |
|
- | 2802 | if(sVal != "") comboBoxCopterHeadingColor.SelectedIndex = Convert.ToInt32(sVal); |
|
2793 | sVal = ini.IniReadValue("waypoints", "landingcolor"); |
2803 | sVal = ini.IniReadValue("waypoints", "landingcolor"); |
2794 | if(sVal != "") comboBoxLandingColor.SelectedIndex = Convert.ToInt32(sVal); |
2804 | if(sVal != "") comboBoxLandingColor.SelectedIndex = Convert.ToInt32(sVal); |
2795 | sVal = ini.IniReadValue("waypoints", "routecolor"); |
2805 | sVal = ini.IniReadValue("waypoints", "routecolor"); |
2796 | if(sVal != "") comboBoxRouteColor.SelectedIndex = Convert.ToInt32(sVal); |
2806 | if(sVal != "") comboBoxRouteColor.SelectedIndex = Convert.ToInt32(sVal); |
2797 | sVal = ini.IniReadValue("waypoints", "showWPRoute"); |
2807 | sVal = ini.IniReadValue("waypoints", "showWPRoute"); |
Line 2895... | Line 2905... | ||
2895 | 2905 | ||
2896 | ini.IniWriteValue("waypoints", "wpcolor", comboBoxWPColor.SelectedIndex.ToString()); |
2906 | ini.IniWriteValue("waypoints", "wpcolor", comboBoxWPColor.SelectedIndex.ToString()); |
2897 | ini.IniWriteValue("waypoints", "poicolor", comboBoxPOIColor.SelectedIndex.ToString()); |
2907 | ini.IniWriteValue("waypoints", "poicolor", comboBoxPOIColor.SelectedIndex.ToString()); |
2898 | ini.IniWriteValue("waypoints", "fscolor", comboBoxFSColor.SelectedIndex.ToString()); |
2908 | ini.IniWriteValue("waypoints", "fscolor", comboBoxFSColor.SelectedIndex.ToString()); |
- | 2909 | ini.IniWriteValue("waypoints", "coptercolor", comboBoxCopterColor.SelectedIndex.ToString()); |
|
2899 | ini.IniWriteValue("waypoints", "coptercolor", comboBoxCopterColor.SelectedIndex.ToString()); |
2910 | ini.IniWriteValue("waypoints", "copterheadingcolor", comboBoxCopterHeadingColor.SelectedIndex.ToString()); |
2900 | ini.IniWriteValue("waypoints", "landingcolor", comboBoxLandingColor.SelectedIndex.ToString()); |
2911 | ini.IniWriteValue("waypoints", "landingcolor", comboBoxLandingColor.SelectedIndex.ToString()); |
2901 | ini.IniWriteValue("waypoints", "routecolor", comboBoxRouteColor.SelectedIndex.ToString()); |
2912 | ini.IniWriteValue("waypoints", "routecolor", comboBoxRouteColor.SelectedIndex.ToString()); |
Line 2902... | Line 2913... | ||
2902 | ini.IniWriteValue("waypoints", "showWPRoute", _bShowWPRoute.ToString()); |
2913 | ini.IniWriteValue("waypoints", "showWPRoute", _bShowWPRoute.ToString()); |
Line 3464... | Line 3475... | ||
3464 | Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance * 1000).ToString("0 m")); |
3475 | Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance * 1000).ToString("0 m")); |
3465 | } |
3476 | } |
3466 | GMapMarker _createWP(PointLatLng p, string name, int type) |
3477 | GMapMarker _createWP(PointLatLng p, string name, int type) |
3467 | { |
3478 | { |
3468 | GMapMarker wpMarker = new GMapMarker(p); |
3479 | GMapMarker wpMarker = new GMapMarker(p); |
- | 3480 | Dispatcher.Invoke(()=> |
|
- | 3481 | { |
|
3469 | wpMarker.Shape = new CustomMarkerWP(this, wpMarker, name, type); |
3482 | wpMarker.Shape = new CustomMarkerWP(this, wpMarker, name, type); |
3470 | wpMarker.Offset = new System.Windows.Point(-11.5, -11.5); |
3483 | wpMarker.Offset = new System.Windows.Point(-11.5, -11.5); |
3471 | wpMarker.ZIndex = 100; |
3484 | wpMarker.ZIndex = 100; |
3472 | _setMarkerColor(wpMarker, type); |
3485 | _setMarkerColor(wpMarker, type); |
3473 | Dispatcher.Invoke(() => MainMap.Markers.Add(wpMarker)); |
3486 | MainMap.Markers.Add(wpMarker); |
3474 | if (type == 0 || type == 3) |
3487 | if (type == 0 || type == 3) |
3475 | wpList.Add(p); |
3488 | wpList.Add(p); |
- | 3489 | }); |
|
3476 | return wpMarker; |
3490 | return wpMarker; |
3477 | } |
3491 | } |
3478 | void _setMarkerColor(GMapMarker wpMarker,int iType) |
3492 | void _setMarkerColor(GMapMarker wpMarker,int iType) |
3479 | { |
3493 | { |
3480 | if(wpMarker != null) |
3494 | if(wpMarker != null) |
Line 3560... | Line 3574... | ||
3560 | } |
3574 | } |
3561 | private void comboBoxLandingColor_DropDownClosed(object sender, EventArgs e) |
3575 | private void comboBoxLandingColor_DropDownClosed(object sender, EventArgs e) |
3562 | { |
3576 | { |
3563 | _MarkerColorSelection(sender,3); |
3577 | _MarkerColorSelection(sender,3); |
3564 | } |
3578 | } |
3565 | private void comboBoxCopterColor_DropDownClosed(object sender, EventArgs e) |
3579 | private void comboBoxCopterColor_DropDownClosed(object sender, EventArgs e) |
3566 | { |
3580 | { |
3567 | Dispatcher.Invoke(() => { |
3581 | Dispatcher.Invoke(() => { |
3568 | if (comboBoxCopterColor.SelectionBoxItem != null) |
3582 | if (comboBoxCopterColor.SelectionBoxItem != null) |
3569 | { |
3583 | { |
3570 | string s = comboBoxCopterColor.SelectionBoxItem.ToString(); |
3584 | string s = comboBoxCopterColor.SelectionBoxItem.ToString(); |
3571 | ((CustomMarkerCopter)(copter.Shape)).setColor(s); |
3585 | ((CustomMarkerCopter)(copter.Shape)).setCopterColor(s); |
3572 | } |
3586 | } |
3573 | else |
3587 | else |
3574 | ((CustomMarkerCopter)(copter.Shape)).setColor("red"); |
3588 | ((CustomMarkerCopter)(copter.Shape)).setCopterColor("red"); |
- | 3589 | }); |
|
- | 3590 | } |
|
- | 3591 | private void comboBoxCopterHeadingColor_DropDownClosed(object sender, EventArgs e) |
|
- | 3592 | { |
|
- | 3593 | Dispatcher.Invoke(() => { |
|
- | 3594 | if (comboBoxCopterHeadingColor.SelectionBoxItem != null) |
|
- | 3595 | { |
|
- | 3596 | string s = comboBoxCopterHeadingColor.SelectionBoxItem.ToString(); |
|
- | 3597 | ((CustomMarkerCopter)(copter.Shape)).setHeadingColor(s); |
|
- | 3598 | } |
|
- | 3599 | else |
|
- | 3600 | ((CustomMarkerCopter)(copter.Shape)).setHeadingColor("red"); |
|
3575 | }); |
3601 | }); |
3576 | } |
3602 | } |
3577 | private void comboBoxRouteColor_DropDownClosed(object sender, EventArgs e) |
3603 | private void comboBoxRouteColor_DropDownClosed(object sender, EventArgs e) |
3578 | { |
3604 | { |
3579 | Dispatcher.Invoke(() => |
3605 | Dispatcher.Invoke(() => |
Line 3657... | Line 3683... | ||
3657 | //row.BorderBrush = new SolidColorBrush(Colors.SpringGreen); |
3683 | //row.BorderBrush = new SolidColorBrush(Colors.SpringGreen); |
3658 | //row.BorderThickness = new Thickness(2); |
3684 | //row.BorderThickness = new Thickness(2); |
3659 | }); |
3685 | }); |
3660 | } |
3686 | } |
3661 | } |
3687 | } |
- | 3688 | private void btnEditWPSendToCopter_Click(object sender, RoutedEventArgs e) |
|
- | 3689 | { |
|
- | 3690 | if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count) |
|
- | 3691 | { |
|
- | 3692 | ||
- | 3693 | object[] o = new object[16]; |
|
- | 3694 | o[0] = dgvWP.SelectedIndex + 1; |
|
- | 3695 | o[1] = cbWPEditType.SelectedIndex; |
|
- | 3696 | o[2] = tbWPEditPrefix.Text + (dgvWP.SelectedIndex + 1).ToString(); |
|
- | 3697 | o[3] = Convert.ToDouble(tbWPEditLat.Text.Replace('.', ',')); |
|
- | 3698 | o[4] = Convert.ToDouble(tbWPEditLon.Text.Replace('.', ',')); |
|
- | 3699 | o[5] = tbWPEditAlt.Text; |
|
- | 3700 | switch (cbWPEditHeading.SelectedIndex) |
|
- | 3701 | { |
|
- | 3702 | case 0: |
|
- | 3703 | o[6] = "0"; |
|
- | 3704 | break; |
|
- | 3705 | case 1: |
|
- | 3706 | o[6] = "-" + tbWPEditHeading.Text; |
|
- | 3707 | break; |
|
- | 3708 | case 2: |
|
- | 3709 | o[6] = tbWPEditHeading.Text; |
|
- | 3710 | break; |
|
- | 3711 | } |
|
- | 3712 | switch (cbWPEditSpeed.SelectedIndex) |
|
- | 3713 | { |
|
- | 3714 | case 0: |
|
- | 3715 | o[7] = "0"; |
|
- | 3716 | break; |
|
- | 3717 | case 1: |
|
- | 3718 | o[7] = (System.Convert.ToDouble(tbWPEditSpeed.Text.Replace('.', ',')) * 10).ToString("0"); |
|
- | 3719 | break; |
|
- | 3720 | case 2: |
|
- | 3721 | o[7] = (256 - Convert.ToInt16(tbWPEditSpeed.Text)).ToString(); |
|
- | 3722 | break; |
|
- | 3723 | } |
|
- | 3724 | switch (cbWPEditClimbrate.SelectedIndex) |
|
- | 3725 | { |
|
- | 3726 | case 0: |
|
- | 3727 | o[8] = "255"; |
|
- | 3728 | break; |
|
- | 3729 | case 1: |
|
- | 3730 | o[8] = (System.Convert.ToDouble(tbWPEditClimbrate.Text.Replace('.', ',')) * 10).ToString("0"); |
|
- | 3731 | break; |
|
- | 3732 | } |
|
- | 3733 | o[9] = tbWPEditRadius.Text; |
|
- | 3734 | o[10] = tbWPEditHoldtime.Text; |
|
- | 3735 | o[11] = tbWPEditAutoTrigger.Text; |
|
- | 3736 | switch (cbWPEditCamAngle.SelectedIndex) |
|
- | 3737 | { |
|
- | 3738 | case 0: |
|
- | 3739 | o[12] = "0"; |
|
- | 3740 | break; |
|
- | 3741 | case 1: |
|
- | 3742 | o[12] = "255"; |
|
- | 3743 | break; |
|
- | 3744 | case 2: |
|
- | 3745 | o[12] = tbWPEditCamAngle.Text; |
|
- | 3746 | break; |
|
- | 3747 | } |
|
- | 3748 | o[13] = 0; |
|
- | 3749 | o[14] = tbWPEditOut1.Text; |
|
- | 3750 | DataRow dr = dtWaypoints.NewRow(); |
|
- | 3751 | dr.ItemArray = o; |
|
- | 3752 | ||
- | 3753 | if (_wpCount > 0) |
|
- | 3754 | _sendWayPoint(dr, -1, 'w', false); |
|
- | 3755 | else |
|
- | 3756 | _sendWayPoint(dr, 1, 'w', false); |
|
- | 3757 | } |
|
- | 3758 | } |
|
3662 | private void btnWPSimulateStart_Click(object sender, RoutedEventArgs e) |
3759 | private void btnWPSimulateStart_Click(object sender, RoutedEventArgs e) |
3663 | { |
3760 | { |
3664 | _Simulate = !_Simulate; |
3761 | _Simulate = !_Simulate; |
3665 | if (dtWaypoints.Rows.Count > 0) |
3762 | if (dtWaypoints.Rows.Count > 0) |
3666 | { |
3763 | { |
Line 4020... | Line 4117... | ||
4020 | if (k.ShowDialog() == true && k.Result.Length > 0) |
4117 | if (k.ShowDialog() == true && k.Result.Length > 0) |
4021 | ((TextBox)sender).Text = k.Result; |
4118 | ((TextBox)sender).Text = k.Result; |
4022 | } |
4119 | } |
Line 4023... | Line 4120... | ||
4023 | 4120 | ||
4024 | } |
- | |
4025 | private void tbWPEditHeading_KeyDown(object sender, KeyEventArgs e) |
- | |
4026 | { |
- | |
4027 | if(!tbWPEditHeading.IsReadOnly) |
- | |
4028 | { |
- | |
4029 | //var x = KeyInterop.VirtualKeyFromKey(e.Key); |
- | |
4030 | KeyConverter x = new KeyConverter(); |
- | |
4031 | string s = x.ConvertToString(e.Key); |
- | |
4032 | - | ||
4033 | if ("1234567890,\b".IndexOf(s) < 0) //general check for valid chars(0-9) and backspace (\b) |
- | |
4034 | e.Handled = true; |
- | |
4035 | else |
- | |
4036 | if ("\b".IndexOf(s) < 0) |
- | |
4037 | if (Convert.ToInt16(((TextBox)sender).Text + s) > 360) //if valid and not backspace, check for upper limit of the resulting number |
- | |
4038 | e.Handled = true; |
- | |
4039 | - | ||
4040 | } |
- | |
4041 | } |
4121 | } |
4042 | private void btnWPAddCurrentPos_Click(object sender, RoutedEventArgs e) |
4122 | private void btnWPAddCurrentPos_Click(object sender, RoutedEventArgs e) |
4043 | { |
4123 | { |
Line 4044... | Line 4124... | ||
4044 | object[] o = new object[16]; |
4124 | object[] o = new object[16]; |
Line 4167... | Line 4247... | ||
4167 | myXmlTextWriter.Close(); |
4247 | myXmlTextWriter.Close(); |
4168 | } |
4248 | } |
4169 | } |
4249 | } |
4170 | } |
4250 | } |
Line -... | Line 4251... | ||
- | 4251 | ||
4171 | 4252 | ||
4172 | private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
4253 | private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
4173 | { |
4254 | { |
4174 | _loadGPXLog(); |
4255 | _loadGPXLog(); |
4175 | } |
4256 | } |