RobotView.xaml.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.ComponentModel.Composition;
  3. using System.Windows;
  4. using Infrastructure;
  5. namespace Modules.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 void btnFindPlayer_Click(object sender, RoutedEventArgs e)
  34. {
  35. this.ViewModel.FindPlayer();
  36. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  37. this.tbLog.ScrollToEnd();
  38. }
  39. private void menuLogin_Click(object sender, RoutedEventArgs e)
  40. {
  41. this.ViewModel.ReLogin();
  42. }
  43. private async void menuServers_Click(object sender, RoutedEventArgs e)
  44. {
  45. await this.ViewModel.Servers();
  46. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  47. this.tbLog.ScrollToEnd();
  48. }
  49. private async void btnForbiddenBuy_Click(object sender, RoutedEventArgs e)
  50. {
  51. await this.ViewModel.ForbiddenBuy();
  52. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  53. this.tbLog.ScrollToEnd();
  54. }
  55. private async void btnAllowBuy_Click(object sender, RoutedEventArgs e)
  56. {
  57. await this.ViewModel.AllowBuy();
  58. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  59. this.tbLog.ScrollToEnd();
  60. }
  61. private async void btnSendCommand_Click(object sender, RoutedEventArgs e)
  62. {
  63. await this.ViewModel.SendCommand();
  64. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  65. this.tbLog.ScrollToEnd();
  66. }
  67. }
  68. }