From 3362a1b47c7c383c3cc958b0ac49038ec0ccb826 Mon Sep 17 00:00:00 2001 From: xu Date: Wed, 26 Feb 2020 02:02:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=99=BB=E5=BD=95=E5=92=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/ChangePasswordView.cs | 150 ++++++++++++++++++ .../ViewModels/LoginViewModel.cs | 123 ++++++++++++++ .../Views/ChangePasswordView.xaml | 77 +++++++++ .../Views/ChangePasswordView.xaml.cs | 24 +++ Plane.FormationCreator/Views/LoginView.xaml | 55 +++++++ .../Views/LoginView.xaml.cs | 24 +++ 6 files changed, 453 insertions(+) create mode 100644 Plane.FormationCreator/ViewModels/ChangePasswordView.cs create mode 100644 Plane.FormationCreator/ViewModels/LoginViewModel.cs create mode 100644 Plane.FormationCreator/Views/ChangePasswordView.xaml create mode 100644 Plane.FormationCreator/Views/ChangePasswordView.xaml.cs create mode 100644 Plane.FormationCreator/Views/LoginView.xaml create mode 100644 Plane.FormationCreator/Views/LoginView.xaml.cs diff --git a/Plane.FormationCreator/ViewModels/ChangePasswordView.cs b/Plane.FormationCreator/ViewModels/ChangePasswordView.cs new file mode 100644 index 0000000..9e1978f --- /dev/null +++ b/Plane.FormationCreator/ViewModels/ChangePasswordView.cs @@ -0,0 +1,150 @@ +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using Microsoft.Practices.ServiceLocation; +using Plane.FormationCreator.Formation; +using Plane.FormationCreator.Util; +using Plane.FormationCreator.Views; +using Plane.Util; +using Plane.Windows.Messages; +using System; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Interactivity; + +namespace Plane.FormationCreator.ViewModels +{ + /// + /// This class contains properties that a View can data bind to. + /// + /// See http://www.galasoft.ch/mvvm + /// + /// + public class ChangePasswordViewModel : ViewModelBase + { + private CopterManager _copterManager = ServiceLocator.Current.GetInstance(); + private MainViewModel _MainViewModel=ServiceLocator.Current.GetInstance(); + /// + /// Initializes a new instance of the LoginViewModel class. + /// + public ChangePasswordViewModel() + { + + NewPassword = ""; + OldPassword = ""; + NewPassword1 = ""; + Username = ""; + } + + + private string _Username=""; + public string Username + { + get { return _Username; } + set + { + Set(nameof(Username), ref _Username, value); + } + } + + + + + private string _OldPassword = ""; + public string OldPassword + { + get { return _OldPassword; } + set + { + Set(nameof(OldPassword), ref _OldPassword, value); + } + } + + private string _NewPassword = ""; + public string NewPassword + { + get { return _NewPassword; } + set + { + Set(nameof(NewPassword), ref _NewPassword, value); + } + } + private string _NewPassword1 = ""; + public string NewPassword1 + { + get { return _NewPassword1; } + set + { + Set(nameof(NewPassword1), ref _NewPassword1, value); + } + } + + + + + + + + private ICommand _ExitCommand; + public ICommand ExitCommand + { + get + { + return _ExitCommand ?? (_ExitCommand = new RelayCommand(wd => + { + if (wd != null) + { + NewPassword = ""; + OldPassword = ""; + NewPassword1 = ""; + Username = ""; + wd.Close(); + } + + })); + } + } + private ICommand _ChangePasswordCommand; + public ICommand ChangePasswordCommand + { + get + { + return _ChangePasswordCommand ?? (_ChangePasswordCommand = new RelayCommand(wd => + { + if (Username.Trim() == "") + { + Alert.Show("请输入账号!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + + if (OldPassword=="") + { + Alert.Show("请输入原密码!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + + if (NewPassword.Length<6) + { + Alert.Show("新密码长度不能低于6位!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + + if (NewPassword != NewPassword1) + { + Alert.Show("两次新密码不相同!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + + + + _copterManager.NetChangePassword(Username.Trim(), OldPassword, NewPassword); + + //wd.Close(); + + })); + } + } + + } +} \ No newline at end of file diff --git a/Plane.FormationCreator/ViewModels/LoginViewModel.cs b/Plane.FormationCreator/ViewModels/LoginViewModel.cs new file mode 100644 index 0000000..ddffd1c --- /dev/null +++ b/Plane.FormationCreator/ViewModels/LoginViewModel.cs @@ -0,0 +1,123 @@ +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using Microsoft.Practices.ServiceLocation; +using Plane.FormationCreator.Formation; +using Plane.FormationCreator.Util; +using Plane.FormationCreator.Views; +using Plane.Util; +using Plane.Windows.Messages; +using System; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Interactivity; + +namespace Plane.FormationCreator.ViewModels +{ + /// + /// This class contains properties that a View can data bind to. + /// + /// See http://www.galasoft.ch/mvvm + /// + /// + public class LoginViewModel : ViewModelBase + { + private CopterManager _copterManager = ServiceLocator.Current.GetInstance(); + private MainViewModel _MainViewModel=ServiceLocator.Current.GetInstance(); + /// + /// Initializes a new instance of the LoginViewModel class. + /// + public LoginViewModel() + { + + Username = VersionControl.Username; + SavePassword = VersionControl.IssavePassword; + if (SavePassword) + Password = VersionControl.Password; + } + + + private string _Username=""; + public string Username + { + get { return _Username; } + set + { + Set(nameof(Username), ref _Username, value); + } + } + + + + + private string _Password = ""; + public string Password + { + get { return _Password; } + set + { + Set(nameof(Password), ref _Password, value); + } + } + + + private bool _SavePassword = false; + public bool SavePassword + { + get { return _SavePassword; } + set + { + Set(nameof(SavePassword), ref _SavePassword, value); + } + } + + + + + + + private ICommand _ExitCommand; + public ICommand ExitCommand + { + get + { + return _ExitCommand ?? (_ExitCommand = new RelayCommand(wd => + { + if (wd != null) + { + wd.Close(); + } + + })); + } + } + private ICommand _LoginCommand; + public ICommand LoginCommand + { + get + { + return _LoginCommand ?? (_LoginCommand = new RelayCommand(wd => + { + if (Username.Trim() == "") + { + Alert.Show("请输入账号!", "登录提示", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + + if (Password == "") + { + Alert.Show("请输入密码!", "登录提示", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + + _copterManager.NetLogoin(Username.Trim(), Password, SavePassword); + if (!SavePassword) Password = ""; + wd.Close(); + + })); + } + } + + } +} \ No newline at end of file diff --git a/Plane.FormationCreator/Views/ChangePasswordView.xaml b/Plane.FormationCreator/Views/ChangePasswordView.xaml new file mode 100644 index 0000000..a1d11e7 --- /dev/null +++ b/Plane.FormationCreator/Views/ChangePasswordView.xaml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + +