-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tools.vb
92 lines (91 loc) · 4.64 KB
/
Tools.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
Public Class Tools
Public Shared Sub TextWriter(file As String, text As String, type As Boolean)
Dim TextWriter As New System.IO.StreamWriter(file, type)
TextWriter.WriteLine(text)
TextWriter.Dispose()
TextWriter.Close()
End Sub
Public Shared Function TestKeyPress(key As String) As Boolean
Dim AllowedKeys As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.0123456789!@#$%^*()_+|}{?><,./[]\-=~`"
If Not AllowedKeys.Contains(key) Then
MainForm.InvalidLabel.Visible = True
WarningSound()
Return True
Else
MainForm.InvalidLabel.Visible = False
Return False
End If
End Function
Public Shared Function ControlToString(sender As Object) As String
Return DirectCast(sender, Object).Name.ToLower.Replace("clear", "")
End Function
Public Shared Sub ButtonChange(button As Button, action As Boolean)
button.Enabled = action
If action = True Then button.BackColor = SystemColors.Desktop Else button.BackColor = Color.DarkGray
End Sub
Public Shared Function CTGEncoderLoader(ByVal sender As Object, ByVal args As ResolveEventArgs) As System.Reflection.Assembly
Using stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CTGCodeSigningTool.CTGEncoder.dll")
Dim assemblyData = New Byte(stream.Length - 1) {}
stream.Read(assemblyData, 0, assemblyData.Length)
Return System.Reflection.Assembly.Load(assemblyData)
End Using
End Function
Public Shared Function CTGRBuilder(text As String)
Dim TimeLimit As Integer = text.Length, Playground As String =
"1234567890-=qwertyuiop[]\asdfghjkl;zxcvbnm,./?><MNBVCXZ:LKJHGFDSA}{POIUYTREWQ+_)(*^%$#@!~` ",
FunTime As New System.Text.StringBuilder, Recess As New System.Text.StringBuilder,
Whistle As New System.Text.StringBuilder
For i = 1 To TimeLimit
FunTime.Append(Playground.Substring(Int((90 * Rnd()) + 1), 1))
Next
Whistle.Append(CStr(Int((99 * Rnd()) + 10))).Append(TimeLimit).Append(FunTime.ToString).Append(text).Append(Chr(39)).
Append(CStr(Int((99 * Rnd()) + 10)))
For i = 1 To (Int((999 * Rnd()) + 1))
Recess.Append(Playground.Substring(Int((90 * Rnd()) + 1), 1))
Next
Whistle.Append(Recess.ToString)
Return Whistle
End Function
Public Shared Function CTGExtractor(text As String) As String
Dim SealTeam As Integer = CInt(text.Substring(2, 2)), DivideAndConquer As String = text.Split(Chr(39))(0)
Dim FinalS As String = DivideAndConquer.Substring(SealTeam + 4, DivideAndConquer.Length - SealTeam - 4)
Return FinalS
End Function
Public Shared Function FindStartsWithInFile(filename As String, startingtext As String)
Dim lines = System.IO.File.ReadAllLines(filename), FoundIt As String = ""
For i = 0 To lines.Length - 1
If lines(i).StartsWith(startingtext) Then
FoundIt = lines(i).ToString
End If
Next
Return FoundIt
End Function
Public Shared Sub WarningSound()
My.Computer.Audio.PlaySystemSound(System.Media.SystemSounds.Exclamation)
End Sub
Public Shared Sub VersionCheck()
Try
MemoryBank.AvailableVersion = ClarkTribeGames.MySQLReader.Query(LCase(Application.ProductName.ToString()), "v")
MemoryBank.UpdateURL = ClarkTribeGames.MySQLReader.Query(LCase(Application.ProductName.ToString()), "u")
If (ClarkTribeGames.Updater.Checker(MemoryBank.VersionNumber, MemoryBank.AvailableVersion)) Then
Dim updatetext = $"Update {MemoryBank.AvailableVersion} Available!", answer As Integer
answer = MsgBox($"{updatetext}{vbCrLf}{vbCrLf}Would you like to update now?", vbYesNo)
If answer = vbYes Then ClarkTribeGames.Updater.InstallUpdate(Application.ProductName, MemoryBank.UpdateURL)
End If
Catch ex As Exception
Logger.Logger.WriteToLog(2, "UpdateCheck", "Could not find update server.", ex)
End Try
End Sub
Public Shared Sub UpdaterCheck()
If System.IO.File.Exists(MemoryBank.UpdaterName) Then
If System.IO.File.GetLastWriteTime(MemoryBank.UpdaterName) < Convert.ToDateTime(MemoryBank.UpdaterDate) Then
System.IO.File.Delete(MemoryBank.UpdaterName)
ClarkTribeGames.Updater.GetUpdater()
Init.Init()
End If
Else
ClarkTribeGames.Updater.GetUpdater()
Init.Init()
End If
End Sub
End Class