为优化速度,2D和3D地图不同时显示位置

This commit is contained in:
xu 2020-01-28 18:12:17 +08:00
parent 7ac2f48500
commit c0fa7d8ddb
7 changed files with 50 additions and 11 deletions

View File

@ -35,6 +35,12 @@
<cnv:BooleanToStringConverter x:Key="ShowModifyTaskViewButtonContentConverter" <cnv:BooleanToStringConverter x:Key="ShowModifyTaskViewButtonContentConverter"
False="【飞行模式】" False="【飞行模式】"
True="【编辑模式】" /> True="【编辑模式】" />
<cnv:BooleanToStringConverter x:Key="Show2d3dButtonContentConverter"
False="平面地图"
True="三维地图" />
<cnv:BooleanToResourceConverter x:Key="CheckSignConverter" <cnv:BooleanToResourceConverter x:Key="CheckSignConverter"
FalseKey="CloseIcon" FalseKey="CloseIcon"
TrueKey="CheckIcon" /> TrueKey="CheckIcon" />

View File

@ -121,7 +121,20 @@ namespace Plane.FormationCreator.Formation
} }
} }
} }
private bool _TaskRun_2D = true;
public bool TaskRun_2D
{
get { return _TaskRun_2D; }
set
{
if (Set(nameof(TaskRun_2D), ref _TaskRun_2D, value))
{
}
}
}
private void AddTakeOffTask(IEnumerable<ICopter> copters) private void AddTakeOffTask(IEnumerable<ICopter> copters)
{ {
@ -1964,10 +1977,7 @@ namespace Plane.FormationCreator.Formation
{ {
if (copter != anotherCopter && copter.IsTooCloseTo(anotherCopter, out distance)) if (copter != anotherCopter && copter.IsTooCloseTo(anotherCopter, out distance))
{ {
//Pause();
Message.Show($"{copter.Name} 与 {anotherCopter.Name} 距离过近,间距{distance}米。"); Message.Show($"{copter.Name} 与 {anotherCopter.Name} 距离过近,间距{distance}米。");
// Alert.Show($"{copter.Name} 与 {anotherCopter.Name} 距离过近,已中止任务。");
//return;
} }
} }
} }

View File

@ -45,7 +45,7 @@
<Button Content="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource ShowModifyTaskViewButtonContentConverter}}" <Button Content="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource ShowModifyTaskViewButtonContentConverter}}"
Command="{Binding ShowOrHideModifyTaskViewCommand}" /> Command="{Binding ShowOrHideModifyTaskViewCommand}" />
<Button Content="切换地图" <Button Content="{Binding b2DMapMode, Converter={StaticResource Show2d3dButtonContentConverter}}"
Command="{Binding ChangeMapModeCommand}"/> Command="{Binding ChangeMapModeCommand}"/>
<Button Content="重启监听" <Button Content="重启监听"
Visibility="Collapsed" Visibility="Collapsed"

View File

@ -160,6 +160,14 @@ namespace Plane.FormationCreator.ViewModels
set { Set(nameof(MapMode), ref _MapMode, value); } set { Set(nameof(MapMode), ref _MapMode, value); }
} }
private bool _b2DMapMode = true;
public bool b2DMapMode
{
get { return _b2DMapMode; }
set { Set(nameof(b2DMapMode), ref _b2DMapMode, value); }
}
private ICommand _ChangeMapModeCommand; private ICommand _ChangeMapModeCommand;
public ICommand ChangeMapModeCommand public ICommand ChangeMapModeCommand
{ {
@ -168,9 +176,21 @@ namespace Plane.FormationCreator.ViewModels
return _ChangeMapModeCommand ?? (_ChangeMapModeCommand = new RelayCommand(() => return _ChangeMapModeCommand ?? (_ChangeMapModeCommand = new RelayCommand(() =>
{ {
if (MapMode == 0) if (MapMode == 0)
{
MapMode = 1; MapMode = 1;
b2DMapMode = false;
_flightTaskManager.TaskRun_2D = b2DMapMode; //3D模式模拟显示
}
else else
{
MapMode = 0; MapMode = 0;
b2DMapMode = true;
_flightTaskManager.TaskRun_2D = b2DMapMode; //2D模式模拟显示
}
})); }));
} }
} }

