修改任务选中颜色,更明显

可导入ai和obj模型文件
增加删除任务和在任务中插入任务功能(添加改为选中任务后一个添加)
航线改为默认显示,优化右键隐藏航点功能
更改飞机和航点默认颜色
界面加入“飞行前准备”等分组页面,更方便操作
修改bug:清除飞机重新添加后飞行航线发虚,右键隐藏状态没有重置,
This commit is contained in:
xu 2020-04-20 00:12:11 +08:00
parent 84c12a1eb7
commit f787069624
17 changed files with 537 additions and 216 deletions

View File

@ -18,7 +18,7 @@ namespace Plane.FormationCreator.Converters
static DropShadowEffect _effect = new DropShadowEffect static DropShadowEffect _effect = new DropShadowEffect
{ {
//任务选中颜色 //任务选中颜色
Color = Colors.Azure, // Colors.LightGray, Color = Colors.Firebrick, // Colors.LightGray,
// Color = Colors.White, // Color = Colors.White,
Direction = 90, Direction = 90,
BlurRadius = 10 BlurRadius = 10

View File

@ -26,6 +26,9 @@ namespace Plane.FormationCreator.Converters
if (status == FlightTaskStatus.Paused) if (status == FlightTaskStatus.Paused)
return _PausedFill; return _PausedFill;
if (status == FlightTaskStatus.Selected)
return _PausedFill;
return _normalFill; return _normalFill;
} }

View File

@ -140,6 +140,13 @@ namespace Plane.FormationCreator.Formation
const int LEVEL_NORMAL = 1; const int LEVEL_NORMAL = 1;
const int LEVEL_ADMIN = 0; const int LEVEL_ADMIN = 0;
//飞机默认颜色
public const string CopterDefaultColor= "1E90FF";
//开始起飞颜色//解锁起飞用暗紫色
public const string CopterTakeoffColor = "FF00FF";
//飞行中颜色
public const string CopterFlyingColor = "32CD32";
private string superDispname = "超级用户"; private string superDispname = "超级用户";
public CopterManager() public CopterManager()

View File

