Initial commit
This commit is contained in:
commit
a491ef2093
813 changed files with 345031 additions and 0 deletions
385
WindowsPowershell/Modules/PowerBoots/Add-BootsFunction.ps1
Normal file
385
WindowsPowershell/Modules/PowerBoots/Add-BootsFunction.ps1
Normal file
|
|
@ -0,0 +1,385 @@
|
|||
function Add-BootsFunction {
|
||||
<#
|
||||
.Synopsis
|
||||
Add support for a new class to Boots by creating the dynamic constructor function(s).
|
||||
.Description
|
||||
Creates a New-Namespace.Type function for each type passed in, as well as a short form "Type" alias.
|
||||
|
||||
Exposes all of the properties and events of the type as perameters to the function.
|
||||
|
||||
NOTE: The Type MUST have a default parameterless constructor.
|
||||
.Parameter Type
|
||||
The type you want to create a constructor function for. It must have a default parameterless constructor.
|
||||
.Example
|
||||
Add-BootsFunction ([System.Windows.Controls.Button])
|
||||
|
||||
Creates a new boots function for the Button control.
|
||||
|
||||
.Example
|
||||
[Reflection.Assembly]::LoadWithPartialName( "PresentationFramework" ).GetTypes() | Add-BootsFunction
|
||||
|
||||
Will create boots functions for all the WPF components in the PresentationFramework assembly. Note that you could also load that assembly using GetAssembly( "System.Windows.Controls.Button" ) or Load( "PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" )
|
||||
|
||||
.Example
|
||||
Add-BootsFunction -Assembly PresentationFramework
|
||||
|
||||
Will create boots functions for all the WPF components in the PresentationFramework assembly.
|
||||
|
||||
.Links
|
||||
http://HuddledMasses.org/powerboots
|
||||
.ReturnValue
|
||||
The name(s) of the function(s) created -- so you can export them, if necessary.
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 2009-01-13 16:35:23
|
||||
#>
|
||||
[CmdletBinding(DefaultParameterSetName="FromType")]
|
||||
PARAM(
|
||||
[Parameter(Position=0,ValueFromPipeline=$true,ParameterSetName="FromType",Mandatory=$true)]
|
||||
[type[]]$type
|
||||
,
|
||||
[Parameter(Position=0,ValueFromPipeline=$true,ParameterSetName="FromAssembly",Mandatory=$true)]
|
||||
[string[]]$Assembly
|
||||
,
|
||||
[Parameter()]
|
||||
[switch]$Force
|
||||
)
|
||||
BEGIN {
|
||||
[Type[]]$Empty=@()
|
||||
if(!(Test-Path $PowerBootsPath\Functions)) {
|
||||
MkDir $PowerBootsPath\Functions
|
||||
}
|
||||
}
|
||||
END {
|
||||
Export-CliXml -Input $DependencyProperties -Path $PowerBootsPath\DependencyProperties.clixml
|
||||
}
|
||||
PROCESS {
|
||||
if($PSCmdlet.ParameterSetName -eq "FromAssembly") {
|
||||
[type[]]$type = @()
|
||||
foreach($lib in $Assembly) {
|
||||
$asm = $null
|
||||
trap { continue }
|
||||
if(Test-Path $lib) {
|
||||
$asm = [Reflection.Assembly]::LoadFrom( (Convert-Path (Resolve-Path $lib -EA "SilentlyContinue") -EA "SilentlyContinue") )
|
||||
}
|
||||
if(!$asm) {
|
||||
## BUGBUG: LoadWithPartialName is "Obsolete" -- but it still works in 2.0/3.5
|
||||
$asm = [Reflection.Assembly]::LoadWithPartialName( $lib )
|
||||
}
|
||||
if($asm) {
|
||||
$type += $asm.GetTypes() | ?{ $_.IsPublic -and !$_.IsEnum -and
|
||||
!$_.IsAbstract -and !$_.IsInterface -and
|
||||
$_.GetConstructor( "Instance,Public", $Null, $Empty, @() )}
|
||||
} else {
|
||||
Write-Error "Can't find the assembly $lib, please check your spelling and try again"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$LoadedAssemblies = Get-BootsAssemblies
|
||||
|
||||
foreach($T in $type) {
|
||||
$TypeName = $T.FullName
|
||||
$ScriptPath = "$PowerBootsPath\Functions\New-$TypeName.ps1"
|
||||
Write-Verbose $TypeName
|
||||
|
||||
## Collect all dependency properties ....
|
||||
$T.GetFields() |
|
||||
Where-Object { $_.FieldType -eq [System.Windows.DependencyProperty] } |
|
||||
Select-Object Name, @{n="DeclaringType";e={$_.DeclaringType.FullName}},
|
||||
@{n="PropertyType";e={$_.DeclaringType::"$($_.Name)".PropertyType.FullName}},
|
||||
@{n="Field";e={$_.DeclaringType::"$($_.Name)".Name}} |
|
||||
ForEach-Object {
|
||||
if($DependencyProperties.ContainsKey( $_.Field )) {
|
||||
$DependencyProperties[$_.Field] = @($DependencyProperties[$_.Field]) + @($_)
|
||||
} else {
|
||||
$DependencyProperties[$_.Field] = $_
|
||||
}
|
||||
}
|
||||
|
||||
if(!( Test-Path $ScriptPath ) -OR $Force) {
|
||||
$Pipelineable = @();
|
||||
## Get (or generate) a set of parameters based on the the Type Name
|
||||
$Parameters = "[CmdletBinding(DefaultParameterSetName='Default')]`nPARAM(`n" + [String]::Join("`n,`n", @(
|
||||
## Add all properties
|
||||
foreach ($p in $T.GetProperties("Public,Instance,FlattenHierarchy") |
|
||||
where {$_.CanWrite -Or $_.PropertyType.GetInterface([System.Collections.IList]) } | Sort Name -Unique)
|
||||
{
|
||||
if($p.Name -match "^$($BootsContentProperties -Join '$|^')`$") {
|
||||
$Pipelineable += @(Add-Member -in $p.Name -Type NoteProperty -Name "IsCollection" -Value $($p.PropertyType.GetInterface([System.Collections.IList]) -ne $null) -Passthru)
|
||||
"`t[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=`$true)]" +
|
||||
"`n`t[Object[]]`$$($p.Name)"
|
||||
} elseif($p.PropertyType -eq [System.Boolean]) {
|
||||
"`t[Parameter(ParameterSetName='Default')]"+
|
||||
"`n`t[Switch]`$$($p.Name)"
|
||||
} else {
|
||||
"`t[Parameter(ParameterSetName='Default')]"+
|
||||
"`n`t[Object[]]`$$($p.Name)"
|
||||
}
|
||||
}
|
||||
|
||||
## Add all events
|
||||
foreach ($e in $T.GetEvents("Public,Instance,FlattenHierarchy"))
|
||||
{
|
||||
"`t[Parameter(ParameterSetName='Default')]" +
|
||||
"`n`t[PSObject]`$On_$($e.Name)"
|
||||
}
|
||||
)) + "`n,`n`t[Parameter(ValueFromRemainingArguments=`$true)]`n`t[string[]]`$DependencyProps`n)"
|
||||
|
||||
$collectable = [bool]$(@(foreach($p in @($Pipelineable)){$p.IsCollection}) -contains $true)
|
||||
$ofs = "`n";
|
||||
|
||||
# Write-Host "Pipelineable Content Property for $TypeName: $($Pipelineable -ne $Null)" -Fore Cyan
|
||||
# foreach($p in $Pipelineable) {write-host "$p is $(if(!$p.IsCollection) { "not " })a collection"}
|
||||
|
||||
### These three are "built in" to boots, so we don't need to write preloading for them
|
||||
# PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
|
||||
# WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
|
||||
# PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
|
||||
|
||||
$function = $(
|
||||
"
|
||||
$Parameters
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), '$($T.Assembly.FullName)' ) -lt 0 ) {
|
||||
$(
|
||||
$index = [Array]::BinarySearch($LoadedAssemblies, $T.Assembly.FullName)
|
||||
|
||||
if( $index -gt 0 -and $LoadedAssemblies[$index].Location ) {
|
||||
" `$null = [Reflection.Assembly]::LoadFrom( '" + $LoadedAssemblies[$index].Location + "' ) "
|
||||
} else {
|
||||
" `$null = [Reflection.Assembly]::Load( '" + $($T.Assembly.FullName) + "' ) "
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
if(`$ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning `"$($T.Name) not invoked in PowerBoots context. Attempting to reinvoke.`"
|
||||
`$scriptParam = `$PSBoundParameters
|
||||
return iex `"& (Get-BootsModule) '`$(`$MyInvocation.MyCommand.Path)' ```@PSBoundParameters`"
|
||||
}
|
||||
# Write-Host ""$($T.Name) in module `$(`$executioncontext.sessionstate.module) context!"" -fore Green
|
||||
|
||||
|
||||
function Global:New-$TypeName {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new $($T.Name) object
|
||||
.Description
|
||||
Generates a new $TypeName object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: $(Get-Date)
|
||||
#>
|
||||
|
||||
$Parameters
|
||||
BEGIN {
|
||||
`$DObject = New-Object $TypeName
|
||||
`$All = Get-Parameter New-$TypeName | ForEach-Object { `$_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
"
|
||||
if(!$collectable) {
|
||||
"
|
||||
# The content of $TypeName is not a collection
|
||||
# So if we're in a pipeline, make a new $($T.Name) each time
|
||||
if(`$_) {
|
||||
`$DObject = New-Object $TypeName
|
||||
}
|
||||
"
|
||||
}
|
||||
|
||||
@'
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
'@
|
||||
if(!$collectable) {
|
||||
@'
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
'@
|
||||
} else {
|
||||
@'
|
||||
} #Process
|
||||
END {
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
}
|
||||
'@
|
||||
}
|
||||
@"
|
||||
}
|
||||
|
||||
New-$TypeName `@PSBoundParameters
|
||||
"@
|
||||
)
|
||||
|
||||
Set-Content -Path $ScriptPath -Value $Function
|
||||
}
|
||||
New-Alias -Name $T.Name "New-$TypeName" -EA "SilentlyContinue"
|
||||
}
|
||||
}#PROCESS
|
||||
}#Add-BootsFunction
|
||||
# SIG # Begin signature block
|
||||
# MIILCQYJKoZIhvcNAQcCoIIK+jCCCvYCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
|
||||
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
|
||||
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUHhtLLvsSLITfQ0Bj8OsPHlJI
|
||||
# u8GgggbgMIIG3DCCBMSgAwIBAgIJALPpqDj9wp7xMA0GCSqGSIb3DQEBBQUAMIHj
|
||||
# MQswCQYDVQQGEwJVUzERMA8GA1UECBMITmV3IFlvcmsxEjAQBgNVBAcTCVJvY2hl
|
||||
# c3RlcjEhMB8GA1UEChMYaHR0cDovL0h1ZGRsZWRNYXNzZXMub3JnMSgwJgYDVQQL
|
||||
# Ex9TY3JpcHRpbmcgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MTcwNQYDVQQDEy5odHRw
|
||||
# Oi8vSHVkZGxlZE1hc3Nlcy5vcmcgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MScwJQYJ
|
||||
# KoZIhvcNAQkBFhhKYXlrdWxASHVkZGxlZE1hc3Nlcy5vcmcwHhcNMDkwMzE1MTkx
|
||||
# OTE5WhcNMTAwMzE1MTkxOTE5WjCBqzELMAkGA1UEBhMCVVMxETAPBgNVBAgTCE5l
|
||||
# dyBZb3JrMRIwEAYDVQQHEwlSb2NoZXN0ZXIxITAfBgNVBAoTGGh0dHA6Ly9IdWRk
|
||||
# bGVkTWFzc2VzLm9yZzESMBAGA1UECxMJU2NyaXB0aW5nMRUwEwYDVQQDEwxKb2Vs
|
||||
# IEJlbm5ldHQxJzAlBgkqhkiG9w0BCQEWGEpheWt1bEBIdWRkbGVkTWFzc2VzLm9y
|
||||
# ZzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAPfqxOG9TQN+qZjZ6KfM
|
||||
# +zBK0YpjeyPL/cFgiGBhiIdYWTBtkbZydFr3IiERKRsUJ0/SKFbhf0C3Bvd/neTJ
|
||||
# qiZjH4D6xkrfdLlWMmmSXXqjSt48jZp+zfCAIaF8K84e9//7lMicdVFE6VcgoATZ
|
||||
# /eMKQky4JvphJpzDHYPLxLJQrKd0pjDDwspjdX5RedWkzeZBG7VfBnebLWUzgnMX
|
||||
# IxRQKfFCMryQDP8weceOnJjfJEf2FYmdpsEg5EKKKbuHsQCMVTxfteKdPvh1oh05
|
||||
# 1GWyPsvEPh4auJUT8pAVvrdxq+/O9KW/UV01UxjRYM1vdklNw8g7mkJTrrHjSjl7
|
||||
# tuugCnJjt5kN6v/OaUtRRMR68O85bSTVGOxJGCHUKlyuuTx9tnfIgy4siFYX1Ve8
|
||||
# xwaAdN3haTon3UkWzncHOq3reCIVF0luwRZu7u+TnOAnz2BRlt+rcT0O73GN20Fx
|
||||
# gyN2f5VGBbw1KuS7T8XZ0TFCspUdgwAcmTGuEVJKGhVcGAvNlLx+KPc5dba4qEfs
|
||||
# VZ0MssC2rALC1z61qWuucb5psHYhuD2tw1SrztywuxihIirZD+1+yKE4LsjkM1zG
|
||||
# fQwDO/DQJwkdByjfB2I64p6mk36OlZAFxVfRBpXSCzdzbgKpuPsbtjkb5lGvKjE1
|
||||
# JFVls1SHLJ9q80jHz6yW7juBAgMBAAGjgcgwgcUwHQYDVR0OBBYEFO0wLZyg+qGH
|
||||
# Z4WO8ucEGNIdU1T9MB8GA1UdIwQYMBaAFN2N42ZweJLF1mz0j70TMxePMcUHMAkG
|
||||
# A1UdEwQCMAAwEQYJYIZIAYb4QgEBBAQDAgTwMCoGA1UdJQEB/wQgMB4GCCsGAQUF
|
||||
# BwMBBggrBgEFBQcDAgYIKwYBBQUHAwMwCwYDVR0PBAQDAgTwMCwGCWCGSAGG+EIB
|
||||
# DQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTANBgkqhkiG9w0BAQUF
|
||||
# AAOCAgEAmKihxd6KYamLG0YLvs/unUTVJ+NW3jZP16R28PpmidY/kaBFOPhYyMl2
|
||||
# bBGQABe7LA5rpHFAs0F56gYETNoFk0qREVvaoz9u18VfLb0Uwqtnq0P68L4c7p2q
|
||||
# V3nKmWjeI6H7BAyFuogxmMH5TGDfiqrrVSuh1LtPbkV2Wtto0SAxP0Ndyts2J8Ha
|
||||
# vu/2rt0Ic5AkyD+RblFPtzkCC/MLVwSNAiDSKGRPRrLaiGxntEzR59GRyf2vwhGg
|
||||
# oAXUqcJ/CVeHCP6qdSTM39Ut3RmMZHXz5qY8bvLgNYL6MtcJAx+EeUhW497alzm1
|
||||
# jInXdbikIh0d/peTSDyLbjS8CPFFtS6Z56TDGMf+ouTpEA16otcWIPA8Zfjq+7n7
|
||||
# iBHjeuy7ONoJ2VDNgqn9B+ft8UWRwnJbyB85T83OAGf4vyhCPz3Kg8kWxY30Bhnp
|
||||
# Fayc6zQKCpn5o5T0/a0BBHwAyMfr7Lhav+61GpzzG1KfAw58N2GV8KCPKNEd3Zdz
|
||||
# y07aJadroVkW5R+35mSafKRJp5pz20GDRwZQllqGH1Y/UJFEiI0Bme9ecbl2vzNp
|
||||
# JjHyl/jLVzNVrBI5Zwb0lCLsykApgNY0yrwEqaiqwcxq5nkXFDhDPQvbdulihSo0
|
||||
# u33fJreCm2fFyGbTuvR61goSksAvLQhvijLAzcKqWKG+laOtYpAxggOTMIIDjwIB
|
||||
# ATCB8TCB4zELMAkGA1UEBhMCVVMxETAPBgNVBAgTCE5ldyBZb3JrMRIwEAYDVQQH
|
||||
# EwlSb2NoZXN0ZXIxITAfBgNVBAoTGGh0dHA6Ly9IdWRkbGVkTWFzc2VzLm9yZzEo
|
||||
# MCYGA1UECxMfU2NyaXB0aW5nIENlcnRpZmljYXRlIEF1dGhvcml0eTE3MDUGA1UE
|
||||
# AxMuaHR0cDovL0h1ZGRsZWRNYXNzZXMub3JnIENlcnRpZmljYXRlIEF1dGhvcml0
|
||||
# eTEnMCUGCSqGSIb3DQEJARYYSmF5a3VsQEh1ZGRsZWRNYXNzZXMub3JnAgkAs+mo
|
||||
# OP3CnvEwCQYFKw4DAhoFAKB4MBgGCisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJ
|
||||
# KoZIhvcNAQkDMQwGCisGAQQBgjcCAQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQB
|
||||
# gjcCARUwIwYJKoZIhvcNAQkEMRYEFLc0+RGhSEPZ4FWvi4ZFzZ+O9lP0MA0GCSqG
|
||||
# SIb3DQEBAQUABIICAC0niyf74gurVX3R+Jf4tKYgTLT8SkE+mfRpuDeY7ss1iNQq
|
||||
# G3Tggsj66W9X5eRy+dKckb5yaymai0LQmiZUKk+/IvQ8LvdJykAqVXKHHlD97SH4
|
||||
# mbL5vB3aM/jnar4zqxb7oCd96H+X21SnJosXImP/GQwi7u1q1TYA7rx1EnvRnnyB
|
||||
# 61O03yF9k5kEhEmuANfzqpaKNRj+QjR1oYfpfou3lfrdoox/Y1JYfOFPvV3w4IU2
|
||||
# LCAyp+IszIYhhvS/+ZvaagjS5cxkWmSb7KU4M1Vq0I67YVMsG6wzZM9Aj4jpdSHy
|
||||
# OZIY6JYE3DnnNYcUAeOL/e3WPyTpN6cLcdMmXVB1cZACteVKIxUopOnyjQMamhT+
|
||||
# kgEK5k3higM6Enz3RNIeVN7MQMd4IPiXmAIuJoRDDzsGt1I/9DarFKxUysk3HXbf
|
||||
# cxLdYH5hF24L6tcnOtT6gZFXBIOnS8qCej+aC61mFbdeDo8dkCVbeeEDieqMdwaf
|
||||
# zqmGTlNwHrdRROdj9EyB+QFoQK1Te+j18ry+NV7TJqjmOhtrKkEFjArU9sYizvO6
|
||||
# Bkljz8n+/bXERGfx//r3fe3+2hywEdLa8N35yR33EWT1OckqmDlwjAX2tkjEPvtg
|
||||
# rbuqMkVRQ6ORg/VH9bDLKszPWBGrkqtyDaKcIFmcY6pUXlgAaPyHsSf+ty3f
|
||||
# SIG # End signature block
|
||||
77
WindowsPowershell/Modules/PowerBoots/ContentProperties.ps1
Normal file
77
WindowsPowershell/Modules/PowerBoots/ContentProperties.ps1
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
$Script:BootsContentProperties = 'Content','Child','Children','Items','Blocks','Inlines','GradientStops','Source','DataPoints', 'Series'
|
||||
function Get-BootsContentProperty {
|
||||
$Script:BootsContentProperties
|
||||
}
|
||||
function Add-BootsContentProperty {
|
||||
PARAM([string[]]$PropertyNames, [switch]$Passthru)
|
||||
$Script:BootsContentProperties = $Script:BootsContentProperties + $PropertyNames | ForEach { [regex]::Escape($_) } | Sort -Unique
|
||||
if($Passthru) {
|
||||
$Script:BootsContentProperties
|
||||
}
|
||||
}
|
||||
function Remove-BootsContentProperty {
|
||||
PARAM([string[]]$PropertyNames)
|
||||
$Script:BootsContentProperties = $Script:BootsContentProperties | Where { $PropertyNames -notcontains $_ }
|
||||
}
|
||||
|
||||
# SIG # Begin signature block
|
||||
# MIILCQYJKoZIhvcNAQcCoIIK+jCCCvYCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
|
||||
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
|
||||
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU6r4WJ2j97nxplwOlpE+H4Jam
|
||||
# 5eugggbgMIIG3DCCBMSgAwIBAgIJALPpqDj9wp7xMA0GCSqGSIb3DQEBBQUAMIHj
|
||||
# MQswCQYDVQQGEwJVUzERMA8GA1UECBMITmV3IFlvcmsxEjAQBgNVBAcTCVJvY2hl
|
||||
# c3RlcjEhMB8GA1UEChMYaHR0cDovL0h1ZGRsZWRNYXNzZXMub3JnMSgwJgYDVQQL
|
||||
# Ex9TY3JpcHRpbmcgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MTcwNQYDVQQDEy5odHRw
|
||||
# Oi8vSHVkZGxlZE1hc3Nlcy5vcmcgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MScwJQYJ
|
||||
# KoZIhvcNAQkBFhhKYXlrdWxASHVkZGxlZE1hc3Nlcy5vcmcwHhcNMDkwMzE1MTkx
|
||||
# OTE5WhcNMTAwMzE1MTkxOTE5WjCBqzELMAkGA1UEBhMCVVMxETAPBgNVBAgTCE5l
|
||||
# dyBZb3JrMRIwEAYDVQQHEwlSb2NoZXN0ZXIxITAfBgNVBAoTGGh0dHA6Ly9IdWRk
|
||||
# bGVkTWFzc2VzLm9yZzESMBAGA1UECxMJU2NyaXB0aW5nMRUwEwYDVQQDEwxKb2Vs
|
||||
# IEJlbm5ldHQxJzAlBgkqhkiG9w0BCQEWGEpheWt1bEBIdWRkbGVkTWFzc2VzLm9y
|
||||
# ZzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAPfqxOG9TQN+qZjZ6KfM
|
||||
# +zBK0YpjeyPL/cFgiGBhiIdYWTBtkbZydFr3IiERKRsUJ0/SKFbhf0C3Bvd/neTJ
|
||||
# qiZjH4D6xkrfdLlWMmmSXXqjSt48jZp+zfCAIaF8K84e9//7lMicdVFE6VcgoATZ
|
||||
# /eMKQky4JvphJpzDHYPLxLJQrKd0pjDDwspjdX5RedWkzeZBG7VfBnebLWUzgnMX
|
||||
# IxRQKfFCMryQDP8weceOnJjfJEf2FYmdpsEg5EKKKbuHsQCMVTxfteKdPvh1oh05
|
||||
# 1GWyPsvEPh4auJUT8pAVvrdxq+/O9KW/UV01UxjRYM1vdklNw8g7mkJTrrHjSjl7
|
||||
# tuugCnJjt5kN6v/OaUtRRMR68O85bSTVGOxJGCHUKlyuuTx9tnfIgy4siFYX1Ve8
|
||||
# xwaAdN3haTon3UkWzncHOq3reCIVF0luwRZu7u+TnOAnz2BRlt+rcT0O73GN20Fx
|
||||
# gyN2f5VGBbw1KuS7T8XZ0TFCspUdgwAcmTGuEVJKGhVcGAvNlLx+KPc5dba4qEfs
|
||||
# VZ0MssC2rALC1z61qWuucb5psHYhuD2tw1SrztywuxihIirZD+1+yKE4LsjkM1zG
|
||||
# fQwDO/DQJwkdByjfB2I64p6mk36OlZAFxVfRBpXSCzdzbgKpuPsbtjkb5lGvKjE1
|
||||
# JFVls1SHLJ9q80jHz6yW7juBAgMBAAGjgcgwgcUwHQYDVR0OBBYEFO0wLZyg+qGH
|
||||
# Z4WO8ucEGNIdU1T9MB8GA1UdIwQYMBaAFN2N42ZweJLF1mz0j70TMxePMcUHMAkG
|
||||
# A1UdEwQCMAAwEQYJYIZIAYb4QgEBBAQDAgTwMCoGA1UdJQEB/wQgMB4GCCsGAQUF
|
||||
# BwMBBggrBgEFBQcDAgYIKwYBBQUHAwMwCwYDVR0PBAQDAgTwMCwGCWCGSAGG+EIB
|
||||
# DQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTANBgkqhkiG9w0BAQUF
|
||||
# AAOCAgEAmKihxd6KYamLG0YLvs/unUTVJ+NW3jZP16R28PpmidY/kaBFOPhYyMl2
|
||||
# bBGQABe7LA5rpHFAs0F56gYETNoFk0qREVvaoz9u18VfLb0Uwqtnq0P68L4c7p2q
|
||||
# V3nKmWjeI6H7BAyFuogxmMH5TGDfiqrrVSuh1LtPbkV2Wtto0SAxP0Ndyts2J8Ha
|
||||
# vu/2rt0Ic5AkyD+RblFPtzkCC/MLVwSNAiDSKGRPRrLaiGxntEzR59GRyf2vwhGg
|
||||
# oAXUqcJ/CVeHCP6qdSTM39Ut3RmMZHXz5qY8bvLgNYL6MtcJAx+EeUhW497alzm1
|
||||
# jInXdbikIh0d/peTSDyLbjS8CPFFtS6Z56TDGMf+ouTpEA16otcWIPA8Zfjq+7n7
|
||||
# iBHjeuy7ONoJ2VDNgqn9B+ft8UWRwnJbyB85T83OAGf4vyhCPz3Kg8kWxY30Bhnp
|
||||
# Fayc6zQKCpn5o5T0/a0BBHwAyMfr7Lhav+61GpzzG1KfAw58N2GV8KCPKNEd3Zdz
|
||||
# y07aJadroVkW5R+35mSafKRJp5pz20GDRwZQllqGH1Y/UJFEiI0Bme9ecbl2vzNp
|
||||
# JjHyl/jLVzNVrBI5Zwb0lCLsykApgNY0yrwEqaiqwcxq5nkXFDhDPQvbdulihSo0
|
||||
# u33fJreCm2fFyGbTuvR61goSksAvLQhvijLAzcKqWKG+laOtYpAxggOTMIIDjwIB
|
||||
# ATCB8TCB4zELMAkGA1UEBhMCVVMxETAPBgNVBAgTCE5ldyBZb3JrMRIwEAYDVQQH
|
||||
# EwlSb2NoZXN0ZXIxITAfBgNVBAoTGGh0dHA6Ly9IdWRkbGVkTWFzc2VzLm9yZzEo
|
||||
# MCYGA1UECxMfU2NyaXB0aW5nIENlcnRpZmljYXRlIEF1dGhvcml0eTE3MDUGA1UE
|
||||
# AxMuaHR0cDovL0h1ZGRsZWRNYXNzZXMub3JnIENlcnRpZmljYXRlIEF1dGhvcml0
|
||||
# eTEnMCUGCSqGSIb3DQEJARYYSmF5a3VsQEh1ZGRsZWRNYXNzZXMub3JnAgkAs+mo
|
||||
# OP3CnvEwCQYFKw4DAhoFAKB4MBgGCisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJ
|
||||
# KoZIhvcNAQkDMQwGCisGAQQBgjcCAQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQB
|
||||
# gjcCARUwIwYJKoZIhvcNAQkEMRYEFNJA//hV/6LH9cEd897GrABXIXehMA0GCSqG
|
||||
# SIb3DQEBAQUABIICAEyNO6oC3/hY1kZouV0j8G6UHkCEaYmHLRtsGwf+Zi2GHFBH
|
||||
# 63hoXTHT5IsdIZI0vk3MoQCUE2YZEMjTpl7MAr9O5nxi2PSrMpCg/+9WFSW/XDAP
|
||||
# WHTvX15MTjGA5egmiyNdP3iHGTbwcd0t0CHRTd2bAfmGXMPwmCJ+zAxH6cBVzJq5
|
||||
# Of1oqsZlpaHDlaBa56kFWnQa7q3d5KyM3isRODwjEIlryhma4xYsdWcHdA4KItMy
|
||||
# gSzJPyq8+ThLvAYwiRTAiilLpo6Z8Ot4kJjW+JjkwbMu/6yJCdqOpCCqqZY+tYDd
|
||||
# +iqO7x/7Q1j4WCAChpOnSBo+UB4Oe106HmXttdfngTcLVMozibDPmO9at38HR2WM
|
||||
# IE0AkaTYY/sfEKSLQvX3t0LXfvtISqH0yGq4p6ATa52y1eSnC18Y+GCRLEhIDehJ
|
||||
# tKcjTrC4LJVhplf9Ibot+ZfPFyEj3+cdCopP2Rg6I8SxZ/bfwpRVH55r3PD73Yfv
|
||||
# 3BmySRu9Eo/egbNSU58KVuoYR+IW7rdOBlKYyRu585l2fxOSKc7p83Wp/mHr8+Zn
|
||||
# HrdV9HRF3nSIKtdIgK2o31o4E0o3KbUapcWCUWuKalFVmFW8KfzUPoJvxzRKfqda
|
||||
# nfFSimQsl6FG6pbNq6SYCMKqckT8ieaPQSky3Jqy45eE3xyJyrdMQUxohHk5
|
||||
# SIG # End signature block
|
||||
BIN
WindowsPowershell/Modules/PowerBoots/DependencyProperties.clixml
Normal file
BIN
WindowsPowershell/Modules/PowerBoots/DependencyProperties.clixml
Normal file
Binary file not shown.
|
|
@ -0,0 +1,271 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AddExtension
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$CheckFileExists
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$CheckPathExists
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DefaultExt
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$DereferenceLinks
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FileName
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FileNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Filter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FilterIndex
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InitialDirectory
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Multiselect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ReadOnlyChecked
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$RestoreDirectory
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$SafeFileNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ShowReadOnly
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Title
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ValidateNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FileOk
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "OpenFileDialog not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "OpenFileDialog in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-Microsoft.Win32.OpenFileDialog {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new OpenFileDialog object
|
||||
.Description
|
||||
Generates a new Microsoft.Win32.OpenFileDialog object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:51
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AddExtension
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$CheckFileExists
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$CheckPathExists
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DefaultExt
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$DereferenceLinks
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FileName
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FileNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Filter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FilterIndex
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InitialDirectory
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Multiselect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ReadOnlyChecked
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$RestoreDirectory
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$SafeFileNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ShowReadOnly
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Title
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ValidateNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FileOk
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object Microsoft.Win32.OpenFileDialog
|
||||
$All = Get-Parameter New-Microsoft.Win32.OpenFileDialog | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of Microsoft.Win32.OpenFileDialog is not a collection
|
||||
# So if we're in a pipeline, make a new OpenFileDialog each time
|
||||
if($_) {
|
||||
$DObject = New-Object Microsoft.Win32.OpenFileDialog
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-Microsoft.Win32.OpenFileDialog @PSBoundParameters
|
||||
|
|
@ -0,0 +1,265 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AddExtension
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$CheckFileExists
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$CheckPathExists
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$CreatePrompt
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DefaultExt
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$DereferenceLinks
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FileName
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FileNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Filter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FilterIndex
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InitialDirectory
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverwritePrompt
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$RestoreDirectory
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$SafeFileNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Title
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ValidateNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FileOk
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "SaveFileDialog not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "SaveFileDialog in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-Microsoft.Win32.SaveFileDialog {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new SaveFileDialog object
|
||||
.Description
|
||||
Generates a new Microsoft.Win32.SaveFileDialog object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:51
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AddExtension
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$CheckFileExists
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$CheckPathExists
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$CreatePrompt
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DefaultExt
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$DereferenceLinks
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FileName
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FileNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Filter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FilterIndex
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InitialDirectory
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverwritePrompt
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$RestoreDirectory
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$SafeFileNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Title
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ValidateNames
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FileOk
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object Microsoft.Win32.SaveFileDialog
|
||||
$All = Get-Parameter New-Microsoft.Win32.SaveFileDialog | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of Microsoft.Win32.SaveFileDialog is not a collection
|
||||
# So if we're in a pipeline, make a new SaveFileDialog each time
|
||||
if($_) {
|
||||
$DObject = New-Object Microsoft.Win32.SaveFileDialog
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-Microsoft.Win32.SaveFileDialog @PSBoundParameters
|
||||
|
|
@ -0,0 +1,193 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Anchors
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Authors
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cargos
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_AuthorChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_AnchorChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_CargoChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "Annotation not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "Annotation in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Annotations.Annotation {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new Annotation object
|
||||
.Description
|
||||
Generates a new System.Windows.Annotations.Annotation object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:51
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Anchors
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Authors
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cargos
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_AuthorChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_AnchorChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_CargoChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Annotations.Annotation
|
||||
$All = Get-Parameter New-System.Windows.Annotations.Annotation | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Annotations.Annotation is not a collection
|
||||
# So if we're in a pipeline, make a new Annotation each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Annotations.Annotation
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Annotations.Annotation @PSBoundParameters
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContentLocators
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Contents
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "AnnotationResource not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "AnnotationResource in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Annotations.AnnotationResource {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new AnnotationResource object
|
||||
.Description
|
||||
Generates a new System.Windows.Annotations.AnnotationResource object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:51
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContentLocators
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Contents
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Annotations.AnnotationResource
|
||||
$All = Get-Parameter New-System.Windows.Annotations.AnnotationResource | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Annotations.AnnotationResource is not a collection
|
||||
# So if we're in a pipeline, make a new AnnotationResource each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Annotations.AnnotationResource
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Annotations.AnnotationResource @PSBoundParameters
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Parts
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "ContentLocator not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "ContentLocator in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Annotations.ContentLocator {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new ContentLocator object
|
||||
.Description
|
||||
Generates a new System.Windows.Annotations.ContentLocator object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:51
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Parts
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Annotations.ContentLocator
|
||||
$All = Get-Parameter New-System.Windows.Annotations.ContentLocator | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Annotations.ContentLocator is not a collection
|
||||
# So if we're in a pipeline, make a new ContentLocator each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Annotations.ContentLocator
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Annotations.ContentLocator @PSBoundParameters
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Locators
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "ContentLocatorGroup not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "ContentLocatorGroup in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Annotations.ContentLocatorGroup {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new ContentLocatorGroup object
|
||||
.Description
|
||||
Generates a new System.Windows.Annotations.ContentLocatorGroup object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:51
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Locators
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Annotations.ContentLocatorGroup
|
||||
$All = Get-Parameter New-System.Windows.Annotations.ContentLocatorGroup | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Annotations.ContentLocatorGroup is not a collection
|
||||
# So if we're in a pipeline, make a new ContentLocatorGroup each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Annotations.ContentLocatorGroup
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Annotations.ContentLocatorGroup @PSBoundParameters
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IncludeDescendants
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "AttachedPropertyBrowsableForChildrenAttribute not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "AttachedPropertyBrowsableForChildrenAttribute in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.AttachedPropertyBrowsableForChildrenAttribute {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new AttachedPropertyBrowsableForChildrenAttribute object
|
||||
.Description
|
||||
Generates a new System.Windows.AttachedPropertyBrowsableForChildrenAttribute object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:59
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IncludeDescendants
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.AttachedPropertyBrowsableForChildrenAttribute
|
||||
$All = Get-Parameter New-System.Windows.AttachedPropertyBrowsableForChildrenAttribute | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.AttachedPropertyBrowsableForChildrenAttribute is not a collection
|
||||
# So if we're in a pipeline, make a new AttachedPropertyBrowsableForChildrenAttribute each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.AttachedPropertyBrowsableForChildrenAttribute
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.AttachedPropertyBrowsableForChildrenAttribute @PSBoundParameters
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "ColorConvertedBitmapExtension not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "ColorConvertedBitmapExtension in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.ColorConvertedBitmapExtension {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new ColorConvertedBitmapExtension object
|
||||
.Description
|
||||
Generates a new System.Windows.ColorConvertedBitmapExtension object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:59
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.ColorConvertedBitmapExtension
|
||||
$All = Get-Parameter New-System.Windows.ColorConvertedBitmapExtension | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.ColorConvertedBitmapExtension is not a collection
|
||||
# So if we're in a pipeline, make a new ColorConvertedBitmapExtension each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.ColorConvertedBitmapExtension
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.ColorConvertedBitmapExtension @PSBoundParameters
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ResourceId
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$TypeInTargetAssembly
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "ComponentResourceKey not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "ComponentResourceKey in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.ComponentResourceKey {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new ComponentResourceKey object
|
||||
.Description
|
||||
Generates a new System.Windows.ComponentResourceKey object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:25:00
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ResourceId
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$TypeInTargetAssembly
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.ComponentResourceKey
|
||||
$All = Get-Parameter New-System.Windows.ComponentResourceKey | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.ComponentResourceKey is not a collection
|
||||
# So if we're in a pipeline, make a new ComponentResourceKey each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.ComponentResourceKey
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.ComponentResourceKey @PSBoundParameters
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Binding
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Property
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$SourceName
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Value
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "Condition not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "Condition in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Condition {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new Condition object
|
||||
.Description
|
||||
Generates a new System.Windows.Condition object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:25:00
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Binding
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Property
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$SourceName
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Value
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Condition
|
||||
$All = Get-Parameter New-System.Windows.Condition | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Condition is not a collection
|
||||
# So if we're in a pipeline, make a new Condition each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Condition
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Condition @PSBoundParameters
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Item
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "ConditionCollection not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "ConditionCollection in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.ConditionCollection {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new ConditionCollection object
|
||||
.Description
|
||||
Generates a new System.Windows.ConditionCollection object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:25:00
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Item
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.ConditionCollection
|
||||
$All = Get-Parameter New-System.Windows.ConditionCollection | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.ConditionCollection is not a collection
|
||||
# So if we're in a pipeline, make a new ConditionCollection each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.ConditionCollection
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.ConditionCollection @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,985 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Child
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "AdornedElementPlaceholder not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "AdornedElementPlaceholder in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.AdornedElementPlaceholder {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new AdornedElementPlaceholder object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.AdornedElementPlaceholder object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:52
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Child
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.AdornedElementPlaceholder
|
||||
$All = Get-Parameter New-System.Windows.Controls.AdornedElementPlaceholder | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.AdornedElementPlaceholder is not a collection
|
||||
# So if we're in a pipeline, make a new AdornedElementPlaceholder each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.AdornedElementPlaceholder
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.AdornedElementPlaceholder @PSBoundParameters
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "AlternationConverter not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "AlternationConverter in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.AlternationConverter {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new AlternationConverter object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.AlternationConverter object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:52
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.AlternationConverter
|
||||
$All = Get-Parameter New-System.Windows.Controls.AlternationConverter | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.AlternationConverter is not a collection
|
||||
# So if we're in a pipeline, make a new AlternationConverter each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.AlternationConverter
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.AlternationConverter @PSBoundParameters
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "BooleanToVisibilityConverter not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "BooleanToVisibilityConverter in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.BooleanToVisibilityConverter {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new BooleanToVisibilityConverter object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.BooleanToVisibilityConverter object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:52
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.BooleanToVisibilityConverter
|
||||
$All = Get-Parameter New-System.Windows.Controls.BooleanToVisibilityConverter | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.BooleanToVisibilityConverter is not a collection
|
||||
# So if we're in a pipeline, make a new BooleanToVisibilityConverter each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.BooleanToVisibilityConverter
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.BooleanToVisibilityConverter @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,161 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "BorderGapMaskConverter not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "BorderGapMaskConverter in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.BorderGapMaskConverter {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new BorderGapMaskConverter object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.BorderGapMaskConverter object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:52
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.BorderGapMaskConverter
|
||||
$All = Get-Parameter New-System.Windows.Controls.BorderGapMaskConverter | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.BorderGapMaskConverter is not a collection
|
||||
# So if we're in a pipeline, make a new BorderGapMaskConverter each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.BorderGapMaskConverter
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.BorderGapMaskConverter @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,992 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Background
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Children
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsItemsHost
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "Canvas not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "Canvas in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.Canvas {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new Canvas object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.Canvas object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:52
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Background
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Children
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsItemsHost
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.Canvas
|
||||
$All = Get-Parameter New-System.Windows.Controls.Canvas | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
} #Process
|
||||
END {
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
}
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.Canvas @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,817 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$SharedSizeGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "ColumnDefinition not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "ColumnDefinition in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.ColumnDefinition {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new ColumnDefinition object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.ColumnDefinition object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:52
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$SharedSizeGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.ColumnDefinition
|
||||
$All = Get-Parameter New-System.Windows.Controls.ColumnDefinition | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.ColumnDefinition is not a collection
|
||||
# So if we're in a pipeline, make a new ColumnDefinition each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.ColumnDefinition
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.ColumnDefinition @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,181 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$TargetType
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VisualTree
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "ControlTemplate not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "ControlTemplate in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.ControlTemplate {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new ControlTemplate object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.ControlTemplate object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:53
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$TargetType
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VisualTree
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.ControlTemplate
|
||||
$All = Get-Parameter New-System.Windows.Controls.ControlTemplate | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.ControlTemplate is not a collection
|
||||
# So if we're in a pipeline, make a new ControlTemplate each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.ControlTemplate
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.ControlTemplate @PSBoundParameters
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ValidatesOnTargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ValidationStep
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "DataErrorValidationRule not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "DataErrorValidationRule in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.DataErrorValidationRule {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new DataErrorValidationRule object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.DataErrorValidationRule object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:53
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ValidatesOnTargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ValidationStep
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.DataErrorValidationRule
|
||||
$All = Get-Parameter New-System.Windows.Controls.DataErrorValidationRule | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.DataErrorValidationRule is not a collection
|
||||
# So if we're in a pipeline, make a new DataErrorValidationRule each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.DataErrorValidationRule
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.DataErrorValidationRule @PSBoundParameters
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "DataTemplateSelector not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "DataTemplateSelector in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.DataTemplateSelector {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new DataTemplateSelector object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.DataTemplateSelector object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:53
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.DataTemplateSelector
|
||||
$All = Get-Parameter New-System.Windows.Controls.DataTemplateSelector | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.DataTemplateSelector is not a collection
|
||||
# So if we're in a pipeline, make a new DataTemplateSelector each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.DataTemplateSelector
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.DataTemplateSelector @PSBoundParameters
|
||||
|
|
@ -0,0 +1,985 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Child
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "Decorator not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "Decorator in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.Decorator {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new Decorator object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.Decorator object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:53
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Child
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.Decorator
|
||||
$All = Get-Parameter New-System.Windows.Controls.Decorator | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.Decorator is not a collection
|
||||
# So if we're in a pipeline, make a new Decorator each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.Decorator
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.Decorator @PSBoundParameters
|
||||
|
|
@ -0,0 +1,998 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Background
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Children
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsItemsHost
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$LastChildFill
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "DockPanel not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "DockPanel in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.DockPanel {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new DockPanel object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.DockPanel object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:53
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Background
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Children
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsItemsHost
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$LastChildFill
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.DockPanel
|
||||
$All = Get-Parameter New-System.Windows.Controls.DockPanel | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
} #Process
|
||||
END {
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
}
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.DockPanel @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,169 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ValidatesOnTargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ValidationStep
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "ExceptionValidationRule not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "ExceptionValidationRule in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.ExceptionValidationRule {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new ExceptionValidationRule object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.ExceptionValidationRule object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:53
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ValidatesOnTargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ValidationStep
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.ExceptionValidationRule
|
||||
$All = Get-Parameter New-System.Windows.Controls.ExceptionValidationRule | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.ExceptionValidationRule is not a collection
|
||||
# So if we're in a pipeline, make a new ExceptionValidationRule each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.ExceptionValidationRule
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.ExceptionValidationRule @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,205 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowsColumnReorder
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderContainerStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderStringFormat
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderTemplate
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderTemplateSelector
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Columns
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "GridView not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "GridView in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.GridView {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new GridView object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.GridView object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:54
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowsColumnReorder
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderContainerStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderStringFormat
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderTemplate
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderTemplateSelector
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ColumnHeaderToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Columns
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.GridView
|
||||
$All = Get-Parameter New-System.Windows.Controls.GridView | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.GridView is not a collection
|
||||
# So if we're in a pipeline, make a new GridView each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.GridView
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.GridView @PSBoundParameters
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ActualWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CellTemplate
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CellTemplateSelector
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DisplayMemberBinding
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Header
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderContainerStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderStringFormat
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderTemplate
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderTemplateSelector
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "GridViewColumn not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "GridViewColumn in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.GridViewColumn {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new GridViewColumn object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.GridViewColumn object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:54
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ActualWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CellTemplate
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CellTemplateSelector
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DisplayMemberBinding
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Header
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderContainerStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderStringFormat
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderTemplate
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderTemplateSelector
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.GridViewColumn
|
||||
$All = Get-Parameter New-System.Windows.Controls.GridViewColumn | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.GridViewColumn is not a collection
|
||||
# So if we're in a pipeline, make a new GridViewColumn each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.GridViewColumn
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.GridViewColumn @PSBoundParameters
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Item
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_CollectionChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "GridViewColumnCollection not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "GridViewColumnCollection in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.GridViewColumnCollection {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new GridViewColumnCollection object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.GridViewColumnCollection object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:54
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Item
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_CollectionChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.GridViewColumnCollection
|
||||
$All = Get-Parameter New-System.Windows.Controls.GridViewColumnCollection | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.GridViewColumnCollection is not a collection
|
||||
# So if we're in a pipeline, make a new GridViewColumnCollection each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.GridViewColumnCollection
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.GridViewColumnCollection @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,991 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Columns
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Content
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "GridViewRowPresenter not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "GridViewRowPresenter in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.GridViewRowPresenter {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new GridViewRowPresenter object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.GridViewRowPresenter object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:54
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Columns
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Content
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.GridViewRowPresenter
|
||||
$All = Get-Parameter New-System.Windows.Controls.GridViewRowPresenter | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.GridViewRowPresenter is not a collection
|
||||
# So if we're in a pipeline, make a new GridViewRowPresenter each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.GridViewRowPresenter
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.GridViewRowPresenter @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,205 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$AlternationCount
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContainerStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContainerStyleSelector
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderStringFormat
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderTemplate
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderTemplateSelector
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$HidesIfEmpty
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Panel
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "GroupStyle not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "GroupStyle in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.GroupStyle {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new GroupStyle object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.GroupStyle object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:54
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$AlternationCount
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContainerStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContainerStyleSelector
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderStringFormat
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderTemplate
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HeaderTemplateSelector
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$HidesIfEmpty
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Panel
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.GroupStyle
|
||||
$All = Get-Parameter New-System.Windows.Controls.GroupStyle | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.GroupStyle is not a collection
|
||||
# So if we're in a pipeline, make a new GroupStyle each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.GroupStyle
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.GroupStyle @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,991 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Child
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Strokes
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "InkPresenter not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "InkPresenter in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.InkPresenter {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new InkPresenter object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.InkPresenter object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:54
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Child
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Strokes
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.InkPresenter
|
||||
$All = Get-Parameter New-System.Windows.Controls.InkPresenter | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.InkPresenter is not a collection
|
||||
# So if we're in a pipeline, make a new InkPresenter each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.InkPresenter
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.InkPresenter @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,169 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VisualTree
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "ItemsPanelTemplate not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "ItemsPanelTemplate in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.ItemsPanelTemplate {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new ItemsPanelTemplate object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.ItemsPanelTemplate object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:54
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VisualTree
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.ItemsPanelTemplate
|
||||
$All = Get-Parameter New-System.Windows.Controls.ItemsPanelTemplate | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.ItemsPanelTemplate is not a collection
|
||||
# So if we're in a pipeline, make a new ItemsPanelTemplate each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.ItemsPanelTemplate
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.ItemsPanelTemplate @PSBoundParameters
|
||||
|
|
@ -0,0 +1,979 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "ItemsPresenter not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "ItemsPresenter in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.ItemsPresenter {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new ItemsPresenter object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.ItemsPresenter object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:54
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.ItemsPresenter
|
||||
$All = Get-Parameter New-System.Windows.Controls.ItemsPresenter | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.ItemsPresenter is not a collection
|
||||
# So if we're in a pipeline, make a new ItemsPresenter each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.ItemsPresenter
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.ItemsPresenter @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,161 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "MenuScrollingVisibilityConverter not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "MenuScrollingVisibilityConverter in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.MenuScrollingVisibilityConverter {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new MenuScrollingVisibilityConverter object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.MenuScrollingVisibilityConverter object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:55
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.MenuScrollingVisibilityConverter
|
||||
$All = Get-Parameter New-System.Windows.Controls.MenuScrollingVisibilityConverter | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.MenuScrollingVisibilityConverter is not a collection
|
||||
# So if we're in a pipeline, make a new MenuScrollingVisibilityConverter each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.MenuScrollingVisibilityConverter
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.MenuScrollingVisibilityConverter @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,997 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Background
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Bullet
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Child
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "BulletDecorator not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "BulletDecorator in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.Primitives.BulletDecorator {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new BulletDecorator object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.Primitives.BulletDecorator object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:51
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Background
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Bullet
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Child
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.Primitives.BulletDecorator
|
||||
$All = Get-Parameter New-System.Windows.Controls.Primitives.BulletDecorator | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.Primitives.BulletDecorator is not a collection
|
||||
# So if we're in a pipeline, make a new BulletDecorator each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.Primitives.BulletDecorator
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.Primitives.BulletDecorator @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,992 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Background
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Children
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsItemsHost
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "TabPanel not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "TabPanel in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.Primitives.TabPanel {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new TabPanel object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.Primitives.TabPanel object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:52
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Background
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Children
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsItemsHost
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.Primitives.TabPanel
|
||||
$All = Get-Parameter New-System.Windows.Controls.Primitives.TabPanel | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
} #Process
|
||||
END {
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
}
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.Primitives.TabPanel @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,998 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Background
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Children
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsItemsHost
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$WrapWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "ToolBarOverflowPanel not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "ToolBarOverflowPanel in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.Primitives.ToolBarOverflowPanel {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new ToolBarOverflowPanel object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.Primitives.ToolBarOverflowPanel object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:52
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Background
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BitmapEffectInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Children
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Clip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ClipToBounds
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Effect
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FlowDirection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HorizontalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsHitTestVisible
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsItemsHost
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$LayoutTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Margin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Opacity
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$OpacityMask
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderSize
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransform
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$RenderTransformOrigin
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$SnapsToDevicePixels
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Triggers
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Uid
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$VerticalAlignment
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Visibility
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Width
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$WrapWidth
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_RequestBringIntoView
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SizeChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LayoutUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsHitTestVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsVisibleChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.Primitives.ToolBarOverflowPanel
|
||||
$All = Get-Parameter New-System.Windows.Controls.Primitives.ToolBarOverflowPanel | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
} #Process
|
||||
END {
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
}
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.Primitives.ToolBarOverflowPanel @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,199 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxPage
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinPage
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$PageRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$PageRangeSelection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$PrintQueue
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$PrintTicket
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$UserPageRangeEnabled
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "PrintDialog not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "PrintDialog in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.PrintDialog {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new PrintDialog object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.PrintDialog object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:55
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxPage
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinPage
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$PageRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$PageRangeSelection
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$PrintQueue
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$PrintTicket
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$UserPageRangeEnabled
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.PrintDialog
|
||||
$All = Get-Parameter New-System.Windows.Controls.PrintDialog | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.PrintDialog is not a collection
|
||||
# So if we're in a pipeline, make a new PrintDialog each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.PrintDialog
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.PrintDialog @PSBoundParameters
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HelpLink
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Source
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "PrintDialogException not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "PrintDialogException in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.PrintDialogException {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new PrintDialogException object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.PrintDialogException object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:55
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$HelpLink
|
||||
,
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Source
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.PrintDialogException
|
||||
$All = Get-Parameter New-System.Windows.Controls.PrintDialogException | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.PrintDialogException is not a collection
|
||||
# So if we're in a pipeline, make a new PrintDialogException each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.PrintDialogException
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.PrintDialogException @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,817 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$SharedSizeGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "RowDefinition not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "RowDefinition in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.RowDefinition {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new RowDefinition object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.RowDefinition object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:55
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$AllowDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$BindingGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$CommandBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ContextMenu
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Cursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$DataContext
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$Focusable
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$FocusVisualStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$ForceCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Height
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputBindings
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$InputScope
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$IsEnabled
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Language
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MaxHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$MinHeight
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Name
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Switch]$OverridesDefaultStyle
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Resources
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$SharedSizeGroup
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Style
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$Tag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[Object[]]$ToolTip
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TargetUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_SourceUpdated
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DataContextChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Initialized
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Loaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Unloaded
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ToolTipClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuOpening
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_ContextMenuClosing
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsEnabledChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_FocusableChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeftButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseRightButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewMouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseWheel
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_MouseLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostMouseCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryCursor
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInAirMove
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusInRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusOutOfRange
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusSystemGesture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostStylusCapture
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_StylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewStylusButtonUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyDown
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewKeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_KeyUp
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GotKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewLostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_LostKeyboardFocus
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewTextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_TextInput
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewQueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_QueryContinueDrag
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewGiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_GiveFeedback
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragEnter
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragOver
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_DragLeave
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_PreviewDrop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_Drop
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsMouseCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusDirectlyOverChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCapturedChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsStylusCaptureWithinChanged
|
||||
,
|
||||
[Parameter(ParameterSetName='Default')]
|
||||
[PSObject]$On_IsKeyboardFocusedChanged
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.RowDefinition
|
||||
$All = Get-Parameter New-System.Windows.Controls.RowDefinition | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.RowDefinition is not a collection
|
||||
# So if we're in a pipeline, make a new RowDefinition each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.RowDefinition
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.RowDefinition @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,163 @@
|
|||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Source
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
|
||||
## Preload the assembly if it's not already loaded
|
||||
|
||||
|
||||
if( [Array]::BinarySearch(@(Get-BootsAssemblies), 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ) -lt 0 ) {
|
||||
$null = [Reflection.Assembly]::Load( 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' )
|
||||
}
|
||||
if($ExecutionContext.SessionState.Module.Guid -ne (Get-BootsModule).Guid) {
|
||||
Write-Warning "SoundPlayerAction not invoked in PowerBoots context. Attempting to reinvoke."
|
||||
$scriptParam = $PSBoundParameters
|
||||
return iex "& (Get-BootsModule) '$($MyInvocation.MyCommand.Path)' `@PSBoundParameters"
|
||||
}
|
||||
# Write-Host "SoundPlayerAction in module $($executioncontext.sessionstate.module) context!" -fore Green
|
||||
|
||||
|
||||
function Global:New-System.Windows.Controls.SoundPlayerAction {
|
||||
<#
|
||||
.Synopsis
|
||||
Create a new SoundPlayerAction object
|
||||
.Description
|
||||
Generates a new System.Windows.Controls.SoundPlayerAction object, and allows setting all of it's properties
|
||||
.Notes
|
||||
AUTHOR: Joel Bennett http://HuddledMasses.org
|
||||
LASTEDIT: 07/23/2009 09:24:55
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
||||
PARAM(
|
||||
[Parameter(ParameterSetName='Default',Position=1,ValueFromPipeline=$true)]
|
||||
[Object[]]$Source
|
||||
,
|
||||
[Parameter(ValueFromRemainingArguments=$true)]
|
||||
[string[]]$DependencyProps
|
||||
)
|
||||
BEGIN {
|
||||
$DObject = New-Object System.Windows.Controls.SoundPlayerAction
|
||||
$All = Get-Parameter New-System.Windows.Controls.SoundPlayerAction | ForEach-Object { $_.Key } | Sort
|
||||
}
|
||||
PROCESS {
|
||||
|
||||
|
||||
# The content of System.Windows.Controls.SoundPlayerAction is not a collection
|
||||
# So if we're in a pipeline, make a new SoundPlayerAction each time
|
||||
if($_) {
|
||||
$DObject = New-Object System.Windows.Controls.SoundPlayerAction
|
||||
}
|
||||
|
||||
foreach ($param in $PSBoundParameters.GetEnumerator() | ? { [Array]::BinarySearch($All,$_.Key) -ge 0 }) {
|
||||
## TODO: HANDLE DEPENDENCY PROPERTIES
|
||||
if($param.Key -eq "DependencyProps") {
|
||||
## HANDLE EVENTS ....
|
||||
} elseif ($param.Key.StartsWith("On_"))
|
||||
{
|
||||
$EventName = "Add_" + $param.Key.SubString(3)
|
||||
$sb = $param.Value -as [ScriptBlock]
|
||||
if(!$sb) {
|
||||
$sb = (Get-Command $param.Value -CommandType Function,ExternalScript).ScriptBlock
|
||||
}
|
||||
Invoke-Expression "`$DObject.$EventName( {$($sb.GetNewClosure())} )"
|
||||
} ## HANDLE PROPERTIES ....
|
||||
else
|
||||
{
|
||||
try {
|
||||
## TODO: File a BUG because Write-DEBUG and Write-VERBOSE die here.
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
Write-Host "Setting $($param.Key) of $($DObject.GetType().Name) to $($param.Value)" -fore Yellow
|
||||
}
|
||||
if(@(foreach($sb in $param.Value) { $sb -is [ScriptBlock] }) -contains $true) {
|
||||
$Values = @()
|
||||
$bMod = Get-BootsModule
|
||||
foreach($sb in $param.Value) {
|
||||
$Values += & $bMod $sb
|
||||
}
|
||||
} else {
|
||||
$Values = $param.Value
|
||||
}
|
||||
|
||||
if ($DObject.$($param.Key) -is [System.Collections.IList]) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Parameter $($param.Name) is an IList" -fore Cyan}
|
||||
foreach ($value in @($Values)) {
|
||||
try {
|
||||
$null = $DObject.$($param.Key).Add($value)
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT array problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $value) )
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
## If they pass an array of 1 when we only want one, we just use the first value
|
||||
if($Values -is [System.Collections.IList] -and $Values.Count -eq 1) {
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is an IList" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values[0]
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT collection value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $Values[0]) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
else ## If they pass an array when we only want one, we try to use it, and failing that, cast it to strings
|
||||
{
|
||||
if($DebugPreference -ne "SilentlyContinue") { Write-Host "Value is a just $Values" -fore Cyan}
|
||||
try {
|
||||
$DObject.$($param.Key) = $Values
|
||||
} catch [Exception]
|
||||
{
|
||||
# Write-Host "CAUGHT value problem" -fore Red
|
||||
if($_.Exception.Message -match "Invalid cast from 'System.String' to 'System.Windows.UIElement'.") {
|
||||
$null = $DObject.$($param.Key).Add( (TextBlock $values) )
|
||||
}else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($DebugPreference -ne "SilentlyContinue") {
|
||||
if( $DObject.$($param.Key) -ne $null ) {
|
||||
Write-Host $DObject.$($param.Key).GetType().FullName -fore Green
|
||||
}
|
||||
}
|
||||
}
|
||||
catch [Exception]
|
||||
{
|
||||
Write-Host "COUGHT AN EXCEPTION" -fore Red
|
||||
Write-Host $_ -fore Red
|
||||
Write-Host $this -fore DarkRed
|
||||
}
|
||||
}
|
||||
|
||||
while($DependencyProps) {
|
||||
$name, $value, $DependencyProps = $DependencyProps
|
||||
$name = ([string]@($name)[0]).Trim("-")
|
||||
if($name -and $value) {
|
||||
Set-DependencyProperty -Element $DObject -Property $name -Value $Value
|
||||
}
|
||||
}
|
||||
}
|
||||
Microsoft.PowerShell.Utility\Write-Output $DObject
|
||||
} #Process
|
||||
}
|
||||
|
||||
New-System.Windows.Controls.SoundPlayerAction @PSBoundParameters
|
||||
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue