WFControlsLIB.psm1
<#
My Function #> Add-Type -AssemblyName System.Windows.Forms function form { param( [string]$sizex, [string]$sizey, [string]$startposition, [bool]$maximizebox, [bool]$controlbox, [string]$formborderstyle ) $form = New-Object System.Windows.Forms.Form $form.Size = New-Object System.Drawing.Point($sizex, $sizey) $form.StartPosition = $startposition $form.MaximizeBox = $maximizebox $form.ControlBox = $controlbox if ($formborderstyle -and $formborderstyle -ne "") { $form.FormBorderStyle = $formborderstyle } return $form } function button{ param( [string]$text, [string]$font, [string]$textalign = "MiddleCenter", [bool]$autosize, [int]$sizex, [int]$sizey, [int]$x, [int]$y, [string]$backcolor, [string]$flatstyle = "Flat", [int]$flatappearance_bordersize, [scriptblock]$onclick ) $button = New-Object System.Windows.Forms.Button $button.Text = $text $button.Font = $font $button.TextAlign = $textalign $button.AutoSize = $autosize $button.Size = New-Object System.Drawing.Size($sizex, $sizey) $button.Location = New-Object System.Drawing.Point($x, $y) $button.BackColor = $backcolor $button.Flatstyle = $flatstyle $button.FlatAppearance.BorderSize = $flatappearance_bordersize if($onclick) { $button.Add_Click($OnClick) } return $button } function label{ param( [string]$text, [string]$font, [bool]$autosize, [int]$sizex, [int]$sizey, [int]$x, [int]$y ) $label = New-Object System.Windows.Forms.Label $label.Text = $text $label.font = $font $label.AutoSize = $autosize $label.Size = New-Object System.Drawing.Size($sizex, $sizey) $label.Location = New-Object System.Drawing.Point($x, $y) return $label } function textbox { param( [string]$text, [string]$font, [string]$textalign, [string]$borderstyle, [bool]$multiline, [int]$sizex, [int]$sizey, [int]$x, [int]$y ) $textbox = New-Object System.Windows.Forms.TextBox $textbox.Text = $text $textbox.Font = $font $textbox.TextAlign = $textalign $textbox.BorderStyle = $borderstyle $textbox.Multiline = $multiline $textbox.Size = New-Object System.Drawing.Size($sizex, $sizey) $textbox.Location = New-Object System.Drawing.Point($x, $y) if ($borderstyle -and $borderstyle -ne "") { $textbox.BorderStyle = [System.Windows.Forms.BorderStyle]::$borderstyle } return $textbox } function checkbox{ param( [int]$x, [int]$y, [bool]$checked ) $checkbox = New-Object System.Windows.Forms.CheckBox $checkbox.Location = New-Object System.Drawing.Point($x, $y) $checkbox.Checked = $checked return $checkbox } function combobox{ param( [string]$dropdownstyle, [string]$font, [int]$sizex, [int]$sizey, [bool]$autosize, [int]$x, [int]$y, [string[]]$items, [string]$flatstyle, [string]$defaultselection ) $combobox = New-Object System.Windows.Forms.ComboBox $combobox.Font = $font $combobox.Size = New-Object System.Drawing.Size($sizex, $sizey) $combobox.AutoSize = $autosize $combobox.Location = New-Object System.Drawing.Point($x, $y) $combobox.Items.AddRange(@($items)) $combobox.FlatStyle = $flatstyle $combobox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::$dropdownstyle $defaultcbindex = $combobox.FindStringExact($defaultselection) if($defaultcbindex -ge 0){ $combobox.SelectedIndex = $defaultcbindex } return $combobox } function tab{ param( [int]$sizex, [int]$sizey, [int]$x, [int]$y ) $tab = New-Object System.Windows.Forms.TabControl $tab.Size = New-Object System.Drawing.Size($sizex, $sizey) $tab.Location = New-Object System.Drawing.Point($x, $y) return $tab } function tabpage{ param( [string]$text ) $tabpage = New-Object System.Windows.Forms.TabPage $tabpage.Text = $text return $tabpage } |