Windows.Forms это не просто, а очень просто.

9 views
Skip to first unread message

ajax76

unread,
Oct 19, 2008, 12:25:59 PM10/19/08
to ru-powershell
[Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')

function Form(){
param(
[hashtable]$properties,
[System.Windows.Forms.Control[]]$controls
)

$form=New-Object system.Windows.Forms.Form

if($properties){
$properties.keys | %{$form.$_=$properties[$_]}
}
if($controls){
$controls | %{$form.controls.add($_)}
}

return $form
}

function Control(){
param(
[string]$name,
[hashtable]$properties
)

$control=new-object $("System.Windows.Forms.$name")
if($properties){
$properties.keys | %{$control.$_=$properties[$_]}
}

return $control
}

Синтаксис:

Form [<[Hashtable] Properties>] [<[Control[]] Controls>]

Control [<String> Name] [<[Hashtable] Properties>]

Пример:

(Form @{
"text"="My Form";
"startposition"="centerscreen"
} @(Control "Label" @{
"text"="My Label";
"Location"=New-Object System.Drawing.Point(50,100)
}
)
).showdialog()

Продолжение следует ..?
Reply all
Reply to author
Forward
0 new messages