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);