mirror of
https://github.com/onyx-and-iris/q3rcon-ps.git
synced 2025-04-20 04:23:47 +01:00
Compare commits
3 Commits
cb7c7b2e04
...
61f7afb9f7
Author | SHA1 | Date | |
---|---|---|---|
61f7afb9f7 | |||
4966bee0b8 | |||
a9ccdb0c19 |
@ -1,3 +1,8 @@
|
|||||||
|
[cmdletbinding()]
|
||||||
|
param()
|
||||||
|
|
||||||
|
Import-Module ../lib/Q3Rcon.psm1
|
||||||
|
|
||||||
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
|
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
|
||||||
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
||||||
|
|
||||||
@ -9,7 +14,7 @@ $Lbl = New-Object System.Windows.Forms.Label
|
|||||||
Function InitForm {
|
Function InitForm {
|
||||||
$form = New-Object System.Windows.Forms.Form
|
$form = New-Object System.Windows.Forms.Form
|
||||||
$form.Text = "Q3Rcon Client"
|
$form.Text = "Q3Rcon Client"
|
||||||
$form.Size = New-Object System.Drawing.Size(300, 200)
|
$form.Size = New-Object System.Drawing.Size(275, 200)
|
||||||
$form.StartPosition = "CenterScreen"
|
$form.StartPosition = "CenterScreen"
|
||||||
return $form
|
return $form
|
||||||
}
|
}
|
||||||
@ -20,7 +25,7 @@ Function AddOkButton {
|
|||||||
$OKB.Location = New-Object System.Drawing.Size(65, 100)
|
$OKB.Location = New-Object System.Drawing.Size(65, 100)
|
||||||
$OKB.Size = New-Object System.Drawing.Size(65, 23)
|
$OKB.Size = New-Object System.Drawing.Size(65, 23)
|
||||||
$OKB.Text = "Send"
|
$OKB.Text = "Send"
|
||||||
$OKB.Add_Click({ $rcon.Send($OTB.Text) })
|
$OKB.Add_Click({ SendRconCommand -rcon $rcon })
|
||||||
$form.Controls.Add($OKB)
|
$form.Controls.Add($OKB)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,9 +44,16 @@ Function AddLabel($form) {
|
|||||||
$form.Controls.Add($Lbl)
|
$form.Controls.Add($Lbl)
|
||||||
}
|
}
|
||||||
|
|
||||||
Function AddTextBox($form) {
|
Function AddTextBox {
|
||||||
|
param($form, $rcon)
|
||||||
|
|
||||||
$OTB.Location = New-Object System.Drawing.Size(10, 50)
|
$OTB.Location = New-Object System.Drawing.Size(10, 50)
|
||||||
$OTB.Size = New-Object System.Drawing.Size(240, 20)
|
$OTB.Size = New-Object System.Drawing.Size(240, 20)
|
||||||
|
$OTB.Add_KeyDown({
|
||||||
|
if ($_.KeyCode -eq [System.Windows.Forms.Keys]::Enter) {
|
||||||
|
SendRconCommand -rcon $rcon
|
||||||
|
}
|
||||||
|
})
|
||||||
$form.Controls.Add($OTB)
|
$form.Controls.Add($OTB)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +62,12 @@ Function FinalizeForm($form) {
|
|||||||
$form.Add_Shown({ $form.Activate() })
|
$form.Add_Shown({ $form.Activate() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function SendRconCommand() {
|
||||||
|
param($rcon)
|
||||||
|
|
||||||
|
$rcon.Send($OTB.Text)
|
||||||
|
$OTB.Text = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Function Get-ConnFromPSD1 {
|
Function Get-ConnFromPSD1 {
|
||||||
@ -57,6 +75,7 @@ Function Get-ConnFromPSD1 {
|
|||||||
return Import-PowerShellDataFile -Path $configpath
|
return Import-PowerShellDataFile -Path $configpath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function Main {
|
||||||
try {
|
try {
|
||||||
$conn = Get-ConnFromPSD1
|
$conn = Get-ConnFromPSD1
|
||||||
$rcon = Connect-Rcon -hostname $conn.host -port $conn.port -passwd $conn.passwd
|
$rcon = Connect-Rcon -hostname $conn.host -port $conn.port -passwd $conn.passwd
|
||||||
@ -66,7 +85,7 @@ try {
|
|||||||
AddOkButton -form $form -rcon $rcon
|
AddOkButton -form $form -rcon $rcon
|
||||||
AddCloseButton($form)
|
AddCloseButton($form)
|
||||||
AddLabel($form)
|
AddLabel($form)
|
||||||
AddTextBox($form)
|
AddTextBox -form $form -rcon $rcon
|
||||||
FinalizeForm($form)
|
FinalizeForm($form)
|
||||||
|
|
||||||
[void] $form.ShowDialog()
|
[void] $form.ShowDialog()
|
||||||
@ -74,3 +93,9 @@ try {
|
|||||||
finally {
|
finally {
|
||||||
Disconnect-Rcon -rcon $rcon
|
Disconnect-Rcon -rcon $rcon
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($MyInvocation.InvocationName -ne '.') {
|
||||||
|
Main
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user