Form2.vb 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. Imports System
  2. Imports System.IO
  3. Public Class Form2
  4. Dim java As String
  5. Dim appPath As String = Application.StartupPath()
  6. Dim programfile As String
  7. Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8. programfile = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
  9. If My.Computer.FileSystem.DirectoryExists(programfile & "\Java") Then
  10. TextBox2.Text = "自動選用本地 Java"
  11. End If
  12. 'Create data folder
  13. If My.Computer.FileSystem.DirectoryExists(appPath & "system\data") = False Then
  14. My.Computer.FileSystem.CreateDirectory(appPath & "\system\data")
  15. End If
  16. 'List all version in folder
  17. For Each Dir As String In Directory.GetDirectories(appPath & "\system\minecraft")
  18. Dim filePath As String = Dir
  19. Dim split As String() = filePath.Split("\")
  20. Dim parentFolder As String = split(split.Length - 1)
  21. ListBox1.Items.Add(parentFolder)
  22. Next
  23. 'Read Old Data
  24. TextBox3.Text = Nothing
  25. If My.Computer.FileSystem.DirectoryExists(appPath & "\lib\") Then
  26. TextBox2.Text = "自動選用程式內置Java"
  27. End If
  28. If My.Computer.FileSystem.FileExists(appPath & "\system\data\player.wtc") Then
  29. Dim fr As String
  30. fr = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\player.wtc")
  31. TextBox1.Text = fr
  32. End If
  33. If My.Computer.FileSystem.FileExists(appPath & "\system\data\ram.wtc") Then
  34. Dim ad As String
  35. ad = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\ram.wtc")
  36. ComboBox1.SelectedIndex = ad
  37. Else
  38. ComboBox1.SelectedIndex = 4
  39. End If
  40. 'Create Java Code
  41. If My.Computer.FileSystem.FileExists(appPath & "system\data\code.ini") = False Then
  42. IO.File.WriteAllText((appPath & "\system\data\code.ini"), TextBox5.Text, System.Text.Encoding.GetEncoding(950))
  43. End If
  44. If My.Computer.FileSystem.FileExists(appPath & "system\data\code.mini") = False Then
  45. IO.File.WriteAllText((appPath & "\system\data\code.mini"), TextBox4.Text, System.Text.Encoding.GetEncoding(950))
  46. End If
  47. If My.Computer.FileSystem.FileExists(appPath & "system\data\marker.ini") = False Then
  48. IO.File.WriteAllText((appPath & "\system\data\marker.ini"), TextBox6.Text, System.Text.Encoding.GetEncoding(950))
  49. End If
  50. End Sub
  51. Private IsFormBeingDragged As Boolean = False
  52. Private MouseDownX As Integer
  53. Private MouseDownY As Integer
  54. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  55. For counter = 10 To 90 Step +20
  56. Me.Opacity = counter / 100
  57. Me.Refresh()
  58. Threading.Thread.Sleep(30)
  59. Next
  60. Me.Opacity = 100
  61. End Sub
  62. Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
  63. If e.Button = MouseButtons.Left Then
  64. IsFormBeingDragged = True
  65. MouseDownX = e.X
  66. MouseDownY = e.Y
  67. End If
  68. End Sub
  69. Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp
  70. If e.Button = MouseButtons.Left Then
  71. IsFormBeingDragged = False
  72. End If
  73. End Sub
  74. Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
  75. If IsFormBeingDragged Then
  76. Dim temp As Point = New Point()
  77. temp.X = Me.Location.X + (e.X - MouseDownX)
  78. temp.Y = Me.Location.Y + (e.Y - MouseDownY)
  79. Me.Location = temp
  80. temp = Nothing
  81. End If
  82. End Sub
  83. Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  84. Dim iCount As Integer
  85. For iCount = 90 To 10 Step -10
  86. Me.Opacity = iCount / 100
  87. Threading.Thread.Sleep(50)
  88. Next
  89. Me.Close()
  90. End Sub
  91. Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
  92. MsgBox("如需高級修改請到啟動檔,根目錄\system\版本.bat 裡修改啟動碼細節")
  93. End Sub
  94. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  95. Dim fd As OpenFileDialog = New OpenFileDialog()
  96. Dim strFileName As String
  97. Try
  98. fd.Title = "請選擇Java 位置"
  99. fd.InitialDirectory = "C:\Program Files\Java"
  100. fd.Filter = "Java 程式|*.exe"
  101. fd.FilterIndex = 2
  102. fd.RestoreDirectory = True
  103. Catch ex As Exception
  104. End Try
  105. If fd.ShowDialog() = DialogResult.OK Then
  106. strFileName = fd.FileName
  107. TextBox2.Text = strFileName
  108. java = strFileName
  109. End If
  110. End Sub
  111. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  112. TextBox1.Text = "Steve"
  113. TextBox2.Text = ""
  114. ComboBox1.SelectedItem = 4
  115. End Sub
  116. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  117. 'Remove old launch file
  118. If ListBox1.SelectedItem = "" Then
  119. ElseIf ComboBox1.SelectedItem = "" Then
  120. MsgBox("請選擇最大記憶體使用量")
  121. End If
  122. If My.Computer.FileSystem.FileExists(appPath & "\system\" & ListBox1.SelectedItem & ".bat") Then
  123. My.Computer.FileSystem.DeleteFile(appPath & "\system\" & ListBox1.SelectedItem & ".bat")
  124. End If
  125. 'Clear Old Data
  126. If My.Computer.FileSystem.FileExists(appPath & "\system\data\name.wtc") Then
  127. My.Computer.FileSystem.DeleteFile(appPath & "\system\data\name.wtc")
  128. End If
  129. If My.Computer.FileSystem.FileExists(appPath & "\system\data\ram.wtc") Then
  130. My.Computer.FileSystem.DeleteFile(appPath & "\system\data\ram.wtc")
  131. End If
  132. If My.Computer.FileSystem.FileExists(appPath & "\system\data\player.wtc") Then
  133. My.Computer.FileSystem.DeleteFile(appPath & "\system\data\player.wtc")
  134. End If
  135. If My.Computer.FileSystem.FileExists(appPath & "\system\data\java.wtc") Then
  136. My.Computer.FileSystem.DeleteFile(appPath & "\system\data\java.wtc")
  137. End If
  138. If My.Computer.FileSystem.FileExists(appPath & "\system\data\java.wtc") Then
  139. Dim fileReader As String
  140. fileReader = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\java.wtc")
  141. TextBox2.Text = fileReader
  142. End If
  143. Dim item As String
  144. item = ListBox1.SelectedItem
  145. Try
  146. 'Read Code data
  147. Dim head As String
  148. head = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\code.ini")
  149. Dim mid As String
  150. mid = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\code.mini")
  151. Dim mark As String
  152. mark = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\marker.ini")
  153. 'Write in
  154. Dim file As System.IO.FileStream
  155. file = System.IO.File.Create(appPath & "\system\" & item & ".bat")
  156. file.Dispose()
  157. TextBox3.Text = head & ComboBox1.SelectedItem & mid & TextBox1.Text & mark
  158. 'Write in bat
  159. Dim sb As New System.Text.StringBuilder
  160. sb.AppendLine("@echo off")
  161. If TextBox2.Text = "" Then
  162. sb.AppendLine("set LIB_HOME=" & appPath & "\lib")
  163. sb.AppendLine("set JAVA_HOME=" & appPath & "\lib\jre7")
  164. sb.AppendLine("set Path=" & appPath & "\lib\jre7\bin")
  165. End If
  166. If My.Computer.FileSystem.DirectoryExists(appPath & "\lib") = False And TextBox2.Text = "" Then
  167. Dim Form4 As New Form4
  168. Form4.Show()
  169. End If
  170. sb.AppendLine("set APPDATA=" & appPath & "\system\minecraft\" & ListBox1.SelectedItem)
  171. sb.AppendLine(TextBox3.Text)
  172. 'Write in file
  173. IO.File.WriteAllText((appPath & "\system\" & item & ".bat"), sb.ToString(), System.Text.Encoding.GetEncoding(950))
  174. 'Write in record
  175. Dim sc As New System.Text.StringBuilder
  176. sc.AppendLine(TextBox2.Text)
  177. IO.File.WriteAllText((appPath & "\system\data\java.wtc"), sc.ToString(), System.Text.Encoding.GetEncoding(950))
  178. Dim sd As New System.Text.StringBuilder
  179. sd.AppendLine(TextBox1.Text)
  180. IO.File.WriteAllText((appPath & "\system\data\player.wtc"), sd.ToString(), System.Text.Encoding.GetEncoding(950))
  181. Dim se As New System.Text.StringBuilder
  182. se.AppendLine(ComboBox1.SelectedIndex)
  183. IO.File.WriteAllText((appPath & "\system\data\ram.wtc"), se.ToString(), System.Text.Encoding.GetEncoding(950))
  184. Dim iCount As Integer
  185. For iCount = 90 To 10 Step -10
  186. Me.Opacity = iCount / 100
  187. Threading.Thread.Sleep(50)
  188. Next
  189. Me.Hide()
  190. Catch ex As Exception
  191. MsgBox("出問題了哦~ " & vbCrLf & ex.Message)
  192. End Try
  193. TextBox3.Text = ""
  194. If My.Computer.FileSystem.FileExists(appPath & "\system\.bat") Then
  195. My.Computer.FileSystem.DeleteFile(appPath & "\system\.bat")
  196. End If
  197. End Sub
  198. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  199. Dim iCount As Integer
  200. For iCount = 90 To 10 Step -10
  201. Me.Opacity = iCount / 100
  202. Threading.Thread.Sleep(50)
  203. Next
  204. Me.Close()
  205. End Sub
  206. Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
  207. End Sub
  208. Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
  209. End Sub
  210. Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
  211. End Sub
  212. End Class