RobotView.xaml.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel.Composition;
  5. using System.IO;
  6. using System.Windows;
  7. using Infrastructure;
  8. using NPOI.HSSF.UserModel;
  9. namespace Robot
  10. {
  11. /// <summary>
  12. /// RobotView.xaml 的交互逻辑
  13. /// </summary>
  14. [ViewExport(RegionName = "RobotRegion"), PartCreationPolicy(CreationPolicy.NonShared)]
  15. public partial class RobotView
  16. {
  17. public RobotView()
  18. {
  19. this.InitializeComponent();
  20. }
  21. [Import]
  22. private RobotViewModel ViewModel
  23. {
  24. get
  25. {
  26. return this.DataContext as RobotViewModel;
  27. }
  28. set
  29. {
  30. this.DataContext = value;
  31. }
  32. }
  33. private void menuReload_Click(object sender, RoutedEventArgs e)
  34. {
  35. this.ViewModel.Reload();
  36. }
  37. private async void btnFindPlayer_Click(object sender, RoutedEventArgs e)
  38. {
  39. await this.ViewModel.GetCharacterInfo();
  40. this.tcCharacterInfo.IsEnabled = true;
  41. this.btnForbidCharacter.IsEnabled = true;
  42. this.btnAllowCharacter.IsEnabled = true;
  43. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  44. this.tbLog.ScrollToEnd();
  45. }
  46. private void menuLogin_Click(object sender, RoutedEventArgs e)
  47. {
  48. this.ViewModel.ReLogin();
  49. }
  50. private async void menuServers_Click(object sender, RoutedEventArgs e)
  51. {
  52. await this.ViewModel.Servers();
  53. this.tcAll.SelectedIndex = 0;
  54. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  55. this.tbLog.ScrollToEnd();
  56. }
  57. private async void btnForbidCharacter_Click(object sender, RoutedEventArgs e)
  58. {
  59. await this.ViewModel.ForbidCharacter(cbForbiddenType.SelectedValue.ToString(), tbForbiddenTime.Text);
  60. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  61. this.tbLog.ScrollToEnd();
  62. }
  63. private async void btnAllowCharacter_Click(object sender, RoutedEventArgs e)
  64. {
  65. await this.ViewModel.ForbidCharacter(cbForbiddenType.SelectedValue.ToString(), "-1");
  66. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  67. this.tbLog.ScrollToEnd();
  68. }
  69. private async void btnSendCommand_Click(object sender, RoutedEventArgs e)
  70. {
  71. await this.ViewModel.SendCommand();
  72. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  73. this.tbLog.ScrollToEnd();
  74. }
  75. private async void btnForbiddenLogin_Click(object sender, RoutedEventArgs e)
  76. {
  77. await this.ViewModel.ForbiddenLogin(
  78. cbForbiddenLogin.SelectedValue.ToString(),
  79. tbForbiddenLoginContent.Text, tbForbiddenLoginTime.Text);
  80. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  81. this.tbLog.ScrollToEnd();
  82. }
  83. private async void btnAllowLogin_Click(object sender, RoutedEventArgs e)
  84. {
  85. await this.ViewModel.ForbiddenLogin(
  86. cbForbiddenLogin.SelectedValue.ToString(), tbForbiddenLoginContent.Text, "-1");
  87. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  88. this.tbLog.ScrollToEnd();
  89. }
  90. private async void btnSendMail_Click(object sender, RoutedEventArgs e)
  91. {
  92. await this.ViewModel.SendMail();
  93. this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
  94. this.tbLog.ScrollToEnd();
  95. }
  96. private void btnExecle_Click(object sender, RoutedEventArgs e)
  97. {
  98. var dict = new Dictionary<string, int>
  99. {
  100. { "英雄令", 1 },
  101. { "英雄令材料", 2 },
  102. { "双倍", 3 },
  103. { "会员", 4 },
  104. { "聊天", 5 },
  105. { "材料", 6 },
  106. { "印记页", 7 },
  107. { "血统页", 8 },
  108. { "坐骑", 9 },
  109. { "染色", 10 },
  110. { "星之魂玉", 11 },
  111. { "月之魂玉", 12 },
  112. { "日之魂玉", 13 },
  113. { "技能书", 14 },
  114. { "混沌之玉", 15 },
  115. { "战绩", 16 },
  116. { "坐骑翅膀", 17 },
  117. { "变身", 18 },
  118. { "将星", 19 },
  119. { "平台装备", 20 },
  120. { "将星装备", 21 },
  121. { "血魄", 22 },
  122. { "装饰", 23 },
  123. { "烟花", 24 },
  124. { "英雄礼包", 25 },
  125. { "套装", 26 },
  126. };
  127. HSSFWorkbook hssfWorkbook = null;
  128. using (var file = new FileStream("F:\\MallItemProto.xls", FileMode.Open, FileAccess.Read))
  129. {
  130. hssfWorkbook = new HSSFWorkbook(file);
  131. }
  132. var sheet = hssfWorkbook.GetSheetAt(0);
  133. IEnumerator rows = sheet.GetRowEnumerator();
  134. const int nameIndex = 'Z' - 'A';
  135. rows.MoveNext();
  136. rows.MoveNext();
  137. rows.MoveNext();
  138. rows.MoveNext();
  139. while (rows.MoveNext())
  140. {
  141. var row = (HSSFRow)rows.Current;
  142. if (row.GetCell(nameIndex) == null)
  143. {
  144. continue;
  145. }
  146. var name = row.GetCell(nameIndex).ToString();
  147. if (dict.ContainsKey(name))
  148. {
  149. row.GetCell(nameIndex - 1).SetCellValue(dict[name].ToString());
  150. }
  151. }
  152. using (var file = new FileStream("F:\\MallItemProto.xls", FileMode.Open, FileAccess.Write))
  153. {
  154. hssfWorkbook.Write(file);
  155. }
  156. lblShowResult.Content = "OK";
  157. }
  158. }
  159. }