diff --git a/Plane.FormationCreator/App.xaml.cs b/Plane.FormationCreator/App.xaml.cs index 9e10f56..c231ce8 100644 --- a/Plane.FormationCreator/App.xaml.cs +++ b/Plane.FormationCreator/App.xaml.cs @@ -143,8 +143,9 @@ namespace Plane.FormationCreator Id = ip, Name = ip.Substring(ip.LastIndexOf('.') + 1) }; - copters.Add(copter); - copterStatus.Add(false); + int _index; + _index=copters.AddCopter(copter); + copterStatus.Insert(_index,false); })); } else diff --git a/Plane.FormationCreator/Formation/CopterManager.cs b/Plane.FormationCreator/Formation/CopterManager.cs index 2313776..5067749 100644 --- a/Plane.FormationCreator/Formation/CopterManager.cs +++ b/Plane.FormationCreator/Formation/CopterManager.cs @@ -10,6 +10,46 @@ using System.Threading.Tasks; namespace Plane.FormationCreator.Formation { + + public class CopterCollection : ObservableCollection + { + /// + /// 实现排序插入 + /// + /// + public int AddCopter(ICopter entityObject) + { + int _index = 0; + if (this.Count == 0) + { + Add(entityObject); + _index = 0; + } + else + { + bool isInsret = false; + for (int i = 0; i < this.Count; i++) + { + if (String.Compare(this[i].Name, entityObject.Name, false) >= 0) + { + InsertItem(i, entityObject); + isInsret = true; + _index= i; + break; + + } + } + if (!isInsret) + { + Add(entityObject); + _index = this.Count()-1 ; + } + } + return _index; + } + } + + public class CopterManager : ObservableObject { public CopterManager() @@ -25,7 +65,7 @@ namespace Plane.FormationCreator.Formation } - public ObservableCollection Copters { get; } = new ObservableCollection(); + public CopterCollection Copters { get;} = new CopterCollection(); public ArrayList CopterStatus = new ArrayList(); //public ObservableCollection Copters diff --git a/Plane.FormationCreator/Formation/FlightTaskManager.cs b/Plane.FormationCreator/Formation/FlightTaskManager.cs index cfcef97..f3b754a 100644 --- a/Plane.FormationCreator/Formation/FlightTaskManager.cs +++ b/Plane.FormationCreator/Formation/FlightTaskManager.cs @@ -128,7 +128,7 @@ namespace Plane.FormationCreator.Formation } foreach (var copter in copters) { - takeOffTask.SingleCopterInfos.Add(FlightTaskSingleCopterInfo.CreateForTakeOffTask(copter, targetAlt: 10)); + takeOffTask.SingleCopterInfos.Add(FlightTaskSingleCopterInfo.CreateForTakeOffTask(copter, targetAlt: 15)); } } @@ -236,7 +236,8 @@ namespace Plane.FormationCreator.Formation } currcol++; coptindex++; - var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, targetLatLng.Item1, targetLatLng.Item2, lastSingleCopterInfo.TargetAlt, true); + var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, targetLatLng.Item1, targetLatLng.Item2, + lastTask.SingleCopterInfos.Find(info => info.Copter == copter).TargetAlt, true); newSingleCopterInfo.TargetHeading = lastSingleCopterInfo.TargetHeading; newSingleCopterInfo.CenterDirectionDeg = lastSingleCopterInfo.TargetHeading; newTask.SingleCopterInfos.Add(newSingleCopterInfo); diff --git a/Plane.FormationCreator/MainWindow.xaml.cs b/Plane.FormationCreator/MainWindow.xaml.cs index e5e4ab2..80deaed 100644 --- a/Plane.FormationCreator/MainWindow.xaml.cs +++ b/Plane.FormationCreator/MainWindow.xaml.cs @@ -94,7 +94,7 @@ namespace Plane.FormationCreator { map.GoHome(); } - + bool Shiftkeydown = false; private async void MetroWindow_PreviewKeyDown(object sender, KeyEventArgs e) { // 如果正在输入,忽略。 @@ -105,6 +105,11 @@ namespace Plane.FormationCreator switch (e.Key) { + case Key.LeftShift: + { + Shiftkeydown = true; + break; + } //开关SHOWLED case Key.C: { @@ -123,7 +128,7 @@ namespace Plane.FormationCreator case Key.S: { - if ((_flightTaskManager.CurrentRunningTask == null) && (_flightTaskManager.SelectedTask != null)) + if (Shiftkeydown &&(_flightTaskManager.CurrentRunningTask == null) && (_flightTaskManager.SelectedTask != null)) { var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault(); @@ -174,7 +179,7 @@ namespace Plane.FormationCreator { - if ((_flightTaskManager.CurrentRunningTask == null)&&(_flightTaskManager.SelectedTask!=null)) + if (Shiftkeydown && (_flightTaskManager.CurrentRunningTask == null)&&(_flightTaskManager.SelectedTask!=null)) { var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault(); @@ -351,6 +356,11 @@ namespace Plane.FormationCreator switch (e.Key) { + case Key.LeftShift: + { + Shiftkeydown = false; + break; + } case Key.W: case Key.S: { diff --git a/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs b/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs index 0966dde..ae1a756 100644 --- a/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs @@ -761,7 +761,7 @@ public ICommand VerticlAlignmentCommand dy = -ax * Math.Sin(k) + ay * Math.Cos(k); //新高度(米) - _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetAlt += (float) dy; + _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetAlt= (float)(centalt + dy); //计算新纬度 double lng2 = 0; double lat2 = 0; @@ -796,9 +796,78 @@ public ICommand VerticlAlignmentCommand } } - - //缩放 + private ICommand _AutoaltCommand; + public ICommand AutoaltCommand + { + get + { + return _AutoaltCommand ?? (_AutoaltCommand = new RelayCommand(async => + { + + + + + + + + + + + + + + + + + })); + } + } + + + private ICommand _PrealtCommand; + public ICommand PrealtCommand + { + get + { + return _PrealtCommand ?? (_PrealtCommand = new RelayCommand(async => + { + + var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault(); + for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) + { + + selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter; + foreach (var capter in _copterManager.SelectedCopters) + { + if (capter == selectedCopter) + { + if (_flightTaskManager.SelectedTaskIndex > 1) + _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetAlt = + _flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex - 1].SingleCopterInfos[i].TargetAlt; + } + + } + + + } + + + + + + + + + })); + } + } + + + + + + //计算距离 private ICommand _calDistinceCommand; public ICommand calDistinceCommand { @@ -811,10 +880,9 @@ public ICommand VerticlAlignmentCommand double distance = 0; var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault(); - bool copterisselect; for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++) { - copterisselect = false; + selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter; foreach (var capter in _copterManager.SelectedCopters) { diff --git a/Plane.FormationCreator/Views/ModifyTaskView.xaml b/Plane.FormationCreator/Views/ModifyTaskView.xaml index c70f8e3..1d3bdd6 100644 --- a/Plane.FormationCreator/Views/ModifyTaskView.xaml +++ b/Plane.FormationCreator/Views/ModifyTaskView.xaml @@ -113,6 +113,17 @@ + + +