From 7e04c83e26cbfeefd0fa5bac7f6e0c5e2ecae761 Mon Sep 17 00:00:00 2001 From: pxzleo Date: Fri, 17 Mar 2017 23:02:08 +0800 Subject: [PATCH] =?UTF-8?q?1.=E9=A3=9E=E6=9C=BA=E6=8C=89=E7=BC=96=E5=8F=B7?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=E5=8A=A0=E5=85=A5=E9=A3=9E=E8=A1=8C=E5=88=97?= =?UTF-8?q?=E8=A1=A8=202.=E9=BB=98=E8=AE=A4=E8=B5=B7=E9=A3=9E=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E4=B8=BA15=E7=B1=B3=203.=E4=BF=AE=E6=94=B9=E8=88=AA?= =?UTF-8?q?=E7=82=B9=E4=BD=8D=E7=BD=AE=E6=94=B9=E4=B8=BA=E6=8C=89=E4=BD=8F?= =?UTF-8?q?=E5=B7=A6shift=E5=86=8D=E6=8C=89=E4=B8=8Basdw=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E6=8C=89shift=E5=88=99=E6=98=AF=E6=8E=A7=E5=88=B6=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E9=A3=9E=E6=9C=BA=204.=E4=BF=AE=E5=A4=8D=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E6=97=8B=E8=BD=AC=E7=9A=84=E9=AB=98=E5=BA=A6bug=205.?= =?UTF-8?q?=E4=B8=BA=E9=98=B2=E6=AD=A2=E7=A2=B0=E6=92=9E=EF=BC=8C=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E4=B8=A4=E4=B8=AA=E6=8C=89=E9=92=AE=EF=BC=8C=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E4=B8=BA=E8=87=AA=E5=8A=A8=E8=AE=A1=E7=AE=97=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=EF=BC=88=E6=9C=AA=E5=AE=9E=E7=8E=B0=EF=BC=89=EF=BC=8C?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E4=B8=BA=E8=87=AA=E5=8A=A8=E8=AE=BE=E4=B8=BA?= =?UTF-8?q?=E5=89=8D=E4=B8=80=E6=AD=A5=E9=AB=98=E5=BA=A6=EF=BC=8C=E8=BF=99?= =?UTF-8?q?=E6=A0=B7=E4=B8=80=E4=B8=AA=E5=9B=BE=E6=A1=88=E5=BA=94=E8=AF=A5?= =?UTF-8?q?=E6=9C=89=E4=B8=89=E4=B8=AA=E5=90=8C=E6=A0=B7=E5=BD=A2=E7=8A=B6?= =?UTF-8?q?=E7=9A=84=E9=A3=9E=E8=A1=8C=E4=BB=BB=E5=8A=A1=EF=BC=8C=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E8=BF=9B=E5=85=A5=EF=BC=88=E9=AB=98=E5=BA=A6=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=EF=BC=89=E4=B8=80=E4=B8=AA=E8=A1=A8=E6=BC=94=EF=BC=8C?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E9=80=80=E5=87=BA=EF=BC=88=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plane.FormationCreator/App.xaml.cs | 5 +- .../Formation/CopterManager.cs | 42 +++++++++- .../Formation/FlightTaskManager.cs | 5 +- Plane.FormationCreator/MainWindow.xaml.cs | 16 +++- .../ViewModels/ModifyTaskViewModel.cs | 78 +++++++++++++++++-- .../Views/ModifyTaskView.xaml | 11 +++ 6 files changed, 144 insertions(+), 13 deletions(-) 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 @@ + + +