-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguisttngs.ps1
executable file
·130 lines (111 loc) · 3.74 KB
/
guisttngs.ps1
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
[CmdletBinding()]
Param(
)
function Parse-IniFile ($file) {
$ini = @{}
# Create a default section if none exist in the file. Like a java prop file.
$section = "NO_SECTION"
$ini[$section] = @{}
switch -regex -file $file {
"^\[(.+)\]$" {
$section = $matches[1].Trim()
$ini[$section] = @{}
}
"^\s*([^#].+?)\s*=\s*(.*)" {
$name,$value = $matches[1..2]
# skip comments that start with semicolon:
if (!($name.StartsWith(";"))) {
$ini[$section][$name] = $value.Trim()
}
}
}
$ini
}
if (Test-Path ".\bang.ini") {
$ini = Parse-IniFile ".\bang.ini"
$hostinfo = $ini["defaults"]["hostinfo"]
$dwnldsrc = $ini["defaults"]["source"]
}
$global:cncl=$false;
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objForm = New-Object System.Windows.Forms.Form
$objForm.Font = New-Object System.Drawing.Font("Arial", 11)
$objForm.Size = New-Object System.Drawing.Size(330,200)
$objForm.StartPosition = "CenterScreen"
$objForm.Text = "Bang Wallpaper Plus settings"
$objcheckBox = New-Object System.Windows.Forms.CheckBox
$objcheckBox.Location = New-Object System.Drawing.Size(10,25)
$objcheckBox.Size = New-Object System.Drawing.Size(145,20)
$objcheckBox.CheckAlign = "MiddleRight";
$objcheckBox.Text = "display host info"
$objcheckBox.Checked = $true
if($hostinfo -eq "no") {
$objcheckBox.Checked = $false
}
$objForm.Controls.Add($objcheckBox)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,80)
$objLabel.Size = New-Object System.Drawing.Size(105,20)
$objLabel.Text = "source"
$objForm.Controls.Add($objLabel)
$objCombobox = New-Object System.Windows.Forms.Combobox
$objCombobox.Location = New-Object System.Drawing.Size(145,80)
$objCombobox.Size = New-Object System.Drawing.Size(160,20)
[void] $objCombobox.Items.Add("bing")
[void] $objCombobox.Items.Add("heise (experimental)")
$objCombobox.SelectedIndex = 0
if($dwnldsrc -eq "heise") {
$objCombobox.SelectedIndex = 1
}
$objCombobox.DropDownStyle = "DropDownList";
$objCombobox.Height = 70
$objForm.Controls.Add($objCombobox)
$objForm.Topmost = $True
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(60,130)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Name = "OK"
$OKButton.DialogResult = "OK"
$OKButton.Add_Click(
{
$hostinfo = $objcheckBox.Checked
$dwnldsrc = $objCombobox.SelectedIndex
$objForm.Close()
})
$objForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(180,130)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.Name = "Cancel"
$CancelButton.DialogResult = "Cancel"
$CancelButton.Add_Click({
$global:cncl = $true
$objForm.Close()
})
$objForm.Controls.Add($CancelButton)
if (Test-Path ".\parrot.ico") {
$objForm.Icon = New-Object System.Drawing.Icon(".\parrot.ico")
}
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
if ($global:cncl) {
exit 0
} else {
if($objCombobox.SelectedIndex -eq 0) {
$dwnldsrc = "bing"
} else {
$dwnldsrc = "heise"
}
if($objcheckBox.Checked) {
$hostinfo = "yes"
} else {
$hostinfo = "no"
}
"[defaults]" | Out-File -FilePath ".\bang.ini" -Encoding ASCII
"hostinfo=$hostinfo" | Out-File -FilePath ".\bang.ini" -Encoding ASCII -Append
"source=$dwnldsrc" | Out-File -FilePath ".\bang.ini" -Encoding ASCII -Append
exit 0
}