@ -11,6 +11,8 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Plane.CommunicationManagement; using Plane.CommunicationManagement;
using FlightRoute;
using System.IO;
namespace Plane.FormationCreator.Formation namespace Plane.FormationCreator.Formation
{ {
@ -183,10 +185,22 @@ namespace Plane.FormationCreator.Formation
{ {
int starttime=0; int starttime=0;
if (_SelectedTask != null) _SelectedTask.IsSelected = false; if (_SelectedTask != null)
{
_SelectedTask.IsSelected = false;
if (TaskState == TasksStatus.Stop)
_SelectedTask.Status = FlightTaskStatus.Stop;
}
if (value != null) if (value != null)
{ {
value.IsSelected = true; value.IsSelected = true;
value.IsRightSelected = true;
RightSelect(value);
if (TaskState== TasksStatus.Stop)
value.Status = FlightTaskStatus.Selected;
for (int i = 0; i < value.TaskIndex; i++) for (int i = 0; i < value.TaskIndex; i++)
starttime += GetTaskTime(i); starttime += GetTaskTime(i);
@ -217,7 +231,9 @@ namespace Plane.FormationCreator.Formation
public int SelectedTaskIndex public int SelectedTaskIndex
{ {
get { return _SelectedTaskIndex; } get { return _SelectedTaskIndex; }
set { Set(nameof(SelectedTaskIndex), ref _SelectedTaskIndex, value); } set { Set(nameof(SelectedTaskIndex), ref _SelectedTaskIndex, value);
// this.SelectedTask = Tasks[value];
}
} }
// 右键单击任务,用于隐藏任务图标, added by ZJF // 右键单击任务,用于隐藏任务图标, added by ZJF
@ -280,7 +296,21 @@ namespace Plane.FormationCreator.Formation
} }
public event EventHandler<FlightTaskAddedEventArgs> TaskAdded; public event EventHandler<FlightTaskAddedEventArgs> TaskAdded;
public event EventHandler<FlightTaskDeledEventArgs> TaskDeled;
public void RaiseTaskDeled(FlightTask vDeledTask,int vTaskIndex)
{
try
{
TaskDeled?.Invoke(this, new FlightTaskDeledEventArgs { DeledTask = vDeledTask, TaskIndex= vTaskIndex });
}
catch (Exception ex)
{
//RaiseExceptionThrown(ex);
}
}
public void RaiseTaskAdded(FlightTask lastTask ,FlightTask newTask) public void RaiseTaskAdded(FlightTask lastTask ,FlightTask newTask)
{ {
try try
@ -334,6 +364,8 @@ namespace Plane.FormationCreator.Formation
if (Tasks.Count == 0) if (Tasks.Count == 0)
AddTakeOffTask(copters); AddTakeOffTask(copters);
var lastTask = Tasks.LastOrDefault(); var lastTask = Tasks.LastOrDefault();
if (SelectedTask !=null)
lastTask = SelectedTask;
var nullableCenter = copters.GetCenter(); var nullableCenter = copters.GetCenter();
if (nullableCenter == null) return; if (nullableCenter == null) return;
var center = nullableCenter.Value; var center = nullableCenter.Value;
@ -382,18 +414,31 @@ namespace Plane.FormationCreator.Formation
newTask.SingleCopterInfos.Add(newSingleCopterInfo); newTask.SingleCopterInfos.Add(newSingleCopterInfo);
} }
int selindex = SelectedTaskIndex+1;
Tasks.Insert(SelectedTaskIndex+1, newTask);
RaiseTaskAdded(lastTask, newTask);
SelectTask(selindex);
/*
Tasks.Add(newTask); Tasks.Add(newTask);
RaiseTaskAdded(lastTask, newTask); RaiseTaskAdded(lastTask, newTask);
SelectedTask = newTask; SelectedTask = newTask;
SelectedTaskIndex = Tasks.Count - 1; SelectedTaskIndex = Tasks.Count - 1;
*/
} }
} }
//是否显示计划航线
private bool _showroute = true;
public bool showroute
{
get { return _showroute; }
set { Set(nameof(showroute), ref _showroute, value); }
}
private double _OriginLat = 0; private double _OriginLat = 0;
public double OriginLat public double OriginLat
@ -424,9 +469,41 @@ namespace Plane.FormationCreator.Formation
this.Tasks.Clear(); this.Tasks.Clear();
SelectedTask = null; SelectedTask = null;
SelectedTaskIndex = 0; SelectedTaskIndex = 0;
TasksCleared?.Invoke(this, EventArgs.Empty); //取消删除事件
/*
if (TaskDeled != null)
{
Delegate[] dels = TaskDeled.GetInvocationList();
if (dels != null)
{
foreach (Delegate d in dels)
{
TaskDeled -= d as EventHandler<FlightTaskDeledEventArgs>;
}
}
}
*/
TasksCleared?.Invoke(this, EventArgs.Empty);
// AddTakeOffTask(_copterManager.Copters); // AddTakeOffTask(_copterManager.Copters);
} }
//删除选中的任务
public void DelSelectedTask()
{
if (SelectedTask == null) return;
if (SelectedTask.TaskType == FlightTaskType.TakeOff) return;
int selindex = SelectedTaskIndex;
// ResetTasks();
SelectedTask.SingleCopterInfos.Clear();
Tasks.RemoveAt(SelectedTaskIndex);
RaiseTaskDeled(SelectedTask,SelectedTaskIndex);
SelectTask(selindex - 1);
// SelectedTaskIndex = 0;
}
@ -597,8 +674,8 @@ namespace Plane.FormationCreator.Formation
altitude:0 altitude:0
); );
//设置灯光为默认 //设置灯光为默认
fc.LEDColor = "000000"; fc.LEDColor = CopterManager.CopterDefaultColor;// "000000";
} }
@ -627,6 +704,57 @@ namespace Plane.FormationCreator.Formation
return sb.ToString().Trim(); return sb.ToString().Trim();
} }
//导入外部航点
public void ImportDlltoTask(string filename)
{
Vector3[] vc;
string extname = Path.GetExtension(filename);
if (extname == ".svg")
{
vc = FlyBase.svgToPos(filename);
}
else if (extname == ".obj")
{
vc = FlyBase.objToPos(filename);
}
else return;
if (vc.Count()!= _copterManager.Copters.Count)
{
Alert.Show($"飞机数量不匹配!导入{vc.Count()}架,实际{_copterManager.Copters.Count}");
return;
}
var lastTask = Tasks.LastOrDefault();
var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = true, FlytoTime = 10, LoiterTime = 1 };
newTask.TaskCnName = Path.GetFileNameWithoutExtension(filename).Substring(0,6);
int id =0;
foreach (Vector3 item in vc)
{
Tuple<double, double> observationLatLng = null;
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
OriginLat,
OriginLng,
90,
(float)item.x / 100);
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
observationLatLng.Item1,
observationLatLng.Item2,
0,
(float)item.z / 100);
var thisSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(
_copterManager.Copters[id++], new LatLng(observationLatLng.Item1 - OriginLat, observationLatLng.Item2 - OriginLng),
(float)item.y / 100, false);
newTask.SingleCopterInfos.Add(thisSingleCopterInfo);
}
Tasks.Add(newTask);
RaiseTaskAdded(lastTask, newTask);
}
public void ImportC4DFlytoTask(string txt) public void ImportC4DFlytoTask(string txt)
{ {
string[] lines = txt.Replace("\r\n", "\n").Split('\n'); string[] lines = txt.Replace("\r\n", "\n").Split('\n');
@ -1193,6 +1321,12 @@ namespace Plane.FormationCreator.Formation
PLLocation prevLoc = new PLLocation(prevInfo.TargetLat, prevInfo.TargetLng, prevInfo.TargetAlt); PLLocation prevLoc = new PLLocation(prevInfo.TargetLat, prevInfo.TargetLng, prevInfo.TargetAlt);
prevTaskPoint.Add(i, prevLoc); prevTaskPoint.Add(i, prevLoc);
} }
// int sss = Plane.AutoLine.CalAutoLine(curTaskPoint, prevTaskPoint);
// Message.Show($"中心点:{sss}");
double farDistance; double farDistance;
double nearDistance; double nearDistance;
int index; int index;
@ -1521,13 +1655,12 @@ namespace Plane.FormationCreator.Formation
} }
public void Select(int taskIndex, ICopter copter) public void SelectTask(int taskIndex)
{ {
if (taskIndex == -1) return;
this.SelectedTaskIndex = taskIndex; this.SelectedTaskIndex = taskIndex;
this.SelectedTask = Tasks[taskIndex]; this.SelectedTask = Tasks[taskIndex];
} }
/** /**
@ -1804,6 +1937,13 @@ namespace Plane.FormationCreator.Formation
public FlightTask AddedTask { get; set; } public FlightTask AddedTask { get; set; }
} }
public class FlightTaskDeledEventArgs : EventArgs
{
public FlightTask DeledTask { get; set; }
public int TaskIndex { get; set; }
}
public class FlightTaskTypeChangedEventArgs : EventArgs public class FlightTaskTypeChangedEventArgs : EventArgs
{ {
public FlightTaskTypeChangedEventArgs(FlightTask changedFlightTask) public FlightTaskTypeChangedEventArgs(FlightTask changedFlightTask)

View File

@ -2,7 +2,8 @@
{ {
Stop, Stop,
Running, Running,
Paused Paused,
Selected
} }
public enum TasksStatus public enum TasksStatus
{ {

View File

@ -124,7 +124,7 @@ namespace Plane.FormationCreator.Formation
// await Task.Delay(10).ConfigureAwait(false); // await Task.Delay(10).ConfigureAwait(false);
// } // }
//解锁起飞用暗紫色 //解锁起飞用暗紫色
info.Copter.LEDColor = "FF00FF"; info.Copter.LEDColor = CopterManager.CopterTakeoffColor;
dtNow = DateTime.Now; dtNow = DateTime.Now;
ts = dtNow - dtLastTime; ts = dtNow - dtLastTime;
@ -141,8 +141,8 @@ namespace Plane.FormationCreator.Formation
dtNow = DateTime.Now; dtNow = DateTime.Now;
ts = dtNow - dtLastTime; ts = dtNow - dtLastTime;
} }
//起飞完成用暗蓝 //起飞完成用默认颜
info.Copter.LEDColor = "0000FF"; info.Copter.LEDColor = CopterManager.CopterFlyingColor;
} }

View File

@ -205,7 +205,7 @@
<StackPanel Grid.Row="1"> <StackPanel Grid.Row="1">
<StackPanel Grid.Row="2" <StackPanel Grid.Row="2"
Visibility="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource InversiveBooleanToVisibilityConverter}}"> Visibility="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource InversiveBooleanToVisibilityConverter}}">
<Separator Grid.ColumnSpan="2" /> <Separator Grid.ColumnSpan="2" Margin="0,5,5,5"/>
<v:ControlPanelView /> <v:ControlPanelView />
</StackPanel> </StackPanel>
@ -218,7 +218,7 @@
<StackPanel Grid.Row="2" <StackPanel Grid.Row="2"
Visibility="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource InversiveBooleanToVisibilityConverter}}"> Visibility="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource InversiveBooleanToVisibilityConverter}}">
<Separator Grid.ColumnSpan="2" /> <Separator Grid.ColumnSpan="2" Margin="0,0,5,5" />
<v:CopterInfoView DataContext="{Binding Path=CopterListViewModel.SelectedCopter}" /> <v:CopterInfoView DataContext="{Binding Path=CopterListViewModel.SelectedCopter}" />
</StackPanel> </StackPanel>
</Grid> </Grid>
@ -237,6 +237,9 @@
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/> <Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/>
<TextBlock Margin="10,4" Width="400" <TextBlock Margin="10,4" Width="400"
Text="{Binding CopterListViewModel.SelectedCopter.StatusText}" /> Text="{Binding CopterListViewModel.SelectedCopter.StatusText}" />
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/>
<TextBlock Margin="10,4" Width="400"
Text="{Binding ControlPanelViewModel.RTKState}" />
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">

View File

@ -51,6 +51,9 @@
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="flyBase">
<HintPath>..\..\Tools\flyBase.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight, Version=5.2.0.37222, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL"> <Reference Include="GalaSoft.MvvmLight, Version=5.2.0.37222, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.2.0.0\lib\net45\GalaSoft.MvvmLight.dll</HintPath> <HintPath>..\packages\MvvmLightLibs.5.2.0.0\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
<Private>True</Private> <Private>True</Private>

View File

@ -549,13 +549,24 @@ namespace Plane.FormationCreator.ViewModels
var dialog = new OpenFileDialog var dialog = new OpenFileDialog
{ {
DefaultExt = "txt", DefaultExt = "txt",
Filter = "文本文件|*.txt" Filter = "航点文件(*.txt,*.svg,*.obj) |*.txt;*.svg;*.obj" // "图片文件(*.jpg, *.gif, *.bmp, *.png) | *.jpg; *.gif; *.bmp; *.png"
}; };
if (dialog.ShowDialog() == true) if (dialog.ShowDialog() == true)
{ {
var tasksText = File.ReadAllText(dialog.FileName); string extname=Path.GetExtension(dialog.FileName);
_flightTaskManager.ImportC4DFlytoTask(tasksText); if (extname == ".txt")
autoalltasktime(); {
var tasksText = File.ReadAllText(dialog.FileName);
_flightTaskManager.ImportC4DFlytoTask(tasksText);
autoalltasktime();
}else
if ((extname == ".svg")|| (extname == ".obj"))
{
_flightTaskManager.ImportDlltoTask(dialog.FileName);
};
//_flightTaskManager.ImportBlenderFlyToTask(tasksText); //_flightTaskManager.ImportBlenderFlyToTask(tasksText);
} }
})); }));

View File

@ -108,12 +108,24 @@ namespace Plane.FormationCreator.ViewModels
private ICommand _DelTaskCommand;
public ICommand DelTaskCommand
{
get
{
return _DelTaskCommand ?? (_DelTaskCommand = new RelayCommand(() =>
{
// _flightTaskManager
// FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
_flightTaskManager.DelSelectedTask();
}));
}
}
private ICommand _SetOriginCommand;
private ICommand _SetOriginCommand;
public ICommand SetOriginCommand public ICommand SetOriginCommand
{ {
get get

View File

@ -29,103 +29,57 @@
Command="{Binding DisconnectCommand}" /> Command="{Binding DisconnectCommand}" />
</WrapPanel>--> </WrapPanel>-->
<TextBlock Text="飞行控制"
Margin="5,0,0,8"/> <TabControl Margin="0,0,13,0">
<WrapPanel> <TabItem Header="飞行前准备">
<Button Content="解锁"
Command="{Binding UnlockCommand}" /> <StackPanel Orientation="Vertical" Margin="0,5,0,0">
<Button Content="起飞" Visibility="Collapsed" <WrapPanel>
Command="{Binding TakeOffCommand}" />
<Button Content="起飞" <Button Content="电压检测"
Command="{Binding GuidAsyncCommand}" /> Command="{Binding DetectionVoltage}" />
<Button Content="悬停" <Button Content="版本检测"
Command="{Binding HoverCommand}" />
<Button Content="手动"
Command="{Binding FloatCommand}" />
<Button Content="参数"
Command="{Binding ParamModify}" />
<Button Content="参数文件" Visibility="Collapsed"
Command="{Binding LoadParamfile}" />
<Button Content="版本"
Command="{Binding GetVersionsCommand}" /> Command="{Binding GetVersionsCommand}" />
<Button Content="校准" <Button Content="通讯版本" Command="{Binding DetectionCommModuleVersion}" />
<Button Content="统计返回"
Command="{Binding DetectionReturnData}" />
<TextBlock
Margin="5,5,5,5" Foreground ="Red" VerticalAlignment="Center"
Text="{Binding RTKState}"
/>
</WrapPanel>
<WrapPanel>
<Button Content="参数设置"
Command="{Binding ParamModify}" />
<Button Content="读入参数"
Command="{Binding LoadParamfile}" />
<Button Content="定位统计" Command="{Binding ReportGPSTypeCommand}"/>
<Button Content="飞机校准"
Command="{Binding CalibrationSingleCommand}" /> Command="{Binding CalibrationSingleCommand}" />
</WrapPanel> <Button Content="正式参数" Command="{Binding TurnOffTestLightsCommand}" Visibility="Collapsed" />
<WrapPanel>
<Button Content="返航" <Button Content="电机测试"
Command="{Binding ReturnToLaunchCommand}" />
<Button Content="降落"
Command="{Binding LandCommand}" />
<Button Content="上锁"
Command="{Binding LockCommand}" />
<Button Content="跳过" Visibility="Collapsed"
Command="{Binding FlagCommand}" />
<Button Content="闪灯"
Command="{Binding LEDFlickerCommand}" />
<Button Content="测试" Visibility="Collapsed"
Command="{Binding TestCommand}" />
<Button Content="开灯"
Command="{Binding LEDOnOffCommand}"
CommandParameter="0"/>
<Button Content="关灯"
Command="{Binding LEDOnOffCommand}"
CommandParameter="1"/>
<Button Content="电机"
Command="{Binding MotorTestCommand}" /> Command="{Binding MotorTestCommand}" />
<TextBox Width="50" <Label Visibility="Collapsed" Content="Lat"/>
Visibility="Collapsed" <TextBox Visibility="Collapsed" Text="{Binding LatOffset}" Width="50"/>
Text="{Binding AltP, UpdateSourceTrigger=PropertyChanged}" /> <Label Visibility="Collapsed" Content="Lng"/>
</WrapPanel> <TextBox Visibility="Collapsed" Text="{Binding LngOffset}" Width="50"/>
<WrapPanel> <Button Visibility="Collapsed" Content="设置返航点" Command="{Binding RLTOffsetCommand}" />
<Button Margin="0,0,0,0" Content="选写航点" Command="{Binding WriteMissionSingleCommand}" /> </WrapPanel>
<Button Margin="3,0,0,0" Content="定位统计" Command="{Binding ReportGPSTypeCommand}"/>
<Button Margin="3,0,0,0" Content="统计模块" Command="{Binding DetectionCommModuleVersion}" />
<Button Margin="3,0,0,0" Content="正式参数" Command="{Binding TurnOffTestLightsCommand}" />
<TextBlock Margin="8,0,5,0" Text="起飞高度" VerticalAlignment="Center"></TextBlock> <WrapPanel>
<TextBox Width="30" Height="25" Text="{Binding TaskOffAlt}" /> <Button Content="写入航点"
<TextBlock Margin="5,0,5,0" Text="米" VerticalAlignment="Center"></TextBlock>
<Label Visibility="Collapsed">Lat</Label>
<TextBox Visibility="Collapsed" Text="{Binding LatOffset}" Width="50"/>
<Label Visibility="Collapsed">Lng</Label>
<TextBox Visibility="Collapsed" Text="{Binding LngOffset}" Width="50"/>
<Button Visibility="Collapsed" Content="设置返航点" Command="{Binding RLTOffsetCommand}" />
</WrapPanel>
<Separator/>
<WrapPanel>
<Button Content="全部降落"
Command="{Binding AllLandCommand}" />
<Button Content="全部加锁"
Command="{Binding LockAllCommand}" />
<Button Content="检测电压"
Command="{Binding DetectionVoltage}" />
<Button Content="统计返回"
Command="{Binding DetectionReturnData}" />
<Button Content="统计航点"
Command="{Binding DetectionMissionData}" />
</WrapPanel>
<WrapPanel>
<Button Content="写入航点"
Command="{Binding WriteMissionCommand}" /> Command="{Binding WriteMissionCommand}" />
<Button Content="全部解锁" <Button Content="航点续写"
Command="{Binding UnlockAllCommand}"
IsEnabled="{Binding AllowMissionStart, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="开始任务"
Command="{Binding MissionStartCommand}"
IsEnabled="{Binding AllowMissionStart, UpdateSourceTrigger=PropertyChanged}"/>
<Button Content="暂停任务"
Command="{Binding MissionPauseCommand}" />
<Button Content="继续任务"
Command="{Binding MissionResumeCommand}" />
</WrapPanel>
<WrapPanel>
<Button Content="航点续写"
Command="{Binding WriteMissionFailedCommand}" /> Command="{Binding WriteMissionFailedCommand}" />
<TextBox <Button Content="选写航点" Command="{Binding WriteMissionSingleCommand}" />
<Button Content="统计航点"
Command="{Binding DetectionMissionData}" />
<TextBox
Grid.Column="1" Grid.Column="1"
Width="55" Width="55"
Margin="5, 5, 5, 5" Margin="5, 5, 5, 5"
@ -134,54 +88,142 @@
Text="{Binding RTKcomvalue, UpdateSourceTrigger=PropertyChanged}" Visibility="Collapsed" Text="{Binding RTKcomvalue, UpdateSourceTrigger=PropertyChanged}" Visibility="Collapsed"
/> />
<Button Content="{Binding Path=RTKbtntxt}" <Button Content="{Binding RTKbtntxt}"
Command="{Binding SendRTKCommand}" Visibility="Collapsed" /> Command="{Binding SendRTKCommand}" Visibility="Collapsed" />
<Button Content="{Binding Path=NTRIPbtntxt}" <Button Content="{Binding NTRIPbtntxt}"
Command="{Binding SendRTCMCommand}" Visibility="Collapsed"/> Command="{Binding SendRTCMCommand}" Visibility="Collapsed"/>
<Button Content="RTK 控制" Command="{Binding OpenRtcmManageCommand}" /> <Button Content="RTK 控制" Command="{Binding OpenRtcmManageCommand}" />
<TextBlock
Margin="5,5,5,5" Foreground ="Red" VerticalAlignment="Center"
Text="{Binding Path=RTKState}"
/>
</WrapPanel>
<!--// 林俊清, 20150920, 目前不再使用 FormationController删除相关按钮。 </WrapPanel>
<StackPanel Visibility="{Binding Source={x:Static fc:AppEx.Current}, Path=AppMode, Converter={StaticResource AppModeToVisibilityConverter}, ConverterParameter=ControlPanelView_Formation}"> </StackPanel>
<TextBlock Text="任务" />
<WrapPanel> </TabItem>
<Button Content="飞到50米高"
Command="{Binding FlyToAltitudeCommand}"
CommandParameter="50" /> <TabItem Header="飞行控制">
<Button Content="飞到15米高"
Command="{Binding FlyToAltitudeCommand}" <StackPanel Orientation="Vertical" Margin="0,5,0,0">
CommandParameter="15" /> <WrapPanel >
<Button Content="Test" <Button Content="解锁"
Command="{Binding TestCommand}" /> Command="{Binding UnlockCommand}" />
</WrapPanel> <Button Content="加锁"
--> Command="{Binding LockCommand}" />
<!--<WrapPanel> <Button Content="起飞" Visibility="Collapsed"
<Button Content="画圈" Command="{Binding TakeOffCommand}" />
Command="{Binding FlyInCircleCommand}" />
<Button Content="绕队列中心画圈"
Command="{Binding FlyAroundCenterOfCoptersCommand}" />
<Button Content="Test" </WrapPanel>
Command="{Binding TestCommand}" /> <WrapPanel>
<Button Content="画矩形" <Button Content="起飞"
Command="{Binding FlyInRectangleCommand}" Command="{Binding GuidAsyncCommand}" />
Visibility="Collapsed" /> <Button Content="悬停"
</WrapPanel> Command="{Binding HoverCommand}" />
<WrapPanel> <Button Content="手动"
<Button Content="飞到一条竖线画圈" Command="{Binding FloatCommand}" />
Command="{Binding FlyToVerticalLineAndMakeCircleCommand}" /> <Button Content="返航"
</WrapPanel>--> Command="{Binding ReturnToLaunchCommand}" />
<!-- <Button Content="降落"
<WrapPanel> Command="{Binding LandCommand}" />
<Button Content="停止"
Command="{Binding StopTaskCommand}" /> <Button Content="跳过" Visibility="Collapsed"
</WrapPanel> Command="{Binding FlagCommand}" />
</StackPanel>-->
<TextBox Width="50"
Visibility="Collapsed"
Text="{Binding AltP, UpdateSourceTrigger=PropertyChanged}" />
</WrapPanel>
<WrapPanel>
<Button Content="闪灯"
Command="{Binding LEDFlickerCommand}" />
<Button Content="测试" Visibility="Collapsed"
Command="{Binding TestCommand}" />
<Button Content="开灯"
Command="{Binding LEDOnOffCommand}"
CommandParameter="0"/>
<Button Content="关灯"
Command="{Binding LEDOnOffCommand}"
CommandParameter="1"/>
<TextBlock Margin="8,-3,5,0" Text="起飞高度" VerticalAlignment="Center"/>
<TextBox VerticalContentAlignment="Center" Margin="0,0,0,5" Width="30" Height="25" Text="{Binding TaskOffAlt}" />
<TextBlock Margin="5,-3,5,0" Text="米" VerticalAlignment="Center"/>
</WrapPanel>
</StackPanel>
</TabItem>
<TabItem Header="任务控制">
<StackPanel Orientation="Vertical" Margin="0,5,0,0">
<WrapPanel>
<Button Content="全部解锁"
Command="{Binding UnlockAllCommand}"
IsEnabled="{Binding AllowMissionStart, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="全部加锁"
Command="{Binding LockAllCommand}" />
</WrapPanel>
<WrapPanel>
<Button Content="开始任务"
Command="{Binding MissionStartCommand}"
IsEnabled="{Binding AllowMissionStart, UpdateSourceTrigger=PropertyChanged}"/>
<Button Content="暂停任务"
Command="{Binding MissionPauseCommand}" />
<Button Content="继续任务"
Command="{Binding MissionResumeCommand}" />
</WrapPanel>
<WrapPanel>
<Button Content="全部降落"
Command="{Binding AllLandCommand}" />
</WrapPanel>
</StackPanel>
</TabItem>
<TabItem Header="飞行报告" Visibility="Collapsed">
<StackPanel Orientation="Vertical" Margin="0,5,0,0">
<WrapPanel>
<Button Content="添加报告"
Command="{Binding UnlockAllCommand}"
IsEnabled="{Binding AllowMissionStart, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="查看报告"
Command="{Binding LockAllCommand}" />
</WrapPanel>
</StackPanel>
</TabItem>
</TabControl>
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@ -45,7 +45,7 @@
/> />
<CheckBox Grid.Row="0" Content="飞行航线" Margin="5,5,0,0" <CheckBox Grid.Row="0" Content="飞行航线" Margin="5,5,0,0"
Click="showpanline_Checked" Click="showpanline_Checked"
Foreground="White" Foreground="White" IsChecked="True"
/> />
<CheckBox Grid.Row="0" Content="实时航线" Margin="5,5,0,0" <CheckBox Grid.Row="0" Content="实时航线" Margin="5,5,0,0"

View File

@ -64,6 +64,7 @@ namespace Plane.FormationCreator.Views
_mapManager.SetCenterGetter(() => new LatLng { Lat = gmap.Position.ToWGS84().Lat, Lng = gmap.Position.ToWGS84().Lng }); _mapManager.SetCenterGetter(() => new LatLng { Lat = gmap.Position.ToWGS84().Lat, Lng = gmap.Position.ToWGS84().Lng });
_flightTaskManager.TaskAdded += FlightTaskManager_TaskAdded; _flightTaskManager.TaskAdded += FlightTaskManager_TaskAdded;
_flightTaskManager.TaskDeled += FlightTaskManager_TaskDeled;
_flightTaskManager.OnOriginalSet += FlightTaskManager_SetOriginal; _flightTaskManager.OnOriginalSet += FlightTaskManager_SetOriginal;
/* /*
@ -105,7 +106,7 @@ namespace Plane.FormationCreator.Views
copterDrawing.ShowWaypoint(_flightTaskManager.SelectedTaskIndex); copterDrawing.ShowWaypoint(_flightTaskManager.SelectedTaskIndex);
copterDrawing.SetTaskEffect(_flightTaskManager.SelectedTaskIndex); copterDrawing.SetTaskEffect(_flightTaskManager.SelectedTaskIndex);
//画计划航线 //画计划航线
copterDrawing.ResetRoute(_flightTaskManager.SelectedTaskIndex); copterDrawing.ResetRoute(_flightTaskManager.SelectedTaskIndex);
} }
break; break;
@ -396,6 +397,11 @@ namespace Plane.FormationCreator.Views
*/ */
gmap.Markers.Clear(); gmap.Markers.Clear();
//_copterManager.Copters.ForEach(copter => _copterDrawings[copter]=null );
_copterDrawings.Clear(); _copterDrawings.Clear();
} }
@ -417,14 +423,28 @@ namespace Plane.FormationCreator.Views
private void FlightTaskManager_TaskAdded(object sender, FlightTaskAddedEventArgs e) private void FlightTaskManager_TaskAdded(object sender, FlightTaskAddedEventArgs e)
{ {
//给每个任务在地图上添加航点
foreach (var info in e.AddedTask.SingleCopterInfos) foreach (var info in e.AddedTask.SingleCopterInfos)
{ {
var drawingInfo = _copterDrawings[info.Copter]; var drawingInfo = _copterDrawings[info.Copter];
//计算位置
var location = new Microsoft.Maps.MapControl.WPF.Location(info.TargetLat, info.TargetLng, info.TargetAlt); var location = new Microsoft.Maps.MapControl.WPF.Location(info.TargetLat, info.TargetLng, info.TargetAlt);
drawingInfo.AddWaypoint(location, e.AddedTask.TaskType); //添加航点
drawingInfo.AddWaypoint(location, e.AddedTask.TaskType,e.AddedTask);
} }
} }
private void FlightTaskManager_TaskDeled(object sender, FlightTaskDeledEventArgs e)
{
//清除每架飞机的这个任务的航点
// foreach (var info in e.DeledTask.SingleCopterInfos)
// {
// _copterDrawings[info.Copter].Waypoints.RemoveAt(e.TaskIndex);
// }
}
GMapMarker originalMarker = null; GMapMarker originalMarker = null;
Microsoft.Expression.Shapes.RegularPolygon original = null; Microsoft.Expression.Shapes.RegularPolygon original = null;
const double ORIGIN_RADIUS = 12; const double ORIGIN_RADIUS = 12;
@ -582,7 +602,8 @@ namespace Plane.FormationCreator.Views
foreach (var item in _copterDrawings) foreach (var item in _copterDrawings)
{ {
var copterDrawing = item.Value; var copterDrawing = item.Value;
copterDrawing.SetShowroute(chk.IsChecked); _flightTaskManager.showroute = chk.IsChecked??false;
copterDrawing.UpdateShowroute();
} }
} }
@ -596,9 +617,6 @@ namespace Plane.FormationCreator.Views
} }
} }
private void RemoveTileLayers() private void RemoveTileLayers()
{ {
/* /*
@ -640,9 +658,7 @@ namespace Plane.FormationCreator.Views
grid_bg.Background = ib; grid_bg.Background = ib;
gmap.Opacity = 0.5; gmap.Opacity = 0.5;
} }
}
}
} }
static class LocationExtensions static class LocationExtensions

View File

@ -40,12 +40,18 @@ namespace Plane.FormationCreator.Views
_brush = new SolidColorBrush(_color); _brush = new SolidColorBrush(_color);
} }
_brush = new SolidColorBrush(Color.FromRgb(45,45,45));
Color Copterdefaultcolor = (Color)ColorConverter.ConvertFromString("#" + CopterManager.CopterDefaultColor);
_brush = new SolidColorBrush(Copterdefaultcolor);
_flightTaskManager.TasksCleared += (sender, e) => _flightTaskManager.TasksCleared += (sender, e) =>
{ {
//清除计划航线
if (Route!=null) if (Route!=null)
Route.Points.Clear(); 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);
@ -60,6 +66,21 @@ namespace Plane.FormationCreator.Views
//_map.ViewChangeOnFrame += new EventHandler<MapEventArgs>(Map_ViewChanged); //_map.ViewChangeOnFrame += new EventHandler<MapEventArgs>(Map_ViewChanged);
//删除任务事件
_flightTaskManager.TaskDeled += (sender, e) =>
{
if (this.Waypoints.Count == 0)
return;
// Waypoints没有起飞任务所以-1
int WaypointsIndex = e.TaskIndex - 1;
//删除地图上的航点
var wp = this.Waypoints[WaypointsIndex];
_map.Markers.Remove(wp);
//删除航点列表里的航点
this.Waypoints.RemoveAt(WaypointsIndex);
};
selectMarkup.Width = 7; selectMarkup.Width = 7;
selectMarkup.Height = 7; selectMarkup.Height = 7;
selectMarkup.HorizontalAlignment = HorizontalAlignment.Left; selectMarkup.HorizontalAlignment = HorizontalAlignment.Left;
@ -100,7 +121,9 @@ namespace Plane.FormationCreator.Views
public MapPolyline Track { get; set; } public MapPolyline Track { get; set; }
public Location LastLocation { get; set; } public Location LastLocation { get; set; }
//计划航线
public GMapRoute Route { get; set; } public GMapRoute Route { get; set; }
//某架飞机的地图显示航点列表
public List<GMapMarker> Waypoints { get; set; } = new List<GMapMarker>(); public List<GMapMarker> Waypoints { get; set; } = new List<GMapMarker>();
GoogleMap.GMap _map; GoogleMap.GMap _map;
@ -206,13 +229,16 @@ namespace Plane.FormationCreator.Views
//MapLayer.SetZIndex(DotContainer, 100); //MapLayer.SetZIndex(DotContainer, 100);
this.Route = new GMapRoute(new List<PointLatLng>() { gmapLatLng, gmapLatLng }); this.Route = new GMapRoute(new List<PointLatLng>() { gmapLatLng, gmapLatLng });
/*
Path path = new Path() Path path = new Path()
{ {
Stroke = _brush, Stroke = new SolidColorBrush(Colors.Red),
StrokeThickness = 2.0 StrokeThickness = 2.0
}; };
this.Route.Shape = path; this.Route.Shape = path;
*/
//显示计划航线 //显示计划航线
//_map.Markers.Add(Route); //_map.Markers.Add(Route);
@ -337,18 +363,33 @@ namespace Plane.FormationCreator.Views
//加入航点
public void AddWaypoint(Location location, FlightTaskType type) public void AddWaypoint(Location location, FlightTaskType type, FlightTask vtask)
{ {
// Add waypoint. // Add waypoint.
LatLng gmapLatLng = new LatLng(location.Latitude, location.Longitude); LatLng gmapLatLng = new LatLng(location.Latitude, location.Longitude);
//创建marker,设定位置
GMapMarker marker = new GMapMarker(gmapLatLng.ToGCJ02()); GMapMarker marker = new GMapMarker(gmapLatLng.ToGCJ02());
ShapesContainer shapesContainer = new ShapesContainer(_brush);
//航点默认颜色
SolidColorBrush Waypoint_brush = new SolidColorBrush(Color.FromRgb(0, 0, 255));
//makrer的形状包含一个圆圈和一个选中方块
ShapesContainer shapesContainer = new ShapesContainer(Waypoint_brush);
shapesContainer.Tag = WAYPOINT_TAG; shapesContainer.Tag = WAYPOINT_TAG;
marker.Tag = WAYPOINT_TAG; marker.Tag = WAYPOINT_TAG;
//形状设置为shapesContainer
marker.Shape = shapesContainer; marker.Shape = shapesContainer;
//加入航点列表Waypoints为某架飞机的航点列表
Waypoints.Insert(vtask.TaskIndex-1,marker);
//该航点的飞机是否选中
bool PontisSelected = _copterManager.SelectedCopters.Contains(Copter);
shapesContainer.Ismark = PontisSelected;
// 选中飞机在地图上显示一个红色方块---选中时也会调用,这儿可以不调用
SetEffect(PontisSelected);
Waypoints.Add(marker);
//_map.Markers.Add(marker); //消耗大量时间费时 为了提高效率改为选中才添加见ShowWaypoint //_map.Markers.Add(marker); //消耗大量时间费时 为了提高效率改为选中才添加见ShowWaypoint
marker.ZIndex = 100; marker.ZIndex = 100;
//MapLayer.SetZIndex(shapesContainer, 100); //MapLayer.SetZIndex(shapesContainer, 100);
@ -357,13 +398,12 @@ namespace Plane.FormationCreator.Views
//wpPos.Y -= WAYPOINT_RADIUS; //wpPos.Y -= WAYPOINT_RADIUS;
//MapLayer.SetPosition(shapesContainer, _map.ViewportPointToLocation(wpPos)); //MapLayer.SetPosition(shapesContainer, _map.ViewportPointToLocation(wpPos));
SetEffect(_copterManager.SelectedCopters.Contains(Copter));
// Register event handlers. // Register event handlers.
RegisterEventHandlersForDraggingWaypoint(marker, taskIndex: Waypoints.Count); RegisterEventHandlersForDraggingWaypoint(marker, vtask);
// Register event handlers for task info. // Register event handlers for task info.
RegisterEventHandlersForTaskInfo(marker, taskIndex: Waypoints.Count); RegisterEventHandlersForTaskInfo(marker, vtask);
} }
private void RegisterEventHandlersForDraggingCopter(GMapMarker copterMarker) private void RegisterEventHandlersForDraggingCopter(GMapMarker copterMarker)
@ -417,7 +457,7 @@ namespace Plane.FormationCreator.Views
private Dictionary<ICopter, GPoint> selectWayOriginPoint = new Dictionary<ICopter, GPoint>(); private Dictionary<ICopter, GPoint> selectWayOriginPoint = new Dictionary<ICopter, GPoint>();
private Dictionary<object, bool> _dictDraggingWp = new Dictionary<object, bool>(); private Dictionary<object, bool> _dictDraggingWp = new Dictionary<object, bool>();
private void RegisterEventHandlersForDraggingWaypoint(GMapMarker wpMarker, int taskIndex) private void RegisterEventHandlersForDraggingWaypoint(GMapMarker wpMarker, FlightTask vtask)
{ {
Grid wp = wpMarker.Shape as Grid; Grid wp = wpMarker.Shape as Grid;
_dictDraggingWp[wp] = false; _dictDraggingWp[wp] = false;
@ -430,11 +470,11 @@ namespace Plane.FormationCreator.Views
//判断点击的航点 //判断点击的航点
//非SelectedTask中的航点 或者 当前SelectedTask中未选择的航点 单选拖动 //非SelectedTask中的航点 或者 当前SelectedTask中未选择的航点 单选拖动
//否则多选拖动 //否则多选拖动
if (_flightTaskManager.SelectedTaskIndex != taskIndex || !_copterManager.SelectedCopters.Contains(this.Copter)) if (_flightTaskManager.SelectedTask != vtask || !_copterManager.SelectedCopters.Contains(this.Copter))
{ {
//_copterManager.Select(null); //_copterManager.Select(null);
_copterManager.Select(this.Copter); _copterManager.Select(this.Copter);
_flightTaskManager.Select(taskIndex, this.Copter); _flightTaskManager.SelectTask(vtask.TaskIndex);
} }
var originPoint = e.GetPosition(_map); var originPoint = e.GetPosition(_map);
@ -460,7 +500,7 @@ namespace Plane.FormationCreator.Views
}; };
wp.MouseRightButtonDown += (sender, e) => wp.MouseRightButtonDown += (sender, e) =>
{ {
_flightTaskManager.RightSelect(taskIndex, this.Copter); _flightTaskManager.RightSelect(vtask.TaskIndex, this.Copter);
}; };
_map.MouseMove += (sender, e) => _map.MouseMove += (sender, e) =>
{ {
@ -506,10 +546,10 @@ namespace Plane.FormationCreator.Views
}; };
} }
private void RegisterEventHandlersForTaskInfo(GMapMarker marker, int taskIndex) private void RegisterEventHandlersForTaskInfo(GMapMarker marker, FlightTask vtask)
{ {
var wp = marker.Shape as ShapesContainer; var wp = marker.Shape as ShapesContainer;
var info = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.FirstOrDefault(i => i.Copter == this.Copter); var info = vtask.SingleCopterInfos.FirstOrDefault(i => i.Copter == this.Copter);
if (info == null) return; if (info == null) return;
info.PropertyChanged += (sender, e) => info.PropertyChanged += (sender, e) =>
{ {
@ -557,21 +597,25 @@ namespace Plane.FormationCreator.Views
//_map.ViewChangeOnFrame -= Map_ViewChanged; //_map.ViewChangeOnFrame -= Map_ViewChanged;
} }
public void SetShowroute(bool? showroute) //显示或隐藏计划线路
public void UpdateShowroute()
{ {
if (showroute ?? false ) if (_flightTaskManager.showroute)
{ {
if (_copterManager.ShowCopter.Count > 0) if (_copterManager.ShowCopter.Count > 0)
{ {
if (_copterManager.ShowCopter.Contains(Copter)) if (_copterManager.ShowCopter.Contains(Copter))
{ {
_map.Markers.Add(this.Route); if (!_map.Markers.Contains(this.Route))
_map.Markers.Add(this.Route);
Route.ZIndex = 99; Route.ZIndex = 99;
} }
} }
else else
{ {
_map.Markers.Add(this.Route); //将计划线路加入地图
if (!_map.Markers.Contains(this.Route))
_map.Markers.Add(this.Route);
Route.ZIndex = 99; Route.ZIndex = 99;
} }
@ -579,7 +623,8 @@ namespace Plane.FormationCreator.Views
} }
else else
{ {
if(_map.Markers.Contains(this.Route)) //将计划线路从地图移除
if (_map.Markers.Contains(this.Route))
_map.Markers.Remove(this.Route); _map.Markers.Remove(this.Route);
} }
@ -593,6 +638,7 @@ namespace Plane.FormationCreator.Views
// _map.Children.Remove(Track); // _map.Children.Remove(Track);
} }
//选中飞机在地图上显示一个红色方块
public void SetEffect(bool selected) public void SetEffect(bool selected)
{ {
@ -620,6 +666,8 @@ namespace Plane.FormationCreator.Views
*/ */
} }
//添加计划航线---只显示两个点
public void ResetRoute(int taskIndex) public void ResetRoute(int taskIndex)
{ {
var wpIndex = taskIndex - 1; // Waypoints 中没有起飞点。 var wpIndex = taskIndex - 1; // Waypoints 中没有起飞点。
@ -627,15 +675,24 @@ namespace Plane.FormationCreator.Views
Route.Points.Clear(); Route.Points.Clear();
if (wpIndex >= 0 && wpIndex < Waypoints.Count) if (wpIndex >= 0 && wpIndex < Waypoints.Count)
{ {
//起始点时
var info1 = _flightTaskManager.Tasks[wpIndex].SingleCopterInfos.Find(i => i.Copter == this.Copter); var info1 = _flightTaskManager.Tasks[wpIndex].SingleCopterInfos.Find(i => i.Copter == this.Copter);
var info2 = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.Find(i => i.Copter == this.Copter); var info2 = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.Find(i => i.Copter == this.Copter);
PointLatLng loc1 = new LatLng(info1.TargetLat, info1.TargetLng).ToGCJ02(); PointLatLng loc1 = new LatLng(info1.TargetLat, info1.TargetLng).ToGCJ02();
PointLatLng loc2 = new LatLng(info2.TargetLat, info2.TargetLng).ToGCJ02(); PointLatLng loc2 = new LatLng(info2.TargetLat, info2.TargetLng).ToGCJ02();
Route.Points.Add(loc1); Route.Points.Add(loc1); //起始点
Route.Points.Add(loc2); Route.Points.Add(loc2); //结束点
} }
Path path = new Path()
{
Stroke = new SolidColorBrush(Colors.Red),
StrokeThickness = 2.0
};
Route.Shape = path;
Route.RegenerateShape(_map); Route.RegenerateShape(_map);
UpdateShowroute();
} }
@ -665,6 +722,7 @@ namespace Plane.FormationCreator.Views
if (!flag) if (!flag)
{ {
wp.Visibility = Visibility.Hidden; wp.Visibility = Visibility.Hidden;
Route.Shape.Visibility= Visibility.Hidden;
} }
else else
{ {
@ -674,15 +732,18 @@ namespace Plane.FormationCreator.Views
if (_copterManager.ShowCopter.Contains(Copter)) if (_copterManager.ShowCopter.Contains(Copter))
{ {
wp.Visibility = Visibility.Visible; wp.Visibility = Visibility.Visible;
Route.Shape.Visibility = Visibility.Visible;
} }
else else
{ {
wp.Visibility = Visibility.Hidden; wp.Visibility = Visibility.Hidden;
Route.Shape.Visibility = Visibility.Hidden;
} }
} }
else else
{ {
wp.Visibility = Visibility.Visible; wp.Visibility = Visibility.Visible;
Route.Shape.Visibility = Visibility.Visible;
} }
//var info = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.Find(i => i.Copter == this.Copter); //var info = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.Find(i => i.Copter == this.Copter);
@ -692,6 +753,7 @@ namespace Plane.FormationCreator.Views
} }
} }
//航点选中方块
public class ShapesContainer : Grid public class ShapesContainer : Grid
{ {
const double WAYPOINT_RADIUS = 6; const double WAYPOINT_RADIUS = 6;
@ -713,6 +775,7 @@ namespace Plane.FormationCreator.Views
mark.HorizontalAlignment = HorizontalAlignment.Left; mark.HorizontalAlignment = HorizontalAlignment.Left;
mark.VerticalAlignment = VerticalAlignment.Top; mark.VerticalAlignment = VerticalAlignment.Top;
mark.Fill = new SolidColorBrush(Colors.GreenYellow); mark.Fill = new SolidColorBrush(Colors.GreenYellow);
this.Children.Add(mark); this.Children.Add(mark);
mark.Visibility = Visibility.Hidden; mark.Visibility = Visibility.Hidden;
@ -721,8 +784,10 @@ namespace Plane.FormationCreator.Views
//public MapPolygon //public MapPolygon
private bool isMarked; private bool isMarked;
public Ellipse wp; public Ellipse wp;
//航点选中方块
public Rectangle mark; public Rectangle mark;
//航点是否选中
public bool Ismark public bool Ismark
{ {
get get

View File

@ -78,12 +78,14 @@
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<Button Content="回前一高度"
<Button Content="回前一任务"
Margin="40,5,5,0" Width="105" Margin="40,5,5,0" Width="105"
Command="{Binding PrealtCommand}" />
<Button Content="回上一任务"
Margin="0,5,5,0" Width="105"
Command="{Binding BackToPreviousTaskPoint}" /> Command="{Binding BackToPreviousTaskPoint}" />
<Button Content="回前一高度"
Margin="0,5,5,0" Width="105"
Command="{Binding PrealtCommand}" />
<Button Content="回起飞点" <Button Content="回起飞点"
Margin="0,5,5,0" Width="105" Margin="0,5,5,0" Width="105"
Command="{Binding BackTakeOffPointCommand}" /> Command="{Binding BackTakeOffPointCommand}" />
@ -450,7 +452,7 @@
<StackPanel x:Name="PanelDesign1"> <StackPanel x:Name="PanelDesign1">
<StackPanel Orientation="Horizontal" Margin="0,5,0,5" > <StackPanel Orientation="Horizontal" Margin="0,5,0,5" >
<Button Width="120" Margin="10,5,0,5" Content="C4D导入航点" Command="{Binding ImportBlenderWayPointCommand}"/> <Button Width="120" Margin="10,5,0,5" Content="导入外部航点" Command="{Binding ImportBlenderWayPointCommand}"/>
<Button Width="120" Content="自动飞行时间" Margin="10,5,0,5" <Button Width="120" Content="自动飞行时间" Margin="10,5,0,5"
Command="{Binding AutoWayPointAllTmCommand}" HorizontalAlignment="Right" /> Command="{Binding AutoWayPointAllTmCommand}" HorizontalAlignment="Right" />
<Button Width="120" Content="飞行图案设计" Margin="10,5,0,5" <Button Width="120" Content="飞行图案设计" Margin="10,5,0,5"

View File

@ -120,7 +120,7 @@
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
<Grid Grid.Column="2"> <Grid Grid.Column="2" >
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
<RowDefinition Height="28"/> <RowDefinition Height="28"/>
@ -196,6 +196,9 @@
<Button Content="添加" x:Name="addtaskbtn" <Button Content="添加" x:Name="addtaskbtn"
Background="#232323" Background="#232323"
Command="{Binding AddTaskCommand}" /> Command="{Binding AddTaskCommand}" />
<Button Content="删除"
Background="#232323"
Command="{Binding DelTaskCommand}" />
<Button Content="清除" <Button Content="清除"
Background="#232323" Background="#232323"
Command="{Binding ClearTasksCommand}" /> Command="{Binding ClearTasksCommand}" />
@ -209,6 +212,8 @@
<Button Content="原点" <Button Content="原点"
Background="#232323" Background="#232323"
Command="{Binding SetOriginCommand}" /> Command="{Binding SetOriginCommand}" />
<!--<Button Content="保存" /> <!--<Button Content="保存" />
<Button Content="取消" />--> <Button Content="取消" />-->
</StackPanel> </StackPanel>

View File

@ -52,9 +52,10 @@ namespace Plane.FormationCreator.Views
_flightTaskManager.PropertyChanged += (sender, e) => _flightTaskManager.PropertyChanged += (sender, e) =>
{ {
if (_flightTaskManager.SelectedTaskIndex == -1) return;
switch (e.PropertyName) switch (e.PropertyName)
{ {
//选中任务时触发 //选中任务时触发--控制任务类型选项卡的显示和是否允许加入新任务
case nameof(FlightTaskManager.SelectedTaskIndex): case nameof(FlightTaskManager.SelectedTaskIndex):
if (_flightTaskManager.Tasks.Count == 0) if (_flightTaskManager.Tasks.Count == 0)
{ {
@ -67,33 +68,41 @@ namespace Plane.FormationCreator.Views
{ {
hintaddtask.Visibility = Visibility.Collapsed; hintaddtask.Visibility = Visibility.Collapsed;
tasktabcont.Visibility = Visibility.Visible; tasktabcont.Visibility = Visibility.Visible;
//刷新任务编号--可能删除了任务
TasksControl.Items.Refresh();
//起飞任务
if (_flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex].TaskType == FlightTaskType.TakeOff) if (_flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex].TaskType == FlightTaskType.TakeOff)
{ {
takeoffpage.Visibility = Visibility.Visible; takeoffpage.Visibility = Visibility.Visible;
landpage.Visibility = Visibility.Collapsed; landpage.Visibility = Visibility.Collapsed;
flytopage.Visibility = Visibility.Collapsed; flytopage.Visibility = Visibility.Collapsed;
}else }else
//选中中间的任务
if (_flightTaskManager.SelectedTaskIndex < (_flightTaskManager.Tasks.Count - 1)) if (_flightTaskManager.SelectedTaskIndex < (_flightTaskManager.Tasks.Count - 1))
{ {
takeoffpage.Visibility = Visibility.Collapsed; takeoffpage.Visibility = Visibility.Collapsed;
landpage.Visibility = Visibility.Collapsed; landpage.Visibility = Visibility.Collapsed;
flytopage.Visibility = Visibility.Visible; flytopage.Visibility = Visibility.Visible;
flytoLabel.Content = (_flightTaskManager.SelectedTaskIndex+1)+" "+ _flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex].TaskCnName; flytoLabel.Content = (_flightTaskManager.SelectedTaskIndex+1)+" "+ _flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex].TaskCnName;
//允许添加中途任务
addtaskbtn.IsEnabled = true;
} }
else else
//最后一个任务--只有最后一个任务能设置成降落-防止中途降落
{ {
takeoffpage.Visibility = Visibility.Collapsed; takeoffpage.Visibility = Visibility.Collapsed;
landpage.Visibility = Visibility.Visible; landpage.Visibility = Visibility.Visible;
flytopage.Visibility = Visibility.Visible; flytopage.Visibility = Visibility.Visible;
//如果不是降落任务
if (_flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex].TaskType != FlightTaskType.Land) if (_flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex].TaskType != FlightTaskType.Land)
{
addtaskbtn.IsEnabled = true;
flytoLabel.Content = (_flightTaskManager.SelectedTaskIndex + 1) + " " + _flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex].TaskCnName; flytoLabel.Content = (_flightTaskManager.SelectedTaskIndex + 1) + " " + _flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex].TaskCnName;
}
else else
{ {
flytoLabel.Content = (_flightTaskManager.SelectedTaskIndex + 1) + " 航点"; flytoLabel.Content = (_flightTaskManager.SelectedTaskIndex + 1) + " 航点";
@ -159,15 +168,15 @@ namespace Plane.FormationCreator.Views
var elem = sender as FrameworkElement; var elem = sender as FrameworkElement;
var task = elem.DataContext as FlightTask; var task = elem.DataContext as FlightTask;
_flightTaskManager.Select(task); _flightTaskManager.Select(task);
}
}
//以前的右键隐藏航点,已不用 //以前的右键隐藏航点,已不用
public void setRightSelect(FlightTask task, bool vRightSelect) public void setRightSelect(FlightTask task, bool vRightSelect)
{ {
}
}
//右键功能 ---隐藏航点 //右键功能 ---隐藏航点
private void HideTask(object sender, MouseButtonEventArgs e) private void HideTask(object sender, MouseButtonEventArgs e)
@ -175,6 +184,8 @@ namespace Plane.FormationCreator.Views
var elem = sender as FrameworkElement; var elem = sender as FrameworkElement;
var task = elem.DataContext as FlightTask; var task = elem.DataContext as FlightTask;
_flightTaskManager.RightSelect(task); _flightTaskManager.RightSelect(task);
setRightSelect(task, true);
} }