TradePWDModifyView.xaml.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Input;
  4. using Muchinfo.MTPClient.Account.ViewModels;
  5. using Muchinfo.WPF.Controls.Windows;
  6. using System.Collections.Generic;
  7. namespace Muchinfo.MTPClient.Account.Views
  8. {
  9. /// <summary>
  10. /// TradeLoginView.xaml 的交互逻辑
  11. /// </summary>
  12. public partial class TradePWDModifyView : Window
  13. {
  14. /// <summary>
  15. /// 是否非强制更新
  16. /// </summary>
  17. /// <param name="isUnforceUpdate">if set to <c>true</c> [is unforce update].</param>
  18. public TradePWDModifyView(bool isUnforceUpdate)
  19. {
  20. InitializeComponent();
  21. this.DataContext = new TradePWDModifyViewModel(isUnforceUpdate);
  22. setFocusList.Add(fundComBoxBox);
  23. fundComBoxBox.GotFocus += fundComBoxBox_GotFocus;
  24. //UserpasswoBox.Password = string.Empty;
  25. //FundsAccountTextBox.Focus();
  26. this.KeyDown += TradePWDModifyView_KeyDown;
  27. }
  28. void TradePWDModifyView_KeyDown(object sender, KeyEventArgs e)
  29. {
  30. //避免按Alt+F4关闭窗口
  31. if (e.KeyboardDevice.Modifiers == ModifierKeys.Alt && e.SystemKey == Key.F4)
  32. {
  33. e.Handled = true;
  34. }
  35. }
  36. void fundComBoxBox_GotFocus(object sender, RoutedEventArgs e)
  37. {
  38. var index = setFocusList.FindIndex((item) => sender.Equals(item));
  39. if (index >= 0)
  40. {
  41. focusIndex = index;
  42. }
  43. }
  44. List<Control> setFocusList = new List<Control>();
  45. private int focusIndex = 0;
  46. private void NewFundsPassword_OnKeyDown(object sender, KeyEventArgs e)
  47. {
  48. PasswordBox password = sender as PasswordBox;
  49. if (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9)
  50. {
  51. if (password != null && password.Password.Length > 5)
  52. {
  53. e.Handled = true;
  54. return;
  55. }
  56. e.Handled = false;
  57. }
  58. else if (e.Key >= Key.D0 && e.Key <= Key.D9)
  59. {
  60. if (password != null && password.Password.Length > 5)
  61. {
  62. e.Handled = true;
  63. return;
  64. }
  65. e.Handled = false;
  66. }
  67. else
  68. {
  69. e.Handled = true;
  70. return;
  71. }
  72. }
  73. private void ConfFundsPassword_OnKeyDown(object sender, KeyEventArgs e)
  74. {
  75. PasswordBox password1 = sender as PasswordBox;
  76. if (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9)
  77. {
  78. if (password1 != null && password1.Password.Length > 5)
  79. {
  80. e.Handled = true;
  81. return;
  82. }
  83. e.Handled = false;
  84. }
  85. else if (e.Key >= Key.D0 && e.Key <= Key.D9)
  86. {
  87. if (password1 != null && password1.Password.Length > 5)
  88. {
  89. e.Handled = true;
  90. return;
  91. }
  92. e.Handled = false;
  93. }
  94. else
  95. {
  96. e.Handled = true;
  97. }
  98. }
  99. }
  100. }