PageLoginMs.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. using System;
  2. using System.CodeDom.Compiler;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Runtime.CompilerServices;
  7. using System.Security.Authentication;
  8. using System.Threading;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Markup;
  12. using Microsoft.VisualBasic.CompilerServices;
  13. using Newtonsoft.Json.Linq;
  14. namespace PCL
  15. {
  16. // Token: 0x020000F4 RID: 244
  17. [DesignerGenerated]
  18. public class PageLoginMs : StackPanel, IComponentConnector
  19. {
  20. // Token: 0x06000956 RID: 2390 RVA: 0x00006BD7 File Offset: 0x00004DD7
  21. public PageLoginMs()
  22. {
  23. this.InitializeComponent();
  24. }
  25. // Token: 0x06000957 RID: 2391 RVA: 0x00048504 File Offset: 0x00046704
  26. public void Reload(bool KeepInput)
  27. {
  28. int selectedIndex = this.ComboAccounts.SelectedIndex;
  29. this.ComboAccounts.Items.Clear();
  30. this.ComboAccounts.Items.Add(new MyComboBoxItem
  31. {
  32. Content = "添加新账号"
  33. });
  34. try
  35. {
  36. JObject jobject = (JObject)ModBase.GetJson(Conversions.ToString(ModBase.m_IdentifierRepository.Get("LoginMsJson", null)));
  37. try
  38. {
  39. foreach (KeyValuePair<string, JToken> keyValuePair in jobject)
  40. {
  41. MyListItem myListItem = (MyListItem)((DataTemplate)base.FindResource("ComboBoxItemTemplateWithDelete")).LoadContent();
  42. myListItem.Tag = keyValuePair.Value.ToString();
  43. myListItem.Title = keyValuePair.Key;
  44. Enumerable.ElementAtOrDefault<MyIconButton>(myListItem.Buttons, 0).Tag = keyValuePair.Key;
  45. this.ComboAccounts.Items.Add(myListItem);
  46. }
  47. }
  48. finally
  49. {
  50. IEnumerator<KeyValuePair<string, JToken>> enumerator;
  51. if (enumerator != null)
  52. {
  53. enumerator.Dispose();
  54. }
  55. }
  56. }
  57. catch (Exception ex)
  58. {
  59. ModBase.Log(ex, string.Format("微软登录信息出错,登录信息已被重置({0})", RuntimeHelpers.GetObjectValue(ModBase.m_IdentifierRepository.Get("LoginMsJson", null))), ModBase.LogLevel.Hint, "出现错误");
  60. ModBase.m_IdentifierRepository.Set("LoginMsJson", "{}", false, null);
  61. }
  62. this.ComboAccounts.SelectedIndex = (KeepInput ? Math.Max(0, selectedIndex) : 0);
  63. }
  64. // Token: 0x06000958 RID: 2392 RVA: 0x00048684 File Offset: 0x00046884
  65. private void ComboAccounts_SelectionChanged(object sender, SelectionChangedEventArgs e)
  66. {
  67. if (ModAnimation.CalcParser() == 0 && this.ComboAccounts.SelectedItem != null && this.ComboAccounts.ResetParser() != null)
  68. {
  69. if (this.ComboAccounts.SelectedItem is MyListItem)
  70. {
  71. this.ComboAccounts.ResetParser().Content = ((MyListItem)this.ComboAccounts.SelectedItem).Title;
  72. return;
  73. }
  74. if (this.ComboAccounts.SelectedItem is MyComboBoxItem)
  75. {
  76. this.ComboAccounts.ResetParser().Content = RuntimeHelpers.GetObjectValue(((MyComboBoxItem)this.ComboAccounts.SelectedItem).Content);
  77. }
  78. }
  79. }
  80. // Token: 0x06000959 RID: 2393 RVA: 0x0004872C File Offset: 0x0004692C
  81. public static ModLaunch.McLoginMs GetLoginData()
  82. {
  83. ModLaunch.McLoginMs result;
  84. if (ModMain.m_ClientRepository == null)
  85. {
  86. result = new ModLaunch.McLoginMs
  87. {
  88. m_SystemMap = Conversions.ToString(ModBase.m_IdentifierRepository.Get("CacheMsV2OAuthRefresh", null)),
  89. observerMap = Conversions.ToString(ModBase.m_IdentifierRepository.Get("CacheMsV2Name", null))
  90. };
  91. }
  92. else
  93. {
  94. ModLaunch.McLoginMs Result = null;
  95. ModBase.RunInUiWait(delegate()
  96. {
  97. if (ModMain.m_ClientRepository.ComboAccounts.SelectedIndex == 0)
  98. {
  99. Result = new ModLaunch.McLoginMs();
  100. return;
  101. }
  102. MyListItem myListItem = (MyListItem)ModMain.m_ClientRepository.ComboAccounts.SelectedItem;
  103. Result = new ModLaunch.McLoginMs
  104. {
  105. m_SystemMap = Conversions.ToString(myListItem.Tag),
  106. observerMap = myListItem.Title
  107. };
  108. });
  109. result = Result;
  110. }
  111. return result;
  112. }
  113. // Token: 0x0600095A RID: 2394 RVA: 0x000487A4 File Offset: 0x000469A4
  114. public static string IsVaild(ModLaunch.McLoginMs LoginData)
  115. {
  116. string result;
  117. if (Operators.CompareString(LoginData.m_SystemMap, "", false) == 0)
  118. {
  119. result = "请在登录账号后再启动游戏!";
  120. }
  121. else
  122. {
  123. result = "";
  124. }
  125. return result;
  126. }
  127. // Token: 0x0600095B RID: 2395 RVA: 0x00006BE6 File Offset: 0x00004DE6
  128. public string IsVaild()
  129. {
  130. return PageLoginMs.IsVaild(PageLoginMs.GetLoginData());
  131. }
  132. // Token: 0x0600095C RID: 2396 RVA: 0x000487D4 File Offset: 0x000469D4
  133. private void BtnLogin_Click(object sender, EventArgs e)
  134. {
  135. this.ComboAccounts.IsEnabled = false;
  136. this.BtnLogin.IsEnabled = false;
  137. this.BtnLogin.Text = "0%";
  138. ModBase.RunInNewThread(delegate
  139. {
  140. try
  141. {
  142. ModLaunch.m_ContainerTests.Start(PageLoginMs.GetLoginData(), true);
  143. while (ModLaunch.m_ContainerTests.State == ModBase.LoadState.Loading)
  144. {
  145. ModBase.RunInUi(delegate()
  146. {
  147. this.BtnLogin.Text = Conversions.ToString(Math.Round(ModLaunch.m_ContainerTests.Progress * 100.0)) + "%";
  148. }, false);
  149. Thread.Sleep(50);
  150. }
  151. if (ModLaunch.m_ContainerTests.State == ModBase.LoadState.Finished)
  152. {
  153. ModBase.RunInUi((PageLoginMs._Closure$__.$I6-2 == null) ? (PageLoginMs._Closure$__.$I6-2 = delegate()
  154. {
  155. ModMain.recordIterator.RefreshPage(false, true);
  156. }) : PageLoginMs._Closure$__.$I6-2, false);
  157. }
  158. else
  159. {
  160. if (ModLaunch.m_ContainerTests.State == ModBase.LoadState.Aborted)
  161. {
  162. throw new ThreadInterruptedException();
  163. }
  164. if (ModLaunch.m_ContainerTests.Error == null)
  165. {
  166. throw new Exception("未知错误!");
  167. }
  168. throw new Exception(ModLaunch.m_ContainerTests.Error.Message, ModLaunch.m_ContainerTests.Error);
  169. }
  170. }
  171. catch (ThreadInterruptedException ex)
  172. {
  173. ModMain.Hint("已取消登录!", ModMain.HintType.Info, true);
  174. }
  175. catch (Exception ex2)
  176. {
  177. if (Operators.CompareString(ex2.Message, "$$", false) != 0)
  178. {
  179. if (ex2.Message.StartsWith("$"))
  180. {
  181. ModMain.Hint(ex2.Message.TrimStart(new char[]
  182. {
  183. '$'
  184. }), ModMain.HintType.Critical, true);
  185. }
  186. else if (ex2 is AuthenticationException && ex2.Message.ContainsF("SSL/TLS", false))
  187. {
  188. ModBase.Log(ex2, "正版登录验证失败,请尝试在 [设置 → 启动器] 中关闭 [验证 SSL 证书] 然后再试。\r\n\r\n原始错误信息:", ModBase.LogLevel.Msgbox, "出现错误");
  189. }
  190. else
  191. {
  192. ModBase.Log(ex2, "正版登录尝试失败", ModBase.LogLevel.Msgbox, "出现错误");
  193. }
  194. }
  195. }
  196. finally
  197. {
  198. ModBase.RunInUi(delegate()
  199. {
  200. this.ComboAccounts.IsEnabled = true;
  201. this.BtnLogin.IsEnabled = true;
  202. this.BtnLogin.Text = "登录";
  203. }, false);
  204. }
  205. }, "Ms Login", ThreadPriority.Normal);
  206. }
  207. // Token: 0x1700014B RID: 331
  208. // (get) Token: 0x0600095D RID: 2397 RVA: 0x00006BF2 File Offset: 0x00004DF2
  209. // (set) Token: 0x0600095E RID: 2398 RVA: 0x00006BFA File Offset: 0x00004DFA
  210. internal virtual Grid PanEmpty { get; set; }
  211. // Token: 0x1700014C RID: 332
  212. // (get) Token: 0x0600095F RID: 2399 RVA: 0x00006C03 File Offset: 0x00004E03
  213. // (set) Token: 0x06000960 RID: 2400 RVA: 0x00048824 File Offset: 0x00046A24
  214. internal virtual MyComboBox ComboAccounts
  215. {
  216. [CompilerGenerated]
  217. get
  218. {
  219. return this.m_RegistryClient;
  220. }
  221. [CompilerGenerated]
  222. set
  223. {
  224. SelectionChangedEventHandler value2 = new SelectionChangedEventHandler(this.ComboAccounts_SelectionChanged);
  225. MyComboBox registryClient = this.m_RegistryClient;
  226. if (registryClient != null)
  227. {
  228. registryClient.SelectionChanged -= value2;
  229. }
  230. this.m_RegistryClient = value;
  231. registryClient = this.m_RegistryClient;
  232. if (registryClient != null)
  233. {
  234. registryClient.SelectionChanged += value2;
  235. }
  236. }
  237. }
  238. // Token: 0x1700014D RID: 333
  239. // (get) Token: 0x06000961 RID: 2401 RVA: 0x00006C0B File Offset: 0x00004E0B
  240. // (set) Token: 0x06000962 RID: 2402 RVA: 0x00048868 File Offset: 0x00046A68
  241. internal virtual MyButton BtnLogin
  242. {
  243. [CompilerGenerated]
  244. get
  245. {
  246. return this.m_RuleClient;
  247. }
  248. [CompilerGenerated]
  249. set
  250. {
  251. MyButton.ClickEventHandler value2 = new MyButton.ClickEventHandler(this.BtnLogin_Click);
  252. MyButton ruleClient = this.m_RuleClient;
  253. if (ruleClient != null)
  254. {
  255. ruleClient.Click -= value2;
  256. }
  257. this.m_RuleClient = value;
  258. ruleClient = this.m_RuleClient;
  259. if (ruleClient != null)
  260. {
  261. ruleClient.Click += value2;
  262. }
  263. }
  264. }
  265. // Token: 0x06000963 RID: 2403 RVA: 0x000488AC File Offset: 0x00046AAC
  266. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  267. public void InitializeComponent()
  268. {
  269. if (!this._ProccesorClient)
  270. {
  271. this._ProccesorClient = true;
  272. Uri resourceLocator = new Uri("/Plain Craft Launcher 2;component/pages/pagelaunch/pageloginms.xaml", UriKind.Relative);
  273. Application.LoadComponent(this, resourceLocator);
  274. }
  275. }
  276. // Token: 0x06000964 RID: 2404 RVA: 0x0000414E File Offset: 0x0000234E
  277. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  278. internal Delegate _CreateDelegate(Type delegateType, string handler)
  279. {
  280. return Delegate.CreateDelegate(delegateType, this, handler);
  281. }
  282. // Token: 0x06000965 RID: 2405 RVA: 0x00006C13 File Offset: 0x00004E13
  283. [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  284. [EditorBrowsable(EditorBrowsableState.Never)]
  285. public void System_Windows_Markup_IComponentConnector_Connect(int connectionId, object target)
  286. {
  287. if (connectionId == 1)
  288. {
  289. this.PanEmpty = (Grid)target;
  290. return;
  291. }
  292. if (connectionId == 2)
  293. {
  294. this.ComboAccounts = (MyComboBox)target;
  295. return;
  296. }
  297. if (connectionId == 3)
  298. {
  299. this.BtnLogin = (MyButton)target;
  300. return;
  301. }
  302. this._ProccesorClient = true;
  303. }
  304. // Token: 0x040004EB RID: 1259
  305. [AccessedThroughProperty("PanEmpty")]
  306. [CompilerGenerated]
  307. private Grid m_WriterClient;
  308. // Token: 0x040004EC RID: 1260
  309. [CompilerGenerated]
  310. [AccessedThroughProperty("ComboAccounts")]
  311. private MyComboBox m_RegistryClient;
  312. // Token: 0x040004ED RID: 1261
  313. [AccessedThroughProperty("BtnLogin")]
  314. [CompilerGenerated]
  315. private MyButton m_RuleClient;
  316. // Token: 0x040004EE RID: 1262
  317. private bool _ProccesorClient;
  318. }
  319. }