PageLoginAuthSkin.xaml.vb 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. Public Class PageLoginAuthSkin
  2. Public Sub New()
  3. InitializeComponent()
  4. Skin.Loader = PageLaunchLeft.SkinAuth
  5. End Sub
  6. Private Sub PageLoginLegacy_Loaded() Handles Me.Loaded
  7. Skin.Loader.Start()
  8. End Sub
  9. ''' <summary>
  10. ''' 刷新页面显示的所有信息。
  11. ''' </summary>
  12. Public Sub Reload(KeepInput As Boolean)
  13. TextName.Text = Settings.Get(Of String)("CacheAuthName")
  14. TextEmail.Text = Settings.Get(Of String)("CacheAuthUsername")
  15. TextEmail.Visibility = If(Settings.Get(Of Boolean)("UiLauncherEmail"), Visibility.Collapsed, Visibility.Visible)
  16. PageLoginLegacy_Loaded()
  17. End Sub
  18. ''' <summary>
  19. ''' 获取当前页面的登录信息。
  20. ''' </summary>
  21. Public Shared Function GetLoginData() As McLoginServer
  22. Dim Server As String = If(IsNothing(McInstanceSelected), Settings.Get(Of String)("CacheAuthServerServer"), Settings.Get(Of String)("VersionServerAuthServer", Instance:=McInstanceSelected)) & "/authserver"
  23. Return New McLoginServer(McLoginType.Auth) With {.Token = "Auth", .BaseUrl = Server, .UserName = Settings.Get(Of String)("CacheAuthUsername"), .Password = Settings.Get(Of String)("CacheAuthPass"), .Description = "Authlib-Injector", .Type = McLoginType.Auth}
  24. End Function
  25. Private Sub PageLoginAuthSkin_MouseEnter(sender As Object, e As MouseEventArgs) Handles PanData.MouseEnter
  26. AniStart({
  27. AaOpacity(BtnEdit, 1 - BtnEdit.Opacity, 80),
  28. AaHeight(BtnEdit, 25.5 - BtnEdit.Height, 140,, New AniEaseOutFluent),
  29. AaHeight(BtnEdit, -1.5, 50, 140, New AniEaseInFluent),
  30. AaOpacity(BtnExit, 1 - BtnExit.Opacity, 80),
  31. AaHeight(BtnExit, 25.5 - BtnExit.Height, 140,, New AniEaseOutFluent),
  32. AaHeight(BtnExit, -1.5, 50, 140, New AniEaseInFluent)
  33. }, "PageLoginAuthSkin Button")
  34. End Sub
  35. Private Sub PageLoginAuthSkin_MouseLeave(sender As Object, e As MouseEventArgs) Handles PanData.MouseLeave
  36. AniStart({
  37. AaOpacity(BtnEdit, -BtnEdit.Opacity, 120,, New AniEaseOutFluent),
  38. AaHeight(BtnEdit, 14 - BtnEdit.Height, 120,, New AniEaseInFluent),
  39. AaOpacity(BtnExit, -BtnExit.Opacity, 120,, New AniEaseOutFluent),
  40. AaHeight(BtnExit, 14 - BtnExit.Height, 120,, New AniEaseInFluent)
  41. }, "PageLoginAuthSkin Button")
  42. End Sub
  43. Private Sub BtnEdit_Click(sender As Object, e As EventArgs) Handles BtnEdit.Click
  44. If McLoginLoader.State = LoadState.Loading Then
  45. Logger.Warn("要求更换角色,但登录加载器繁忙")
  46. If TypeOf McLoginLoader.Input Is McLoginServer AndAlso CType(McLoginLoader.Input, McLoginServer).ForceReselectProfile Then
  47. Hint("正在尝试更换,请稍候!")
  48. Else
  49. Hint("正在登录中,请稍后再更换角色!", HintType.Red)
  50. End If
  51. Return
  52. End If
  53. Hint("正在尝试更换,请稍候!")
  54. Settings.Set("CacheAuthUuid", "") '清空选择缓存
  55. Settings.Set("CacheAuthName", "")
  56. RunInThread(
  57. Sub()
  58. Try
  59. Dim Data As McLoginServer = GetLoginData()
  60. Data.ForceReselectProfile = True
  61. McLoginLoader.WaitForExit(Data, IsForceRestart:=True)
  62. RunInUi(Sub() Reload(True))
  63. Catch ex As Exception
  64. Logger.Error(ex, "更换角色失败", LogBehavior.Toast)
  65. End Try
  66. End Sub)
  67. End Sub
  68. Public Shared Sub ExitLogin() Handles BtnExit.Click
  69. Settings.Set("CacheAuthAccess", "")
  70. Settings.Set("CacheAuthUuid", "")
  71. Settings.Set("CacheAuthName", "")
  72. McLoginAuthLoader.Input = Nothing '防止因为输入的用户名密码相同,直接使用了上次登录的加载器结果
  73. FrmLaunchLeft.RefreshPage(False, True)
  74. End Sub
  75. Private Sub Skin_Click(sender As Object, e As MouseButtonEventArgs) Handles Skin.Click
  76. Dim Address As String = If(McInstanceSelected IsNot Nothing, Settings.Get(Of String)("VersionServerAuthRegister", Instance:=McInstanceSelected), Settings.Get(Of String)("CacheAuthServerRegister"))
  77. If String.IsNullOrEmpty(New ValidateHttp().Validate(Address)) Then OpenWebsite(Address.Replace("/auth/register", "/user/closet"))
  78. End Sub
  79. End Class