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",
    [string]$flatappearance_bordercolor,
    [int]$flatappearance_bordersize,
    [scriptblock]$onclick,
    [bool]$visible
    )
    
    $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.BorderColor = $flatappearance_bordercolor
    $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
    )

    $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
    )

    $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
    )

    $checkbox = New-Object System.Windows.Forms.CheckBox
    $checkbox.Location = New-Object System.Drawing.Point($x, $y)
    $checkbox.Checked = $checked
    $checkbox.Visible = $visible

    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
    )
    
    $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
    )
    
    $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
    )

    $tabpage = New-Object System.Windows.Forms.TabPage
    $tabpage.Text = $text
    $tabpage.Visible = $visible

    return $tabpage
}