-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartMenu.ps1
More file actions
127 lines (113 loc) · 3.21 KB
/
startMenu.ps1
File metadata and controls
127 lines (113 loc) · 3.21 KB
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
. '.\General.ps1'
Function startMenu([System.Windows.Forms.Form]$appBar)
{
#This is needed for calculating Control.Sizes
[int]$myWidth = 464
[int]$myHeight = 486
[int]$btnMargin = 12
[int]$btnHeight = 30
#Predefined Slot algorithm for perfect placements of startMenuItems
Function Slot([Int]$intSlot)
{
If ($intSlot -gt 0)
{
return ($btnMargin + ($intSlot * ($btnHeight + $btnMargin)))
} Else
{
return $btnMargin
}
}
[System.Windows.Forms.Form]$menuForm = New-Object System.Windows.Forms.Form -Property @{
visible = $False
AutoScaleDimensions = New-Object System.Drawing.SizeF(6.0, 13.0)
AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::Font
BackColor = [System.Drawing.SystemColors]::ControlDark
ClientSize = New-Object System.Drawing.Size($myWidth, $myHeight)
ShowInTaskbar = $False
FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::None
Name = "StartMenu"
StartPosition = [System.Windows.Forms.FormStartPosition]::Manual
}
$menuForm.SuspendLayout()
switch ($appBar.ABE)
{
ABE_LEFT
{
#0
}
ABE_TOP
{
#1
$menuForm.left = $appBar.left
$menuForm.top = $appBar.Bottom
}
ABE_RIGHT
{
#2
}
ABE_BOTTOM
{
#3
$menuForm.left = $appBar.left
$menuForm.bottom = $appBar.Top
}
default {Write-Host "This should never ever happen."}
}
$sc = New-Object System.Windows.Forms.SplitContainer -Property @{
TabIndex = 0
Dock = [System.Windows.Forms.DockStyle]::Fill
Location = New-Object System.Drawing.Point(0, 0)
Size = $menuForm.Size
SplitterDistance = $myWidth * 0.45
BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D
}
#If this goes bigger: http://powershell.org/wp/2013/01/23/join-powershell-hash-tables/
[hashtable]$btnProto=@{
Size = New-Object System.Drawing.Size(($sc.SplitterDistance - 2 * $btnMargin), $btnHeight)
UseVisualStyleBackColor = $True
}
$btnComputer = New-Object System.Windows.Forms.Button -Property ($btnProto+@{
Name = "btnComputer"
Text = "Computer"
TabIndex = 0
Location = New-Object System.Drawing.Point($btnMargin, (Slot(0)))
})
$btnCmd = New-Object System.Windows.Forms.Button -Property ($btnProto+@{
Name = "btnCmd"
Text = "CommandPrompt"
TabIndex = 1
Location = New-Object System.Drawing.Point($btnMargin, (Slot(1)))
})
$btndrei = New-Object System.Windows.Forms.Button -Property ($btnProto+@{
Name = "btndrei"
Text = "TestKnopf"
TabIndex = 2
Location = New-Object System.Drawing.Point($btnMargin, (Slot(2)))
})
$btnShutdown = New-Object System.Windows.Forms.Button -Property ($btnProto+@{
Name = "btnShutdown"
Text = "Shutdown"
TabIndex = 0
Location = New-Object System.Drawing.Point($btnMargin, 431)
})
$btnCmd.Add_Click(
{
Start-Process "CMD"
#Attention:
$startM.Hide()
}
)
$btndrei.Add_Click({Start-Process "explorer"})
#$sc.beginInit()
$sc.Panel1.Controls.AddRange(@(
$btnComputer,
$btnCmd,
$btndrei
))
$sc.Panel2.Controls.Add($btnShutdown)
$sc.Panel2.BackColor = [System.Drawing.SystemColors]::ControlDark
#$sc.EndInit()
$menuForm.Controls.Add($sc)
$menuForm.ResumeLayout($False)
Return $menuForm
}