Powershell使用WPF技術(shù)實(shí)現(xiàn)彈窗提示實(shí)例
WPF (Windows Presentation Foundation) 技術(shù)能讓你創(chuàng)建窗口和對(duì)話框。它的優(yōu)勢(shì)是在窗體設(shè)計(jì)時(shí)能與代碼分開。
這里有個(gè)簡(jiǎn)單的顯示彈出消息練習(xí)。這個(gè)消息是定義在XAML代碼中它的實(shí)現(xiàn)類似HTML(但是請(qǐng)區(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中使用GetType獲取變量數(shù)據(jù)類型
這篇文章主要介紹了PowerShell中使用GetType獲取變量數(shù)據(jù)類型,本文使用實(shí)例來說明GetType的使用方法,并對(duì)返回值作了一定的解釋,需要的朋友可以參考下2014-08-08
PowerShell中查找字符串位置的IndexOf函數(shù)使用實(shí)例
這篇文章主要介紹了PowerShell中查找字符串位置的IndexOf函數(shù)使用實(shí)例,例子簡(jiǎn)單明了,容易看懂,需要的朋友可以參考下2014-08-08
Powershell小技巧之系統(tǒng)運(yùn)行時(shí)間
本文主要教你如何使用powershell計(jì)算系統(tǒng)運(yùn)行時(shí)間,其實(shí)很簡(jiǎn)單,因?yàn)閃indows每次啟動(dòng)都有一個(gè)高進(jìn)度計(jì)數(shù)器并且當(dāng)系統(tǒng)運(yùn)行這個(gè)計(jì)數(shù)器將返回一個(gè)毫秒,我們把這個(gè)毫秒計(jì)算下就得到系統(tǒng)運(yùn)行時(shí)間了2014-09-09
PowerShell定義函數(shù)參數(shù)的2種方法和傳參方法實(shí)例
這篇文章主要介紹了PowerShell定義函數(shù)參數(shù)的2種方法和使用方法實(shí)例,簡(jiǎn)潔易懂的好文,需要的朋友可以參考下2014-07-07
PowerShell腳本清理指定天數(shù)前的臨時(shí)文件夾實(shí)現(xiàn)代碼
這篇文章主要介紹了PowerShell腳本清理指定天數(shù)前的臨時(shí)文件夾實(shí)現(xiàn)代碼,指定天數(shù)可以任意修改數(shù)字實(shí)現(xiàn),需要的朋友可以參考下2014-08-08
PowerShell小技巧之獲取TCP響應(yīng)(類Telnet)
這篇文章主要介紹了使用PowerShell獲取TCP響應(yīng)(類Telnet)的小技巧,需要的朋友可以參考下2014-10-10
PowerShell腳本實(shí)現(xiàn)檢測(cè)網(wǎng)絡(luò)內(nèi)主機(jī)類型
這篇文章主要介紹了PowerShell腳本實(shí)現(xiàn)檢測(cè)網(wǎng)絡(luò)內(nèi)主機(jī)類型,本文腳本基本功能可以實(shí)現(xiàn)判斷主機(jī)操作系統(tǒng)類型,如果是域內(nèi)的主機(jī)可以獲取主機(jī)的硬件參數(shù)和性能參數(shù),并判斷是否存在網(wǎng)絡(luò)設(shè)備,需要的朋友可以參考下2014-12-12

