Powershell使用WPF技術(shù)實(shí)現(xiàn)彈窗提示實(shí)例
WPF (Windows Presentation Foundation) 技術(shù)能讓你創(chuàng)建窗口和對話框。它的優(yōu)勢是在窗體設(shè)計(jì)時(shí)能與代碼分開。
這里有個(gè)簡單的顯示彈出消息練習(xí)。這個(gè)消息是定義在XAML代碼中它的實(shí)現(xiàn)類似HTML(但是請區(qū)分大小寫)。你能輕松的調(diào)整字體大小,內(nèi)容,顏色等等。不需要嵌入任何代碼。
$xaml = @"
<Window
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'>
<Border BorderThickness="20" BorderBrush="Yellow" CornerRadius="9" Background='Red'>
<StackPanel>
<Label FontSize="50" FontFamily='Stencil' Background='Red' Foreground='White' BorderThickness='0'>
System will be rebooted in 15 minutes!
</Label>
<Label HorizontalAlignment="Center" FontSize="15" FontFamily='Consolas' Background='Red' Foreground='White' BorderThickness='0'>
Worried about losing data? Talk to your friendly help desk representative and freely share your concerns!
</Label>
</StackPanel>
</Border>
</Window>
"@
$reader = [System.XML.XMLReader]::Create([System.IO.StringReader] $xaml)
$window = [System.Windows.Markup.XAMLReader]::Load($reader)
$Window.AllowsTransparency = $True
$window.SizeToContent = 'WidthAndHeight'
$window.ResizeMode = 'NoResize'
$Window.Opacity = .7
$window.Topmost = $true
$window.WindowStartupLocation = 'CenterScreen'
$window.WindowStyle = 'None'
# show message for 5 seconds:
$null = $window.Show()
Start-Sleep -Seconds 5
$window.Close()
相關(guān)文章
PowerShell 讀取性能計(jì)數(shù)器二進(jìn)制文件(.blg)記錄并匯總計(jì)算
由于監(jiān)控及報(bào)告需要,要統(tǒng)計(jì)性能計(jì)數(shù)器每天數(shù)值情況,確認(rèn)數(shù)據(jù)庫服務(wù)器的運(yùn)行狀況。若打開計(jì)數(shù)器填寫,比較麻煩,現(xiàn)在統(tǒng)計(jì)用 powershell 來讀取計(jì)數(shù)器的值2016-11-11Windows Powershell對象轉(zhuǎn)換成文本
怎樣將Powershell的對象結(jié)果轉(zhuǎn)換成文本并顯示在控制臺(tái)上。Powershell已經(jīng)內(nèi)置Out-Default命令追加在管道的命令串的末尾。因此你使用dir 和dir | out-default的結(jié)果是相同的。2014-09-09PowerShell函數(shù)中使用$PSBoundParameters獲取輸入?yún)?shù)列表實(shí)例
這篇文章主要介紹了PowerShell函數(shù)中使用$PSBoundParameters獲取輸入?yún)?shù)列表實(shí)例,需要的朋友可以參考下2014-07-07Powershell使用嵌套哈希表實(shí)例 嵌套哈希表的2種寫法例子
這篇文章主要介紹了Powershell使用嵌套哈希表實(shí)例,嵌套哈希表的2種寫法例子,需要的朋友可以參考下2014-07-07PowerShell數(shù)組結(jié)合switch語句產(chǎn)生的奇特效果介紹
這篇文章主要介紹了PowerShell數(shù)組結(jié)合switch語句產(chǎn)生的奇特效果介紹,產(chǎn)生了類似枚舉的效果,需要的朋友可以參考下2014-08-08PowerShell入門教程之函數(shù)、腳本、作用域介紹
這篇文章主要介紹了PowerShell入門教程之函數(shù)、腳本、作用域介紹,本文所講內(nèi)容都是PowerShell的基礎(chǔ)知識(shí),需要的朋友可以參考下2014-10-10PowerShell中使用replace操作符替換字符串實(shí)例
這篇文章主要介紹了PowerShell中使用replace操作符與替換字符串實(shí)例,著重介紹了replace的語法,需要的朋友可以參考下2014-07-07