修改背景和UI
添加飞机摆放设置 修改为Gmap目前使用的bing模式 添加3D视图和背景 取消断线重连的提示改为状态显示
This commit is contained in:
parent
80aa891a33
commit
039f2a57af
@ -33,40 +33,74 @@ Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
v4.0-Debug|Any CPU = v4.0-Debug|Any CPU
|
||||
v4.0-Release|Any CPU = v4.0-Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{61E2F31E-220A-4E3F-A64D-F7CDC2135008}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{61E2F31E-220A-4E3F-A64D-F7CDC2135008}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{61E2F31E-220A-4E3F-A64D-F7CDC2135008}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{61E2F31E-220A-4E3F-A64D-F7CDC2135008}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{61E2F31E-220A-4E3F-A64D-F7CDC2135008}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{61E2F31E-220A-4E3F-A64D-F7CDC2135008}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{61E2F31E-220A-4E3F-A64D-F7CDC2135008}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{61E2F31E-220A-4E3F-A64D-F7CDC2135008}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0111EB6E-72E3-499C-A3BA-022F5BBC4CAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0111EB6E-72E3-499C-A3BA-022F5BBC4CAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0111EB6E-72E3-499C-A3BA-022F5BBC4CAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0111EB6E-72E3-499C-A3BA-022F5BBC4CAF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0111EB6E-72E3-499C-A3BA-022F5BBC4CAF}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0111EB6E-72E3-499C-A3BA-022F5BBC4CAF}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0111EB6E-72E3-499C-A3BA-022F5BBC4CAF}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0111EB6E-72E3-499C-A3BA-022F5BBC4CAF}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{47141894-ECE3-48CA-8DCF-CA751BDA231E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{47141894-ECE3-48CA-8DCF-CA751BDA231E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{47141894-ECE3-48CA-8DCF-CA751BDA231E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{47141894-ECE3-48CA-8DCF-CA751BDA231E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{47141894-ECE3-48CA-8DCF-CA751BDA231E}.v4.0-Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{47141894-ECE3-48CA-8DCF-CA751BDA231E}.v4.0-Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{47141894-ECE3-48CA-8DCF-CA751BDA231E}.v4.0-Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{47141894-ECE3-48CA-8DCF-CA751BDA231E}.v4.0-Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,18 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="Plane.FormationCreator.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
|
||||
</startup>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="Plane.FormationCreator.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0"/>
|
||||
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.109.0" newVersion="1.0.109.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
@ -23,4 +33,21 @@
|
||||
</setting>
|
||||
</Plane.FormationCreator.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="mssqllocaldb" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<remove invariant="System.Data.SQLite.EF6" />
|
||||
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
|
||||
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
|
||||
</system.data>
|
||||
</configuration>
|
@ -40,7 +40,7 @@ namespace Plane.FormationCreator
|
||||
App.Current.Exit += (sender, e) =>
|
||||
{
|
||||
this.Center = _mapManager.Center;
|
||||
this.ZoomLevel = _mapManager.MapView.map.ZoomLevel;
|
||||
this.ZoomLevel = _mapManager.MapView.gmap.Zoom;
|
||||
this.Save();
|
||||
};
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ namespace Plane.FormationCreator.Converters
|
||||
{
|
||||
public class FlightTaskStatusToFillConverter : IValueConverter
|
||||
{
|
||||
static SolidColorBrush _normalFill = new SolidColorBrush(Colors.LightGray);
|
||||
static SolidColorBrush _runningFill = new SolidColorBrush(Colors.OrangeRed);
|
||||
static SolidColorBrush _PausedFill = new SolidColorBrush(Colors.Yellow);
|
||||
static SolidColorBrush _normalFill = new SolidColorBrush(Color.FromRgb(45, 45, 45));
|
||||
static SolidColorBrush _runningFill = new SolidColorBrush(Colors.Green);
|
||||
static SolidColorBrush _PausedFill = new SolidColorBrush(Colors.Red);
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var status = (FlightTaskStatus)value;
|
||||
|
@ -40,6 +40,7 @@ namespace Plane.FormationCreator.Formation
|
||||
//if (_TaskType != value)
|
||||
{
|
||||
RaisePropertyChanged(nameof(TaskTypeIndex));
|
||||
RaisePropertyChanged(nameof(TaskCnName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -60,6 +61,21 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
*/
|
||||
|
||||
public string TaskCnName
|
||||
{
|
||||
get
|
||||
{
|
||||
string CnName = "";
|
||||
switch (TaskType)
|
||||
{
|
||||
case FlightTaskType.TakeOff: CnName = (TaskIndex + 1).ToString() + ".起飞"; break;
|
||||
case FlightTaskType.FlyTo: CnName = (TaskIndex + 1).ToString() + ".航点"; break;
|
||||
case FlightTaskType.Land: CnName = (TaskIndex + 1).ToString() + ".降落"; break;
|
||||
}
|
||||
return CnName;
|
||||
}
|
||||
}
|
||||
|
||||
public int TaskTypeIndex
|
||||
{
|
||||
get {
|
||||
@ -83,6 +99,15 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
}
|
||||
|
||||
//task在所以任务中的index
|
||||
public int TaskIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return _flightTaskManager.Tasks.IndexOf(this);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _IsSelected;
|
||||
public bool IsSelected
|
||||
{
|
||||
|
@ -18,8 +18,9 @@ namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
public FlightTaskManager(CopterManager copterManager)
|
||||
{
|
||||
_copterManager = copterManager;
|
||||
|
||||
LoadIni();
|
||||
_copterManager = copterManager;
|
||||
|
||||
//AddTakeOffTask(_copterManager.Copters);
|
||||
|
||||
_copterManager.Copters.CollectionChanged += (sender, e) =>
|
||||
@ -87,6 +88,7 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
|
||||
private CopterManager _copterManager;
|
||||
|
||||
|
||||
private int _TakeOffNumAttr = 1;
|
||||
public int TakeOffNumAttr
|
||||
@ -191,6 +193,35 @@ namespace Plane.FormationCreator.Formation
|
||||
private set { Set(nameof(CurrentRunningTaskIndex), ref _CurrentRunningTaskIndex, value); }
|
||||
}
|
||||
|
||||
private int _ColumnCount = 5;
|
||||
public int ColumnCount
|
||||
{
|
||||
get { return _ColumnCount; }
|
||||
set { Set(nameof(ColumnCount), ref _ColumnCount, value); }
|
||||
}
|
||||
|
||||
|
||||
private float _ColumnDistance = 4.0f;
|
||||
public float ColumnDistance
|
||||
{
|
||||
get { return _ColumnDistance; }
|
||||
set { Set(nameof(ColumnDistance), ref _ColumnDistance, value); }
|
||||
}
|
||||
|
||||
private float _RowDistance = 4.0f;
|
||||
public float RowDistance
|
||||
{
|
||||
get { return _RowDistance; }
|
||||
set { Set(nameof(RowDistance), ref _RowDistance, value); }
|
||||
}
|
||||
|
||||
private int _Orientation = 0;
|
||||
public int Orientation
|
||||
{
|
||||
get { return _Orientation; }
|
||||
set { Set(nameof(Orientation), ref _Orientation, value); }
|
||||
}
|
||||
|
||||
|
||||
private TasksStatus _TaskState = TasksStatus.Stop;
|
||||
public TasksStatus TaskState
|
||||
@ -227,12 +258,11 @@ namespace Plane.FormationCreator.Formation
|
||||
var newTask = new FlightTask(FlightTaskType.FlyTo);
|
||||
int coptindex = 0;
|
||||
|
||||
int colnum = 20; //自动生成列数=4
|
||||
float coldis = 2.5f;//列相距5米
|
||||
float rowdis = 5f;//行相距5米
|
||||
int colnum = ColumnCount; //自动生成列数=4
|
||||
float coldis = ColumnDistance;//列相距5米
|
||||
float rowdis = RowDistance;//行相距5米
|
||||
float matrixdis = 20; //生成方阵距离30米
|
||||
|
||||
|
||||
int currcol = 0; //当前列号
|
||||
int currrow = 0; //当前行
|
||||
Tuple<double, double> colLatLng = new Tuple<double, double>(0, 0);
|
||||
@ -1040,9 +1070,9 @@ namespace Plane.FormationCreator.Formation
|
||||
|
||||
var pointjson= points[i];
|
||||
System.Windows.Point point = new System.Windows.Point((int)pointjson.x, (int)pointjson.y);
|
||||
Microsoft.Maps.MapControl.WPF.Location loc = _mapManager.MapView.map.ViewportPointToLocation(point);
|
||||
SelectedTask.SingleCopterInfos[i].TargetLat = loc.Latitude;
|
||||
SelectedTask.SingleCopterInfos[i].TargetLng = loc.Longitude;
|
||||
var loc = _mapManager.MapView.gmap.FromLocalToLatLng((int)point.X , (int)point.Y);
|
||||
SelectedTask.SingleCopterInfos[i].TargetLat = loc.Lat;
|
||||
SelectedTask.SingleCopterInfos[i].TargetLng = loc.Lng;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1314,6 +1344,40 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadIni()
|
||||
{
|
||||
Windows.IniHelper.IniFiles inifilse = new Windows.IniHelper.IniFiles();
|
||||
string readvalue = "";
|
||||
int intTemp;
|
||||
float floatTemp;
|
||||
readvalue = inifilse.IniReadvalue("Default", "ColumnCount");
|
||||
if (readvalue!= "" && int.TryParse(readvalue,out intTemp))
|
||||
ColumnCount = int.Parse(readvalue);
|
||||
|
||||
readvalue = inifilse.IniReadvalue("Default", "ColumnDistance");
|
||||
if (readvalue != "" && float.TryParse(readvalue, out floatTemp))
|
||||
ColumnDistance = float.Parse(readvalue);
|
||||
|
||||
readvalue = inifilse.IniReadvalue("Default", "RowDistance");
|
||||
if (readvalue != "" && float.TryParse(readvalue, out floatTemp))
|
||||
RowDistance = float.Parse(readvalue);
|
||||
|
||||
readvalue = inifilse.IniReadvalue("Default", "Orientation");
|
||||
if (readvalue != "" && int.TryParse(readvalue, out intTemp))
|
||||
Orientation = int.Parse(readvalue);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void SaveIni()
|
||||
{
|
||||
Windows.IniHelper.IniFiles inifilse = new Windows.IniHelper.IniFiles();
|
||||
inifilse.IniWritevalue("Default", "ColumnCount", ColumnCount.ToString());
|
||||
inifilse.IniWritevalue("Default", "ColumnDistance", ColumnDistance.ToString());
|
||||
inifilse.IniWritevalue("Default", "RowDistance", RowDistance.ToString());
|
||||
inifilse.IniWritevalue("Default", "Orientation", Orientation.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public class FlightTaskAddedEventArgs : EventArgs
|
||||
|
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using GMap.NET;
|
||||
using Plane.FormationCreator.Maps;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
14
Plane.FormationCreator/GMap.cs
Normal file
14
Plane.FormationCreator/GMap.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using GMap.NET.WindowsPresentation;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System;
|
||||
|
||||
namespace Plane.GoogleMap
|
||||
{
|
||||
class GMap : GMapControl
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -42,6 +42,7 @@
|
||||
|
||||
<c:MetroWindow.RightWindowCommands>
|
||||
<c:WindowCommands>
|
||||
<Button Content="切换地图" Command="{Binding ChangeMapModeCommand}"></Button>
|
||||
<Button Content="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource ShowModifyTaskViewButtonContentConverter}}"
|
||||
Command="{Binding ShowOrHideModifyTaskViewCommand}" />
|
||||
<Button Content="重启监听"
|
||||
@ -60,7 +61,10 @@
|
||||
<Button Name="btnShowLog"
|
||||
Content="日志"
|
||||
Click="btnShowLog_Click"
|
||||
Visibility="Collapsed"/>
|
||||
/>
|
||||
<Button Content="地图透明"
|
||||
Click="Map_Opacity_Click"
|
||||
/>
|
||||
<Button Name="btnGoHome"
|
||||
Content="回家"
|
||||
Click="btnGoHome_Click" />
|
||||
@ -115,7 +119,7 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Margin="10,20,10,10">
|
||||
<Grid Margin="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="73*" />
|
||||
<ColumnDefinition Width="27*" MinWidth="360" />
|
||||
@ -123,14 +127,29 @@
|
||||
|
||||
<Grid Margin="0,0,10,0"
|
||||
Width="Auto" >
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<v:MapView x:Name="map"
|
||||
/>
|
||||
|
||||
|
||||
<TabControl SelectedIndex="{Binding MapMode,UpdateSourceTrigger=PropertyChanged}">
|
||||
<TabItem Visibility="Collapsed">
|
||||
<v:MapView x:Name="map"/>
|
||||
</TabItem >
|
||||
<TabItem Visibility="Collapsed">
|
||||
<v:View3D/>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
<!--
|
||||
|
||||
<v:MapView x:Name="map"/>
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<v:TaskBarView
|
||||
x:Name="TaskbarControl"
|
||||
VerticalAlignment="Bottom"
|
||||
@ -179,13 +198,21 @@
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="1"
|
||||
Background="{StaticResource HighlightBrush}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="4"
|
||||
Background="{StaticResource WhiteBrush}">
|
||||
<Grid>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Margin="4"
|
||||
Text="{Binding Message}" MouseUp="LogShowHide"/>
|
||||
<TextBlock Margin="4"
|
||||
<TextBlock Margin="4"
|
||||
Text="{Binding CopterListViewModel.SelectedCopter.StatusText}" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<TextBlock Text="通信连接:" Margin="4"/>
|
||||
<ContentPresenter Content="{Binding CommunicationModuleConnected, Converter={StaticResource CheckSignConverter}, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
<TextBox Name="logTextBox" Height="700" Width="600" Background="#FF2D2D2D"
|
||||
HorizontalAlignment="Left"
|
||||
|
@ -495,5 +495,17 @@ namespace Plane.FormationCreator
|
||||
{
|
||||
logTextBox.ScrollToEnd();
|
||||
}
|
||||
|
||||
private void Map_Opacity_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (map.Opacity == 1)
|
||||
{
|
||||
map.Opacity = 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
map.Opacity = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
290
Plane.FormationCreator/Maps/MapConverter.cs
Normal file
290
Plane.FormationCreator/Maps/MapConverter.cs
Normal file
@ -0,0 +1,290 @@
|
||||
/* ----------------------------------------------------------
|
||||
* 文件名称:MapConverter.cs
|
||||
*
|
||||
* 作者:秦建辉
|
||||
*
|
||||
* 微信:splashcn
|
||||
*
|
||||
* 博客:http://www.firstsolver.com/wordpress/
|
||||
*
|
||||
* 开发环境:
|
||||
* Visual Studio V2017
|
||||
* .NETCore 1.1
|
||||
*
|
||||
* 版本历史:
|
||||
* V1.0 2017年05月16日
|
||||
* 坐标转换器
|
||||
*
|
||||
* 说明:
|
||||
* WGS84:为一种大地坐标系,也是目前广泛使用的GPS全球卫星定位系统使用的坐标系。
|
||||
* GCJ02:又称火星坐标系,是由中国国家测绘局制定的地理坐标系统,是由WGS84加密后得到的坐标系。
|
||||
* BD09:为百度坐标系,在GCJ02坐标系基础上再次加密。其中bd09ll表示百度经纬度坐标,bd09mc表示百度墨卡托米制坐标。
|
||||
*
|
||||
* 参考资料:
|
||||
* https://www.oschina.net/code/snippet_260395_39205
|
||||
------------------------------------------------------------ */
|
||||
using GMap.NET;
|
||||
using GMap.NET.WindowsPresentation;
|
||||
using Plane.FormationCreator.Formation;
|
||||
using System;
|
||||
|
||||
namespace Plane.FormationCreator.Maps
|
||||
{
|
||||
/// <summary>
|
||||
/// WGS-84、GCJ-02(火星坐标系)、BD-09(百度坐标系)之间的坐标转换器
|
||||
/// </summary>
|
||||
public static class MapConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Gmap的PointLatLng转换为WGS84
|
||||
/// </summary>
|
||||
/// <param name="GCJ02"></param>
|
||||
/// <returns></returns>
|
||||
public static LatLng ToWGS84(this PointLatLng LatLng_GCJ02)
|
||||
{
|
||||
// double WGS84_lat;
|
||||
// double WGS84_lng;
|
||||
// GCJ02ToWGS84Exact(LatLng_GCJ02.Lat, LatLng_GCJ02.Lng, out WGS84_lat, out WGS84_lng);
|
||||
// return new LatLng(WGS84_lat, WGS84_lng);
|
||||
return new LatLng(LatLng_GCJ02.Lat, LatLng_GCJ02.Lng);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LatLng转换为ToGCJ02
|
||||
/// </summary>
|
||||
/// <param name="LatLng_WGS84"></param>
|
||||
/// <returns></returns>
|
||||
public static PointLatLng ToGCJ02(this LatLng LatLng_WGS84)
|
||||
{
|
||||
|
||||
// double GCJ02_lat;
|
||||
// double GCJ02_lng;
|
||||
// WGS84ToGCJ02(LatLng_WGS84.Lat, LatLng_WGS84.Lng, out GCJ02_lat, out GCJ02_lng);
|
||||
// return new PointLatLng(GCJ02_lat, GCJ02_lng);
|
||||
return new PointLatLng(LatLng_WGS84.Lat, LatLng_WGS84.Lng);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 圆周率
|
||||
/// </summary>
|
||||
private const double PI = 3.1415926535897932384626;
|
||||
private const double X_PI = PI * 3000.0 / 180.0;
|
||||
|
||||
/// <summary>
|
||||
/// 地理位置是否位于中国以外
|
||||
/// </summary>
|
||||
/// <param name="wgLat">WGS-84坐标纬度</param>
|
||||
/// <param name="wgLon">WGS-84坐标经度</param>
|
||||
/// <returns>
|
||||
/// true:国外
|
||||
/// false:国内
|
||||
/// </returns>
|
||||
public static bool OutOfChina(double wgLat, double wgLon)
|
||||
{
|
||||
if (wgLon < 72.004 || wgLon > 137.8347) return true;
|
||||
if (wgLat < 0.8293 || wgLat > 55.8271) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WGS-84坐标系转火星坐标系 (GCJ-02)
|
||||
/// </summary>
|
||||
/// <param name="wgLat">WGS-84坐标纬度</param>
|
||||
/// <param name="wgLon">WGS-84坐标经度</param>
|
||||
/// <param name="mgLat">输出:GCJ-02坐标纬度</param>
|
||||
/// <param name="mgLon">输出:GCJ-02坐标经度</param>
|
||||
public static void WGS84ToGCJ02(double wgLat, double wgLon, out double mgLat, out double mgLon)
|
||||
{
|
||||
if (OutOfChina(wgLat, wgLon))
|
||||
{
|
||||
mgLat = wgLat;
|
||||
mgLon = wgLon;
|
||||
}
|
||||
else
|
||||
{
|
||||
double dLat;
|
||||
double dLon;
|
||||
Delta(wgLat, wgLon, out dLat, out dLon);
|
||||
mgLat = wgLat + dLat;
|
||||
mgLon = wgLon + dLon;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 火星坐标系 (GCJ-02)转WGS-84坐标系
|
||||
/// </summary>
|
||||
/// <param name="mgLat">GCJ-02坐标纬度</param>
|
||||
/// <param name="mgLon">GCJ-02坐标经度</param>
|
||||
/// <param name="wgLat">输出:WGS-84坐标纬度</param>
|
||||
/// <param name="wgLon">输出:WGS-84坐标经度</param>
|
||||
public static void GCJ02ToWGS84(double mgLat, double mgLon, out double wgLat, out double wgLon)
|
||||
{
|
||||
if (OutOfChina(mgLat, mgLon))
|
||||
{
|
||||
wgLat = mgLat;
|
||||
wgLon = mgLon;
|
||||
}
|
||||
else
|
||||
{
|
||||
double dLat;
|
||||
double dLon;
|
||||
Delta(mgLat, mgLon, out dLat, out dLon);
|
||||
wgLat = mgLat - dLat;
|
||||
wgLon = mgLon - dLon;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 火星坐标系 (GCJ-02)转WGS-84坐标系
|
||||
/// </summary>
|
||||
/// <param name="mgLat">GCJ-02坐标纬度</param>
|
||||
/// <param name="mgLon">GCJ-02坐标经度</param>
|
||||
/// <param name="wgLat">输出:WGS-84坐标纬度</param>
|
||||
/// <param name="wgLon">输出:WGS-84坐标经度</param>
|
||||
public static void GCJ02ToWGS84Exact(double mgLat, double mgLon, out double wgLat, out double wgLon)
|
||||
{
|
||||
const double InitDelta = 0.01;
|
||||
const double Threshold = 0.000001;
|
||||
|
||||
double dLat = InitDelta;
|
||||
double dLon = InitDelta;
|
||||
double mLat = mgLat - dLat;
|
||||
double mLon = mgLon - dLon;
|
||||
double pLat = mgLat + dLat;
|
||||
double pLon = mgLon + dLon;
|
||||
|
||||
double nLat;
|
||||
double nLon;
|
||||
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
wgLat = (mLat + pLat) / 2;
|
||||
wgLon = (mLon + pLon) / 2;
|
||||
|
||||
WGS84ToGCJ02(wgLat, wgLon, out nLat, out nLon);
|
||||
|
||||
dLat = nLat - mgLat;
|
||||
dLon = nLon - mgLon;
|
||||
if ((Math.Abs(dLat) < Threshold) && (Math.Abs(dLon) < Threshold)) break;
|
||||
|
||||
if (dLat > 0) pLat = wgLat; else mLat = wgLat;
|
||||
if (dLon > 0) pLon = wgLon; else mLon = wgLon;
|
||||
System.Diagnostics.Debug.WriteLine($"times:{i}");
|
||||
} while (++i <= 30);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 百度坐标系 (BD-09)转火星坐标系 (GCJ-02)
|
||||
/// </summary>
|
||||
/// <param name="bdLat">百度坐标系纬度</param>
|
||||
/// <param name="bdLon">百度坐标系经度</param>
|
||||
/// <param name="mgLat">输出:GCJ-02坐标纬度</param>
|
||||
/// <param name="mgLon">输出:GCJ-02坐标经度</param>
|
||||
public static void BD09ToGCJ02(double bdLat, double bdLon, out double mgLat, out double mgLon)
|
||||
{
|
||||
double x = bdLon - 0.0065;
|
||||
double y = bdLat - 0.006;
|
||||
double z = Math.Sqrt(x * x + y * y) - 0.00002 * Math.Sin(y * X_PI);
|
||||
double theta = Math.Atan2(y, x) - 0.000003 * Math.Cos(x * X_PI);
|
||||
mgLat = z * Math.Sin(theta);
|
||||
mgLon = z * Math.Cos(theta);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 火星坐标系 (GCJ-02)转百度坐标系 (BD-09)
|
||||
/// </summary>
|
||||
/// <param name="mgLat">GCJ-02坐标纬度</param>
|
||||
/// <param name="mgLon">GCJ-02坐标经度</param>
|
||||
/// <param name="bdLat">输出:百度坐标系纬度</param>
|
||||
/// <param name="bdLon">输出:百度坐标系经度</param>
|
||||
public static void GCJ02ToBD09(double mgLat, double mgLon, out double bdLat, out double bdLon)
|
||||
{
|
||||
double x = mgLon;
|
||||
double y = mgLat;
|
||||
double z = Math.Sqrt(x * x + y * y) + 0.00002 * Math.Sin(y * X_PI);
|
||||
double theta = Math.Atan2(y, x) + 0.000003 * Math.Cos(x * X_PI);
|
||||
bdLat = z * Math.Sin(theta) + 0.006;
|
||||
bdLon = z * Math.Cos(theta) + 0.0065;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WGS-84坐标系转百度坐标系 (BD-09)
|
||||
/// </summary>
|
||||
/// <param name="wgLat">WGS-84坐标纬度</param>
|
||||
/// <param name="wgLon">WGS-84坐标经度</param>
|
||||
/// <param name="bdLat">输出:百度坐标系纬度</param>
|
||||
/// <param name="bdLon">输出:百度坐标系经度</param>
|
||||
public static void WGS84ToBD09(double wgLat, double wgLon, out double bdLat, out double bdLon)
|
||||
{
|
||||
double mgLat;
|
||||
double mgLon;
|
||||
|
||||
WGS84ToGCJ02(wgLat, wgLon, out mgLat, out mgLon);
|
||||
GCJ02ToBD09(mgLat, mgLon, out bdLat, out bdLon);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 百度坐标系 (BD-09)转WGS-84坐标系
|
||||
/// </summary>
|
||||
/// <param name="bdLat">百度坐标系纬度</param>
|
||||
/// <param name="bdLon">百度坐标系经度</param>
|
||||
/// <param name="wgLat">输出:WGS-84坐标纬度</param>
|
||||
/// <param name="wgLon">输出:WGS-84坐标经度</param>
|
||||
public static void BD09ToWGS84(double bdLat, double bdLon, out double wgLat, out double wgLon)
|
||||
{
|
||||
double mgLat;
|
||||
double mgLon;
|
||||
|
||||
BD09ToGCJ02(bdLat, bdLon, out mgLat, out mgLon);
|
||||
GCJ02ToWGS84(mgLat, mgLon, out wgLat, out wgLon);
|
||||
}
|
||||
|
||||
public static double Distance(double LatA, double LonA, double LatB, double LonB)
|
||||
{
|
||||
const double EarthR = 6371000.0;
|
||||
|
||||
double x = Math.Cos(LatA * PI / 180.0) * Math.Cos(LatB * PI / 180.0) * Math.Cos((LonA - LonB) * PI / 180);
|
||||
double y = Math.Sin(LatA * PI / 180.0) * Math.Sin(LatB * PI / 180.0);
|
||||
double s = x + y;
|
||||
if (s > 1) s = 1;
|
||||
if (s < -1) s = -1;
|
||||
|
||||
return Math.Acos(s) * EarthR;
|
||||
}
|
||||
|
||||
private static void Delta(double Lat, double Lon, out double dLat, out double dLon)
|
||||
{
|
||||
const double AXIS = 6378245.0;
|
||||
const double EE = 0.00669342162296594323;
|
||||
|
||||
dLat = TransformLat(Lon - 105.0, Lat - 35.0);
|
||||
dLon = TransformLon(Lon - 105.0, Lat - 35.0);
|
||||
double radLat = Lat / 180.0 * PI;
|
||||
double magic = Math.Sin(radLat);
|
||||
magic = 1 - EE * magic * magic;
|
||||
double sqrtMagic = Math.Sqrt(magic);
|
||||
dLat = (dLat * 180.0) / ((AXIS * (1 - EE)) / (magic * sqrtMagic) * PI);
|
||||
dLon = (dLon * 180.0) / (AXIS / sqrtMagic * Math.Cos(radLat) * PI);
|
||||
}
|
||||
|
||||
private static double TransformLat(double x, double y)
|
||||
{
|
||||
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.Sqrt(Math.Abs(x));
|
||||
ret += (20.0 * Math.Sin(6.0 * x * PI) + 20.0 * Math.Sin(2.0 * x * PI)) * 2.0 / 3.0;
|
||||
ret += (20.0 * Math.Sin(y * PI) + 40.0 * Math.Sin(y / 3.0 * PI)) * 2.0 / 3.0;
|
||||
ret += (160.0 * Math.Sin(y / 12.0 * PI) + 320 * Math.Sin(y * PI / 30.0)) * 2.0 / 3.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static double TransformLon(double x, double y)
|
||||
{
|
||||
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.Sqrt(Math.Abs(x));
|
||||
ret += (20.0 * Math.Sin(6.0 * x * PI) + 20.0 * Math.Sin(2.0 * x * PI)) * 2.0 / 3.0;
|
||||
ret += (20.0 * Math.Sin(x * PI) + 40.0 * Math.Sin(x / 3.0 * PI)) * 2.0 / 3.0;
|
||||
ret += (150.0 * Math.Sin(x / 12.0 * PI) + 300.0 * Math.Sin(x / 30.0 * PI)) * 2.0 / 3.0;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
@ -14,6 +14,8 @@
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@ -25,6 +27,8 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>true</UseVSHostingProcess>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@ -39,6 +43,14 @@
|
||||
<ApplicationIcon>gcs.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<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>
|
||||
<Private>True</Private>
|
||||
@ -51,6 +63,22 @@
|
||||
<HintPath>..\packages\MvvmLightLibs.5.2.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="GMap.NET.Core, Version=1.8.5.0, Culture=neutral, PublicKeyToken=b85b9027b614afef, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\GMap.NET.Windows.1.8.5\lib\net40\GMap.NET.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="GMap.NET.WindowsPresentation, Version=1.8.5.0, Culture=neutral, PublicKeyToken=b85b9027b614afef, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\GMap.NET.Windows.1.8.5\lib\net40\GMap.NET.WindowsPresentation.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="HelixToolkit, Version=2.4.0.0, Culture=neutral, PublicKeyToken=52aa3500039caf0d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\HelixToolkit.2.4.0\lib\netstandard1.1\HelixToolkit.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="HelixToolkit.Wpf, Version=2.4.0.0, Culture=neutral, PublicKeyToken=52aa3500039caf0d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\HelixToolkit.Wpf.2.4.0\lib\net45\HelixToolkit.Wpf.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -71,13 +99,26 @@
|
||||
<Reference Include="Microsoft.Practices.ServiceLocation">
|
||||
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework.Aero" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Data.SQLite.Core.1.0.109.1\lib\net46\System.Data.SQLite.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SQLite.EF6, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Data.SQLite.EF6.1.0.109.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SQLite.Linq, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.109.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -140,8 +181,8 @@
|
||||
<Compile Include="Formation\FlightTaskManager.cs" />
|
||||
<Compile Include="Formation\PropertyChangedEventArgs.cs" />
|
||||
<Compile Include="Formation\FlightTask_TakeOff.cs" />
|
||||
<Compile Include="Maps\OpenStreetMapTileLayer.cs" />
|
||||
<Compile Include="Maps\OpenStreetMapTileSource.cs" />
|
||||
<Compile Include="GMap.cs" />
|
||||
<Compile Include="Maps\MapConverter.cs" />
|
||||
<Compile Include="ModifyParam.xaml.cs">
|
||||
<DependentUpon>ModifyParam.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -157,6 +198,7 @@
|
||||
<Compile Include="ViewModels\ModifyTaskViewModel.cs" />
|
||||
<Compile Include="ViewModels\ModiLEDModel.cs" />
|
||||
<Compile Include="ViewModels\TaskBarViewModel.cs" />
|
||||
<Compile Include="ViewModels\View3DViewModel.cs" />
|
||||
<Compile Include="Views\ControlPanelView.xaml.cs">
|
||||
<DependentUpon>ControlPanelView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -179,9 +221,15 @@
|
||||
<Compile Include="Views\ModifyTaskView.xaml.cs">
|
||||
<DependentUpon>ModifyTaskView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\SetCoptersPutView.xaml.cs">
|
||||
<DependentUpon>SetCoptersPutView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\TaskBarView.xaml.cs">
|
||||
<DependentUpon>TaskBarView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\View3D.xaml.cs">
|
||||
<DependentUpon>View3D.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
@ -291,10 +339,18 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\SetCoptersPutView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\TaskBarView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\View3D.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Plane.Libraries\Plane.Logging\Plane.Logging.csproj">
|
||||
@ -336,6 +392,13 @@
|
||||
<Resource Include="bg.jpg" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\System.Data.SQLite.Core.1.0.109.1\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.109.1\build\net46\System.Data.SQLite.Core.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.109.1\build\net46\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.109.1\build\net46\System.Data.SQLite.Core.targets'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
@ -0,0 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Plane.FormationCreator.Properties">
|
||||
|
||||
</ResourceDictionary>
|
@ -31,6 +31,7 @@ namespace Plane.FormationCreator
|
||||
_container.Register<ControlPanelViewModel>();
|
||||
_container.Register<CopterListViewModel>();
|
||||
_container.Register<TaskBarViewModel>();
|
||||
_container.Register<View3DViewModel>();
|
||||
_container.Register<ModifyTaskViewModel>();
|
||||
|
||||
_container.Register<ILogger>(() => new LocalFileLogger(new DebugLogger()));
|
||||
|
@ -8,10 +8,10 @@
|
||||
<SolidColorBrush x:Key="Background"
|
||||
Color="#1C1C1C" />
|
||||
<SolidColorBrush x:Key="LightBackground"
|
||||
Color="#2D2D30" />
|
||||
Color="#001B35" />
|
||||
<Color x:Key="AccentColor">Transparent</Color>
|
||||
<Color x:Key="BlackColor">#FFFFFFFF</Color>
|
||||
<Color x:Key="WhiteColor">#2D2D30</Color>
|
||||
<Color x:Key="WhiteColor">#001B35</Color>
|
||||
<Color x:Key="HighlightColor">Transparent</Color>
|
||||
|
||||
<!-- re-set brushes too -->
|
||||
|
119
Plane.FormationCreator/Util/ParamFile.cs
Normal file
119
Plane.FormationCreator/Util/ParamFile.cs
Normal file
@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace Plane.Util
|
||||
{
|
||||
public class ParamFile
|
||||
{
|
||||
//private static readonly ILog log =
|
||||
// LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public static string FileMask = "Parameter File|*.param;*.parm|All Files|*.*";
|
||||
|
||||
public static Dictionary<string, double> loadParamFile(string Filename)
|
||||
{
|
||||
Dictionary<string, double> param = new Dictionary<string, double>();
|
||||
|
||||
using (StreamReader sr = new StreamReader(Filename))
|
||||
{
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
string line = sr.ReadLine();
|
||||
|
||||
if (line.Contains("NOTE:"))
|
||||
{
|
||||
// CustomMessageBox.Show(line, "Saved Note");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.StartsWith("#"))
|
||||
continue;
|
||||
|
||||
string[] items = line.Split(new char[] {' ', ',', '\t'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (items.Length != 2)
|
||||
continue;
|
||||
|
||||
string name = items[0];
|
||||
double value = 0;
|
||||
try
|
||||
{
|
||||
value = double.Parse(items[1], System.Globalization.CultureInfo.InvariantCulture);
|
||||
// new System.Globalization.CultureInfo("en-US"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//log.Error(ex);
|
||||
throw new FormatException("Invalid number on param " + name + " : " + items[1].ToString());
|
||||
}
|
||||
|
||||
if (name == "SYSID_SW_MREV")
|
||||
continue;
|
||||
if (name == "WP_TOTAL")
|
||||
continue;
|
||||
if (name == "CMD_TOTAL")
|
||||
continue;
|
||||
if (name == "FENCE_TOTAL")
|
||||
continue;
|
||||
if (name == "SYS_NUM_RESETS")
|
||||
continue;
|
||||
if (name == "ARSPD_OFFSET")
|
||||
continue;
|
||||
if (name == "GND_ABS_PRESS")
|
||||
continue;
|
||||
if (name == "GND_TEMP")
|
||||
continue;
|
||||
if (name == "CMD_INDEX")
|
||||
continue;
|
||||
if (name == "LOG_LASTFILE")
|
||||
continue;
|
||||
if (name == "FORMAT_VERSION")
|
||||
continue;
|
||||
|
||||
param[name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
public static void SaveParamFile(string fn, Hashtable paramlist)
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(File.Open(fn, FileMode.Create)))
|
||||
{
|
||||
string input = DateTime.Now + " Frame : ";
|
||||
//if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduPlane)
|
||||
// {
|
||||
// input = DateTime.Now + " Plane: Skywalker";
|
||||
// }
|
||||
// InputBox.Show("Custom Note", "Enter your Notes/Frame Type etc", ref input);
|
||||
if (input != "")
|
||||
sw.WriteLine("#NOTE: " + input.Replace(',', '|'));
|
||||
|
||||
var list = new SortedList(paramlist);
|
||||
|
||||
foreach (var item in list.Keys)
|
||||
{
|
||||
double value = double.Parse(paramlist[item].ToString());
|
||||
|
||||
string valueasstring = value.ToString(new System.Globalization.CultureInfo("en-US"));
|
||||
|
||||
if (valueasstring.Contains("."))
|
||||
{
|
||||
sw.WriteLine(item + "," +
|
||||
((float) value).ToString(new System.Globalization.CultureInfo("en-US")));
|
||||
}
|
||||
else
|
||||
{
|
||||
sw.WriteLine(item + "," + valueasstring);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -195,6 +195,18 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _UpdateAllCopterCommand;
|
||||
public ICommand UpdateAllCopterCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _UpdateAllCopterCommand ?? (_UpdateAllCopterCommand = new RelayCommand(async () =>
|
||||
{
|
||||
await commModule.UpdateCommModule();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _CommDataAsync;
|
||||
public ICommand CommDataAsync
|
||||
{
|
||||
|
@ -940,7 +940,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
int utcsecond = DateTime.UtcNow.AddSeconds(5).Second;
|
||||
|
||||
//循环3次 发送起飞命令 避免通信问题
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
await _commModuleManager.DoMissionStartAsync(utchour,
|
||||
utcminute,
|
||||
@ -949,7 +949,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
_flightTaskManager.OriginLat
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
foreach (var vcopter in _copterManager.Copters)
|
||||
{
|
||||
await vcopter.MissionStartAsync(utchour,
|
||||
@ -959,6 +959,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
_flightTaskManager.OriginLat
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
}
|
||||
@ -1185,7 +1186,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
foreach (LEDInfo ledInfo in LEDInfos)
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString("#" + ledInfo.LEDRGB);
|
||||
if (ledInfo.LEDMode == 5) ledInfo.LEDMode = 6;
|
||||
//if (ledInfo.LEDMode == 5) ledInfo.LEDMode = 6;
|
||||
IMission LEDMission = Mission.CreateLEDControlMission(
|
||||
(int)(ledInfo.Delay * 10),
|
||||
ledInfo.LEDMode,
|
||||
|
@ -25,13 +25,12 @@ namespace Plane.FormationCreator.ViewModels
|
||||
_copterManager = copterManager;
|
||||
_mapManager = mapManager;
|
||||
_flightTaskManager = flightTaskManager;
|
||||
/*
|
||||
System.Timers.Timer t = new System.Timers.Timer(5000); //实例化Timer类,设置间隔时间为1秒;
|
||||
t.Elapsed += new System.Timers.ElapsedEventHandler(theout); //到达时间的时候执行事件;
|
||||
t.AutoReset = true; //设置是执行一次(false)还是一直执行(true);
|
||||
t.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件;
|
||||
|
||||
|
||||
|
||||
t.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件;
|
||||
*/
|
||||
}
|
||||
|
||||
public void theout(object source, System.Timers.ElapsedEventArgs e)
|
||||
@ -46,16 +45,12 @@ namespace Plane.FormationCreator.ViewModels
|
||||
allrec += copterrec;
|
||||
allsend += coptersend;
|
||||
copter.ResetCommunicationNumber();
|
||||
|
||||
|
||||
}
|
||||
allrec /= 5;
|
||||
allsend /= 5;
|
||||
if (_copterManager.Copters.Count>0)
|
||||
Communinfo = "接收:" + allrec + "/s;发送:"+ allsend+"/s 单机:"+ allrec/ _copterManager.Copters.Count+"/s;"+
|
||||
allsend / _copterManager.Copters.Count+"/s";
|
||||
|
||||
|
||||
}
|
||||
|
||||
private CopterManager _copterManager;
|
||||
@ -74,7 +69,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
private int _virtualCopterId = 1;
|
||||
private LatLng? _lastVirtualCopterLocation;
|
||||
|
||||
private string _Communinfo = "0字节/秒";
|
||||
private string _Communinfo = "";
|
||||
public string Communinfo
|
||||
{
|
||||
get { return _Communinfo; }
|
||||
@ -95,6 +90,8 @@ namespace Plane.FormationCreator.ViewModels
|
||||
set { Set(nameof(ContinuousNum), ref _ContinuousNum, value); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ICommand _IntervalSelectCoptersCommand;
|
||||
public ICommand IntervalSelectCoptersCommand
|
||||
{
|
||||
@ -134,9 +131,9 @@ namespace Plane.FormationCreator.ViewModels
|
||||
var center = _mapManager.Center;
|
||||
string id;
|
||||
|
||||
int colnum = 5; //自动生成列数=4
|
||||
float coldis = 3.5f;//列相距5米
|
||||
float rowdis = 3f;//行相距5米
|
||||
int colnum = _flightTaskManager.ColumnCount; //自动生成列数=4
|
||||
float coldis = _flightTaskManager.ColumnDistance;//列相距5米
|
||||
float rowdis = _flightTaskManager.RowDistance;//行相距5米
|
||||
int currcol = 0; //当前列号
|
||||
int currrow = 0; //当前行
|
||||
Tuple<double, double> colheadLatLng = new Tuple<double, double>(0, 0);
|
||||
@ -147,8 +144,6 @@ namespace Plane.FormationCreator.ViewModels
|
||||
for (int i = 0; i < addcount; ++i, ++_virtualCopterId)
|
||||
{
|
||||
id = _virtualCopterId.ToString();
|
||||
|
||||
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
@ -196,13 +191,39 @@ namespace Plane.FormationCreator.ViewModels
|
||||
);
|
||||
await copter.ConnectAsync();
|
||||
await copter.GetCopterDataAsync();
|
||||
_copterManager.Copters.Add(copter);
|
||||
_copterManager.Copters.AddCopter(copter);
|
||||
_copterManager.CopterStatus.Add(false);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _SetCoptersPutCommand;
|
||||
public ICommand SetCoptersPutCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SetCoptersPutCommand ?? (_SetCoptersPutCommand = new RelayCommand(async () =>
|
||||
{
|
||||
var SetCoptersPutView = new Views.SetCoptersPutView(
|
||||
_flightTaskManager.ColumnCount,
|
||||
_flightTaskManager.ColumnDistance,
|
||||
_flightTaskManager.RowDistance,
|
||||
_flightTaskManager.Orientation
|
||||
);
|
||||
if (SetCoptersPutView.ShowDialog() == true)
|
||||
{
|
||||
_flightTaskManager.ColumnCount = int.Parse(SetCoptersPutView.textboxColNum.Text);
|
||||
_flightTaskManager.ColumnDistance = float.Parse(SetCoptersPutView.textboxColDis.Text);
|
||||
_flightTaskManager.RowDistance = float.Parse(SetCoptersPutView.textboxRowDis.Text);
|
||||
_flightTaskManager.Orientation = int.Parse(SetCoptersPutView.textboxOrientation.Text);
|
||||
_flightTaskManager.SaveIni();
|
||||
}
|
||||
await Task.Delay(100);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _ClearCoptersCommand;
|
||||
public ICommand ClearCoptersCommand
|
||||
{
|
||||
|
@ -22,6 +22,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
_copterListViewModel = copterListViewModel;
|
||||
|
||||
Plane.Windows.Messages.Message.Configure(showAction: msg => this.Message = msg);
|
||||
Plane.Windows.Messages.Message.Configure(connectAction: connected => this.CommunicationModuleConnected = connected);
|
||||
|
||||
this.SwitchVelocityModeButtonContent = GetSwitchVelocityModeButtonContent();
|
||||
|
||||
@ -63,6 +64,16 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private bool _CommunicationModuleConnected;
|
||||
public bool CommunicationModuleConnected
|
||||
{
|
||||
get { return _CommunicationModuleConnected; }
|
||||
set
|
||||
{
|
||||
Set(nameof(CommunicationModuleConnected), ref _CommunicationModuleConnected, value);
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> _MessageList = new List<string>();
|
||||
|
||||
public string Messages
|
||||
@ -137,6 +148,30 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private int _MapMode=0;
|
||||
public int MapMode
|
||||
{
|
||||
get { return _MapMode; }
|
||||
set { Set(nameof(MapMode), ref _MapMode, value); }
|
||||
}
|
||||
|
||||
private ICommand _ChangeMapModeCommand;
|
||||
public ICommand ChangeMapModeCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ChangeMapModeCommand ?? (_ChangeMapModeCommand = new RelayCommand(() =>
|
||||
{
|
||||
if (MapMode == 0)
|
||||
MapMode = 1;
|
||||
else
|
||||
MapMode = 0;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private ICommand _ExportTasksCommand;
|
||||
public ICommand ExportTasksCommand
|
||||
|
13
Plane.FormationCreator/ViewModels/ModiLEDModel.cs
Normal file
13
Plane.FormationCreator/ViewModels/ModiLEDModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using GalaSoft.MvvmLight;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
class ModiLEDModel : ViewModelBase
|
||||
{
|
||||
}
|
||||
}
|
12
Plane.FormationCreator/ViewModels/ModiLEDViewModel.cs
Normal file
12
Plane.FormationCreator/ViewModels/ModiLEDViewModel.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
class ModiLEDViewModel :ViewModelBase
|
||||
{
|
||||
}
|
||||
}
|
@ -278,6 +278,28 @@ namespace Plane.FormationCreator.ViewModels
|
||||
double tlng = 0;
|
||||
double avgl = 0;
|
||||
|
||||
if (_copterManager.SelectedCopters.Count() > 2)
|
||||
{
|
||||
List<FlightTaskSingleCopterInfo> selectTaskInfos = new List<FlightTaskSingleCopterInfo>();
|
||||
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
||||
{
|
||||
|
||||
if (_copterManager.SelectedCopters.Contains(_flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter))
|
||||
selectTaskInfos.Add(_flightTaskManager.SelectedTask.SingleCopterInfos[i]);
|
||||
}
|
||||
selectTaskInfos.Sort((x, y) => x.TargetLng.CompareTo(y.TargetLng));
|
||||
minlng = selectTaskInfos[0].TargetLng;
|
||||
maxlng = selectTaskInfos[selectTaskInfos.Count - 1].TargetLng;
|
||||
tlng = (maxlng - minlng) / (selectTaskInfos.Count - 1);
|
||||
|
||||
for (int i = 0; i < selectTaskInfos.Count; i++)
|
||||
{
|
||||
selectTaskInfos[i].TargetLng = minlng + i * tlng;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (Alert.Show("本操作将导致飞机位置重新排列,编号最小的飞机在最左边,您确定要继续吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
|
||||
== MessageBoxResult.OK)
|
||||
{
|
||||
@ -334,7 +356,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
///////////////////////
|
||||
|
||||
// await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
||||
@ -359,6 +381,27 @@ namespace Plane.FormationCreator.ViewModels
|
||||
|
||||
double avgl = 0;
|
||||
|
||||
if (_copterManager.SelectedCopters.Count() > 2)
|
||||
{
|
||||
List<FlightTaskSingleCopterInfo> selectTaskInfos = new List<FlightTaskSingleCopterInfo>();
|
||||
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
||||
{
|
||||
|
||||
if (_copterManager.SelectedCopters.Contains(_flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter))
|
||||
selectTaskInfos.Add(_flightTaskManager.SelectedTask.SingleCopterInfos[i]);
|
||||
}
|
||||
selectTaskInfos.Sort((x, y) => x.TargetLat.CompareTo(y.TargetLat));
|
||||
minlat = selectTaskInfos[0].TargetLat;
|
||||
maxlat = selectTaskInfos[selectTaskInfos.Count - 1].TargetLat;
|
||||
tlat = (maxlat - minlat) / (selectTaskInfos.Count - 1);
|
||||
|
||||
for (int i = 0; i < selectTaskInfos.Count; i++)
|
||||
{
|
||||
selectTaskInfos[i].TargetLat = minlat + i * tlat;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (Alert.Show("本操作将导致飞机位置重新排列,编号最小的飞机在最上边,您确定要继续吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
|
||||
== MessageBoxResult.OK)
|
||||
{
|
||||
@ -414,12 +457,12 @@ namespace Plane.FormationCreator.ViewModels
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
|
||||
// await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}));
|
||||
}
|
||||
}
|
||||
@ -1183,6 +1226,8 @@ public ICommand VerticlAlignmentCommand
|
||||
{
|
||||
return _calDistinceCommand ?? (_calDistinceCommand = new RelayCommand<double>(async =>
|
||||
{
|
||||
if (_copterManager.AcceptingControlCopters.Count() < 2)
|
||||
return;
|
||||
|
||||
double minDistance = double.MaxValue;
|
||||
|
||||
@ -1222,6 +1267,34 @@ public ICommand VerticlAlignmentCommand
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _WayPointDistinceCommand;
|
||||
public ICommand WayPointDistinceCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _WayPointDistinceCommand ?? (_WayPointDistinceCommand = new RelayCommand<double>(async =>
|
||||
{
|
||||
if (_copterManager.AcceptingControlCopters.Count() != 1)
|
||||
return;
|
||||
|
||||
int taskIndex = _flightTaskManager.SelectedTaskIndex;
|
||||
if (taskIndex != 0 || _flightTaskManager.SelectedTask.TaskType == FlightTaskType.FlyTo)
|
||||
{
|
||||
var curCopter = _copterManager.AcceptingControlCopters.First();
|
||||
|
||||
var prevWaypoint = _flightTaskManager.Tasks[taskIndex - 1].SingleCopterInfos.FirstOrDefault(c => c.Copter == curCopter);
|
||||
var curWaypoint = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.FirstOrDefault(c => c.Copter == curCopter);
|
||||
|
||||
double distance = GeographyUtils.CalcDistance(
|
||||
prevWaypoint.TargetLat, prevWaypoint.TargetLng, prevWaypoint.TargetAlt,
|
||||
curWaypoint.TargetLat, curWaypoint.TargetLng, curWaypoint.TargetAlt);
|
||||
|
||||
Message.Show($"航点间距 = {distance}");
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
86
Plane.FormationCreator/ViewModels/View3DViewModel.cs
Normal file
86
Plane.FormationCreator/ViewModels/View3DViewModel.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using HelixToolkit.Wpf;
|
||||
using Plane.FormationCreator.Formation;
|
||||
using Plane.Geography;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Media3D;
|
||||
|
||||
namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
public class View3DViewModel : ViewModelBase
|
||||
{
|
||||
private FlightTaskManager _flightTaskManager;
|
||||
|
||||
public View3DViewModel(FlightTaskManager flightTaskManager)
|
||||
{
|
||||
modelGroup = new Model3DGroup();
|
||||
planeGroup = new Model3DGroup();
|
||||
waypointGroup = new Model3DGroup();
|
||||
modelGroup.Children.Add(planeGroup);
|
||||
modelGroup.Children.Add(waypointGroup);
|
||||
this.Model = modelGroup;
|
||||
_flightTaskManager = flightTaskManager;
|
||||
_flightTaskManager.PropertyChanged += new PropertyChangedEventHandler(flightTaskPropertyChanged);
|
||||
}
|
||||
|
||||
private void flightTaskPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(FlightTaskManager.SelectedTaskIndex):
|
||||
SelectTask();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectTask()
|
||||
{
|
||||
if (_flightTaskManager.SelectedTaskIndex > 0)
|
||||
{
|
||||
//modelGroup.Children.Clear();
|
||||
if (waypointGroup == null) waypointGroup = new Model3DGroup();
|
||||
waypointGroup.Children.Clear();
|
||||
|
||||
|
||||
var meshBuilderwaypoint = new MeshBuilder(false, false);
|
||||
meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.3);
|
||||
var meshwaypoint = meshBuilderwaypoint.ToMesh(true);
|
||||
var greenMaterial = MaterialHelper.CreateMaterial(Color.FromRgb(0,255,0));
|
||||
|
||||
foreach (FlightTaskSingleCopterInfo info in _flightTaskManager.Tasks[_flightTaskManager.SelectedTaskIndex].SingleCopterInfos)
|
||||
{
|
||||
|
||||
double x = GeographyUtils.CalcDistance(_flightTaskManager.OriginLng, 0, 0, info.TargetLng, 0, 0);
|
||||
if (_flightTaskManager.OriginLng > info.TargetLng) x = -x;
|
||||
double y = GeographyUtils.CalcDistance(0, _flightTaskManager.OriginLat, 0, 0, info.TargetLat, 0);
|
||||
if (_flightTaskManager.OriginLat > info.TargetLat) y = -y;
|
||||
|
||||
waypointGroup.Children.Add(new GeometryModel3D
|
||||
{
|
||||
Geometry = meshwaypoint,
|
||||
Transform = new TranslateTransform3D(x, y, info.TargetAlt),
|
||||
Material = greenMaterial,
|
||||
BackMaterial = greenMaterial
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Model3D Model { get; set; }
|
||||
public Model3DGroup modelGroup { get; set; }
|
||||
|
||||
public Model3DGroup planeGroup { get; set; }
|
||||
public Model3DGroup waypointGroup { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
Title="连接"
|
||||
Width="429.175"
|
||||
Height="570.371"
|
||||
Style="{StaticResource VSWindowStyleKey}"
|
||||
|
||||
WindowStartupLocation="CenterScreen"
|
||||
FontFamily="Microsoft YaHei"
|
||||
ResizeMode="NoResize">
|
||||
@ -67,6 +67,7 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@ -143,5 +144,12 @@
|
||||
<Button Content="搜索飞机" Margin="5" Command="{Binding QueryAllCopterCommand}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="4"
|
||||
Grid.ColumnSpan="3">
|
||||
<Button Content="空中升级" Margin="5" Command="{Binding UpdateAllCopterCommand}"></Button>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</c:MetroWindow>
|
||||
|
@ -20,6 +20,7 @@
|
||||
<ListBox x:Name="lvwDrones"
|
||||
ItemsSource="{Binding CopterManager.Copters}"
|
||||
SelectedItem="{Binding SelectedCopter}"
|
||||
PreviewKeyDown="_listBoxCopters_PreviewKeyDown"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
SelectionMode="Extended"
|
||||
@ -77,8 +78,11 @@
|
||||
Command="{Binding AddVirtualCopterCommand}"
|
||||
CommandParameter="{Binding Text, ElementName=txtVirtualCopterCount}" />
|
||||
<Button Content="清除"
|
||||
Margin="5,0,5,0"
|
||||
Margin="5,0,0,0"
|
||||
Command="{Binding ClearCoptersCommand}" />
|
||||
<Button Content="设置"
|
||||
Margin="5,0,5,0"
|
||||
Command="{Binding SetCoptersPutCommand}" />
|
||||
<TextBlock Text="总数"
|
||||
Margin="5,5,0,0"/>
|
||||
<TextBlock Text="{Binding CopterManager.Copters.Count}"
|
||||
|
@ -37,6 +37,7 @@ namespace Plane.FormationCreator.Views
|
||||
lvwDrones.SelectionChanged += (sender, e) =>
|
||||
{
|
||||
_copterManager.RaiseSelectedCoptersChanged(e.AddedItems.Cast<ICopter>(), e.RemovedItems.Cast<ICopter>());
|
||||
lvwDrones.ScrollIntoView(lvwDrones.SelectedItem);
|
||||
};
|
||||
}
|
||||
|
||||
@ -65,5 +66,31 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
lvwDrones.SelectedItems.Clear();
|
||||
}
|
||||
|
||||
private void _listBoxCopters_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (!this.lvwDrones.HasItems)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool prev = e.Key == Key.Up;
|
||||
bool next = e.Key == Key.Down;
|
||||
if (prev | next)
|
||||
{
|
||||
int afterIndex;
|
||||
if (prev)
|
||||
{
|
||||
afterIndex = lvwDrones.SelectedIndex - 1;
|
||||
lvwDrones.SelectedIndex = afterIndex < 0 ? 0 : afterIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
afterIndex = lvwDrones.SelectedIndex + 1;
|
||||
lvwDrones.SelectedIndex = afterIndex > lvwDrones.Items.Count - 1 ? lvwDrones.Items.Count - 1 : afterIndex;
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
Plane.FormationCreator/Views/LogUserControl.xaml
Normal file
12
Plane.FormationCreator/Views/LogUserControl.xaml
Normal file
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Plane.FormationCreator.Views.LogUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Plane.FormationCreator.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<TextBox/>
|
||||
</Grid>
|
||||
</UserControl>
|
28
Plane.FormationCreator/Views/LogUserControl.xaml.cs
Normal file
28
Plane.FormationCreator/Views/LogUserControl.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Plane.FormationCreator.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// LogUserControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class LogUserControl : UserControl
|
||||
{
|
||||
public LogUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -6,12 +6,14 @@
|
||||
xmlns:local="clr-namespace:Plane.FormationCreator.Views"
|
||||
xmlns:c="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
xmlns:ec="clr-namespace:Plane.Windows.Controls;assembly=Plane.Windows"
|
||||
xmlns:src="clr-namespace:Plane.GoogleMap"
|
||||
mc:Ignorable="d"
|
||||
Style="{StaticResource VSWindowStyleKey}"
|
||||
|
||||
Title="日志" Height="776.219" Width="1195.283">
|
||||
|
||||
<Grid>
|
||||
<TabControl>
|
||||
<src:GMap x:Name="mapControl" Zoom="13" MaxZoom="24" MinZoom="1" />
|
||||
<TabControl Visibility="Collapsed">
|
||||
<TabItem Header="软件日志">
|
||||
<TextBox
|
||||
Name="textAppLog"
|
||||
@ -20,7 +22,8 @@
|
||||
Margin="10,10,10,10"
|
||||
TextWrapping="Wrap"
|
||||
IsReadOnly="True"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"/>
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||
/>
|
||||
</TabItem>
|
||||
<TabItem Header="飞机日志">
|
||||
<TextBox
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Plane.FormationCreator.Formation;
|
||||
|
||||
using Plane.FormationCreator.Formation;
|
||||
using Plane.FormationCreator.ViewModels;
|
||||
using MahApps.Metro.Controls;
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
@ -18,6 +19,10 @@ using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Plane.Logging;
|
||||
using GMap.NET;
|
||||
using GMap.NET.MapProviders;
|
||||
using GMap.NET.WindowsPresentation;
|
||||
using Plane.FormationCreator.Maps;
|
||||
|
||||
namespace Plane.FormationCreator.Views
|
||||
{
|
||||
@ -29,6 +34,8 @@ namespace Plane.FormationCreator.Views
|
||||
public LogWindow(string log)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
textAppLog.Text = log;
|
||||
textAppLog.SelectionStart = textAppLog.Text.Length;
|
||||
textAppLog.ScrollToEnd();
|
||||
@ -36,6 +43,37 @@ namespace Plane.FormationCreator.Views
|
||||
string loger = _logger.ReadLog();
|
||||
textCopterLog.Text = loger;
|
||||
textCopterLog.SelectionStart = textCopterLog.Text.Length;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("ditu.google.cn");
|
||||
}
|
||||
catch
|
||||
{
|
||||
mapControl.Manager.Mode = AccessMode.CacheOnly;
|
||||
MessageBox.Show("No internet connection avaible, going to CacheOnly mode.", "GMap.NET Demo", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
|
||||
mapControl.MapProvider = GMapProviders.GoogleChinaSatelliteMap; //google china 地图
|
||||
mapControl.MinZoom = 2; //最小缩放
|
||||
mapControl.MaxZoom = 23; //最大缩放
|
||||
mapControl.Zoom = 19; //当前缩放
|
||||
mapControl.ShowCenter = true; //不显示中心十字点
|
||||
|
||||
mapControl.DragButton = MouseButton.Left; //左键拖拽地图
|
||||
mapControl.Position = new LatLng(40.07734857737275, 116.34323845862502).ToGCJ02();
|
||||
|
||||
mapControl.MouseLeftButtonDown += new MouseButtonEventHandler(mapControl_MouseLeftButtonDown);
|
||||
|
||||
}
|
||||
|
||||
void mapControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Point clickPoint = e.GetPosition(mapControl);
|
||||
PointLatLng point = mapControl.FromLocalToLatLng((int)clickPoint.X, (int)clickPoint.Y);
|
||||
GMapMarker marker = new GMapMarker(point);
|
||||
mapControl.Markers.Add(marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,22 @@
|
||||
xmlns:local="clr-namespace:Plane.FormationCreator.Views"
|
||||
xmlns:m="clr-namespace:Plane.FormationCreator.Maps"
|
||||
xmlns:bingMaps="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
|
||||
xmlns:googleMaps="clr-namespace:Plane.GoogleMap"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300">
|
||||
<Grid>
|
||||
|
||||
<UserControl.Resources>
|
||||
<ContextMenu x:Key="MapMenu" >
|
||||
<MenuItem Header="地图透明" Click="Map_Opacity"
|
||||
Foreground="White"/>
|
||||
<MenuItem Header="加载图片" Click="Load_Background"
|
||||
Foreground="White"/>
|
||||
</ContextMenu>
|
||||
</UserControl.Resources>
|
||||
<Grid Name="grid_bg">
|
||||
|
||||
<googleMaps:GMap x:Name="gmap" Opacity="1" ContextMenu="{StaticResource MapMenu}"/>
|
||||
<!--
|
||||
<bingMaps:Map Name="map"
|
||||
CredentialsProvider="8IGVSMWVqW8lDaMuGr2c~XaqB2qlBDLvSvXFzrQ8c-A~AiPIQttopdwAl4kXs8xm6_r59NEGdyqXejcaMDum6qB1BUJ6e25uViKL7fEdEROP"
|
||||
ZoomLevel="20" Opacity="1">
|
||||
@ -21,8 +32,9 @@
|
||||
<bingMaps:Location Latitude="40.055905"
|
||||
Longitude="116.322233" />
|
||||
</bingMaps:Map.Center>
|
||||
<!--<m:OpenStreetMapTileLayer UriFormat="http://tile.openstreetmap.org/{z}/{x}/{y}.png" />-->
|
||||
|
||||
</bingMaps:Map>
|
||||
-->
|
||||
<StackPanel HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Orientation="Horizontal"
|
||||
|
@ -23,14 +23,15 @@ using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Plane.Collections;
|
||||
using Microsoft.Maps.MapControl.WPF;
|
||||
using Microsoft.Maps.MapControl.WPF.Overlays;
|
||||
using System.Windows.Media.Effects;
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
using Plane.FormationCreator.ViewModels;
|
||||
using Plane.Geography;
|
||||
using Plane.FormationCreator.Maps;
|
||||
using Plane.Windows.Messages;
|
||||
using GMap.NET;
|
||||
using GMap.NET.WindowsPresentation;
|
||||
using GMap.NET.MapProviders;
|
||||
|
||||
namespace Plane.FormationCreator.Views
|
||||
{
|
||||
@ -44,9 +45,16 @@ namespace Plane.FormationCreator.Views
|
||||
InitializeComponent();
|
||||
|
||||
this.DataContext = ServiceLocator.Current.GetInstance<MapViewModel>();
|
||||
gmap.MapProvider = GMapProviders.BingHybridMap; //google china 地图
|
||||
gmap.MinZoom = 2; //最小缩放
|
||||
gmap.MaxZoom = 30; //最大缩放
|
||||
gmap.Zoom = 19; //当前缩放
|
||||
gmap.ShowCenter = false; //不显示中心十字点
|
||||
gmap.DragButton = MouseButton.Left; //左键拖拽地图
|
||||
gmap.Position = new LatLng(40.07734857737275, 116.34323845862502).ToGCJ02();
|
||||
|
||||
_mapManager.MapView = this;
|
||||
_mapManager.SetCenterGetter(() => new LatLng { Lat = map.Center.Latitude, Lng = map.Center.Longitude });
|
||||
_mapManager.SetCenterGetter(() => new LatLng { Lat = gmap.Position.ToWGS84().Lat, Lng = gmap.Position.ToWGS84().Lng });
|
||||
|
||||
_flightTaskManager.TaskAdded += FlightTaskManager_TaskAdded;
|
||||
_flightTaskManager.OnOriginalSet += FlightTaskManager_SetOriginal;
|
||||
@ -100,7 +108,7 @@ namespace Plane.FormationCreator.Views
|
||||
}
|
||||
};
|
||||
|
||||
map.MouseLeftButtonDown += (sender, e) =>
|
||||
gmap.MouseLeftButtonDown += (sender, e) =>
|
||||
{
|
||||
if (IsMouseOnCopterOrWaypoint(e.OriginalSource))
|
||||
{
|
||||
@ -113,7 +121,7 @@ namespace Plane.FormationCreator.Views
|
||||
//_copterManager.Copters.ForEach(copter => AddOrMoveCopterForModifyingTask(copter));
|
||||
//_copterManager.Copters.CollectionChanged += CoptersForModifyingTask_CollectionChanged;
|
||||
|
||||
map.MouseDoubleClick += async (sender, e) =>
|
||||
gmap.MouseDoubleClick += async (sender, e) =>
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
@ -129,42 +137,48 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
if (!copters.Any()) return;
|
||||
|
||||
var pos = map.ViewportPointToLocation(e.GetPosition(map));
|
||||
Point clickPoint = e.GetPosition(gmap);
|
||||
var pos = gmap.FromLocalToLatLng((int)clickPoint.X, (int)clickPoint.Y);
|
||||
var centerLat = copters.Average(c => c.Latitude);
|
||||
var centerLng = copters.Average(c => c.Longitude);
|
||||
var latDelta = pos.Latitude - centerLat;
|
||||
var lngDelta = pos.Longitude - centerLng;
|
||||
var latDelta = pos.Lat - centerLat;
|
||||
var lngDelta = pos.Lng - centerLng;
|
||||
|
||||
|
||||
await Task.WhenAll(copters.Select(copter => copter.FlyToAsync(copter.Latitude + latDelta, copter.Longitude + lngDelta, copter.Altitude)));
|
||||
};
|
||||
|
||||
var center = _appConfig.Center;
|
||||
map.Center = new Location(center.Lat, center.Lng);
|
||||
map.ZoomLevel = _appConfig.ZoomLevel;
|
||||
gmap.Position = new LatLng(center.Lat, center.Lng).ToGCJ02();
|
||||
gmap.Zoom = _appConfig.ZoomLevel;
|
||||
|
||||
|
||||
map.ViewChangeOnFrame += (object sender, MapEventArgs e) =>
|
||||
|
||||
gmap.OnMapZoomChanged += () =>
|
||||
{
|
||||
if ( map.Mode.GetType().ToString() == "Microsoft.Maps.MapControl.WPF.AerialMode")
|
||||
if (map.ZoomLevel >19)
|
||||
map.ZoomLevel = 19;
|
||||
if (original!= null && map.Children.Contains(original))
|
||||
// if ( gmap.Mode.GetType().ToString() == "Microsoft.Maps.MapControl.WPF.AerialMode")
|
||||
// if (map.ZoomLevel >19)
|
||||
// map.ZoomLevel = 19;
|
||||
if (originalMarker != null && gmap.Markers.Contains(originalMarker))
|
||||
{
|
||||
Location location = new Location(_flightTaskManager.OriginLat, _flightTaskManager.OriginLng);
|
||||
Point wpPos = map.LocationToViewportPoint(location);
|
||||
wpPos.X -= ORIGIN_RADIUS;
|
||||
wpPos.Y -= ORIGIN_RADIUS;
|
||||
MapLayer.SetPosition(original, map.ViewportPointToLocation(wpPos));
|
||||
PointLatLng location = new LatLng(_flightTaskManager.OriginLat, _flightTaskManager.OriginLng).ToGCJ02();
|
||||
GPoint wpPos = gmap.FromLatLngToLocal(location);
|
||||
//Point wpPos = gmap.LocationToViewportPoint(location);
|
||||
wpPos.X -= (long)ORIGIN_RADIUS;
|
||||
wpPos.Y -= (long)ORIGIN_RADIUS;
|
||||
originalMarker.Position = gmap.FromLocalToLatLng((int)wpPos.X, (int)wpPos.Y);
|
||||
//MapLayer.SetPosition(original, gmap.ViewportPointToLocation(wpPos));
|
||||
}
|
||||
};
|
||||
|
||||
GMapMarker rectangleMarker = null;
|
||||
Rectangle rectangle = new Rectangle();
|
||||
bool drawRectangle = false;
|
||||
Point startPosition = new Point();
|
||||
Point leftTopPoint = new Point();
|
||||
map.MouseRightButtonDown += (sender, e) =>
|
||||
gmap.MouseRightButtonDown += (sender, e) =>
|
||||
{
|
||||
startPosition = e.GetPosition(this);
|
||||
rectangleMarker = new GMapMarker(gmap.FromLocalToLatLng((int)startPosition.X, (int)startPosition.Y));
|
||||
rectangle = new Rectangle();
|
||||
rectangle.Width = 0;
|
||||
rectangle.Height = 0;
|
||||
@ -173,31 +187,33 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
rectangle.Fill = new SolidColorBrush(Color.FromArgb(80, 0, 120, 215));
|
||||
rectangle.Tag = "Rectangle";
|
||||
rectangleMarker.Shape = rectangle;
|
||||
rectangleMarker.Tag = "Rectangle";
|
||||
gmap.Markers.Add(rectangleMarker);
|
||||
|
||||
map.Children.Add(rectangle);
|
||||
startPosition = e.GetPosition(this);
|
||||
MapLayer.SetPosition(rectangle, map.ViewportPointToLocation(startPosition));
|
||||
//MapLayer.SetPosition(rectangle, map.ViewportPointToLocation(startPosition));
|
||||
drawRectangle = true;
|
||||
};
|
||||
|
||||
map.MouseMove += (sender, e) =>
|
||||
gmap.MouseMove += (sender, e) =>
|
||||
{
|
||||
if (drawRectangle)
|
||||
{
|
||||
Point mousePosition = e.GetPosition(this);
|
||||
Point mousePosition = e.GetPosition(gmap);
|
||||
rectangle.Width = Math.Abs(mousePosition.X - startPosition.X);
|
||||
rectangle.Height = Math.Abs(mousePosition.Y - startPosition.Y);
|
||||
leftTopPoint = new Point(Math.Min(mousePosition.X, startPosition.X), Math.Min(mousePosition.Y, startPosition.Y));
|
||||
MapLayer.SetPosition(rectangle, map.ViewportPointToLocation(leftTopPoint));
|
||||
rectangleMarker.Position = gmap.FromLocalToLatLng((int)leftTopPoint.X, (int)leftTopPoint.Y);
|
||||
//MapLayer.SetPosition(rectangle, map.ViewportPointToLocation(leftTopPoint));
|
||||
}
|
||||
};
|
||||
int selectedCount = 0;
|
||||
map.MouseRightButtonUp += (sender, e) =>
|
||||
gmap.MouseRightButtonUp += (sender, e) =>
|
||||
{
|
||||
selectedCount = 0;
|
||||
if (rectangle != null && map.Children.Contains(rectangle))
|
||||
if (rectangleMarker != null && gmap.Markers.Contains(rectangleMarker))
|
||||
{
|
||||
map.Children.Remove(rectangle);
|
||||
gmap.Markers.Remove(rectangleMarker);
|
||||
_copterManager.Select(null);
|
||||
if (_flightTaskManager.SelectedTask != null && _flightTaskManager.SelectedTask.TaskType != FlightTaskType.TakeOff)
|
||||
{
|
||||
@ -205,8 +221,8 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
foreach (FlightTaskSingleCopterInfo taskCopterInfo in _flightTaskManager.SelectedTask.SingleCopterInfos)
|
||||
{
|
||||
Location seekLocation = new Location(taskCopterInfo.TargetLat, taskCopterInfo.TargetLng);
|
||||
Point seekPoint = map.LocationToViewportPoint(seekLocation);
|
||||
PointLatLng seekLocation = new LatLng(taskCopterInfo.TargetLat, taskCopterInfo.TargetLng).ToGCJ02();
|
||||
GPoint seekPoint = gmap.FromLatLngToLocal(seekLocation);
|
||||
if ((seekPoint.X > leftTopPoint.X && seekPoint.X < leftTopPoint.X + rectangle.Width) &&
|
||||
seekPoint.Y > leftTopPoint.Y && seekPoint.Y < leftTopPoint.Y + rectangle.Height)
|
||||
{
|
||||
@ -218,22 +234,23 @@ namespace Plane.FormationCreator.Views
|
||||
}
|
||||
}
|
||||
rectangle = null;
|
||||
rectangleMarker = null;
|
||||
drawRectangle = false;
|
||||
};
|
||||
|
||||
map.MouseLeave += (sender, e) =>
|
||||
gmap.MouseLeave += (sender, e) =>
|
||||
{
|
||||
if (map.Children.Contains(rectangle))
|
||||
if (gmap.Markers.Contains(rectangleMarker))
|
||||
{
|
||||
map.Children.Remove(rectangle);
|
||||
gmap.Markers.Remove(rectangleMarker);
|
||||
}
|
||||
rectangle = null;
|
||||
drawRectangle = false;
|
||||
};
|
||||
|
||||
|
||||
map.MouseMove += new MouseEventHandler(OriginalMove);
|
||||
map.MouseLeftButtonUp += new MouseButtonEventHandler(OriginalMouseUp);
|
||||
gmap.MouseMove += new MouseEventHandler(OriginalMove);
|
||||
gmap.MouseLeftButtonUp += new MouseButtonEventHandler(OriginalMouseUp);
|
||||
}
|
||||
|
||||
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
||||
@ -255,6 +272,7 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
public bool RemoveLoadingErrorMessage()
|
||||
{
|
||||
/*
|
||||
var errorElement = map.Children.OfType<LoadingErrorMessage>().FirstOrDefault();
|
||||
if (errorElement != null)
|
||||
{
|
||||
@ -265,13 +283,16 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public void GoHome()
|
||||
{
|
||||
map.ZoomLevel = 19;
|
||||
gmap.Zoom = 19;
|
||||
//map.Center = new Location(40.0559055, 116.322233);
|
||||
map.Center = new Location(40.6801557090282, 114.670060030638);
|
||||
//gmap.Position = new LatLng(40.6801557090282, 114.670060030638).ToGCJ02();
|
||||
gmap.Position = new PointLatLng(40.1484605429763, 116.293929666281);
|
||||
}
|
||||
|
||||
|
||||
@ -305,7 +326,7 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
var drawing = _copterDrawings.ContainsKey(copter) ?
|
||||
_copterDrawings[copter] :
|
||||
(_copterDrawings[copter] = new CopterDrawing(copter, map));
|
||||
(_copterDrawings[copter] = new CopterDrawing(copter, gmap));
|
||||
drawing.AddOrMoveCopter();
|
||||
}
|
||||
|
||||
@ -321,6 +342,7 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
public void ClearCopters()
|
||||
{
|
||||
/*
|
||||
for (int i = map.Children.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (!(map.Children[i] is MapTileLayer))
|
||||
@ -332,6 +354,9 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
item.Value.RemoveMap_ViewChanged();
|
||||
}
|
||||
*/
|
||||
|
||||
gmap.Markers.Clear();
|
||||
_copterDrawings.Clear();
|
||||
}
|
||||
|
||||
@ -339,7 +364,7 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
var elem = originalSource as FrameworkElement;
|
||||
string tag;
|
||||
while (elem != map && elem != null)
|
||||
while (elem != gmap && elem != null)
|
||||
{
|
||||
tag = elem.Tag?.ToString();
|
||||
if (tag == COPTER_TAG || tag == WAYPOINT_TAG || tag == ORIGINALPOINT_TAG)
|
||||
@ -356,28 +381,29 @@ namespace Plane.FormationCreator.Views
|
||||
foreach (var info in e.AddedTask.SingleCopterInfos)
|
||||
{
|
||||
var drawingInfo = _copterDrawings[info.Copter];
|
||||
var location = new 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);
|
||||
}
|
||||
}
|
||||
|
||||
GMapMarker originalMarker = null;
|
||||
Microsoft.Expression.Shapes.RegularPolygon original = null;
|
||||
const double ORIGIN_RADIUS = 12;
|
||||
private void FlightTaskManager_SetOriginal(object sender, FlightTaskAddedOriginalEventArgs e)
|
||||
{
|
||||
if (_copterManager.Copters.Count == 0) return;
|
||||
if (map.Children.Contains(original))
|
||||
map.Children.Remove(original);
|
||||
Location location = new Location(_copterManager.Copters[0].Latitude, _copterManager.Copters[0].Longitude);
|
||||
Point point = map.LocationToViewportPoint(location);
|
||||
point.X -= ORIGIN_RADIUS;
|
||||
point.Y -= ORIGIN_RADIUS;
|
||||
Location mapLocation = map.ViewportPointToLocation(point);
|
||||
if (gmap.Markers.Contains(originalMarker))
|
||||
gmap.Markers.Remove(originalMarker);
|
||||
PointLatLng location = new LatLng(_copterManager.Copters[0].Latitude, _copterManager.Copters[0].Longitude).ToGCJ02();
|
||||
GPoint point = gmap.FromLatLngToLocal(location);
|
||||
point.X -= (long)ORIGIN_RADIUS;
|
||||
point.Y -= (long)ORIGIN_RADIUS;
|
||||
PointLatLng mapLocation = gmap.FromLocalToLatLng((int)point.X , (int)point.Y);
|
||||
|
||||
original = new Microsoft.Expression.Shapes.RegularPolygon
|
||||
{
|
||||
Tag = ORIGINALPOINT_TAG,
|
||||
Fill = new SolidColorBrush(Color.FromArgb(200,237, 155, 3)),
|
||||
Fill = new SolidColorBrush(Color.FromArgb(200, 237, 155, 3)),
|
||||
Stroke = new SolidColorBrush(Color.FromArgb(200, 238, 80, 238)),
|
||||
StrokeThickness = 1,
|
||||
Width = ORIGIN_RADIUS * 2,
|
||||
@ -385,16 +411,17 @@ namespace Plane.FormationCreator.Views
|
||||
InnerRadius = 0.5,
|
||||
PointCount = 5,
|
||||
};
|
||||
originalMarker = new GMapMarker(mapLocation);
|
||||
originalMarker.ZIndex = 200;
|
||||
originalMarker.Shape = original;
|
||||
|
||||
|
||||
|
||||
map.Children.Add(original);
|
||||
MapLayer.SetPosition(original, mapLocation);
|
||||
MapLayer.SetZIndex(original, 200);
|
||||
gmap.Markers.Add(originalMarker);
|
||||
//MapLayer.SetPosition(original, mapLocation);
|
||||
//MapLayer.SetZIndex(original, 200);
|
||||
original.ToolTip = location.ToString();
|
||||
originaDrag = false;
|
||||
_flightTaskManager.OriginLat = location.Latitude;
|
||||
_flightTaskManager.OriginLng = location.Longitude;
|
||||
_flightTaskManager.OriginLat = location.Lat;
|
||||
_flightTaskManager.OriginLng = location.Lng;
|
||||
original.MouseLeftButtonDown += new MouseButtonEventHandler(OriginalMouseDown);
|
||||
|
||||
}
|
||||
@ -408,8 +435,8 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
originaDrag = true;
|
||||
|
||||
|
||||
var originPoint = e.GetPosition(map);
|
||||
gmap.CanDragMap = false;
|
||||
var originPoint = e.GetPosition(gmap);
|
||||
originX = originPoint.X;
|
||||
originY = originPoint.Y;
|
||||
|
||||
@ -422,9 +449,10 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
if (originaDrag)
|
||||
{
|
||||
Point eventPos = e.GetPosition(map);
|
||||
Point eventPos = e.GetPosition(gmap);
|
||||
var leftTopPos = new Point(eventPos.X - wpOffsetX, eventPos.Y - wpOffsetY);
|
||||
MapLayer.SetPosition(original, map.ViewportPointToLocation(leftTopPos));
|
||||
originalMarker.Position = gmap.FromLocalToLatLng((int)leftTopPos.X, (int)leftTopPos.Y);
|
||||
//MapLayer.SetPosition(original, map.ViewportPointToLocation(leftTopPos));
|
||||
}
|
||||
|
||||
}
|
||||
@ -433,23 +461,22 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
if (originaDrag)
|
||||
{
|
||||
|
||||
|
||||
|
||||
Point eventPos = e.GetPosition(map);
|
||||
Point eventPos = e.GetPosition(gmap);
|
||||
var centrePos = new Point(eventPos.X - wpOffsetX + ORIGIN_RADIUS, eventPos.Y - wpOffsetY + ORIGIN_RADIUS);
|
||||
Location location = map.ViewportPointToLocation(centrePos);
|
||||
_flightTaskManager.OriginLat = location.Latitude;
|
||||
_flightTaskManager.OriginLng = location.Longitude;
|
||||
PointLatLng location = gmap.FromLocalToLatLng((int)centrePos.X, (int)centrePos.Y);
|
||||
_flightTaskManager.OriginLat = location.Lat;
|
||||
_flightTaskManager.OriginLng = location.Lng;
|
||||
original.ToolTip = location.ToString();
|
||||
Clipboard.SetDataObject(string.Format("{0},{1}", location.Latitude, location.Longitude), true);
|
||||
//Clipboard.SetDataObject(string.Format("{0},{1}", location.Lat, location.Lng), true);
|
||||
originaDrag = false;
|
||||
gmap.CanDragMap = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void MapSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
/*
|
||||
switch ((e.AddedItems[0] as FrameworkElement).Tag.ToString())
|
||||
{
|
||||
case "卫星地图":
|
||||
@ -472,6 +499,7 @@ namespace Plane.FormationCreator.Views
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void showallpoint_Checked(object sender, RoutedEventArgs e)
|
||||
@ -488,11 +516,7 @@ namespace Plane.FormationCreator.Views
|
||||
_flightTaskManager.RightSelect(taskitme);
|
||||
// TaskbarControl.setRightSelect(taskitme, ischecked);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -521,6 +545,7 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
private void RemoveTileLayers()
|
||||
{
|
||||
/*
|
||||
for (int i = map.Children.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (map.Children[i] is MapTileLayer)
|
||||
@ -528,12 +553,45 @@ namespace Plane.FormationCreator.Views
|
||||
map.Children.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void Map_Opacity(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (gmap.Opacity == 1)
|
||||
{
|
||||
gmap.Opacity = 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
gmap.Opacity = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void Load_Background(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "图片 |*.jpg;*.bmp;*.png"
|
||||
};
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
ImageBrush ib = new ImageBrush();
|
||||
ib.AlignmentX = AlignmentX.Left;
|
||||
ib.AlignmentY = AlignmentY.Top;
|
||||
ib.Stretch = Stretch.None;
|
||||
ib.ImageSource = new BitmapImage(new Uri(dialog.FileName, UriKind.RelativeOrAbsolute));
|
||||
grid_bg.Background = ib;
|
||||
gmap.Opacity = 0.5;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static class LocationExtensions
|
||||
{
|
||||
public static double CalcDistance(this Location loc1, Location loc2)
|
||||
public static double CalcDistance(this Microsoft.Maps.MapControl.WPF.Location loc1, Microsoft.Maps.MapControl.WPF.Location loc2)
|
||||
{
|
||||
if (loc1 == null)
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Plane.Copters;
|
||||
using Plane.FormationCreator.Formation;
|
||||
using Plane.Logging;
|
||||
using Microsoft.Maps.MapControl.WPF;
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -14,6 +13,11 @@ using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
using System.Windows.Shapes;
|
||||
using GMap.NET.WindowsPresentation;
|
||||
using GMap.NET;
|
||||
using Plane.FormationCreator.Maps;
|
||||
using Microsoft.Maps.MapControl.WPF;
|
||||
using Plane.FormationCreator.ViewModels;
|
||||
|
||||
namespace Plane.FormationCreator.Views
|
||||
{
|
||||
@ -21,7 +25,7 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
private class CopterDrawing
|
||||
{
|
||||
public CopterDrawing(ICopter copter, Map map)
|
||||
public CopterDrawing(ICopter copter, GoogleMap.GMap map)
|
||||
{
|
||||
this.Copter = copter;
|
||||
_map = map;
|
||||
@ -38,13 +42,14 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
_flightTaskManager.TasksCleared += (sender, e) =>
|
||||
{
|
||||
for (int i = this.Route.Locations.Count - 1; i >= 1; i--)
|
||||
{
|
||||
this.Route.Locations.RemoveAt(i);
|
||||
}
|
||||
Route.Points.Clear();
|
||||
// for (int i = this.Route.Locations.Count - 1; i >= 1; i--)
|
||||
// {
|
||||
// this.Route.Locations.RemoveAt(i);
|
||||
// }
|
||||
foreach (var wp in this.Waypoints)
|
||||
{
|
||||
_map.Children.Remove(wp);
|
||||
_map.Markers.Remove(wp);
|
||||
}
|
||||
this.Waypoints.Clear();
|
||||
};
|
||||
@ -83,6 +88,7 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
|
||||
public ICopter Copter { get; set; }
|
||||
public GMapMarker DotMarker { get; set; }
|
||||
public Grid DotContainer { get; set; }
|
||||
public Polygon Dot { get; set; }
|
||||
|
||||
@ -91,20 +97,22 @@ namespace Plane.FormationCreator.Views
|
||||
public MapPolyline Track { get; set; }
|
||||
public Location LastLocation { get; set; }
|
||||
|
||||
public MapPolyline Route { get; set; }
|
||||
public List<ShapesContainer> Waypoints { get; set; } = new List<ShapesContainer>();
|
||||
public GMapRoute Route { get; set; }
|
||||
public List<GMapMarker> Waypoints { get; set; } = new List<GMapMarker>();
|
||||
|
||||
Map _map;
|
||||
GoogleMap.GMap _map;
|
||||
Color _color;
|
||||
Brush _brush;
|
||||
|
||||
ILogger _logger = ServiceLocator.Current.GetInstance<ILogger>();
|
||||
CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
||||
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
|
||||
View3DViewModel _view3DViewModel = ServiceLocator.Current.GetInstance<View3DViewModel>();
|
||||
|
||||
|
||||
private void Map_ViewChanged<MapEventArgs>(object sender, MapEventArgs e)
|
||||
{
|
||||
/*
|
||||
for (int index = 1; index < _flightTaskManager.Tasks.Count; index++)
|
||||
{
|
||||
var info = _flightTaskManager.Tasks[index].SingleCopterInfos.Find(i => i.Copter == this.Copter); ;
|
||||
@ -115,6 +123,7 @@ namespace Plane.FormationCreator.Views
|
||||
wpPos.Y -= WAYPOINT_RADIUS;
|
||||
MapLayer.SetPosition(wpContainer, _map.ViewportPointToLocation(wpPos));
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@ -122,7 +131,7 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
try
|
||||
{
|
||||
var location = new Location(Copter.Latitude, Copter.Longitude, Copter.Altitude);
|
||||
var location = new Microsoft.Maps.MapControl.WPF.Location(Copter.Latitude, Copter.Longitude, Copter.Altitude);
|
||||
|
||||
if (this.Dot != null )
|
||||
{
|
||||
@ -132,9 +141,8 @@ namespace Plane.FormationCreator.Views
|
||||
this.Dot.Fill = _brush;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Point center = _map.LocationToViewportPoint(location);
|
||||
PointLatLng gmapLatLng = new LatLng(location.Latitude, location.Longitude).ToGCJ02();
|
||||
GPoint center = _map.FromLatLngToLocal(gmapLatLng);
|
||||
bool locationUpdated = true;
|
||||
SolidColorBrush blackBrush = new SolidColorBrush();
|
||||
if (this.Dot == null)
|
||||
@ -166,8 +174,6 @@ namespace Plane.FormationCreator.Views
|
||||
DotContainer.Children.Add(Dot);
|
||||
|
||||
//飞机里面的编号
|
||||
|
||||
|
||||
CopterText = new TextBlock
|
||||
{
|
||||
Text = Copter.Name,
|
||||
@ -177,29 +183,29 @@ namespace Plane.FormationCreator.Views
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
|
||||
|
||||
DotMarker = new GMapMarker(new PointLatLng(0, 0));
|
||||
DotContainer.Children.Add(CopterText);
|
||||
DotMarker.Shape = DotContainer;
|
||||
_map.Markers.Add(DotMarker);
|
||||
//MapLayer.SetZIndex(DotContainer, 100);
|
||||
|
||||
_map.Children.Add(DotContainer);
|
||||
MapLayer.SetZIndex(DotContainer, 100);
|
||||
this.Route = new GMapRoute(new List<PointLatLng>() { gmapLatLng, gmapLatLng });
|
||||
Path path = new Path()
|
||||
{
|
||||
Stroke = _brush,
|
||||
StrokeThickness = 2.0
|
||||
};
|
||||
|
||||
this.Route = new MapPolyline { Locations = new LocationCollection { location } };
|
||||
this.Route.Stroke = _brush;
|
||||
this.Route.StrokeThickness = 2.0;
|
||||
this.Route.Shape = path;
|
||||
//显示计划航线
|
||||
|
||||
// _map.Children.Add(this.Route);
|
||||
|
||||
|
||||
//_map.Markers.Add(Route);
|
||||
|
||||
this.LastLocation = location;
|
||||
|
||||
RegisterEventHandlersForDraggingCopter(DotContainer);
|
||||
RegisterEventHandlersForDraggingCopter(DotMarker);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
if ((bool)_copterManager.CopterStatus[_copterManager.Copters.IndexOf(Copter)])
|
||||
{
|
||||
CopterText.Foreground = new SolidColorBrush(Colors.Red);
|
||||
@ -209,8 +215,6 @@ namespace Plane.FormationCreator.Views
|
||||
CopterText.Foreground = new SolidColorBrush(Colors.White);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (LastLocation != null && location.CalcDistance(LastLocation) < 0.1)
|
||||
{
|
||||
locationUpdated = false;
|
||||
@ -244,7 +248,8 @@ namespace Plane.FormationCreator.Views
|
||||
if (locationUpdated)
|
||||
{
|
||||
Track.Locations.Add(location);
|
||||
MapLayer.SetPosition(Dot.Parent, location);
|
||||
DotMarker.Position = new LatLng(location.Latitude, location.Longitude).ToGCJ02();
|
||||
//MapLayer.SetPosition(Dot.Parent, location);
|
||||
this.LastLocation = location;
|
||||
}
|
||||
}
|
||||
@ -257,30 +262,34 @@ namespace Plane.FormationCreator.Views
|
||||
public void AddWaypoint(Location location, FlightTaskType type)
|
||||
{
|
||||
// Add waypoint.
|
||||
|
||||
|
||||
LatLng gmapLatLng = new LatLng(location.Latitude, location.Longitude);
|
||||
GMapMarker marker = new GMapMarker(gmapLatLng.ToGCJ02());
|
||||
ShapesContainer shapesContainer = new ShapesContainer(_brush);
|
||||
shapesContainer.Tag = WAYPOINT_TAG;
|
||||
marker.Tag = WAYPOINT_TAG;
|
||||
marker.Shape = shapesContainer;
|
||||
|
||||
Waypoints.Add(shapesContainer);
|
||||
_map.Children.Add(shapesContainer);
|
||||
MapLayer.SetZIndex(shapesContainer, 100);
|
||||
var wpPos = _map.LocationToViewportPoint(location);
|
||||
Waypoints.Add(marker);
|
||||
_map.Markers.Add(marker);
|
||||
marker.ZIndex = 100;
|
||||
//MapLayer.SetZIndex(shapesContainer, 100);
|
||||
//var wpPos = _map.LocationToViewportPoint(location);
|
||||
//wpPos.X -= 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.
|
||||
RegisterEventHandlersForDraggingWaypoint(shapesContainer, taskIndex: Waypoints.Count);
|
||||
RegisterEventHandlersForDraggingWaypoint(marker, taskIndex: Waypoints.Count);
|
||||
|
||||
// Register event handlers for task info.
|
||||
RegisterEventHandlersForTaskInfo(shapesContainer, taskIndex: Waypoints.Count);
|
||||
RegisterEventHandlersForTaskInfo(marker, taskIndex: Waypoints.Count);
|
||||
}
|
||||
|
||||
private void RegisterEventHandlersForDraggingCopter(Grid copterElement)
|
||||
private void RegisterEventHandlersForDraggingCopter(GMapMarker copterMarker)
|
||||
{
|
||||
Grid copterElement = copterMarker.Shape as Grid;
|
||||
var dragMoving = false;
|
||||
double offsetX = 0;
|
||||
double offsetY = 0;
|
||||
@ -294,6 +303,7 @@ namespace Plane.FormationCreator.Views
|
||||
offsetY = posInObject.Y;
|
||||
|
||||
dragMoving = true;
|
||||
_map.CanDragMap = false;
|
||||
}
|
||||
};
|
||||
_map.MouseMove += (sender, e) =>
|
||||
@ -303,9 +313,10 @@ namespace Plane.FormationCreator.Views
|
||||
var pos = e.GetPosition(_map);
|
||||
pos.X -= offsetX;
|
||||
pos.Y -= offsetY;
|
||||
MapLayer.SetPosition(copterElement, _map.ViewportPointToLocation(pos));
|
||||
copterMarker.Position = _map.FromLocalToLatLng((int)pos.X, (int)pos.Y);
|
||||
//MapLayer.SetPosition(copterElement, _map.ViewportPointToLocation(pos));
|
||||
|
||||
var center = _map.ViewportPointToLocation(pos);
|
||||
//var center = _map.ViewportPointToLocation(pos);
|
||||
|
||||
// var routePoint = this.Route.Locations[0];
|
||||
// routePoint.Latitude = center.Latitude;
|
||||
@ -313,21 +324,23 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
var fc = Copter as FakeCopter;
|
||||
fc.SetProperties(
|
||||
latitude: center.Latitude,
|
||||
longitude: center.Longitude
|
||||
latitude: copterMarker.Position.ToWGS84().Lat,
|
||||
longitude: copterMarker.Position.ToWGS84().Lng
|
||||
);
|
||||
}
|
||||
};
|
||||
_map.MouseLeftButtonUp += (sender, e) =>
|
||||
{
|
||||
_map.CanDragMap = true;
|
||||
if (dragMoving) dragMoving = false;
|
||||
};
|
||||
}
|
||||
|
||||
private Dictionary<ICopter, Point> selectWayOriginPoint = new Dictionary<ICopter, Point>();
|
||||
private Dictionary<ICopter, GPoint> selectWayOriginPoint = new Dictionary<ICopter, GPoint>();
|
||||
private Dictionary<object, bool> _dictDraggingWp = new Dictionary<object, bool>();
|
||||
private void RegisterEventHandlersForDraggingWaypoint(Grid wp, int taskIndex)
|
||||
private void RegisterEventHandlersForDraggingWaypoint(GMapMarker wpMarker, int taskIndex)
|
||||
{
|
||||
Grid wp = wpMarker.Shape as Grid;
|
||||
_dictDraggingWp[wp] = false;
|
||||
double originX = 0;
|
||||
double originY = 0;
|
||||
@ -360,10 +373,11 @@ namespace Plane.FormationCreator.Views
|
||||
{
|
||||
if (_copterManager.SelectedCopters.Contains(info.Copter))
|
||||
{
|
||||
Location originLocation = new Location(info.TargetLat, info.TargetLng);
|
||||
selectWayOriginPoint[info.Copter] = _map.LocationToViewportPoint(originLocation);
|
||||
PointLatLng originLocation = new LatLng(info.TargetLat, info.TargetLng).ToGCJ02();
|
||||
selectWayOriginPoint[info.Copter] = _map.FromLatLngToLocal(originLocation);
|
||||
}
|
||||
}
|
||||
_map.CanDragMap = false;
|
||||
};
|
||||
wp.MouseRightButtonDown += (sender, e) =>
|
||||
{
|
||||
@ -377,35 +391,45 @@ namespace Plane.FormationCreator.Views
|
||||
var offsetX = eventPos.X - originX;
|
||||
var offsetY = eventPos.Y - originY;
|
||||
|
||||
foreach (KeyValuePair<ICopter, Point> kv in selectWayOriginPoint)
|
||||
foreach (KeyValuePair<ICopter, GPoint> kv in selectWayOriginPoint)
|
||||
{
|
||||
Point curPoint = new Point(kv.Value.X + offsetX, kv.Value.Y + offsetY);
|
||||
var curLoc = _map.ViewportPointToLocation(curPoint);
|
||||
|
||||
var curLoc = _map.FromLocalToLatLng((int)curPoint.X, (int)curPoint.Y).ToWGS84();
|
||||
|
||||
var modifyingSingleCopterInfo = _flightTaskManager.SelectedTask.SingleCopterInfos.Find(i => i.Copter == kv.Key);
|
||||
//modifyingSingleCopterInfo.TargetLat = routePoint.Latitude = curLoc.Latitude;
|
||||
//modifyingSingleCopterInfo.TargetLng = routePoint.Longitude = curLoc.Longitude;
|
||||
modifyingSingleCopterInfo.TargetLat = curLoc.Latitude;
|
||||
modifyingSingleCopterInfo.TargetLng = curLoc.Longitude;
|
||||
modifyingSingleCopterInfo.TargetLat = curLoc.Lat;
|
||||
modifyingSingleCopterInfo.TargetLng = curLoc.Lng;
|
||||
Console.WriteLine("-------" + curLoc.Lat + "," + curLoc.Lng);
|
||||
|
||||
}
|
||||
|
||||
var routePoint = this.Route.Locations[1];
|
||||
// var routePoint = this.Route.Points[1];
|
||||
var leftTopPos = new Point(eventPos.X - wpOffsetX, eventPos.Y - wpOffsetY);
|
||||
var newRoutePoint = new Point(leftTopPos.X + WAYPOINT_RADIUS, leftTopPos.Y + WAYPOINT_RADIUS);
|
||||
routePoint.Latitude = _map.ViewportPointToLocation(leftTopPos).Latitude;
|
||||
routePoint.Longitude = _map.ViewportPointToLocation(leftTopPos).Longitude;
|
||||
MapLayer.SetPosition(wp, _map.ViewportPointToLocation(leftTopPos));
|
||||
var lat_lng = _map.FromLocalToLatLng((int)leftTopPos.X, (int)leftTopPos.Y);
|
||||
|
||||
Route.Points.RemoveAt(1);
|
||||
Route.Points.Add(lat_lng);
|
||||
|
||||
// routePoint.Lat = lat_lng.Lat;
|
||||
// routePoint.Lng = lat_lng.Lng;
|
||||
this.Route.RegenerateShape(_map);
|
||||
wpMarker.Position = lat_lng;
|
||||
//MapLayer.SetPosition(wp, _map.ViewportPointToLocation(leftTopPos));
|
||||
}
|
||||
};
|
||||
_map.MouseLeftButtonUp += (sender, e) =>
|
||||
{
|
||||
_map.CanDragMap = true;
|
||||
if (_dictDraggingWp[wp]) _dictDraggingWp[wp] = false;
|
||||
};
|
||||
}
|
||||
|
||||
private void RegisterEventHandlersForTaskInfo(Grid wp, int taskIndex)
|
||||
private void RegisterEventHandlersForTaskInfo(GMapMarker marker, int taskIndex)
|
||||
{
|
||||
var wp = marker.Shape as ShapesContainer;
|
||||
var info = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.FirstOrDefault(i => i.Copter == this.Copter);
|
||||
if (info == null) return;
|
||||
info.PropertyChanged += (sender, e) =>
|
||||
@ -417,14 +441,18 @@ namespace Plane.FormationCreator.Views
|
||||
case nameof(FlightTaskSingleCopterInfo.TargetAlt):
|
||||
if (!_dictDraggingWp.GetValue(wp, false))
|
||||
{
|
||||
var centerLocation = new Location(info.TargetLat, info.TargetLng, info.TargetAlt);
|
||||
var centerPos = _map.LocationToViewportPoint(centerLocation);
|
||||
var leftTopPos = new Point(centerPos.X, centerPos.Y);
|
||||
MapLayer.SetPosition(wp, _map.ViewportPointToLocation(leftTopPos));
|
||||
var routePoint = Route.Locations[1];
|
||||
routePoint.Latitude = info.TargetLat;
|
||||
routePoint.Longitude = info.TargetLng;
|
||||
routePoint.Altitude = info.TargetAlt;
|
||||
//var centerLocation = new Location(info.TargetLat, info.TargetLng, info.TargetAlt);
|
||||
//var centerPos = _map.LocationToViewportPoint(centerLocation);
|
||||
//var leftTopPos = new Point(centerPos.X, centerPos.Y);
|
||||
//MapLayer.SetPosition(wp, _map.ViewportPointToLocation(leftTopPos));
|
||||
marker.Position = new LatLng(info.TargetLat, info.TargetLng).ToGCJ02();
|
||||
// var routePoint = Route.Points[1];
|
||||
// routePoint.Lat = info.TargetLat;
|
||||
// routePoint.Lng = info.TargetLng;
|
||||
Route.Points.RemoveAt(1);
|
||||
Route.Points.Add(marker.Position);
|
||||
this.Route.RegenerateShape(_map);
|
||||
//routePoint.Altitude = info.TargetAlt;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -433,44 +461,39 @@ namespace Plane.FormationCreator.Views
|
||||
|
||||
public void RemoveCopter()
|
||||
{
|
||||
_map.Children.Remove(this.DotContainer);
|
||||
_map.Children.Remove(this.Track);
|
||||
_map.Children.Remove(this.Route);
|
||||
_map.Markers.Remove(this.DotMarker);
|
||||
//_map.Markers.Remove(this.Track);
|
||||
//_map.Markers.Remove(this.Route);
|
||||
foreach (var item in this.Waypoints)
|
||||
{
|
||||
_map.Children.Remove(item);
|
||||
_map.Markers.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveMap_ViewChanged()
|
||||
{
|
||||
_map.ViewChangeOnFrame -= Map_ViewChanged;
|
||||
//_map.ViewChangeOnFrame -= Map_ViewChanged;
|
||||
}
|
||||
|
||||
public void SetShowroute(bool? showroute)
|
||||
{
|
||||
|
||||
if (showroute ?? false )
|
||||
{
|
||||
_map.Children.Add(this.Route);
|
||||
MapLayer.SetZIndex(this.Route, 99);
|
||||
}
|
||||
|
||||
_map.Markers.Add(this.Route);
|
||||
Route.ZIndex = 99;
|
||||
}
|
||||
else
|
||||
_map.Children.Remove(this.Route);
|
||||
_map.Markers.Remove(this.Route);
|
||||
}
|
||||
|
||||
public void SetShowtrack(bool? showtrack)
|
||||
{
|
||||
if (showtrack ?? false)
|
||||
_map.Children.Add(Track);
|
||||
else
|
||||
_map.Children.Remove(Track);
|
||||
// if (showtrack ?? false)
|
||||
// _map.Children.Add(Track);
|
||||
// else
|
||||
// _map.Children.Remove(Track);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void SetEffect(bool selected)
|
||||
{
|
||||
|
||||
@ -487,7 +510,7 @@ namespace Plane.FormationCreator.Views
|
||||
}
|
||||
|
||||
|
||||
Waypoints.ForEach(wp => wp.Ismark = selected);
|
||||
Waypoints.ForEach(wp => ((ShapesContainer)(wp.Shape)).Ismark = selected);
|
||||
|
||||
|
||||
/*
|
||||
@ -501,16 +524,18 @@ namespace Plane.FormationCreator.Views
|
||||
public void ResetRoute(int taskIndex)
|
||||
{
|
||||
var wpIndex = taskIndex - 1; // Waypoints 中没有起飞点。
|
||||
Route.Locations.Clear();
|
||||
Route.Points.Clear();
|
||||
if (wpIndex >= 0 && wpIndex < Waypoints.Count)
|
||||
{
|
||||
var info1 = _flightTaskManager.Tasks[wpIndex].SingleCopterInfos.Find(i => i.Copter == this.Copter);
|
||||
var info2 = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.Find(i => i.Copter == this.Copter);
|
||||
|
||||
Location loc1 = new Location(info1.TargetLat, info1.TargetLng);
|
||||
Location loc2 = new Location(info2.TargetLat, info2.TargetLng);
|
||||
Route.Locations.Add(loc1);
|
||||
Route.Locations.Add(loc2);
|
||||
PointLatLng loc1 = new LatLng(info1.TargetLat, info1.TargetLng).ToGCJ02();
|
||||
PointLatLng loc2 = new LatLng(info2.TargetLat, info2.TargetLng).ToGCJ02();
|
||||
Route.Points.Add(loc1);
|
||||
Route.Points.Add(loc2);
|
||||
//if (0)
|
||||
Route.RegenerateShape(_map);
|
||||
}
|
||||
|
||||
|
||||
@ -521,8 +546,8 @@ namespace Plane.FormationCreator.Views
|
||||
var wpIndex = taskIndex - 1; // Waypoints 中没有起飞点。
|
||||
if (wpIndex >= 0 && wpIndex < Waypoints.Count)
|
||||
{
|
||||
Waypoints.ForEach(p => p.wp.Stroke = null);
|
||||
var wp = Waypoints[wpIndex].wp;
|
||||
Waypoints.ForEach(p => ((ShapesContainer)(p.Shape)).wp.Stroke = null);
|
||||
var wp = ((ShapesContainer)(Waypoints[wpIndex].Shape)).wp;
|
||||
wp.Stroke = _selectedTaskStroke;
|
||||
}
|
||||
}
|
||||
@ -533,25 +558,15 @@ namespace Plane.FormationCreator.Views
|
||||
var wpIndex = taskIndex - 1; // Waypoints 中没有起飞点。
|
||||
if (wpIndex >= 0 && wpIndex < Waypoints.Count)
|
||||
{
|
||||
// Waypoints.ForEach(p => p.Stroke = null);
|
||||
var wp = Waypoints[wpIndex];
|
||||
// Route.Locations.RemoveAt(wpIndex);
|
||||
// Route.Visibility = Visibility.Hidden;
|
||||
// wp.Stroke = _selectedTaskStroke;
|
||||
// var flightTaskTmp = _flightTaskManager.Tasks[taskIndex];
|
||||
var wp = Waypoints[wpIndex].Shape as ShapesContainer;
|
||||
if (!flag)
|
||||
{
|
||||
wp.Visibility = Visibility.Hidden;
|
||||
//Route.Visibility = Visibility.Hidden;
|
||||
//Route.Children.RemoveAt(1);
|
||||
//Route.Locations.RemoveAt(taskIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
wp.Visibility = Visibility.Visible;
|
||||
var info = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.Find(i => i.Copter == this.Copter);
|
||||
//Route.Locations.Insert(taskIndex, new Location(info.TargetLat, info.TargetLng));
|
||||
//Route.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -132,7 +132,9 @@
|
||||
<Button Content="最小距离"
|
||||
Margin="0,5,5,0"
|
||||
Command="{Binding calDistinceCommand}"/>
|
||||
|
||||
<Button Content="航点间距"
|
||||
Margin="0,5,5,0"
|
||||
Command="{Binding WayPointDistinceCommand}"/>
|
||||
|
||||
<Button Content="前一高度"
|
||||
Margin="0,5,5,0"
|
||||
@ -239,13 +241,13 @@
|
||||
<StackPanel Margin="0,2" Grid.Column="1">
|
||||
<TextBlock Text="水平"/>
|
||||
<TextBox Width="45" Margin="5,0,0,5"
|
||||
Text="{Binding LevelSpeed}"/>
|
||||
Text="{Binding LevelSpeed, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
<TextBlock Text="上升" Margin="15,0,0,0"/>
|
||||
<TextBox Width="45" Margin="5,0,0,5"
|
||||
Text="{Binding UpSpeed}"/>
|
||||
Text="{Binding UpSpeed, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
<TextBlock Text="下降" Margin="15,0,0,0"/>
|
||||
<TextBox Width="45" Margin="5,0,0,5"
|
||||
Text="{Binding DownSpeed}"/>
|
||||
Text="{Binding DownSpeed, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</StackPanel>
|
||||
<Button Content="应用到所选" Grid.Row="1" Grid.Column="1" Command="{Binding SetIsChangeCommand}"/>
|
||||
|
||||
@ -338,7 +340,7 @@
|
||||
<DataTemplate>
|
||||
<StackPanel Margin="0,5,0,0" Orientation="Horizontal" >
|
||||
<TextBlock Text="类型" Margin="0,0,0,0" VerticalAlignment="Center" ></TextBlock>
|
||||
<ComboBox MinWidth="80" Margin="5,0,0,0" Foreground="White" VerticalContentAlignment="Center"
|
||||
<ComboBox MinWidth="125" Width="125" Margin="5,0,0,0" Foreground="White" VerticalContentAlignment="Center"
|
||||
SelectedIndex="{Binding Path=LEDMode}">
|
||||
<ComboBox.ItemContainerStyle>
|
||||
<Style>
|
||||
@ -346,11 +348,13 @@
|
||||
</Style>
|
||||
</ComboBox.ItemContainerStyle>
|
||||
<ComboBoxItem Content="常亮" />
|
||||
<ComboBoxItem Content="闪烁" />
|
||||
<ComboBoxItem Content="随机" />
|
||||
<ComboBoxItem Content="同步闪烁(单色)" />
|
||||
<ComboBoxItem Content="异步闪烁(随机)" />
|
||||
<ComboBoxItem Content="渐亮" />
|
||||
<ComboBoxItem Content="渐暗" />
|
||||
<ComboBoxItem Content="同步随机" />
|
||||
<ComboBoxItem Content="呼吸灯" />
|
||||
<ComboBoxItem Content="同步闪烁(随机)" />
|
||||
<ComboBoxItem Content="异步闪烁(单色)" />
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Text="时间" Margin="12,0,0,0" VerticalAlignment="Center"></TextBlock>
|
||||
@ -362,8 +366,8 @@
|
||||
<TextBox MinWidth="40" MaxWidth="50" Margin="5,0,0,0"
|
||||
Text="{Binding Path=LEDRate, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Text="颜色" Margin="12,0,0,0" VerticalAlignment="Center"></TextBlock>
|
||||
<TextBox Margin="5,0,0,0"
|
||||
<TextBlock Text="颜色" Margin="12,0,0,0" VerticalAlignment="Center"></TextBlock>
|
||||
<TextBox Margin="5,0,0,0" MinWidth="60" Width="60"
|
||||
Text="{Binding LEDRGB, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<Button Content="删除" Margin="12,0,0,0"
|
||||
|
35
Plane.FormationCreator/Views/SetCoptersPutView.xaml
Normal file
35
Plane.FormationCreator/Views/SetCoptersPutView.xaml
Normal file
@ -0,0 +1,35 @@
|
||||
<Window x:Class="Plane.FormationCreator.Views.SetCoptersPutView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Plane.FormationCreator.Views"
|
||||
mc:Ignorable="d"
|
||||
Title="设置摆放" Height="301.595" Width="364.628" WindowStartupLocation="CenterScreen" WindowStyle="ToolWindow" ResizeMode="NoResize">
|
||||
<Grid Margin="90,45">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="每列数量" Margin="5,2"></Label>
|
||||
<TextBox Name="textboxColNum" Grid.Column="1" Margin="5" Width="80" ></TextBox>
|
||||
|
||||
<Label Content="列间距" Margin="5,2" Grid.Row="1"></Label>
|
||||
<TextBox Name="textboxColDis" Grid.Column="1" Margin="5" Grid.Row="1" Width="80"></TextBox>
|
||||
|
||||
<Label Content="行间距" Margin="5,2" Grid.Row="2"></Label>
|
||||
<TextBox Name="textboxRowDis" Grid.Column="1" Margin="5" Grid.Row="2" Width="80"></TextBox>
|
||||
|
||||
<Label Content="朝向" Margin="5,2" Grid.Row="3"></Label>
|
||||
<TextBox Name="textboxOrientation" Grid.Column="1" Margin="5" Grid.Row="3" Width="80"></TextBox>
|
||||
|
||||
<Button Content="确定" Width="80" Height="28" Grid.Row="4" Grid.ColumnSpan="2" Click="BtnOK_Click"/>
|
||||
</Grid>
|
||||
</Window>
|
51
Plane.FormationCreator/Views/SetCoptersPutView.xaml.cs
Normal file
51
Plane.FormationCreator/Views/SetCoptersPutView.xaml.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Plane.FormationCreator.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// SetCoptersPutView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SetCoptersPutView : Window
|
||||
{
|
||||
public SetCoptersPutView(int col_num, float col_dis, float row_dis, int orientation)
|
||||
{
|
||||
InitializeComponent();
|
||||
textboxColNum.Text = col_num.ToString();
|
||||
textboxColDis.Text = col_dis.ToString();
|
||||
textboxRowDis.Text = row_dis.ToString();
|
||||
textboxOrientation.Text = orientation.ToString();
|
||||
}
|
||||
|
||||
private void BtnOK_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
int tempint = 0;
|
||||
float tempfloat = 0;
|
||||
if (
|
||||
int.TryParse(textboxColNum.Text, out tempint) &&
|
||||
float.TryParse(textboxColDis.Text, out tempfloat) &&
|
||||
float.TryParse(textboxRowDis.Text, out tempfloat) &&
|
||||
int.TryParse(textboxOrientation.Text, out tempint)
|
||||
)
|
||||
{
|
||||
this.DialogResult = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("请输入正确的数字");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -11,25 +11,25 @@
|
||||
d:DesignWidth="500">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button HorizontalAlignment="Left"
|
||||
<Button HorizontalAlignment="Left" Grid.Column="1"
|
||||
Visibility="{Binding FlightTaskManager.IsPaused, Converter={StaticResource IsPausedToRunButtonVisibilityConverter}}"
|
||||
Command="{Binding RunTasksCommand}">
|
||||
<Button.Template>
|
||||
<ControlTemplate>
|
||||
<Grid Width="40"
|
||||
Height="40"
|
||||
Background="#31000000"
|
||||
<Grid Width="30"
|
||||
Height="30"
|
||||
Background="#00FFFFFF"
|
||||
VerticalAlignment="Bottom">
|
||||
<ed:RegularPolygon Fill="LightGray"
|
||||
<ed:RegularPolygon Fill="Black"
|
||||
InnerRadius="1"
|
||||
PointCount="3"
|
||||
Width="40"
|
||||
Height="40"
|
||||
Width="30"
|
||||
Height="30"
|
||||
Stretch="Fill"
|
||||
Stroke="Gray">
|
||||
<ed:RegularPolygon.RenderTransform>
|
||||
@ -37,7 +37,7 @@
|
||||
<ScaleTransform />
|
||||
<SkewTransform />
|
||||
<RotateTransform Angle="90" />
|
||||
<TranslateTransform X="40" />
|
||||
<TranslateTransform X="30" />
|
||||
</TransformGroup>
|
||||
</ed:RegularPolygon.RenderTransform>
|
||||
</ed:RegularPolygon>
|
||||
@ -45,32 +45,33 @@
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
<Button HorizontalAlignment="Left"
|
||||
Background="#232323"
|
||||
<Button HorizontalAlignment="Left" Grid.Column="1"
|
||||
Background="#00FFFFFF"
|
||||
Visibility="{Binding FlightTaskManager.IsPaused, Converter={StaticResource IsPausedToPauseButtonVisibilityConverter}}"
|
||||
Command="{Binding PauseTasksCommand}">
|
||||
<Button.Template>
|
||||
<ControlTemplate>
|
||||
<Grid Width="40"
|
||||
Height="40"
|
||||
<Grid Width="30"
|
||||
Height="30"
|
||||
VerticalAlignment="Bottom"
|
||||
Background="#33000000">
|
||||
<Rectangle Fill="LightGray"
|
||||
Background="#00FFFFFF">
|
||||
<Rectangle Fill="Black"
|
||||
HorizontalAlignment="Left"
|
||||
Width="15"
|
||||
Height="40"
|
||||
Width="10"
|
||||
Height="30"
|
||||
Stroke="Gray" />
|
||||
<Rectangle Fill="LightGray"
|
||||
<Rectangle Fill="Black"
|
||||
Margin="0,0,3,0"
|
||||
HorizontalAlignment="Right"
|
||||
Width="15"
|
||||
Height="40"
|
||||
Width="10"
|
||||
Height="30"
|
||||
Stroke="Gray" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
|
||||
<ItemsControl Grid.Column="1"
|
||||
<ItemsControl Grid.Column="0"
|
||||
VerticalAlignment="Bottom"
|
||||
ItemsSource="{Binding Tasks}"
|
||||
Name="TasksControl">
|
||||
@ -90,10 +91,10 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Background="{Binding Status, Converter={StaticResource FlightTaskStatusToFillConverter}}"
|
||||
Width="100"
|
||||
Height="15"
|
||||
BorderThickness="2"
|
||||
BorderBrush="Gray"
|
||||
Width="85"
|
||||
Height="19"
|
||||
BorderThickness="1"
|
||||
BorderBrush="Black"
|
||||
Effect="{Binding IsSelected, Converter={StaticResource FlightTaskIsSelectedToEffectConverter}}"
|
||||
MouseLeftButtonUp="SelectTask"
|
||||
MouseRightButtonUp="HideTask">
|
||||
@ -101,9 +102,9 @@
|
||||
<TextBlock Width="auto"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="11"
|
||||
Foreground="Black"
|
||||
Text="{Binding TaskType}" />
|
||||
FontSize="12"
|
||||
Foreground="White"
|
||||
Text="{Binding TaskCnName}" />
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
32
Plane.FormationCreator/Views/View3D.xaml
Normal file
32
Plane.FormationCreator/Views/View3D.xaml
Normal file
@ -0,0 +1,32 @@
|
||||
<UserControl x:Class="Plane.FormationCreator.Views.View3D"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Plane.FormationCreator.Views"
|
||||
xmlns:HelixToolkit="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<HelixToolkit:HelixViewport3D Name="view3d" ShowViewCube="False" ShowCameraTarget="False" CameraMode="FixedPosition" RotationSensitivity="0.6">
|
||||
<ModelVisual3D>
|
||||
<ModelVisual3D.Content>
|
||||
<AmbientLight Color="White"/>
|
||||
</ModelVisual3D.Content>
|
||||
</ModelVisual3D>
|
||||
|
||||
<ModelVisual3D Content="{Binding Model, UpdateSourceTrigger=PropertyChanged}">
|
||||
|
||||
</ModelVisual3D>
|
||||
<HelixToolkit:PanoramaCube3D Source="E:\test\3DView\3DView\Models\Opera\"/>
|
||||
</HelixToolkit:HelixViewport3D>
|
||||
|
||||
<StackPanel HorizontalAlignment="Left" Margin="2"
|
||||
VerticalAlignment="Top"
|
||||
Orientation="Horizontal"
|
||||
>
|
||||
<Button Content="重置镜头" Click="ResetCamera_Click" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
60
Plane.FormationCreator/Views/View3D.xaml.cs
Normal file
60
Plane.FormationCreator/Views/View3D.xaml.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using HelixToolkit.Wpf;
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
using Plane.FormationCreator.Formation;
|
||||
using Plane.FormationCreator.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Media.Media3D;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Plane.FormationCreator.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// View3D.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class View3D : UserControl
|
||||
{
|
||||
private FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
|
||||
public View3D()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var camera = view3d.Camera as PerspectiveCamera;
|
||||
camera.Position = new Point3D(0, 0, 0);
|
||||
camera.LookDirection = new Vector3D(0, 1, 0);
|
||||
camera.UpDirection = new Vector3D(0, 0, 1);
|
||||
camera.FieldOfView = 120;
|
||||
|
||||
this.DataContext = ServiceLocator.Current.GetInstance<View3DViewModel>();
|
||||
view3d.ShowCameraInfo = true;
|
||||
view3d.ShowFieldOfView = true;
|
||||
}
|
||||
|
||||
|
||||
private void ResetCamera_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// view3d.CameraController.CameraPosition = new Point3D(0, 40, 1);
|
||||
// view3d.CameraController.CameraUpDirection = new Vector3D(0, -1, 10);
|
||||
// view3d.CameraController.CameraTarget = new Point3D(0, 1, 10);
|
||||
// view3d.CameraController.CameraMode = CameraMode.FixedPosition;
|
||||
// view3d.CameraController.CameraRotationMode = CameraRotationMode.Turntable;
|
||||
|
||||
var camera = view3d.Camera as PerspectiveCamera;
|
||||
camera.Position = new Point3D(0, 0, 0);
|
||||
camera.LookDirection = new Vector3D(0, 1, 0);
|
||||
camera.UpDirection = new Vector3D(0, 0, 1);
|
||||
camera.FieldOfView = 120;
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 226 KiB After Width: | Height: | Size: 43 KiB |
@ -1,10 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="CommonServiceLocator" version="1.3" targetFramework="net45" />
|
||||
<package id="EntityFramework" version="6.2.0" targetFramework="net46" />
|
||||
<package id="GMap.NET.Windows" version="1.8.5" targetFramework="net46" />
|
||||
<package id="HelixToolkit" version="2.4.0" targetFramework="net46" />
|
||||
<package id="HelixToolkit.Wpf" version="2.4.0" targetFramework="net46" />
|
||||
<package id="MahApps.Metro" version="1.5.0" targetFramework="net46" />
|
||||
<package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" />
|
||||
<package id="MaterialDesignThemes" version="1.4.0.473" targetFramework="net46" />
|
||||
<package id="Microsoft.Maps.MapControl.WPF" version="1.0.0.3" targetFramework="net45" />
|
||||
<package id="Microsoft.Maps.MapControl.WPF" version="1.0.0.3" targetFramework="net46" />
|
||||
<package id="MvvmLightLibs" version="5.2.0.0" targetFramework="net46" />
|
||||
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net46" />
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net46" />
|
||||
<package id="System.Data.SQLite" version="1.0.109.1" targetFramework="net46" />
|
||||
<package id="System.Data.SQLite.Core" version="1.0.109.1" targetFramework="net46" />
|
||||
<package id="System.Data.SQLite.EF6" version="1.0.109.0" targetFramework="net46" />
|
||||
<package id="System.Data.SQLite.Linq" version="1.0.109.0" targetFramework="net46" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user