Public Class Form1
'delcare variables
Public mpchcpath As String
Private mpchcgetname As String
Public mpcbepath As String
Private mpcbegetname As String
Private kodixmlpath As String
Private kodixmlgetname As String
Public mpchcreturnvalue As String
Private xdrdataDirectory As String = String.Format("{0}\Data\", Environment.CurrentDirectory)
Public Function checkplayers()
'function to enable and disable buttons depending on 1 or 2 players set
Dim mpchckeyname As String = "HKEY_CURRENT_USER\Software\XDR"
Dim mpchcvaluename As String = "pathtompchc"
Dim mpchcvaluename1 As String = "pathtompcbe"
Dim mpchcvalue As String = ""
Dim mpchcvalue1 As String = ""
Dim mpchcreturnvalue As Object
Dim mpcbereturnvalue As Object
Label2.Text = ""
Label3.Text = ""
mpchcreturnvalue = GetValue(mpchckeyname, mpchcvaluename, mpchcvalue)
mpcbereturnvalue = GetValue(mpchckeyname, mpchcvaluename1, mpchcvalue1)
If mpchcreturnvalue = "" And mpcbereturnvalue = "" Then Button3.Enabled = False
If mpchcreturnvalue = "" And mpcbereturnvalue = "" Then Button4.Enabled = False
If mpchcreturnvalue IsNot "" Then Button3.Enabled = True
If mpchcreturnvalue IsNot "" Then Button4.Enabled = True
If mpcbereturnvalue IsNot "" Then Button3.Enabled = True
If mpcbereturnvalue IsNot "" Then Button4.Enabled = True
If mpchcreturnvalue = "" And mpcbereturnvalue = "" Then Label2.Text = "Create playercorefactory.xml -Disabled - Set player to enable!"
If mpchcreturnvalue = "" And mpcbereturnvalue = "" Then Label3.Text = "Setup for XDR Desktop - Disabled- Set player to enable!"
If mpchcreturnvalue IsNot "" Then Label2.Text = ""
If mpchcreturnvalue IsNot "" Then Label3.Text = ""
If mpcbereturnvalue IsNot "" Then Label2.Text = ""
If mpcbereturnvalue IsNot "" Then Label3.Text = ""
End Function
Function loadpath()
'used to get input from user to set paths to players for mpchcfn.exe and mpcbefn.exe as well as the playercorefactory.xml
OpenFileDialog1.ShowDialog()
mpchcpath = OpenFileDialog1().FileName
mpchcgetname = OpenFileDialog1.SafeFileName
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'check status of set players first load
checkplayers()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'delcare variables to use
Dim mpchckeyname As String = "HKEY_CURRENT_USER\Software\XDR"
Dim mpchcvaluename As String = "pathtompchc"
Dim mpchcvaluename1 As String = "pathtompcbe"
Dim mpchcvalue As String = ""
Dim mpchcvalue1 As String = ""
Dim mpchcreturnvalue As Object
Dim mpchcresult As DialogResult
'get the value for mpchc to test if player path is set or not
mpchcreturnvalue = GetValue(mpchckeyname, mpchcvaluename, mpchcvalue)
If mpchcreturnvalue = "" Then GoTo pathset :
If mpchcreturnvalue IsNot "" Then GoTo pathnotset :
GoTo mpchcend
pathnotset:
'Player detected do you want to remove
mpchcresult = MessageBox.Show("XDR has detected you have alreaady setup mpc-hc64.exe. Would you like to remove this player?", "XDRConfig", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If mpchcresult = DialogResult.Yes Then GoTo erasempchc :
GoTo mpchcend
pathset:
'used to set the path of mpchc player and also to disable player
mpchcresult = MessageBox.Show("XDR has detected no path has been set to mpc-hc64.exe. Would you like to set this up now?", "XDRConfig", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If mpchcresult = DialogResult.Yes Then GoTo mpcwritepath
GoTo mpchcend
mpcwritepath:
'message sucess of player path stored
loadpath()
If mpchcgetname = "mpc-hc64.exe" Then MessageBox.Show("Thankyou for setting the file location to mpc-hc64.exe!", "XDRConfig", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
If mpchcgetname = "mpc-hc64.exe" Then GoTo mpchcWritempchcpath :
'if not then goto endmpc but msgbox error
MessageBox.Show("The file you have selected is not a compatible player. XDR is looking for mpc-hc64.exe. If you do not have the correct version please download and install MPC-HC 64 Bit and try again", "XDRConfig", MessageBoxButtons.OK, MessageBoxIcon.Error)
erasempchc:
'no value is set delete value in regristry
CurrentUser.CreateSubKey("Software\\XDR\\").SetValue("pathtompchc", "")
CurrentUser.Close()
mpchcreturnvalue = GetValue(mpchckeyname, mpchcvaluename1, mpchcvalue1)
If mpchcreturnvalue = "" Then MessageBox.Show("Mpc-hc64.exe player has been disabled! XDR has also detected NO players are set! You need at least 1 player set for XDR to work in XDRDesktop and Kodi functions", "XDRConfig", MessageBoxButtons.OK, MessageBoxIcon.Warning)
If mpchcreturnvalue IsNot "" Then MessageBox.Show("Mpc-hc64.exe player has been disabled! XDR has detect that you still have mpc-be64.exe set. You must have a miminum of one player set for XDR to remain active!", "XDRConfig", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
GoTo mpchcend
mpchcWritempchcpath:
'write file path to regristry mpchc to be used by other programs
CurrentUser.CreateSubKey("Software\\XDR\\").SetValue("pathtompchc", mpchcpath)
CurrentUser.Close()
mpchcend:
'final check to analize buttons on off depending on user input of players set
checkplayers()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
'gets the install path of xdr to set path to mpchcfn.exe mpcbefn.exe and the script
CurrentUser.CreateSubKey("Software\\XDR\\").SetValue("pathtoxdr", xdrdataDirectory)
CurrentUser.Close()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'delcare variables to use
Dim mpchckeyname As String = "HKEY_CURRENT_USER\Software\XDR"
Dim mpchcvaluename As String = "pathtompchc"
Dim mpchcvaluename1 As String = "pathtompcbe"
Dim mpchcvalue As String = ""
Dim mpchcvalue1 As String = ""
Dim mpchcreturnvalue As Object
Dim mpchcresult As DialogResult
'get the value for mpchc to test if player path is set or not
mpchcreturnvalue = GetValue(mpchckeyname, mpchcvaluename1, mpchcvalue1)
If mpchcreturnvalue = "" Then GoTo pathset1 :
If mpchcreturnvalue IsNot "" Then GoTo pathnotset1 :
GoTo mpcbeend
pathnotset1:
'Player detected do you want to remove
mpchcresult = MessageBox.Show("XDR has detected you have alreaady setup mpc-be64.exe. Would you like to remove this player?", "XDRConfig", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If mpchcresult = DialogResult.Yes Then GoTo erasempcbe :
GoTo mpcbeend
pathset1:
'used to set the path of mpchc player and also to disable player
mpchcresult = MessageBox.Show("XDR has detected no path has been set to mpc-be64.exe. Would you like to set this up now?", "XDRConfig", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If mpchcresult = DialogResult.Yes Then GoTo mpcwritepath1
GoTo mpcbeend
mpcwritepath1:
loadpath()
If mpchcgetname = "mpc-be64.exe" Then MessageBox.Show("Thankyou for setting the file location to mpc-be64.exe!", "XDRConfig", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
If mpchcgetname = "mpc-be64.exe" Then GoTo mpcbeWritempchcpath :
'if not then goto mpcbeend but msgbox error
MessageBox.Show("The file you have selected is not a compatible player. XDR is looking for mpc-be64.exe. If you do not have the correct version please download and install MPC-BE 64 Bit and try again", "XDRConfig", MessageBoxButtons.OK, MessageBoxIcon.Error)
erasempcbe:
'no value is set delete value in regristry
CurrentUser.CreateSubKey("Software\\XDR\\").SetValue("pathtompcbe", "")
CurrentUser.Close()
mpchcreturnvalue = GetValue(mpchckeyname, mpchcvaluename, mpchcvalue)
If mpchcreturnvalue = "" Then MessageBox.Show("Mpc-bc64.exe player has been disabled! XDR has also detected NO players are set! You need at least 1 player set for XDR to work in XDRDesktop and Kodi functions", "XDRConfig", MessageBoxButtons.OK, MessageBoxIcon.Warning)
If mpchcreturnvalue IsNot "" Then MessageBox.Show("Mpc-be64.exe player has been disabled! XDR has detect that you still have mpc-hc64.exe set. You must have a miminum of one player set for XDR to remain active!", "XDRConfig", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
GoTo mpcbeend
mpcbeWritempchcpath:
'write file path to regristry mpcbe to be used by other programs
CurrentUser.CreateSubKey("Software\\XDR\\").SetValue("pathtompcbe", mpchcpath)
CurrentUser.Close()
mpcbeend:
'final check to analize buttons on off depending on user input of players set
checkplayers()
End Sub
End Class