'WSZSTools - GUI, GUI to handle Wiimms SZS Tools 'Copyright (C) 2011 VulcSoft 'This program is free software: you can redistribute it and/or modify 'it under the terms of the GNU General Public License as published by 'the Free Software Foundation, either version 3 of the License, or '(at your option) any later version. 'This program is distributed in the hope that it will be useful, 'but WITHOUT ANY WARRANTY; without even the implied warranty of 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 'GNU General Public License for more details. 'You should have received a copy of the GNU General Public License 'along with this program. If not, see . Public Class frmCommandConsole ' --- Public Variables --- Dim CCFile1Result As String = "" Dim CCFile2Result As String = "" Dim CCDir1Result As String = "" Dim CCDir2Result As String = "" ' ----- Public Sub Shell2(ByVal FileName As String, ByVal Arguments As String) Dim ProcessInfo As New ProcessStartInfo With ProcessInfo .FileName = FileName .Arguments = Arguments End With Process.Start(ProcessInfo) End Sub Public Function Unixpathmkr(ByVal Inputvar As String) Dim UnixPathmkr1 As String Dim UnixPathmkr2 As String = "" Dim UnixPathmkr3 As String = "" Dim Outputvar As String = "" UnixPathmkr1 = Inputvar If InStr(1, UnixPathmkr1, "\") > 0 Then UnixPathmkr2 = Replace(UnixPathmkr1, "\", "/") End If If InStr(1, UnixPathmkr2, "C:/") > 0 Then Outputvar = Replace(UnixPathmkr2, "C:/", "/cygdrive/c/") End If Return Outputvar End Function Private Sub DoExecute() If My.Settings.Configured = True Then Dim CodeBoxText As String = CodeBox.Text Dim Tool As String = "" ' --- Set General replacement variables --- Dim File1Result As String = _ Unixpathmkr(CCFile1Result) Dim File2Result As String = _ Unixpathmkr(CCFile2Result) Dim Dir1Result As String = _ Unixpathmkr(CCDir1Result) Dim Dir2Result As String = _ Unixpathmkr(CCDir2Result) ' ------- ' Check if a tool is selected If InStr(CodeBoxText, "#wszst# ") > 0 Then CodeBoxText = Replace(CodeBoxText, "#wszst# ", "") Tool = "\wszst.exe" End If If InStr(CodeBoxText, "#wkmpt# ") > 0 Then CodeBoxText = Replace(CodeBoxText, "#wkmpt# ", "") Tool = "\wkmpt.exe" End If If InStr(CodeBoxText, "#wstrt# ") > 0 Then CodeBoxText = Replace(CodeBoxText, "#wstrt# ", "") Tool = "\wstrt.exe" End If If InStr(CodeBoxText, "#wbmgt# ") > 0 Then CodeBoxText = Replace(CodeBoxText, "#wbmgt# ", "") Tool = "\wbmgt.exe" End If If InStr(CodeBoxText, "#wimgt# ") > 0 Then CodeBoxText = Replace(CodeBoxText, "#wimgt# ", "") Tool = "\wimgt.exe" End If ' ---- ' Replace paths If InStr(CodeBoxText, "#file1#") > 0 Then CodeBoxText = Replace(CodeBoxText, "#file1#", Chr(34) & File1Result & Chr(34)) End If If InStr(CodeBoxText, "#file2#") > 0 Then CodeBoxText = Replace(CodeBoxText, "#file2#", Chr(34) & File2Result & Chr(34)) End If If InStr(CodeBoxText, "#folder1#") > 0 Then CodeBoxText = Replace(CodeBoxText, "#folder1#", Chr(34) & Dir1Result & Chr(34)) End If If InStr(CodeBoxText, "#folder2#") > 0 Then CodeBoxText = Replace(CodeBoxText, "#folder2#", Chr(34) & Dir2Result & Chr(34)) End If If InStr(CodeBoxText, "#open#") > 0 Then CodeBoxText = Replace(CodeBoxText, "#open#", Chr(34) & frmMain.OpenTempUnix & Chr(34)) End If ' ----- ' Execute command: Dim WSZSTPath = My.Settings.WSZSTPath Try Shell2(WSZSTPath & Tool, CodeBoxText) Catch ex As Exception MsgBox(ex.Message) End Try Else MsgBox("First Configure Wiimms SZS Tools") End If End Sub Private Sub CommandHelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CommandHelpToolStripMenuItem.Click frmConsoleHelp.Show() End Sub Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecute.Click DoExecute() End Sub Private Sub ExecuteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExecuteToolStripMenuItem.Click DoExecute() End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Close() End Sub Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click AboutBox1.Show() End Sub Private Sub btnFile1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFile1.Click Dim CCFile1Dialog As New SaveFileDialog CCFile1Dialog.OverwritePrompt = False Dim NoCancelCheck As Integer = CCFile1Dialog.ShowDialog() If NoCancelCheck = DialogResult.Cancel Then 'Do nothing Else CCFile1Result = CCFile1Dialog.FileName btnFile1.Text = "#file1#" End If End Sub Private Sub btnFile2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFile2.Click Dim CCFile2Dialog As New SaveFileDialog CCFile2Dialog.OverwritePrompt = False Dim NoCancelCheck As Integer = CCFile2Dialog.ShowDialog() If NoCancelCheck = DialogResult.Cancel Then 'Do nothing Else CCFile2Result = CCFile2Dialog.FileName btnFile2.Text = "#file2#" End If End Sub Private Sub btnDir1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDir1.Click Dim CCDir1Dialog As New FolderBrowserDialog Dim NoCancelCheck As Integer = CCDir1Dialog.ShowDialog() If NoCancelCheck = DialogResult.Cancel Then 'Do nothing Else CCDir1Result = CCDir1Dialog.SelectedPath btnDir1.Text = "#folder1#" End If End Sub Private Sub btnDir2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDir2.Click Dim CCDir2Dialog As New FolderBrowserDialog Dim NoCancelCheck As Integer = CCDir2Dialog.ShowDialog() If NoCancelCheck = DialogResult.Cancel Then 'Do nothing Else CCDir2Result = CCDir2Dialog.SelectedPath btnDir2.Text = "#folder2#" End If End Sub End Class