diff --git a/Plane.FormationCreator/AppConfig.cs b/Plane.FormationCreator/AppConfig.cs index 8311b30..2eaf127 100644 --- a/Plane.FormationCreator/AppConfig.cs +++ b/Plane.FormationCreator/AppConfig.cs @@ -69,6 +69,7 @@ namespace Plane.FormationCreator } set { + if (_config!=null) _config.Center = $"{value.Lat},{value.Lng}"; } } @@ -89,7 +90,8 @@ namespace Plane.FormationCreator } set { - _config.ZoomLevel = value; + if (_config != null) + _config.ZoomLevel = value; } } @@ -99,7 +101,8 @@ namespace Plane.FormationCreator { Directory.CreateDirectory(_dirPath); } - File.WriteAllText(_filePath, JsonConvert.SerializeObject(_config)); + if (_config != null) + File.WriteAllText(_filePath, JsonConvert.SerializeObject(_config)); } } } diff --git a/Plane.FormationCreator/Formation/CopterManager.cs b/Plane.FormationCreator/Formation/CopterManager.cs index 5067749..3cd1d9c 100644 --- a/Plane.FormationCreator/Formation/CopterManager.cs +++ b/Plane.FormationCreator/Formation/CopterManager.cs @@ -87,6 +87,11 @@ namespace Plane.FormationCreator.Formation //} + public bool shiftkeydown; + + + + public IEnumerable SelectedCopters { get { return _selectedCoptersGetter().Cast(); } } /// diff --git a/Plane.FormationCreator/Formation/FlightTaskManager.cs b/Plane.FormationCreator/Formation/FlightTaskManager.cs index 6751c95..cb9bc5f 100644 --- a/Plane.FormationCreator/Formation/FlightTaskManager.cs +++ b/Plane.FormationCreator/Formation/FlightTaskManager.cs @@ -363,6 +363,7 @@ namespace Plane.FormationCreator.Formation public void RestoreFlyToTask(bool staggerRoutes, dynamic singleCopterInfos) { var copters = _copterManager.Copters; + float tagalt = 15; if (!copters.Any()) return; AppEx.Current.AppMode = AppMode.ModifyingTask; var lastTask = Tasks.LastOrDefault(); @@ -371,11 +372,23 @@ namespace Plane.FormationCreator.Formation var center = nullableCenter.Value; var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = staggerRoutes }; // TODO: 林俊清, 20150801, 处理实际飞行器数目与记录中数目不一致的情况。 - for (int i = 0; i < copters.Count && i < singleCopterInfos.Count; i++) + for (int i = 0; i < copters.Count; i++) { var copter = copters[i]; - var singleCopterInfoObj = singleCopterInfos[i]; - var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, new LatLng((double)singleCopterInfoObj.latOffset, (double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt,(bool)singleCopterInfoObj.showLED); + FlightTaskSingleCopterInfo newSingleCopterInfo; + if (i < singleCopterInfos.Count) + { + var singleCopterInfoObj = singleCopterInfos[i]; + tagalt = (float)singleCopterInfoObj.targetAlt; + newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, new LatLng((double)singleCopterInfoObj.latOffset, (double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt, (bool)singleCopterInfoObj.showLED); + + } + else + { + newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask + (copter, (double)copter.Latitude, (double)copter.Longitude, tagalt, (bool)false); + + } newTask.SingleCopterInfos.Add(newSingleCopterInfo); } Tasks.Add(newTask); @@ -495,12 +508,32 @@ namespace Plane.FormationCreator.Formation // foreach (var copter in copters) - for (int i=0; i < copters.Count && i < singleCopterInfos.Count; i++) + for (int i=0; i < copters.Count ; i++) { var copter = copters[i]; - var singleCopterInfoObj = singleCopterInfos[i]; - var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForLoiterTimeTask(copter, new LatLng((double)singleCopterInfoObj.latOffset, (double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt); + float tagalt = 15; + + // var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForLoiterTimeTask(copter, new LatLng((double)singleCopterInfoObj.latOffset, (double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt); + + FlightTaskSingleCopterInfo newSingleCopterInfo; + if (i < singleCopterInfos.Count) + { + var singleCopterInfoObj = singleCopterInfos[i]; + tagalt = (float)singleCopterInfoObj.targetAlt; + newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForLoiterTimeTask(copter, new LatLng((double)singleCopterInfoObj.latOffset, (double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt); + + } + else + { + newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForLoiterTimeTask + (copter, (double)copter.Latitude, + (double)copter.Longitude, tagalt); + + + } loiterTimeTask.SingleCopterInfos.Add(newSingleCopterInfo); + + } Tasks.Add(loiterTimeTask); TaskAdded?.Invoke(this, new FlightTaskAddedEventArgs { LastTask = lastTask, AddedTask = loiterTimeTask }); @@ -755,9 +788,15 @@ namespace Plane.FormationCreator.Formation RestoreCircleTask(task.singleCopterInfos); break; case FlightTaskType.Loiter: - RestoreLoiterTimeTask((float)task.loiterTimeAttr, (bool)task.flashCheck, (float)task.flashCheckPeriod, - (bool)task.oneByOneCheck, (float)task.oneByOneCheckPeriod, (string)task.flashNameArray, - (string)task.flashIndexArray, (bool)task.ChangeYaw, (float)task.HeadYaw , (bool)task.numberShow, task.singleCopterInfos); + if (task.numberShow!=null) + RestoreLoiterTimeTask((float)task.loiterTimeAttr, (bool)task.flashCheck, (float)task.flashCheckPeriod, + (bool)task.oneByOneCheck, (float)task.oneByOneCheckPeriod, (string)task.flashNameArray, + (string)task.flashIndexArray, (bool)task.ChangeYaw, (float)task.HeadYaw , (bool)task.numberShow, task.singleCopterInfos); + else + RestoreLoiterTimeTask((float)task.loiterTimeAttr, (bool)task.flashCheck, (float)task.flashCheckPeriod, + (bool)task.oneByOneCheck, (float)task.oneByOneCheckPeriod, (string)task.flashNameArray, + (string)task.flashIndexArray, (bool)task.ChangeYaw, (float)task.HeadYaw, false, task.singleCopterInfos); + break; case FlightTaskType.SimpleCircle: @@ -796,9 +835,14 @@ namespace Plane.FormationCreator.Formation RestoreCircleTask(task.singleCopterInfos); break; case FlightTaskType.Loiter: - RestoreLoiterTimeTask( (float)task.loiterTimeAttr, (bool)task.flashCheck, (float)task.flashCheckPeriod, - (bool)task.oneByOneCheck, (float)task.oneByOneCheckPeriod, (string)task.flashNameArray, - (string)task.flashIndexArray, (bool)task.ChangeYaw, (float)task.HeadYaw, (bool)task.numberShow, task.singleCopterInfos); + if (task.numberShow != null) + RestoreLoiterTimeTask((float)task.loiterTimeAttr, (bool)task.flashCheck, (float)task.flashCheckPeriod, + (bool)task.oneByOneCheck, (float)task.oneByOneCheckPeriod, (string)task.flashNameArray, + (string)task.flashIndexArray, (bool)task.ChangeYaw, (float)task.HeadYaw, (bool)task.numberShow, task.singleCopterInfos); + else + RestoreLoiterTimeTask((float)task.loiterTimeAttr, (bool)task.flashCheck, (float)task.flashCheckPeriod, + (bool)task.oneByOneCheck, (float)task.oneByOneCheckPeriod, (string)task.flashNameArray, + (string)task.flashIndexArray, (bool)task.ChangeYaw, (float)task.HeadYaw, false, task.singleCopterInfos); break; case FlightTaskType.SimpleCircle: @@ -818,10 +862,10 @@ namespace Plane.FormationCreator.Formation // 在悬停任务时,左键waypoint为选中 // 在悬停任务模式,且LED控制被选中时 - if ((this.SelectedTask.TaskType == FlightTaskType.Loiter) && (this.SelectedTask.flashAttr || this.SelectedTask.oneByOneAttr|| this.SelectedTask.numberShow)) + if ((this.SelectedTask.TaskType == FlightTaskType.Loiter) && (this.SelectedTask.flashAttr || this.SelectedTask.oneByOneAttr || this.SelectedTask.numberShow)) { string copterNameStr = this.SelectedTask.flashCopterNameArray; - + string[] copterArray = copterNameStr.Split(','); bool flag = false; for (int i = 0; i < copterArray.Length; i++) @@ -839,15 +883,22 @@ namespace Plane.FormationCreator.Formation if (copterArray[0].Equals("")) { this.SelectedTask.flashCopterNameArray += copter.Name; - // SelectedTask.flashCopterIndexArray += Name2Index(copter.Name); + // SelectedTask.flashCopterIndexArray += Name2Index(copter.Name); } else { this.SelectedTask.flashCopterNameArray += "," + copter.Name; - // SelectedTask.flashCopterIndexArray += "," + Name2Index(copter.Name); + // SelectedTask.flashCopterIndexArray += "," + Name2Index(copter.Name); } - + } + } + else + { + + + + } } diff --git a/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_LoiterTime.cs b/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_LoiterTime.cs index d59e131..f3462a2 100644 --- a/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_LoiterTime.cs +++ b/Plane.FormationCreator/Formation/FlightTaskSingleCopterInfo_LoiterTime.cs @@ -18,5 +18,20 @@ namespace Plane.FormationCreator.Formation }; return info; } + + public static FlightTaskSingleCopterInfo CreateForLoiterTimeTask(ICopter copter, double targetLat, double targetLng, float targetAlt) + { + var info = new FlightTaskSingleCopterInfo(copter) + { + TargetLat = targetLat, + TargetLng = targetLng, + TargetAlt = targetAlt, + }; + return info; + } + + + + } } diff --git a/Plane.FormationCreator/Formation/FlightTask_LoiterTime.cs b/Plane.FormationCreator/Formation/FlightTask_LoiterTime.cs index 86661db..f43b34e 100644 --- a/Plane.FormationCreator/Formation/FlightTask_LoiterTime.cs +++ b/Plane.FormationCreator/Formation/FlightTask_LoiterTime.cs @@ -269,11 +269,11 @@ namespace Plane.FormationCreator.Formation private int[] lineTen = { 25 }; - private int[] numberfive = { 0, 1, 2, 3, 5, 6, 7, 9,10,11, 12 }; - private int[] numberFour = { 0, 2, 3, 4, 5, 6, 7, 9, 12 }; + private int[] numberfive = { 0, 1, 2, 4, 5, 6, 7, 8,10,11, 12 }; + private int[] numberFour = { 2, 4, 5, 6, 7,8, 9,10, 12 }; private int[] numberthree = { 0, 1, 2, 4, 5, 6, 7, 9, 10, 11, 12 }; - private int[] numbertwo = { 0, 1, 2, 4, 5, 6, 7, 8, 10, 11, 12 }; - private int[] numberone = { 2, 4, 7, 9, 12 }; + private int[] numbertwo = { 0, 1, 2, 3, 5, 6, 7, 9, 10, 11, 12 }; + private int[] numberone = { 0, 4, 7, 9, 12 }; private int[] numberzero = { 0, 1, 2, 3, 4,5, 7, 8,9, 10, 11, 12 }; @@ -838,5 +838,38 @@ namespace Plane.FormationCreator.Formation await Task.WhenAll(tasks_selected).ConfigureAwait(false); } + + private async Task LEDNumberFlashAsync(bool isOn) + { + List numberfivenew = new List(); + var infos = SingleCopterInfos; + + if (flashCopterNameArray.Equals("")) + return; + string[] copterArray = flashCopterIndexArray.Split(','); + //没有13架 + if (copterArray.Count() != 13) + return; + var tasks_selected = new Task[copterArray.Count()]; + + // 转换序号 + for (int i = 0; i < copterArray.Length; i++) + { + if (copterArray[i] == "") break; + + + int index = int.Parse(copterArray[i]); + var info = infos[index]; + tasks_selected[i] = await Task.Factory.StartNew(async () => + { + var internalInfo = info; + await LEDFlashTaskFlySingleCopterAsync(internalInfo, isOn); + + + }); + + } + await Task.WhenAll(tasks_selected).ConfigureAwait(false); + } } } diff --git a/Plane.FormationCreator/MainWindow.xaml.cs b/Plane.FormationCreator/MainWindow.xaml.cs index 80deaed..61e6aad 100644 --- a/Plane.FormationCreator/MainWindow.xaml.cs +++ b/Plane.FormationCreator/MainWindow.xaml.cs @@ -107,7 +107,9 @@ namespace Plane.FormationCreator case Key.LeftShift: { + var copters = _copterManager.AcceptingControlCopters; Shiftkeydown = true; + _copterManager.shiftkeydown = true; break; } //开关SHOWLED @@ -359,6 +361,8 @@ namespace Plane.FormationCreator case Key.LeftShift: { Shiftkeydown = false; + _copterManager.shiftkeydown = false; + break; } case Key.W: diff --git a/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs b/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs index 938c939..b51698e 100644 --- a/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs @@ -290,56 +290,60 @@ namespace Plane.FormationCreator.ViewModels var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault(); - bool copterisselect; - int selectednumber = _copterManager.SelectedCopters.Count() - 1; - for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) + if (_flightTaskManager.SelectedTask != null) { - copterisselect = false; - selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter; - foreach (var capter in _copterManager.SelectedCopters) + bool copterisselect; + int selectednumber = _copterManager.SelectedCopters.Count() - 1; + for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) { - if (capter == selectedCopter) - copterisselect = true; + copterisselect = false; + selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter; + foreach (var capter in _copterManager.SelectedCopters) + { + if (capter == selectedCopter) + copterisselect = true; + } + if (copterisselect) + { + + tlng = _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLng; + if (minlng == 0) + minlng = tlng; + if (tlng > maxlng) + maxlng = tlng; + else if (tlng < minlng) + minlng = tlng; + + } } - if (copterisselect) + avgl = (maxlng - minlng) / selectednumber; + int coptnum = 0; + + for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) { + copterisselect = false; + selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter; + foreach (var capter in _copterManager.SelectedCopters) + { + if (capter == selectedCopter) + copterisselect = true; - tlng = _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLng; - if (minlng == 0) - minlng = tlng; - if (tlng > maxlng) - maxlng = tlng; - else if (tlng < minlng) - minlng = tlng; + } + if (copterisselect) + { + _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLng = minlng + avgl * coptnum; + coptnum++; + + } } + } - avgl = (maxlng - minlng) / selectednumber; - int coptnum = 0; - - for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) - { - copterisselect = false; - selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter; - foreach (var capter in _copterManager.SelectedCopters) - { - if (capter == selectedCopter) - copterisselect = true; - - } - if (copterisselect) - { - - _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLng = minlng + avgl * coptnum; - coptnum++; - - } - } - } + /////////////////////// // await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。 @@ -371,56 +375,59 @@ namespace Plane.FormationCreator.ViewModels ////////////////////// var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault(); - bool copterisselect; - int selectednumber = _copterManager.SelectedCopters.Count() - 1; - for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) + if (_flightTaskManager.SelectedTask != null) { - copterisselect = false; - selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter; - foreach (var capter in _copterManager.SelectedCopters) + bool copterisselect; + int selectednumber = _copterManager.SelectedCopters.Count() - 1; + for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) { - if (capter == selectedCopter) - copterisselect = true; + copterisselect = false; + selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter; + foreach (var capter in _copterManager.SelectedCopters) + { + if (capter == selectedCopter) + copterisselect = true; + } + if (copterisselect) + { + + tlat = _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLat; + if (minlat == 0) + minlat = tlat; + if (tlat > maxlat) + maxlat = tlat; + else if (tlat < minlat) + minlat = tlat; + + } } - if (copterisselect) + avgl = (maxlat - minlat) / selectednumber; + int coptnum = 0; + + for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) { + copterisselect = false; + selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter; + foreach (var capter in _copterManager.SelectedCopters) + { + if (capter == selectedCopter) + copterisselect = true; - tlat = _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLat; - if (minlat == 0) - minlat = tlat; - if (tlat > maxlat) - maxlat = tlat; - else if (tlat < minlat) - minlat = tlat; + } + if (copterisselect) + { + _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLat = maxlat - avgl * coptnum; + coptnum++; + + } } + + /////////////////////// + + // await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。 } - avgl = (maxlat - minlat) / selectednumber; - int coptnum = 0; - - for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) - { - copterisselect = false; - selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter; - foreach (var capter in _copterManager.SelectedCopters) - { - if (capter == selectedCopter) - copterisselect = true; - - } - if (copterisselect) - { - - _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLat = maxlat - avgl * coptnum; - coptnum++; - - } - } - - /////////////////////// - - // await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。 } })); } @@ -442,6 +449,8 @@ namespace Plane.FormationCreator.ViewModels var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault(); + if (_flightTaskManager.SelectedTask != null) + { bool copterisselect; for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) { @@ -482,13 +491,48 @@ namespace Plane.FormationCreator.ViewModels } } - - - - //await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。 - })); + } + else + //调整飞机 + { + //模拟飞机才能调整 + if (selectedCopter is FakeCopter) + { + foreach (var capter in _copterManager.SelectedCopters) + { + tlat = capter.Latitude; + if (tlat > maxlat) + maxlat = tlat; + } + + foreach (var capter in _copterManager.SelectedCopters) + { + var copterfk = (FakeCopter)capter; + copterfk.SetProperties( + latitude: maxlat, + longitude: copterfk.Longitude); + } + } + } + + + + + + + + + + + + + + + + + })); } } @@ -510,6 +554,8 @@ public ICommand VerticlAlignmentCommand double tlng = 0; var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault(); bool copterisselect; + if (_flightTaskManager.SelectedTask != null) + { for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) { copterisselect = false; @@ -549,10 +595,33 @@ public ICommand VerticlAlignmentCommand } } - - //await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。 - })); + //await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。 + } + else + //调整飞机 + { + //模拟飞机才能调整 + if (selectedCopter is FakeCopter) + { + foreach (var capter in _copterManager.SelectedCopters) + { + tlng = capter.Longitude; + if (tlng > maxlng) + maxlng = tlng; + } + + foreach (var capter in _copterManager.SelectedCopters) + { + var copterfk = (FakeCopter)capter; + copterfk.SetProperties( + latitude: copterfk.Latitude, + longitude: maxlng ); + } + } + } + + })); } } @@ -628,8 +697,11 @@ public ICommand VerticlAlignmentCommand double centlng = 0; double centlat = 0; var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault(); - bool copterisselect; - for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) + if (_flightTaskManager.SelectedTask != null) + { + + bool copterisselect; + for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) { copterisselect = false; selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter; @@ -690,7 +762,76 @@ public ICommand VerticlAlignmentCommand //// await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。 - })); + + } + else + //调整飞机 + { + //模拟飞机才能调整 + if (selectedCopter is FakeCopter) + { + foreach (var capter in _copterManager.SelectedCopters) + { + lngsum += capter.Longitude; + latsum += capter.Latitude; + selectcount++; + } + + //计算旋转中心 + if (selectcount > 0) + { + centlng = lngsum / selectcount; + centlat = latsum / selectcount; + } + else return; + + foreach (var capter in _copterManager.SelectedCopters) + { + + + double lpDistance = CalculationLogLatDistance.GetDistanceOne(centlng, centlat, + capter.Longitude, + capter.Latitude); + + CalculationLogLatDistance.MyLatLng mypos1, mypos2; + mypos1 = new CalculationLogLatDistance.MyLatLng(centlng, centlat); + mypos2 = new CalculationLogLatDistance.MyLatLng( + capter.Longitude + , capter.Latitude); + double lpAzimuth = CalculationLogLatDistance.getAngle(mypos1, mypos2); + double lng2 = 0; + double lat2 = 0; + CalculationLogLatDistance.ConvertDistanceToLogLat(centlng, centlat, lpDistance, + lpAzimuth + (double)RotateLine, out lng2, out lat2); + + var copterfk = (FakeCopter)capter; + copterfk.SetProperties( + latitude: lat2, + longitude: lng2); + } + } + } + + + + + + + + + + + + + + + + + + + + + })); } } @@ -796,7 +937,9 @@ public ICommand VerticlAlignmentCommand double centlat = 0; double centalt = 0; var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault(); - bool copterisselect; + if (_flightTaskManager.SelectedTask != null) + { + bool copterisselect; for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) { copterisselect = false; @@ -888,13 +1031,15 @@ public ICommand VerticlAlignmentCommand } } //// - - - - await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。 - })); + + + } + + + + })); } } diff --git a/Plane.FormationCreator/Views/CopterListView.xaml.cs b/Plane.FormationCreator/Views/CopterListView.xaml.cs index a401157..7c0150c 100644 --- a/Plane.FormationCreator/Views/CopterListView.xaml.cs +++ b/Plane.FormationCreator/Views/CopterListView.xaml.cs @@ -32,7 +32,7 @@ namespace Plane.FormationCreator.Views _copterManager.SetSelectionDelegates( () => lvwDrones.SelectedItems, - copter => lvwDrones.SelectedItem = copter + SelectitemMessage ); lvwDrones.SelectionChanged += (sender, e) => { @@ -41,5 +41,14 @@ namespace Plane.FormationCreator.Views } private CopterManager _copterManager = ServiceLocator.Current.GetInstance(); + private void SelectitemMessage(ICopter copter) + { + + + if (!_copterManager.shiftkeydown) + lvwDrones.SelectedItem = copter; + else + lvwDrones.SelectedItems.Add(copter); + } } } diff --git a/Plane.FormationCreator/Views/MapView_CopterDrawing.cs b/Plane.FormationCreator/Views/MapView_CopterDrawing.cs index 7fdaa91..37dd7e0 100644 --- a/Plane.FormationCreator/Views/MapView_CopterDrawing.cs +++ b/Plane.FormationCreator/Views/MapView_CopterDrawing.cs @@ -345,6 +345,7 @@ namespace Plane.FormationCreator.Views private void RegisterEventHandlersForTaskInfo(Ellipse wp, int taskIndex) { var info = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.FirstOrDefault(i => i.Copter == this.Copter); + if (info == null) return; info.PropertyChanged += (sender, e) => { switch (e.PropertyName)