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]$r, [int]$g, [int]$b, [int]$flatappearance_bordersize, [scriptblock]$onclick, [bool]$visible = $true ) $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 $button.Visible = $visible 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, [bool]$visible = $true ) $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) $label.Visible = $visible return $label } function textbox { param( [string]$text, [string]$font, [string]$textalign, [string]$borderstyle, [bool]$multiline, [int]$sizex, [int]$sizey, [int]$x, [int]$y, [bool]$visible = $true ) $textbox = New-Object System.Windows.Forms.TextBox $textbox.Text = $text $textbox.Font = $font $textbox.TextAlign = "Left" $textbox.BorderStyle = $borderstyle $textbox.Multiline = $multiline $textbox.Size = New-Object System.Drawing.Size($sizex, $sizey) $textbox.Location = New-Object System.Drawing.Point($x, $y) $textbox.Visible = $visible if ($borderstyle -and $borderstyle -ne "") { $textbox.BorderStyle = [System.Windows.Forms.BorderStyle]::$borderstyle } return $textbox } function checkbox{ param( [int]$x, [int]$y, [bool]$checked, [bool]$visible = $true, [scriptblock]$checkedchanged ) $checkbox = New-Object System.Windows.Forms.CheckBox $checkbox.Location = New-Object System.Drawing.Point($x, $y) $checkbox.Checked = $checked $checkbox.Visible = $visible if($checkedchanged) { $checkbox.Add_CheckedChanged($checkedchanged) } 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, [bool]$visible = $true ) $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 $combobox.Visible = $visible $defaultcbindex = $combobox.FindStringExact($defaultselection) if($defaultcbindex -ge 0){ $combobox.SelectedIndex = $defaultcbindex } return $combobox } function tab{ param( [int]$sizex, [int]$sizey, [int]$x, [int]$y, [bool]$visible = $true ) $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) $tab.Visible = $visible return $tab } function tabpage{ param( [string]$text, [bool]$visible = $true ) $tabpage = New-Object System.Windows.Forms.TabPage $tabpage.Text = $text $tabpage.Visible = $visible return $tabpage } function checkedlistbox{ param ( [int]$x, [int]$y, [int]$sizex, [int]$sizey, [bool]$autosize = $false, [string[]]$items ) $checkedlistbox = New-Object System.Windows.Forms.CheckedListBox $checkedlistbox.Location = New-Object System.Drawing.Point($x, $y) $checkedlistbox.Size = New-Object System.Drawing.Size($sizex ,$sizey) $checkedlistbox.AutoSize = $autosize foreach($item in $items){ $checkedlistbox.items.addrange(@("$item")) } return $checkedlistbox } function tooltip{ param( [object[]]$control [string]$text ) $tooltip = New-Object System.Windows.Forms.Tooltip $tooltip.SetToolTip($control, $text) } |