From b289618a874e08b80da761f07353e3ce38495828 Mon Sep 17 00:00:00 2001 From: pxzleo Date: Wed, 22 Nov 2023 15:42:39 +0800 Subject: [PATCH] =?UTF-8?q?1c4D=E5=AF=BC=E5=85=A5V3=E7=89=88=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=AF=BC=E5=85=A5=E6=97=B6=E9=97=B4=EF=BC=8C=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E8=88=AA=E7=82=B9=E4=B8=8D=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=97=B6=E9=97=B4=202=E6=B7=BB=E5=8A=A0=E7=9A=84=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E9=A3=9E=E8=A1=8C=E8=88=AA=E7=82=B9=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=92=8C=E8=B5=B7=E9=A3=9E=E7=82=B9=E5=9C=A8=E4=B8=80?= =?UTF-8?q?=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Formation/FlightTaskManager.cs | 35 +++++++++++++++++-- .../ViewModels/ModifyTaskViewModel.cs | 9 +++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/Plane.FormationCreator/Formation/FlightTaskManager.cs b/Plane.FormationCreator/Formation/FlightTaskManager.cs index 9b2e30b..a5a7280 100644 --- a/Plane.FormationCreator/Formation/FlightTaskManager.cs +++ b/Plane.FormationCreator/Formation/FlightTaskManager.cs @@ -505,7 +505,20 @@ namespace Plane.FormationCreator.Formation Tasks.Insert(SelectedTaskIndex+1, newTask); RaiseTaskAdded(lastTask, newTask); SelectTask(selindex); - + + //第一个航点,回起飞点 + if (Tasks.Count == 2) + { + foreach (FlightTaskSingleCopterInfo info in SelectedTask.SingleCopterInfos) + { + info.TargetLat = info.Copter.Latitude; + info.TargetLng = info.Copter.Longitude; + } + // SelectedTask.TaskCnName = "检查航点"; + + + + } /* Tasks.Add(newTask); @@ -1013,12 +1026,30 @@ namespace Plane.FormationCreator.Formation int taskCount = lines.Length / (_copterManager.Copters.Count + 1); int startIndex; + int flytime = 10; string line; Dictionary PointDic; for (int i = 0; i < taskCount; i++) { startIndex = i * (_copterManager.Copters.Count + 1); string taskName = lines[startIndex]; + if (taskName != "") + { + //去掉前后的"[]" + string taskName_temp = taskName.Substring(1); + taskName_temp= taskName_temp.Remove(taskName_temp.Length - 1); + //新版用":"分割时间 + string[] words = taskName_temp.Split(':'); + if (words.Count()==2) + { + taskName = words[0]; + flytime = int.Parse(words[1]); + if (flytime == -1) //第一个航点是-1 先设置成0 后面计算时间 + flytime = 0; + + } + } + PointDic = new Dictionary(); for (int j = 0; j < _copterManager.Copters.Count; j++) { @@ -1034,7 +1065,7 @@ namespace Plane.FormationCreator.Formation } var lastTask = Tasks.LastOrDefault(); - var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = true, FlytoTime = 10, LoiterTime = 1 }; + var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = true, FlytoTime = flytime, LoiterTime = 1 }; newTask.TaskCnName = taskName; for (int k = 0; k < PointDic.Count; k++) { diff --git a/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs b/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs index 39ea3c9..368f989 100644 --- a/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs @@ -805,8 +805,13 @@ namespace Plane.FormationCreator.ViewModels { var tasksText = File.ReadAllText(dialog.FileName); _flightTaskManager.ImportC4DFlytoTask(tasksText); - _flightTaskManager.SetAllTaskFlytime(); - }else + if (_copterManager.FC_VER_NO >= 3) + Alert.Show($"导入的第一个航点默认为0,需要重新计算时间", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); + else + _flightTaskManager.SetAllTaskFlytime(); + + } + else if ((extname == ".svg")|| (extname == ".obj")) { _flightTaskManager.ImportDlltoTask(dialog.FileName);