加入和服务器交互,必须登录服务器账号才能允许加入飞机
飞机数量控制以前的ini方式去掉,改为仅仅账号控制 加入登录登出服务器日志 加入飞行任务服务器日志 加入修改密码功能 用户级别也只能用账号方式控制 超级用户硬编码到代码里,不用登录服务器:admin 密码 fxmf0622
This commit is contained in:
parent
6cb44d5401
commit
92044ae56b
@ -69,7 +69,7 @@ namespace Plane.FormationCreator
|
||||
};
|
||||
//new Test().Prepare().Run();
|
||||
|
||||
VersionControl.GetVersionFromIni();
|
||||
VersionControl.GetSettingFromIni();
|
||||
}
|
||||
|
||||
private ILogger _logger;
|
||||
@ -177,16 +177,19 @@ namespace Plane.FormationCreator
|
||||
{
|
||||
await Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
copter = new Copter(Connection, SynchronizationContext.Current, _mapManager.Center.Lat, _mapManager.Center.Lng)
|
||||
if (_copterManager.EnAddCopter_Real())
|
||||
{
|
||||
Id = ip,
|
||||
Name = ip.Substring(ip.LastIndexOf('.') + 1)
|
||||
|
||||
};
|
||||
int _index;
|
||||
_index=copters.AddCopter(copter);
|
||||
copterStatus.Insert(_index,false);
|
||||
copter.TextReceived += Copter_TextReceived;
|
||||
copter = new Copter(Connection, SynchronizationContext.Current, _mapManager.Center.Lat, _mapManager.Center.Lng)
|
||||
{
|
||||
Id = ip,
|
||||
Name = ip.Substring(ip.LastIndexOf('.') + 1)
|
||||
|
||||
};
|
||||
int _index;
|
||||
_index = copters.AddCopter(copter);
|
||||
copterStatus.Insert(_index, false);
|
||||
copter.TextReceived += Copter_TextReceived;
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
@ -243,17 +246,21 @@ namespace Plane.FormationCreator
|
||||
var copter = _copterManager.Copters.FirstOrDefault(c => c.Id == id.ToString());
|
||||
if (copter == null)
|
||||
{
|
||||
var copterStatus = _copterManager.CopterStatus;
|
||||
var connection = new CommConnection();
|
||||
copter = new Copter(connection, SynchronizationContext.Current, _mapManager.Center.Lat, _mapManager.Center.Lng)
|
||||
if (_copterManager.EnAddCopter_Real())
|
||||
{
|
||||
Id = id.ToString(),
|
||||
Name = id.ToString(),
|
||||
};
|
||||
int _index;
|
||||
_index = _copterManager.Copters.AddCopter(copter);
|
||||
copterStatus.Insert(_index, false);
|
||||
copter.TextReceived += Copter_TextReceived;
|
||||
|
||||
var copterStatus = _copterManager.CopterStatus;
|
||||
var connection = new CommConnection();
|
||||
copter = new Copter(connection, SynchronizationContext.Current, _mapManager.Center.Lat, _mapManager.Center.Lng)
|
||||
{
|
||||
Id = id.ToString(),
|
||||
Name = id.ToString(),
|
||||
};
|
||||
int _index;
|
||||
_index = _copterManager.Copters.AddCopter(copter);
|
||||
copterStatus.Insert(_index, false);
|
||||
copter.TextReceived += Copter_TextReceived;
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
@ -8,12 +8,25 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Plane.FormationCreator.Util;
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
using Plane.FormationCreator.ViewModels;
|
||||
using System.Threading;
|
||||
using Plane.Communication;
|
||||
using Plane.Util;
|
||||
using System.Windows;
|
||||
using Plane.Windows.Messages;
|
||||
|
||||
namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
|
||||
public class CopterCollection : ObservableCollection<ICopter>
|
||||
{
|
||||
|
||||
public int EnCopterNumber = 0;
|
||||
|
||||
public int EnVCopterNumber = 0;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 实现排序插入
|
||||
/// </summary>
|
||||
@ -33,12 +46,39 @@ namespace Plane.FormationCreator.Formation
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (this.Count >= VersionControl.CopterUpperLimit)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//网络登录限制
|
||||
// if (!VersionControl.IsFullVersion)
|
||||
{
|
||||
if (entityObject is FakeCopter)
|
||||
{
|
||||
if (this.Count >= EnVCopterNumber)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.Count >= EnCopterNumber)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
int _index = 0;
|
||||
if (this.Count == 0)
|
||||
{
|
||||
@ -88,6 +128,16 @@ namespace Plane.FormationCreator.Formation
|
||||
|
||||
public class CopterManager : ObservableObject
|
||||
{
|
||||
const string supername = "admin";
|
||||
const string superpass = "fxmf0622";
|
||||
//服务器地址
|
||||
const string strUrlPre = "http://111.229.174.37:81/login/checkforapp.php";
|
||||
//用户级别
|
||||
const int LEVEL_NORMAL = 1;
|
||||
const int LEVEL_ADMIN = 0;
|
||||
|
||||
|
||||
private string superDispname = "超级用户";
|
||||
public CopterManager()
|
||||
{
|
||||
AppEx.Current.AppModeChanged += (sender, e) =>
|
||||
@ -103,7 +153,7 @@ namespace Plane.FormationCreator.Formation
|
||||
|
||||
public List<ICopter> ShowCopter = new List<ICopter>();
|
||||
|
||||
|
||||
|
||||
//3维视图显示比例,有些大的图案显示不出来可以缩小
|
||||
private float _scale3d = 1.0f;
|
||||
public float scale3d
|
||||
@ -112,9 +162,12 @@ namespace Plane.FormationCreator.Formation
|
||||
set { Set(nameof(scale3d), ref _scale3d, value); }
|
||||
}
|
||||
|
||||
public delegate void NetStatusChanged(bool Logined, string status);
|
||||
public event NetStatusChanged netStatusChanged;
|
||||
|
||||
public CopterCollection Copters { get;} = new CopterCollection();
|
||||
|
||||
|
||||
//标记某飞机是否需要跳过
|
||||
public ArrayList CopterStatus = new ArrayList();
|
||||
//public ObservableCollection<ICopter> Copters
|
||||
//{
|
||||
@ -134,6 +187,295 @@ namespace Plane.FormationCreator.Formation
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
private string _Loginstate = "未登录";
|
||||
public string Loginstate
|
||||
{
|
||||
get { return _Loginstate; }
|
||||
set
|
||||
{
|
||||
Set(nameof(Loginstate), ref _Loginstate, value);
|
||||
netStatusChanged(Logined,Loginstate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int _EnCopterNumber = 0;
|
||||
public int EnCopterNumber
|
||||
{
|
||||
get { return _EnCopterNumber; }
|
||||
set
|
||||
{
|
||||
Set(nameof(EnCopterNumber), ref _EnCopterNumber, value);
|
||||
Copters.EnCopterNumber = EnCopterNumber;
|
||||
}
|
||||
}
|
||||
|
||||
private int _EnVCopterNumber = 0;
|
||||
public int EnVCopterNumber
|
||||
{
|
||||
get { return _EnVCopterNumber; }
|
||||
set
|
||||
{
|
||||
Set(nameof(EnVCopterNumber), ref _EnVCopterNumber, value);
|
||||
Copters.EnVCopterNumber = EnVCopterNumber;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _Logined = false;
|
||||
public bool Logined
|
||||
{
|
||||
get { return _Logined; }
|
||||
set
|
||||
{
|
||||
Set(nameof(Logined), ref _Logined, value);
|
||||
netStatusChanged(Logined, Loginstate);
|
||||
}
|
||||
}
|
||||
|
||||
private string _UserName = "";
|
||||
private string _UserDisplayName = "";
|
||||
|
||||
public void NetLogined(string UserName,string UserDisplayName,int vEnCopterNumber,int vEnVCopterNumber,int userlever=1)
|
||||
{
|
||||
_UserName = UserName;
|
||||
EnCopterNumber = vEnCopterNumber;
|
||||
EnVCopterNumber = vEnVCopterNumber;
|
||||
_UserDisplayName = UserDisplayName;
|
||||
string dis_EnCopterNumber ="<"+ EnCopterNumber.ToString()+">";
|
||||
string dis_EnVCopterNumber = "<" + EnVCopterNumber.ToString() + ">";
|
||||
if (EnCopterNumber == -1) dis_EnCopterNumber = "<无限>";
|
||||
if (EnVCopterNumber == -1) dis_EnVCopterNumber = "<无限>";
|
||||
Loginstate ="["+ UserDisplayName + "]已登录,模拟飞机:"+ dis_EnVCopterNumber + "架,真实飞机:"+ dis_EnCopterNumber + "架";
|
||||
Logined = true;
|
||||
VersionControl.SetUserLever(userlever);
|
||||
if (UserName != supername)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
while (Logined)
|
||||
{
|
||||
NetActivePost();
|
||||
//30秒一次保持活跃
|
||||
await Task.Delay(30 * 1000).ConfigureAwait(false);
|
||||
}
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
private void NetActivePost()
|
||||
{
|
||||
// 发送请求
|
||||
StringBuilder sbUrl = new StringBuilder(); // 请求URL内容
|
||||
sbUrl.Append(strUrlPre);
|
||||
sbUrl.Append("?");
|
||||
sbUrl.Append("username=" + _UserName);
|
||||
sbUrl.Append("&type=Active");
|
||||
String strUrl = sbUrl.ToString();
|
||||
string errorstr;
|
||||
new AsynDataUtils().AsynGetData(strUrl, null,out errorstr);
|
||||
}
|
||||
|
||||
private void NetLogoutPost()
|
||||
{
|
||||
// 发送请求
|
||||
StringBuilder sbUrl = new StringBuilder(); // 请求URL内容
|
||||
sbUrl.Append(strUrlPre);
|
||||
sbUrl.Append("?");
|
||||
sbUrl.Append("username=" + _UserName);
|
||||
|
||||
sbUrl.Append("&" + "clientname=" + System.Net.Dns.GetHostName());
|
||||
sbUrl.Append("&type=Logout");
|
||||
|
||||
String strUrl = sbUrl.ToString();
|
||||
string errorstr;
|
||||
new AsynDataUtils().AsynGetData(strUrl, null, out errorstr);
|
||||
}
|
||||
public void NetLogout()
|
||||
{
|
||||
if (Logined)
|
||||
NetLogoutPost();
|
||||
|
||||
|
||||
Logined = false;
|
||||
EnCopterNumber = 0;
|
||||
EnVCopterNumber = 0;
|
||||
_UserDisplayName = "";
|
||||
_UserName = "";
|
||||
VersionControl.SetUserLever(LEVEL_NORMAL);
|
||||
Loginstate = "未登录";
|
||||
}
|
||||
|
||||
|
||||
//提交飞行记录
|
||||
public void Net_PostStartMission(DateTime MissionTime,double OriginLng, double OriginLat)
|
||||
{
|
||||
|
||||
// 发送请求
|
||||
StringBuilder sbUrl = new StringBuilder(); // 请求URL内容
|
||||
sbUrl.Append(strUrlPre);
|
||||
sbUrl.Append("?");
|
||||
sbUrl.Append("username=" + _UserName);
|
||||
sbUrl.Append("&" + "clientname=" + System.Net.Dns.GetHostName());
|
||||
sbUrl.Append("&type=StartMission");
|
||||
sbUrl.Append("&mtime="+ MissionTime.ToString());
|
||||
sbUrl.Append("&orgLng="+ OriginLng.ToString());
|
||||
sbUrl.Append("&orgLat="+ OriginLat.ToString());
|
||||
sbUrl.Append("&coptercount=" + Copters.Count().ToString());
|
||||
|
||||
String strUrl = sbUrl.ToString();
|
||||
string errorstr;
|
||||
new AsynDataUtils().AsynGetData(strUrl, null, out errorstr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private string tempuser;
|
||||
private string tempPassword;
|
||||
private bool tempSavePassword;
|
||||
|
||||
//在这个方法里面接收回调的返回信息
|
||||
private void DataResultCallBack(string data,bool haveerror)
|
||||
{
|
||||
if (haveerror)
|
||||
{
|
||||
Loginstate = "登录失败,"+ data;
|
||||
return;
|
||||
}
|
||||
if (data == "")
|
||||
{
|
||||
Loginstate = "登录失败,请检查网络连接";
|
||||
return;
|
||||
}
|
||||
string[] arr = data.Split(';');
|
||||
string loginret = arr[0];
|
||||
if (loginret == "Login ok")
|
||||
{
|
||||
if (arr.Length!= 5)
|
||||
{
|
||||
Alert.Show("系统版本不正确!", "登录提示", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string UserDisplayName = arr[1];
|
||||
int vEnCopterNumber = int.Parse(arr[2]);
|
||||
int vEnVCopterNumber = int.Parse(arr[3]);
|
||||
int userlevel = int.Parse(arr[4]);
|
||||
NetLogined(tempuser, UserDisplayName, vEnCopterNumber, vEnVCopterNumber, userlevel);
|
||||
VersionControl.SaveLogininfoToIni(tempuser, tempPassword, tempSavePassword);
|
||||
//MessageBox.Show(UserDisplayName + " 登录成功!", "登录提示");
|
||||
}
|
||||
else
|
||||
if (loginret == "username error")
|
||||
{
|
||||
NetLogout();
|
||||
Alert.Show("账号错误!", "登录提示", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
else
|
||||
if (loginret == "password error")
|
||||
{
|
||||
NetLogout();
|
||||
Alert.Show("密码错误!", "登录提示", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
else
|
||||
if (loginret == "replogin error")
|
||||
{
|
||||
NetLogout();
|
||||
Alert.Show("该账号已在其他地方登录!", "登录提示", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
public void NetLogoin(string username,string password,bool savepassword)
|
||||
{
|
||||
Logined = false;
|
||||
//超级用户,无限制
|
||||
if ((username== supername) && (password== superpass))
|
||||
{
|
||||
NetLogined(supername, superDispname, -1, -1, LEVEL_ADMIN);
|
||||
return;
|
||||
}
|
||||
|
||||
tempuser = username;
|
||||
tempPassword = password;
|
||||
tempSavePassword = savepassword;
|
||||
// 发送请求
|
||||
StringBuilder sbUrl = new StringBuilder(); // 请求URL内容
|
||||
sbUrl.Append(strUrlPre);
|
||||
sbUrl.Append("?");
|
||||
sbUrl.Append("username=" + username);
|
||||
sbUrl.Append("&" + "password=" + password);
|
||||
sbUrl.Append("&" + "clientname=" + System.Net.Dns.GetHostName());
|
||||
String strUrl = sbUrl.ToString();
|
||||
string errorstr;
|
||||
if (new AsynDataUtils().AsynGetData(strUrl, DataResultCallBack, out errorstr))
|
||||
Loginstate = "登录中...";
|
||||
else Loginstate = "登录失败,"+ errorstr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//在这个方法里面接收回调的返回信息
|
||||
private void DataResultCallBack_changepassword(string data, bool haveerror)
|
||||
{
|
||||
if (haveerror)
|
||||
{
|
||||
MessageBox.Show("更改失败," + data, "提示");
|
||||
return;
|
||||
}
|
||||
if (data == "")
|
||||
{
|
||||
MessageBox.Show("更改失败,请检查网络", "提示");
|
||||
return;
|
||||
}
|
||||
string[] arr = data.Split(';');
|
||||
string loginret = arr[0];
|
||||
if (loginret == "chpassword ok")
|
||||
{
|
||||
MessageBox.Show( "密码更改成功!", "提示");
|
||||
}
|
||||
else
|
||||
if (loginret == "username error")
|
||||
{
|
||||
|
||||
MessageBox.Show("账号错误!", "提示");
|
||||
}
|
||||
else
|
||||
if (loginret == "password error")
|
||||
{
|
||||
MessageBox.Show("原密码错误!", "提示");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void NetChangePassword(string username, string oldpassword, string newpassword)
|
||||
{
|
||||
tempuser = username;
|
||||
tempPassword = oldpassword;
|
||||
// 发送请求
|
||||
StringBuilder sbUrl = new StringBuilder(); // 请求URL内容
|
||||
sbUrl.Append(strUrlPre);
|
||||
sbUrl.Append("?");
|
||||
sbUrl.Append("username=" + username);
|
||||
sbUrl.Append("&password=" + oldpassword);
|
||||
sbUrl.Append("&clientname=" + System.Net.Dns.GetHostName());
|
||||
sbUrl.Append("&type=Chpassword");
|
||||
sbUrl.Append("&newpassword=" + newpassword);
|
||||
String strUrl = sbUrl.ToString();
|
||||
string errorstr;
|
||||
if (!new AsynDataUtils().AsynGetData(strUrl, DataResultCallBack_changepassword, out errorstr))
|
||||
MessageBox.Show("更改失败," + errorstr, "提示");
|
||||
}
|
||||
|
||||
public bool shiftkeydown;
|
||||
public IEnumerable<ICopter> SelectedCopters { get { return _selectedCoptersGetter().Cast<ICopter>(); } }
|
||||
|
||||
@ -166,10 +508,28 @@ namespace Plane.FormationCreator.Formation
|
||||
SeletedCopterCount = SelectedCopters.Count();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public bool EnAddCopter_Real()
|
||||
{
|
||||
if (EnCopterNumber == -1) return true;
|
||||
else
|
||||
return Copters.Count < EnCopterNumber;
|
||||
}
|
||||
|
||||
public bool EnAddCopter_Fake()
|
||||
{
|
||||
if (EnVCopterNumber == -1) return true;
|
||||
else
|
||||
return Copters.Count < EnVCopterNumber;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 选择飞机
|
||||
/// </summary>
|
||||
/// <param name="copter">Null表示清除所有选择</param>
|
||||
/// 选择飞机
|
||||
/// </summary>
|
||||
/// <param name="copter">Null表示清除所有选择</param>
|
||||
public void Select(ICopter copter)
|
||||
{
|
||||
_selectCopterAction(copter);
|
||||
|
@ -18,7 +18,9 @@
|
||||
PreviewKeyUp="MetroWindow_PreviewKeyUp"
|
||||
Style="{StaticResource VSWindowStyleKey}"
|
||||
Width="1920"
|
||||
Height="1080" >
|
||||
Height="1080"
|
||||
Closing="Window_Closing"
|
||||
>
|
||||
|
||||
<c:MetroWindow.Resources>
|
||||
<Style TargetType="Separator"
|
||||
@ -43,7 +45,7 @@
|
||||
<c:MetroWindow.RightWindowCommands>
|
||||
<c:WindowCommands>
|
||||
|
||||
<Button Content="登陆"
|
||||
<Button Content="{Binding LoginDisp}"
|
||||
Command="{Binding LoginCommand}" />
|
||||
|
||||
<Button Content="{Binding AppEx.ShowModifyTaskView, Converter={StaticResource ShowModifyTaskViewButtonContentConverter}}"
|
||||
@ -237,6 +239,7 @@
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<TextBlock Text="{Binding Loginstate}" Margin="0,4,14,0"/>
|
||||
<TextBlock Text="通信连接:" Margin="4"/>
|
||||
<ContentPresenter Margin="0,4,14,0" Content="{Binding CommunicationModuleConnected, Converter={StaticResource CheckSignConverter}, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
|
@ -35,9 +35,10 @@ namespace Plane.FormationCreator
|
||||
InitializeComponent();
|
||||
|
||||
this.DataContext = ServiceLocator.Current.GetInstance<MainViewModel>();
|
||||
// this.OnClosing += Window_Closing;
|
||||
//改到设置窗口显示版本信息
|
||||
// var version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
// Title = "飞行魔方无人机编队控制系统 V" + version.ToString() + "编译时间[" + System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location).ToString() + "]";
|
||||
// Title = "飞行魔方无人机编队控制系统 V" + version.ToString() + "编译时间[" + System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location).ToString() + "]";
|
||||
|
||||
|
||||
//ShowConnectDialog();
|
||||
@ -59,7 +60,17 @@ namespace Plane.FormationCreator
|
||||
}
|
||||
loginWindow.ShowDialog ();
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
_copterManager.NetLogout();
|
||||
/*
|
||||
MessageBoxResult result = MessageBox.Show("Do you really want to exit?", "", MessageBoxButton.YesNo);
|
||||
if (result == MessageBoxResult.No)
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
private void btnLogin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var loginWindow = new ConnectWindow
|
||||
@ -485,7 +496,7 @@ namespace Plane.FormationCreator
|
||||
{
|
||||
MainViewModel vm = DataContext as MainViewModel;
|
||||
LogWindow logWindows = new LogWindow(vm.Messages);
|
||||
logWindows.Show();
|
||||
logWindows.ShowDialog();
|
||||
}
|
||||
|
||||
private void LogShowHide(object sender, MouseButtonEventArgs e)
|
||||
|
@ -195,6 +195,7 @@
|
||||
<Compile Include="Util\ICommsSerial.cs" />
|
||||
<Compile Include="Util\ICorrections.cs" />
|
||||
<Compile Include="Util\ParamFile.cs" />
|
||||
<Compile Include="Util\PasswordBoxHelper.cs" />
|
||||
<Compile Include="Util\rtcm3.cs" />
|
||||
<Compile Include="Util\VersionControl.cs" />
|
||||
<Compile Include="ViewModels\CalibrationViewModel.cs" />
|
||||
@ -203,6 +204,8 @@
|
||||
<Compile Include="ViewModels\ControlPanelViewModel.cs" />
|
||||
<Compile Include="ViewModels\CopterListViewModel.cs" />
|
||||
<Compile Include="ViewModels\GroupsViewModel.cs" />
|
||||
<Compile Include="ViewModels\ChangePasswordView.cs" />
|
||||
<Compile Include="ViewModels\LoginViewModel.cs" />
|
||||
<Compile Include="ViewModels\MainViewModel.cs" />
|
||||
<Compile Include="ViewModels\MapViewModel.cs" />
|
||||
<Compile Include="ViewModels\ModifyTaskViewModel.cs" />
|
||||
@ -234,6 +237,12 @@
|
||||
<Compile Include="Views\ConnectWindow.xaml.cs">
|
||||
<DependentUpon>ConnectWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ChangePasswordView.xaml.cs">
|
||||
<DependentUpon>ChangePasswordView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\LoginView.xaml.cs">
|
||||
<DependentUpon>LoginView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\LogWindow.xaml.cs">
|
||||
<DependentUpon>LogWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -373,6 +382,14 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\ChangePasswordView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\LoginView.xaml">
|
||||
<SubType>Form</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\LogWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -34,6 +34,8 @@ namespace Plane.FormationCreator
|
||||
_container.Register<View3DViewModel>();
|
||||
_container.Register<ModifyTaskViewModel>();
|
||||
_container.Register<CalibrationViewModel>();
|
||||
_container.Register<LoginViewModel>();
|
||||
_container.Register<ChangePasswordViewModel>();
|
||||
_container.Register<GroupsViewModel>();
|
||||
_container.Register<RtcmInfoViewModel>();
|
||||
_container.Register<ConfigVirtualIdViewModel>();
|
||||
|
@ -7,10 +7,14 @@ namespace Plane.Util
|
||||
{
|
||||
public class AsynDataUtils
|
||||
{
|
||||
public delegate void DataResultCallBack(string data);
|
||||
public delegate void DataResultCallBack(string data,bool haveerror);
|
||||
DataResultCallBack _callback;
|
||||
public void AsynGetData(string tagUrl, DataResultCallBack callback)
|
||||
bool haveerror;
|
||||
string errorstr;
|
||||
public bool AsynGetData(string tagUrl, DataResultCallBack callback, out string verrorstr)
|
||||
{
|
||||
haveerror = false;
|
||||
errorstr = "";
|
||||
try
|
||||
{
|
||||
_callback = callback;
|
||||
@ -18,8 +22,13 @@ namespace Plane.Util
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorstr += ex.Message;
|
||||
haveerror = true;
|
||||
Console.WriteLine(ex.Message);
|
||||
|
||||
}
|
||||
verrorstr = errorstr;
|
||||
return !haveerror;
|
||||
}
|
||||
|
||||
private void ReadCallback(IAsyncResult asynchronousResult)
|
||||
@ -39,13 +48,18 @@ namespace Plane.Util
|
||||
Console.WriteLine(resultString);
|
||||
if (_callback != null)
|
||||
{
|
||||
_callback(resultString);
|
||||
_callback(resultString,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
if (_callback != null)
|
||||
{
|
||||
_callback(ex.Message, true);
|
||||
}
|
||||
Console.WriteLine(ex.Message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,13 +20,30 @@ namespace Plane.FormationCreator.Util
|
||||
/// </summary>
|
||||
public static int CopterUpperLimit = 50;
|
||||
|
||||
public static void GetVersionFromIni()
|
||||
public static string Username = "";
|
||||
public static string Password = "";
|
||||
public static bool IssavePassword = false;
|
||||
|
||||
public static void SetUserLever(int vuserlever)
|
||||
{
|
||||
if (vuserlever==0)
|
||||
//管理员
|
||||
IsFullVersion = true;
|
||||
else
|
||||
IsFullVersion = false;
|
||||
}
|
||||
|
||||
|
||||
public static void GetSettingFromIni()
|
||||
{
|
||||
IniFiles iniFiles = new IniFiles();
|
||||
|
||||
int intTemp;
|
||||
bool boolTemp;
|
||||
string readvalue;
|
||||
|
||||
//完整版本和更多飞机数量通过网络授权或者超级用户得到
|
||||
|
||||
/*
|
||||
readvalue = iniFiles.IniReadvalue("Version", "Version");
|
||||
if (readvalue != "" && int.TryParse(readvalue, out intTemp))
|
||||
Version = int.Parse(readvalue);
|
||||
@ -35,6 +52,42 @@ namespace Plane.FormationCreator.Util
|
||||
readvalue = iniFiles.IniReadvalue("Version", "CopterUpperLimit");
|
||||
if (readvalue != "" && int.TryParse(readvalue, out intTemp))
|
||||
CopterUpperLimit = int.Parse(readvalue);
|
||||
*/
|
||||
|
||||
readvalue = iniFiles.IniReadvalue("Login", "Username");
|
||||
if (readvalue != "")
|
||||
Username = readvalue;
|
||||
|
||||
readvalue = iniFiles.IniReadvalue("Login", "Password");
|
||||
if (readvalue != "")
|
||||
Password = readvalue;
|
||||
|
||||
|
||||
readvalue = iniFiles.IniReadvalue("Login", "issavePassword");
|
||||
if (readvalue != "" && bool.TryParse(readvalue, out boolTemp))
|
||||
IssavePassword = bool.Parse(readvalue);
|
||||
|
||||
}
|
||||
|
||||
public static void SaveLogininfoToIni(string username,string password,bool issavepassword)
|
||||
{
|
||||
Username = username;
|
||||
Password = password;
|
||||
IssavePassword = issavepassword;
|
||||
IniFiles iniFiles = new IniFiles();
|
||||
iniFiles.IniWritevalue("Login", "Username", username);
|
||||
if (issavepassword)
|
||||
iniFiles.IniWritevalue("Login", "Password", password);
|
||||
else
|
||||
iniFiles.IniWritevalue("Login", "Password", "");
|
||||
|
||||
iniFiles.IniWritevalue("Login", "issavepassword", issavepassword.ToString());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ using Plane.CommunicationManagement;
|
||||
using Plane.Protocols;
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
using System.Windows.Media;
|
||||
using Plane.FormationCreator.Views;
|
||||
|
||||
namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
@ -229,7 +230,18 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _ChangepasswordCommand;
|
||||
public ICommand ChangepasswordCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ChangepasswordCommand ?? (_ChangepasswordCommand = new RelayCommand( () =>
|
||||
{
|
||||
ChangePasswordView changePasswordView = new ChangePasswordView();
|
||||
changePasswordView.ShowDialog();
|
||||
}));
|
||||
}
|
||||
}
|
||||
private ICommand _CommDataAsync;
|
||||
public ICommand CommDataAsync
|
||||
{
|
||||
|
@ -1148,17 +1148,16 @@ namespace Plane.FormationCreator.ViewModels
|
||||
Alert.Show("作为参照的原点未设置,无法开始任务!", "提示");
|
||||
return;
|
||||
}
|
||||
int utchour = DateTime.UtcNow.AddSeconds(5).Hour;
|
||||
int utcminute = DateTime.UtcNow.AddSeconds(5).Minute;
|
||||
int utcsecond = DateTime.UtcNow.AddSeconds(5).Second;
|
||||
Message.Show("开始任务");
|
||||
|
||||
DateTime MissionTime = DateTime.UtcNow.AddSeconds(5);
|
||||
Message.Show("开始任务"+ MissionTime.ToString());
|
||||
//循环3次 发送起飞命令 避免通信问题
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
await _commModuleManager.DoMissionStartAsync(_copterManager.Copters,
|
||||
utchour,
|
||||
utcminute,
|
||||
utcsecond,
|
||||
MissionTime.Hour,
|
||||
MissionTime.Minute,
|
||||
MissionTime.Second,
|
||||
_flightTaskManager.OriginLng,
|
||||
_flightTaskManager.OriginLat
|
||||
);
|
||||
@ -1176,7 +1175,9 @@ namespace Plane.FormationCreator.ViewModels
|
||||
*/
|
||||
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
_copterManager.Net_PostStartMission(MissionTime, _flightTaskManager.OriginLng, _flightTaskManager.OriginLat);
|
||||
Alert.Show("所有飞机开始执行航点任务。请勿多次开始任务!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}));
|
||||
}
|
||||
|
@ -270,10 +270,10 @@ namespace Plane.FormationCreator.ViewModels
|
||||
return _AddVirtualCopterCommand ?? (_AddVirtualCopterCommand = new RelayCommand<int>(async addcount =>
|
||||
{
|
||||
//给第三方时候限制数量用
|
||||
if (_copterManager.Copters.Count() >= VersionControl.CopterUpperLimit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// if (_copterManager.Copters.Count() >= VersionControl.CopterUpperLimit)
|
||||
/// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
var center = _mapManager.Center;
|
||||
string id;
|
||||
@ -352,19 +352,20 @@ namespace Plane.FormationCreator.ViewModels
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
var copter = new FakeCopter(SynchronizationContext.Current);
|
||||
copter.SetProperties(
|
||||
latitude: _lastVirtualCopterLocation.Value.Lat,
|
||||
longitude: _lastVirtualCopterLocation.Value.Lng,
|
||||
id: id,
|
||||
name: id
|
||||
);
|
||||
await copter.ConnectAsync();
|
||||
await copter.GetCopterDataAsync();
|
||||
_copterManager.Copters.AddCopter(copter);
|
||||
_copterManager.CopterStatus.Add(false);
|
||||
if (_copterManager.EnAddCopter_Fake())
|
||||
{
|
||||
var copter = new FakeCopter(SynchronizationContext.Current);
|
||||
copter.SetProperties(
|
||||
latitude: _lastVirtualCopterLocation.Value.Lat,
|
||||
longitude: _lastVirtualCopterLocation.Value.Lng,
|
||||
id: id,
|
||||
name: id
|
||||
);
|
||||
await copter.ConnectAsync();
|
||||
await copter.GetCopterDataAsync();
|
||||
_copterManager.Copters.AddCopter(copter);
|
||||
_copterManager.CopterStatus.Add(false);
|
||||
}
|
||||
}
|
||||
if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0)
|
||||
_flightTaskManager.SetOriginal();
|
||||
|
@ -14,6 +14,8 @@ using Microsoft.Practices.ServiceLocation;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Plane.Geography;
|
||||
using Plane.FormationCreator.Views;
|
||||
using System.Windows;
|
||||
|
||||
namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
@ -33,6 +35,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
this.SwitchVelocityModeButtonContent = GetSwitchVelocityModeButtonContent();
|
||||
|
||||
AppEx.Current.PropertyChanged += AppEx_PropertyChanged;
|
||||
_copterManager.netStatusChanged += CopterManagernetStatusChanged;
|
||||
}
|
||||
|
||||
private CopterListViewModel _copterListViewModel;
|
||||
@ -43,6 +46,8 @@ namespace Plane.FormationCreator.ViewModels
|
||||
|
||||
public AppEx AppEx { get; } = AppEx.Current;
|
||||
|
||||
|
||||
|
||||
private void AppEx_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
@ -55,6 +60,14 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void CopterManagernetStatusChanged(bool Logined, string status)
|
||||
{
|
||||
Loginstate = status;
|
||||
if (Logined)
|
||||
LoginDisp = "注销";
|
||||
else LoginDisp = "登录";
|
||||
}
|
||||
|
||||
private string _SwitchVelocityModeButtonContent;
|
||||
public string SwitchVelocityModeButtonContent
|
||||
{
|
||||
@ -159,6 +172,20 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private string _Loginstate = "未登录";
|
||||
public string Loginstate
|
||||
{
|
||||
get { return _copterManager.Loginstate ; }
|
||||
set
|
||||
{
|
||||
Set(nameof(Loginstate), ref _Loginstate, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ICommand _LoginCommand;
|
||||
public ICommand LoginCommand
|
||||
@ -167,7 +194,26 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
return _LoginCommand ?? (_LoginCommand = new RelayCommand(() =>
|
||||
{
|
||||
// AppEx.Current.ShowModifyTaskView = !AppEx.Current.ShowModifyTaskView;
|
||||
|
||||
if (!_copterManager.Logined)
|
||||
{
|
||||
LoginView loginview = new LoginView();
|
||||
loginview.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_copterManager.Copters.Count() > 0)
|
||||
{
|
||||
if (Alert.Show("注销将导致飞机全部清除,您确定要继续吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
|
||||
== MessageBoxResult.Cancel)
|
||||
return;
|
||||
}
|
||||
_copterListViewModel.ClearCoptersCommand.Execute(null);
|
||||
_copterManager.NetLogout();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
}
|
||||
@ -199,6 +245,15 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
|
||||
|
||||
private string _LoginDisp = "登录";
|
||||
public string LoginDisp
|
||||
{
|
||||
get { return _LoginDisp; }
|
||||
set { Set(nameof(LoginDisp), ref _LoginDisp, value); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ICommand _ChangeMapModeCommand;
|
||||
public ICommand ChangeMapModeCommand
|
||||
{
|
||||
|
@ -56,8 +56,9 @@
|
||||
<Button Content="立体缩放" Width="90" Margin="5,5,5,5" Command="{Binding UpdateAllCopterCommand}"></Button>
|
||||
<TextBlock Margin="5" VerticalAlignment="Center" Text="比例:" />
|
||||
<TextBox Width="30" VerticalContentAlignment="Center" Text="{Binding scale3d}" Margin="5,5,5,5" />
|
||||
<Button Content="更改密码" Width="90" Margin="5,5,5,5" Command="{Binding ChangepasswordCommand}"></Button>
|
||||
|
||||
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Left"
|
||||
|
Loading…
Reference in New Issue
Block a user