From 1b574fa118e949d0c35913af1f9a8a7d0c183929 Mon Sep 17 00:00:00 2001 From: pxzleo Date: Mon, 11 Sep 2017 20:07:01 +0800 Subject: [PATCH] =?UTF-8?q?[ModifyTaskView.xaml]=20=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=95=B4=E4=BD=93=E4=BD=8D=E7=BD=AE=E8=B0=83?= =?UTF-8?q?=E6=95=B4=20[MapView=5FCopterDrawing.cs]=E6=AD=A3=E5=9C=A8?= =?UTF-8?q?=E9=A3=9E=E8=A1=8C=E4=B8=AD=E5=89=8D=E9=9D=A2=E5=8A=A0=E5=B0=96?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E7=BC=96=E5=8F=B7=E5=8F=98=E8=89=B2=20[Modif?= =?UTF-8?q?yTaskViewModel.cs]=E5=8A=A0=E5=85=A5=E4=BB=BB=E5=8A=A1=E6=95=B4?= =?UTF-8?q?=E4=BD=93=E4=BD=8D=E7=BD=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/ModifyTaskViewModel.cs | 57 ++++++++++++++++++- .../Views/MapView_CopterDrawing.cs | 27 +++++---- .../Views/ModifyTaskView.xaml | 55 ++++++++++-------- 3 files changed, 100 insertions(+), 39 deletions(-) diff --git a/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs b/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs index 1e79bbb..938c939 100644 --- a/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ModifyTaskViewModel.cs @@ -159,8 +159,13 @@ namespace Plane.FormationCreator.ViewModels get { return _Modialtvalue; } set { Set(nameof(Modialtvalue), ref _Modialtvalue, value); } } - - + + private float _directionvalue=0; + public float directionvalue + { + get { return _directionvalue; } + set { Set(nameof(directionvalue), ref _directionvalue, value); } + } private int _txtStarindex=0; public int txtStarindex { @@ -1012,9 +1017,57 @@ public ICommand VerticlAlignmentCommand } } + //调整所有任务经度 + private ICommand _ModiAllPosCommand; + public ICommand ModiAllPosCommand + { + get + { + return _ModiAllPosCommand ?? (_ModiAllPosCommand = new RelayCommand(async => + { + if (_flightTaskManager.Tasks.Count < 2) return; + + float lowalt = 200; + int _startindex = 0; + int _endindex = _flightTaskManager.Tasks.Count - 1; + int lowtask = 0; + int lowCopter = 0; + if ((txtStarindex != 0) && (txtendindex != 0)) + { + _startindex = txtStarindex; + _endindex = txtendindex; + } + + for (int i = _startindex; i <= _endindex; i++) + { + + if ((_flightTaskManager.Tasks[i].TaskType == FlightTaskType.TakeOff) || + (_flightTaskManager.Tasks[i].TaskType == FlightTaskType.ReturnToLand)) + continue; + + + for (int j = 0; j < _flightTaskManager.Tasks[i].SingleCopterInfos.Count; j++) + { + Tuple targetLatLng = new Tuple(0, 0); + + targetLatLng=GeographyUtils.CalcLatLngSomeMetersAway2D( + _flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLat, + _flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLng, + directionvalue, + Modialtvalue + ); + _flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLat = targetLatLng.Item1; + _flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLng= targetLatLng.Item2; + } + } + Alert.Show("指定步骤任务位置已向"+ directionvalue + "度改变" + Modialtvalue + "米,注意是否有障碍物!"); + + })); + } + } //计算距离 diff --git a/Plane.FormationCreator/Views/MapView_CopterDrawing.cs b/Plane.FormationCreator/Views/MapView_CopterDrawing.cs index 1b69eea..7fdaa91 100644 --- a/Plane.FormationCreator/Views/MapView_CopterDrawing.cs +++ b/Plane.FormationCreator/Views/MapView_CopterDrawing.cs @@ -73,6 +73,9 @@ namespace Plane.FormationCreator.Views public ICopter Copter { get; set; } public Grid DotContainer { get; set; } public Polygon Dot { get; set; } + + public TextBlock CopterText { get; set; } + public MapPolyline Track { get; set; } public Location LastLocation { get; set; } @@ -130,14 +133,19 @@ namespace Plane.FormationCreator.Views DotContainer = new Grid { Tag = COPTER_TAG }; DotContainer.Children.Add(Dot); //飞机里面的编号 - DotContainer.Children.Add(new TextBlock + + + CopterText = new TextBlock { Text = Copter.Name, - Foreground = new SolidColorBrush(Colors.White), + Foreground = new SolidColorBrush(Colors.Black), Margin = new Thickness(-COPTER_RADIUS * 2, -COPTER_RADIUS * 1.5, 0, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center - }); + }; + + + DotContainer.Children.Add(CopterText); //飞机加入地图 _map.Children.Add(DotContainer); @@ -160,23 +168,14 @@ namespace Plane.FormationCreator.Views } else { - Dot.Points.Clear(); if (Copter.MissionStatus == 1) { - Dot.Points.Add(new Point(-4, -COPTER_RADIUS)); - Dot.Points.Add(new Point(0, -COPTER_RADIUS)); - Dot.Points.Add(new Point(-COPTER_RADIUS * 2 / 3, COPTER_RADIUS)); - Dot.Points.Add(new Point(COPTER_RADIUS * 2 / 3, COPTER_RADIUS)); + CopterText.Foreground = new SolidColorBrush(Colors.White); } else { - Dot.Points.Add(new Point(0, -COPTER_RADIUS)); - Dot.Points.Add(new Point(-COPTER_RADIUS * 2 / 3, COPTER_RADIUS)); - Dot.Points.Add(new Point(COPTER_RADIUS * 2 / 3, COPTER_RADIUS)); + CopterText.Foreground = new SolidColorBrush(Colors.Black); } - - - if (LastLocation != null && location.CalcDistance(LastLocation) < 0.1) { locationUpdated = false; diff --git a/Plane.FormationCreator/Views/ModifyTaskView.xaml b/Plane.FormationCreator/Views/ModifyTaskView.xaml index afa8fac..3164a68 100644 --- a/Plane.FormationCreator/Views/ModifyTaskView.xaml +++ b/Plane.FormationCreator/Views/ModifyTaskView.xaml @@ -71,18 +71,21 @@ Margin="0,5,5,0" Command="{Binding VerticlRotateCommand}" CommandParameter="{Binding ElementName=txtAlignmentLine, Path=Text}"/> +