123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- Imports System
- Imports System.IO
- Public Class Form2
- Dim java As String
- Dim appPath As String = Application.StartupPath()
- Dim programfile As String
- Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- programfile = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
- If My.Computer.FileSystem.DirectoryExists(programfile & "\Java") Then
- TextBox2.Text = "自動選用本地 Java"
- End If
- 'Create data folder
- If My.Computer.FileSystem.DirectoryExists(appPath & "system\data") = False Then
- My.Computer.FileSystem.CreateDirectory(appPath & "\system\data")
- End If
- 'List all version in folder
- For Each Dir As String In Directory.GetDirectories(appPath & "\system\minecraft")
- Dim filePath As String = Dir
- Dim split As String() = filePath.Split("\")
- Dim parentFolder As String = split(split.Length - 1)
- ListBox1.Items.Add(parentFolder)
- Next
- 'Read Old Data
- TextBox3.Text = Nothing
- If My.Computer.FileSystem.DirectoryExists(appPath & "\lib\") Then
- TextBox2.Text = "自動選用程式內置Java"
- End If
- If My.Computer.FileSystem.FileExists(appPath & "\system\data\player.wtc") Then
- Dim fr As String
- fr = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\player.wtc")
- TextBox1.Text = fr
- End If
- If My.Computer.FileSystem.FileExists(appPath & "\system\data\ram.wtc") Then
- Dim ad As String
- ad = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\ram.wtc")
- ComboBox1.SelectedIndex = ad
- Else
- ComboBox1.SelectedIndex = 4
- End If
- 'Create Java Code
- If My.Computer.FileSystem.FileExists(appPath & "system\data\code.ini") = False Then
- IO.File.WriteAllText((appPath & "\system\data\code.ini"), TextBox5.Text, System.Text.Encoding.GetEncoding(950))
- End If
- If My.Computer.FileSystem.FileExists(appPath & "system\data\code.mini") = False Then
- IO.File.WriteAllText((appPath & "\system\data\code.mini"), TextBox4.Text, System.Text.Encoding.GetEncoding(950))
- End If
- If My.Computer.FileSystem.FileExists(appPath & "system\data\marker.ini") = False Then
- IO.File.WriteAllText((appPath & "\system\data\marker.ini"), TextBox6.Text, System.Text.Encoding.GetEncoding(950))
- End If
- End Sub
- Private IsFormBeingDragged As Boolean = False
- Private MouseDownX As Integer
- Private MouseDownY As Integer
- Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- For counter = 10 To 90 Step +20
- Me.Opacity = counter / 100
- Me.Refresh()
- Threading.Thread.Sleep(30)
- Next
- Me.Opacity = 100
- End Sub
- Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
- If e.Button = MouseButtons.Left Then
- IsFormBeingDragged = True
- MouseDownX = e.X
- MouseDownY = e.Y
- End If
- End Sub
- Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp
- If e.Button = MouseButtons.Left Then
- IsFormBeingDragged = False
- End If
- End Sub
- Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
- If IsFormBeingDragged Then
- Dim temp As Point = New Point()
- temp.X = Me.Location.X + (e.X - MouseDownX)
- temp.Y = Me.Location.Y + (e.Y - MouseDownY)
- Me.Location = temp
- temp = Nothing
- End If
- End Sub
- Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
- Dim iCount As Integer
- For iCount = 90 To 10 Step -10
- Me.Opacity = iCount / 100
- Threading.Thread.Sleep(50)
- Next
- Me.Close()
- End Sub
- Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
- MsgBox("如需高級修改請到啟動檔,根目錄\system\版本.bat 裡修改啟動碼細節")
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim fd As OpenFileDialog = New OpenFileDialog()
- Dim strFileName As String
- Try
- fd.Title = "請選擇Java 位置"
- fd.InitialDirectory = "C:\Program Files\Java"
- fd.Filter = "Java 程式|*.exe"
- fd.FilterIndex = 2
- fd.RestoreDirectory = True
- Catch ex As Exception
- End Try
- If fd.ShowDialog() = DialogResult.OK Then
- strFileName = fd.FileName
- TextBox2.Text = strFileName
- java = strFileName
- End If
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- TextBox1.Text = "Steve"
- TextBox2.Text = ""
- ComboBox1.SelectedItem = 4
- End Sub
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
- 'Remove old launch file
-
- If ListBox1.SelectedItem = "" Then
- ElseIf ComboBox1.SelectedItem = "" Then
- MsgBox("請選擇最大記憶體使用量")
- End If
- If My.Computer.FileSystem.FileExists(appPath & "\system\" & ListBox1.SelectedItem & ".bat") Then
- My.Computer.FileSystem.DeleteFile(appPath & "\system\" & ListBox1.SelectedItem & ".bat")
- End If
- 'Clear Old Data
- If My.Computer.FileSystem.FileExists(appPath & "\system\data\name.wtc") Then
- My.Computer.FileSystem.DeleteFile(appPath & "\system\data\name.wtc")
- End If
- If My.Computer.FileSystem.FileExists(appPath & "\system\data\ram.wtc") Then
- My.Computer.FileSystem.DeleteFile(appPath & "\system\data\ram.wtc")
- End If
- If My.Computer.FileSystem.FileExists(appPath & "\system\data\player.wtc") Then
- My.Computer.FileSystem.DeleteFile(appPath & "\system\data\player.wtc")
- End If
- If My.Computer.FileSystem.FileExists(appPath & "\system\data\java.wtc") Then
- My.Computer.FileSystem.DeleteFile(appPath & "\system\data\java.wtc")
- End If
-
- If My.Computer.FileSystem.FileExists(appPath & "\system\data\java.wtc") Then
- Dim fileReader As String
- fileReader = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\java.wtc")
- TextBox2.Text = fileReader
- End If
- Dim item As String
- item = ListBox1.SelectedItem
- Try
- 'Read Code data
- Dim head As String
- head = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\code.ini")
- Dim mid As String
- mid = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\code.mini")
- Dim mark As String
- mark = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\marker.ini")
- 'Write in
- Dim file As System.IO.FileStream
- file = System.IO.File.Create(appPath & "\system\" & item & ".bat")
- file.Dispose()
-
- TextBox3.Text = head & ComboBox1.SelectedItem & mid & TextBox1.Text & mark
- 'Write in bat
- Dim sb As New System.Text.StringBuilder
- sb.AppendLine("@echo off")
- If TextBox2.Text = "" Then
- sb.AppendLine("set LIB_HOME=" & appPath & "\lib")
- sb.AppendLine("set JAVA_HOME=" & appPath & "\lib\jre7")
- sb.AppendLine("set Path=" & appPath & "\lib\jre7\bin")
- End If
- If My.Computer.FileSystem.DirectoryExists(appPath & "\lib") = False And TextBox2.Text = "" Then
- Dim Form4 As New Form4
- Form4.Show()
- End If
-
- sb.AppendLine("set APPDATA=" & appPath & "\system\minecraft\" & ListBox1.SelectedItem)
- sb.AppendLine(TextBox3.Text)
-
- 'Write in file
- IO.File.WriteAllText((appPath & "\system\" & item & ".bat"), sb.ToString(), System.Text.Encoding.GetEncoding(950))
- 'Write in record
- Dim sc As New System.Text.StringBuilder
- sc.AppendLine(TextBox2.Text)
- IO.File.WriteAllText((appPath & "\system\data\java.wtc"), sc.ToString(), System.Text.Encoding.GetEncoding(950))
- Dim sd As New System.Text.StringBuilder
- sd.AppendLine(TextBox1.Text)
- IO.File.WriteAllText((appPath & "\system\data\player.wtc"), sd.ToString(), System.Text.Encoding.GetEncoding(950))
- Dim se As New System.Text.StringBuilder
- se.AppendLine(ComboBox1.SelectedIndex)
- IO.File.WriteAllText((appPath & "\system\data\ram.wtc"), se.ToString(), System.Text.Encoding.GetEncoding(950))
- Dim iCount As Integer
- For iCount = 90 To 10 Step -10
- Me.Opacity = iCount / 100
- Threading.Thread.Sleep(50)
- Next
- Me.Hide()
- Catch ex As Exception
- MsgBox("出問題了哦~ " & vbCrLf & ex.Message)
- End Try
- TextBox3.Text = ""
- If My.Computer.FileSystem.FileExists(appPath & "\system\.bat") Then
- My.Computer.FileSystem.DeleteFile(appPath & "\system\.bat")
- End If
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- Dim iCount As Integer
- For iCount = 90 To 10 Step -10
- Me.Opacity = iCount / 100
- Threading.Thread.Sleep(50)
- Next
- Me.Close()
- End Sub
- Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
- End Sub
- Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
- End Sub
- Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
- End Sub
- End Class
|