WPF或Silverlight中的屏幕闪烁效果

WPF或Silverlight中的屏幕闪烁效果,第1张

概述我正在寻找一种方法来为我正在研究的全屏 WPF应用程序创建一个“看起来很酷”的效果 – 一种“屏幕闪烁”效果,可以在整个屏幕上激活或移动,从而发出闪亮的显示体验.我正在考虑创建一个带有突出显示渐变和透明背景的大矩形,可以在屏幕上进行动画制作.有任何想法如何在XAML中有效地完成这项工作? 我提出了一个看起来很不错的解决方案.我在Blend 2.0 SP1中编写的一些示例XAML如下所示: <Win 我正在寻找一种方法来为我正在研究的全屏 WPF应用程序创建一个“看起来很酷”的效果 – 一种“屏幕闪烁”效果,可以在整个屏幕上激活或移动,从而发出闪亮的显示体验.我正在考虑创建一个带有突出显示渐变和透明背景的大矩形,可以在屏幕上进行动画制作.有任何想法如何在XAML中有效地完成这项工作?解决方法 我提出了一个看起来很不错的解决方案.我在Blend 2.0 SP1中编写的一些示例XAML如下所示:

<Window    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    x:Class="ScreenGlintApplication.Window1"    x:name="Window"    title="Window1"    WIDth="500" Height="250" Background="#FF000000" Foreground="#FF3EE229" >    <GrID x:name="LayoutRoot">        <TextBlock textwrapPing="Wrap" FontSize="40" >        <Run Text="This is some sample text to have something to work with. Have a nice day! /Johan"/>        </TextBlock>        <Canvas Panel.ZIndex="99" >        <Rectangle x:name="ScreenGlintrect"              WIDth="{Binding Path=ActualWIDth,Elementname=Window,Mode=Default}"             Height="{Binding Path=ActualHeight,Mode=Default}"             Opacity="0.4" >            <Rectangle.Triggers>                 <EventTrigger RoutedEvent="Rectangle.Loaded">                   <BeginStoryboard>                     <Storyboard>                     <DoubleAnimation Storyboard.Targetname="ScreenGlintrect"                     Storyboard.TargetProperty="(Canvas.left)"                    From="-500" To="1000" Duration="0:0:2" />                    </Storyboard>                   </BeginStoryboard>                 </EventTrigger>           </Rectangle.Triggers>             <Rectangle.Fill>                <linearGradIEntBrush StartPoint="0,1" EndPoint="1,1">                    <GradIEntStop color="transparent" Offset="0.0" />                    <GradIEntStop x:name="Glintcolor" color="lightGreen" Offset="0.50" />                    <GradIEntStop color="transparent" Offset="1" />                </linearGradIEntBrush>            </Rectangle.Fill>        </Rectangle>        </Canvas>    </GrID></Window>

一个选项是在后面的代码中执行此 *** 作,如果您想要对动画进行精细控制,这非常简洁.例如:

ScreenGlintrect.WIDth = WIDth;    ScreenGlintrect.Height = Height;    var animation = new DoubleAnimation    {        Duration = new Duration(TimeSpan.FromSeconds(2)),From = (-WIDth),To = WIDth * 2    };    ScreenGlintrect.BeginAnimation(Canvas.leftProperty,animation);

这是我正在使用的代码,它对我来说看起来不错.如果你有硬件加速,你可以尝试添加一些模糊.您可能需要调整代码并隐藏/显示矩形,但基本上就是这样.

总结

以上是内存溢出为你收集整理的WPF或Silverlight中的屏幕闪烁效果全部内容,希望文章能够帮你解决WPF或Silverlight中的屏幕闪烁效果所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1005466.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存