国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PowerShell > 正文

PowerShell中調用WPF生成炫酷窗口實例

2020-10-29 20:58:43
字體:
來源:轉載
供稿:網友

怎樣在PowerShell中調用WPF,你知道,我也知道;怎樣在PowerShell中將很長的.NET類型名稱縮短成別名,你知道,我也知道。但是怎樣將這兩個知識點融匯貫通,寫出一個優雅的DEMO,并且讓你一眼就能看出,這就是WPF,不是別的,也許你以前就知道,而我直到今天才知道,有種相見恨晚的感覺。

先看一下炫酷的效果吧!

PowerShell之WPF炫酷

# 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]@{    Drawing = [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'    Endpoint = '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 = 800  Height = 400  WindowStyle = 'None'  AllowsTransparency = $true  Effect = [DropShadowEffect]@{    BlurRadius = 10  }  TopMost = $true  Content = & {    $Stos = [StackPanel]@{      VerticalAlignment = 'Center'      HorizontalAlignment = 'Center'    }     $Stos.AddChild(      [Label]@{        Content = 'PowerShell Rocks!'        FontSize = 80        FontFamily = 'Consolas'        Foreground = 'White'        Effect = [DropShadowEffect]@{          BlurRadius = 5        }      }    )    , $Stos  }} | ForEach-Object {  $_.Add_MouseLeftButtonDown({    $this.DragMove()  })  $_.Add_MouseRightButtonDown({    $this.Close()  })  $_.ShowDialog() | Out-Null}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柘荣县| 南木林县| 昌都县| 民县| 阿勒泰市| 长海县| 望江县| 瓮安县| 泾源县| 武安市| 布尔津县| 永新县| 榆社县| 河东区| 嘉鱼县| 烟台市| 泾源县| 赤城县| 大荔县| 南汇区| 上虞市| 汉沽区| 通道| 武城县| 鹤山市| 普洱| 灵丘县| 开平市| 卓尼县| 炉霍县| 蒲城县| 巢湖市| 武强县| 同德县| 西乌| 西林县| 醴陵市| 重庆市| 汾西县| 会理县| 双鸭山市|