RobotView.xaml.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System;
  2. using System.ComponentModel.Composition;
  3. using System.Windows;
  4. using Infrastructure;
  5. namespace Robot
  6. {
  7. /// <summary>
  8. /// RobotView.xaml 的交互逻辑
  9. /// </summary>
  10. [ViewExport(RegionName = "RobotRegion"), PartCreationPolicy(CreationPolicy.NonShared)]
  11. public partial class RobotView
  12. {
  13. public RobotView()
  14. {
  15. this.InitializeComponent();
  16. }
  17. [Import]
  18. private RobotViewModel ViewModel
  19. {
  20. get
  21. {
  22. return this.DataContext as RobotViewModel;
  23. }
  24. set
  25. {
  26. this.DataContext = value;
  27. }
  28. }
  29. private void menuReload_Click(object sender, RoutedEventArgs e)
  30. {
  31. this.ViewModel.Reload();
  32. }
  33. private async void btnFindPlayer_Click(object sender, RoutedEventArgs e)
  34. {
  35. await this.ViewModel.GetCharacterInfo();
  36. this.tcCharacterInfo.IsEnabled = true;
  37. this.btnForbidCharacter.IsEnabled = true;
  38. this.btnAllowCharacter.IsEnabled = true;
  39. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  40. this.tbLog.ScrollToEnd();
  41. }
  42. private void menuLogin_Click(object sender, RoutedEventArgs e)
  43. {
  44. this.ViewModel.ReLogin();
  45. }
  46. private async void menuServers_Click(object sender, RoutedEventArgs e)
  47. {
  48. await this.ViewModel.Servers();
  49. this.tcAll.SelectedIndex = 0;
  50. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  51. this.tbLog.ScrollToEnd();
  52. }
  53. private async void btnForbidCharacter_Click(object sender, RoutedEventArgs e)
  54. {
  55. await this.ViewModel.ForbidCharacter(cbForbiddenType.SelectedValue.ToString(), tbForbiddenTime.Text);
  56. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  57. this.tbLog.ScrollToEnd();
  58. }
  59. private async void btnAllowCharacter_Click(object sender, RoutedEventArgs e)
  60. {
  61. await this.ViewModel.ForbidCharacter(cbForbiddenType.SelectedValue.ToString(), "-1");
  62. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  63. this.tbLog.ScrollToEnd();
  64. }
  65. private async void btnSendCommand_Click(object sender, RoutedEventArgs e)
  66. {
  67. await this.ViewModel.SendCommand();
  68. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  69. this.tbLog.ScrollToEnd();
  70. }
  71. private async void btnForbiddenLogin_Click(object sender, RoutedEventArgs e)
  72. {
  73. await this.ViewModel.ForbiddenLogin(
  74. cbForbiddenLogin.SelectedValue.ToString(),
  75. tbForbiddenLoginContent.Text, tbForbiddenLoginTime.Text);
  76. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  77. this.tbLog.ScrollToEnd();
  78. }
  79. private async void btnAllowLogin_Click(object sender, RoutedEventArgs e)
  80. {
  81. await this.ViewModel.ForbiddenLogin(
  82. cbForbiddenLogin.SelectedValue.ToString(), tbForbiddenLoginContent.Text, "-1");
  83. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  84. this.tbLog.ScrollToEnd();
  85. }
  86. private async void btnSendMail_Click(object sender, RoutedEventArgs e)
  87. {
  88. await this.ViewModel.SendMail();
  89. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  90. this.tbLog.ScrollToEnd();
  91. }
  92. }
  93. }