Powershell使用WPF技术实现弹窗提示实例

发布时间:2022-04-19 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Powershell使用WPF技术实现弹窗提示实例脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

WPF (Windows PResentation Foundation) 技能让你创建窗口和对话框。它的优势是在窗体设计时能与代码分开。

这里有个简单的显示弹出消息练习。这个消息是定义在XamL代码中它的实现类似HTML(但是请区分大小写)。你能轻松的调整字体大小,内容,颜色等等。不需要嵌入任何代码。

复制代码 代码如下:

$xaml = @"
<Window
&nbsp;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()

脚本宝典总结

以上是脚本宝典为你收集整理的Powershell使用WPF技术实现弹窗提示实例全部内容,希望文章能够帮你解决Powershell使用WPF技术实现弹窗提示实例所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:Powershell