View File

@ -103,6 +103,7 @@ namespace Plane.FormationCreator.ViewModels
private void AddOrMove3DCopter(ICopter copter) private void AddOrMove3DCopter(ICopter copter)
{ {
if (_flightTaskManager.TaskRun_2D) return; //不在3D模式运行直接退出
//var copternum1 = _copterManager.Copters.FirstOrDefault(); //var copternum1 = _copterManager.Copters.FirstOrDefault();
if (_flightTaskManager.OriginLat == 0 || _flightTaskManager.OriginLng == 0) if (_flightTaskManager.OriginLat == 0 || _flightTaskManager.OriginLng == 0)
return; return;

View File

@ -44,7 +44,8 @@ namespace Plane.FormationCreator.Views
_flightTaskManager.TasksCleared += (sender, e) => _flightTaskManager.TasksCleared += (sender, e) =>
{ {
Route.Points.Clear(); if (Route!=null)
Route.Points.Clear();
// for (int i = this.Route.Locations.Count - 1; i >= 1; i--) // for (int i = this.Route.Locations.Count - 1; i >= 1; i--)
// { // {
// this.Route.Locations.RemoveAt(i); // this.Route.Locations.RemoveAt(i);
@ -131,6 +132,8 @@ namespace Plane.FormationCreator.Views
public void AddOrMoveCopter() public void AddOrMoveCopter()
{ {
// return;
if (!_flightTaskManager.TaskRun_2D) return; //不在2D模式运行直接退出
try try
{ {
var location = new Microsoft.Maps.MapControl.WPF.Location(Copter.Latitude, Copter.Longitude, Copter.Altitude); var location = new Microsoft.Maps.MapControl.WPF.Location(Copter.Latitude, Copter.Longitude, Copter.Altitude);
@ -578,13 +581,13 @@ namespace Plane.FormationCreator.Views
if (selected) if (selected)
{ {
if (!DotContainer.Children.Contains(selectMarkup)) if ((DotContainer!=null)&&(!DotContainer.Children.Contains(selectMarkup)))
DotContainer.Children.Add(selectMarkup); DotContainer.Children.Add(selectMarkup);
} }
else else
{ {
if (DotContainer.Children.Contains(selectMarkup)) if ((DotContainer != null) && (DotContainer.Children.Contains(selectMarkup)))
DotContainer.Children.Remove(selectMarkup); DotContainer.Children.Remove(selectMarkup);
} }
@ -603,6 +606,7 @@ namespace Plane.FormationCreator.Views
public void ResetRoute(int taskIndex) public void ResetRoute(int taskIndex)
{ {
var wpIndex = taskIndex - 1; // Waypoints 中没有起飞点。 var wpIndex = taskIndex - 1; // Waypoints 中没有起飞点。
if (Route == null) return;
Route.Points.Clear(); Route.Points.Clear();
if (wpIndex >= 0 && wpIndex < Waypoints.Count) if (wpIndex >= 0 && wpIndex < Waypoints.Count)
{ {

View File

@ -193,9 +193,7 @@
<Button Content="重置" <Button Content="重置"
Background="#232323" Background="#232323"
Command="{Binding ResetTasksCommand}" /> Command="{Binding ResetTasksCommand}" />
<Button Content="下一步"
Background="#232323"
Command="{Binding NextTasksCommand}" />
<Button Content="飞到任务" <Button Content="飞到任务"
Background="#232323" Background="#232323"
Command="{Binding flyTotaskCommand}" /> Command="{Binding flyTotaskCommand}" />