PasswordMsgBox.xaml.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Input;
  5. using Aitex.Core.Account;
  6. using MECF.Framework.UI.Core.Applications;
  7. namespace MECF.Framework.UI.Core.Accounts
  8. {
  9. /// <summary>
  10. /// Interaction logic for MainLogin.xaml
  11. /// </summary>
  12. public partial class PasswordMsgBox : Window
  13. {
  14. PasswordMsgBoxModel viewModel;
  15. public PasswordMsgBox()
  16. {
  17. InitializeComponent();
  18. viewModel = new PasswordMsgBoxModel();
  19. DataContext = viewModel;
  20. }
  21. private string userName = "admin";
  22. private void OnLoginClicked(object sender, RoutedEventArgs e)
  23. {
  24. IntPtr p = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(passwordBox.SecurePassword);
  25. string passWord = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(p);
  26. viewModel.UserName = userName;
  27. viewModel.Password = passWord;
  28. LoginResult loginResult = AccountClient.Instance.Service.Login(userName, passWord);
  29. LabelResult.Content = loginResult.Description;
  30. if (loginResult.ActSucc)
  31. {
  32. this.DialogResult = true;
  33. this.Close();
  34. }
  35. else
  36. {
  37. this.passwordBox.Focus();
  38. this.LabelResult.Content = "error in your password. Please re-enter";
  39. }
  40. }
  41. private void OnExitClicked(object sender, RoutedEventArgs e)
  42. {
  43. this.DialogResult = false;
  44. this.Close();
  45. }
  46. }
  47. }