PowerShell to invoke WPF generate Cool window instance in the _powershell

Source: Internet
Author: User

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}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.