How to invoke WPF in PowerShell, you know, I also know how to shorten a long. NET type name to alias in PowerShell, you know, I know. But how to integrate the two knowledge points, write an elegant demo, and let you see at a glance, this is WPF, is not anything else, perhaps you know before, and I didn't know until today, there is a feeling of encounter.
Let's take a look at the cool effect!
PowerShell's WPF Cool
# PLIK:4_DEMO_V3_REFLECTION.PS1 #requires-version 3 $Akceleratory = [PsObject].
Assembly. GetType ("System.Management.Automation.TypeAccelerators") Add-type-assemblyname PresentationCore,
Presentationframework-passthru |
Where-object IsPublic | foreach-object {$Class = $_ try {$Akceleratory:: Add ($Class. Name, $Class)} catch {"Failed to Add $ ($Class. Name) accelerator pointing to $ ($Class. FullName) "}} [window]@{opacitymask = [drawingbrush]@{Dr awing = [drawinggroup]@{Children = & {$Kolekcja = New-object drawingcollection $Kolekcja. ADD (
geometrydrawing]@{Brush = ' black ' Geometry = [ellipsegeometry]@{RadiusX = 0.48
RadiusY = 0.48 Center = ' 0.5,0.5 '}} $Kolekcja. ADD ([geometrydrawing]@{
Brush = ' transparent ' Geometry = [rectanglegeometry]@{Rect = ' 0,0,1,1 '}}], $Kolekcja}} Background = [lineargradientbrush]@{Opacity = 0.5 startpoint = ' 0,0.5 ' Endpoi
NT = ' 1,0.5 ' GradientStops = & {$Stopki = new-object gradientstopcollection $Colors = ' Blue ', ' Green '
foreach ($i in 0..1) {$Stopki. ADD ([gradientstop]@{Color = $Colors [$i] Offset = $i})}, $Stopki} Width = Height = WindowStyle = ' None ' allowstransparency = $true Effect = [dropshadoweffect]@{Blurradius = ten} topmost = $true Content = & Amp {$Stos = [stackpanel]@{verticalalignment = ' center ' horizontalalignment = ' center '} $Stos. Add
Child ([label]@{Content = ' PowerShell rocks! ')
FontSize = FontFamily = ' Consolas ' foreground = ' white ' Effect = [dropshadoweffect]@{ Blurradius = 5}}), $Stos}} | Foreach-objeCT {$_. Add_mouseleftbuttondown ({$this. DragMove ()}) $_. Add_mouserightbuttondown ({$this. Close ()}) $_. ShowDialog () | Out-null}