原文:WPF用Blend写的交通信号灯

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yangyisen0713/article/details/18357035

用Blend写WPF界面和Behavior特别方便,下面是我写的一个交通信号灯,用Blend写完后代码直接Copy到wpf窗体就可以了。

1.打开Blend做一个矩形和三个圆形,然后分别填充颜色,把矩形的四角编程圆角;

2.添加时间动画并设置动画循环显示:

3.xaml代码如下:

<Window  x:Class="wpf红绿灯.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="106.879" Width="218.457">
<Window.Resources>
<Storyboard x:Key="Storyboard1" AutoReverse="True" RepeatBehavior="Forever">
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="ellipse1">
<EasingColorKeyFrame KeyTime="0:0:0.4" Value="sc#1, 0.004391442, 0.004024717, 0.004024717"/>
<EasingColorKeyFrame KeyTime="0:0:0.9" Value="#FFF9FF00"/>
<EasingColorKeyFrame KeyTime="0:0:1.5" Value="sc#1, 0.004391442, 0.004024717, 0.004024717"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="ellipse2">
<EasingColorKeyFrame KeyTime="0:0:0.4" Value="#FF1B1C1B"/>
<EasingColorKeyFrame KeyTime="0:0:0.9" Value="#FF0F0E0E"/>
<EasingColorKeyFrame KeyTime="0:0:2" Value="#FF1DFF00"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="ellipse">
<EasingColorKeyFrame KeyTime="0:0:0.9" Value="#FF0F0E0E"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
</EventTrigger>
</Window.Triggers>
<Grid x:Name="grid">
<Rectangle Fill="#FF0063FF" HorizontalAlignment="Left" Height="65" Margin="6,6,0,0" Stroke="Black" VerticalAlignment="Top" Width="202" RadiusY="13.394" RadiusX="13.394"/>
<Ellipse x:Name="ellipse" Fill="#FFFF0006" HorizontalAlignment="Left" Height="57" Margin="11,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="56"/>
<Ellipse x:Name="ellipse1" Fill="#FF070707" HorizontalAlignment="Left" Height="57" Margin="77,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="56"/>
<Ellipse x:Name="ellipse2" Fill="#FF101111" HorizontalAlignment="Left" Height="57" Margin="145,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="56"/> </Grid> </Window>

4.最后效果如图:

下面这个是竖着的效果图:

WPF用Blend写的交通信号灯的更多相关文章

  1. WPF-利用Blend写的平面控制闸门开关动画

    原文:WPF-利用Blend写的平面控制闸门开关动画 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/yangyisen0713/article/de ...

  2. 用Micro:bit做交通信号灯

    交通信号灯项目在控制技术中,有点像"Hello world!" 是一个入门级的范例. 对于孩子来说,交通灯跟日常生活息息相关,他们都熟悉,充分知道需要做什么这是一个让孩子开始的好项 ...

  3. 最新用WPF为触摸屏写了一个手写程序,双格输入的

    原文:最新用WPF为触摸屏写了一个手写程序,双格输入的 双格输入可以提高手写速度,当前字写完以后可以自动识别提交,写下一个字.这样比单格手写速度提高一倍.特别适合触摸屏程序使用 界面如下: 程序如下: ...

  4. 【FPGA】Verilog实现交通信号灯

    大二数字电路的课程设计中,有一份日常作业使用Xilinx FPGA实现简易交通信号灯,但很可惜当时时间有限,没能最终完成.正好在这一学期选修SOPC设计课程,同样采用了Xilinx FPGA,故打算重 ...

  5. n个并发进程共用一个公共变量Q,写出用信号灯实现n个进程互斥的程序描述,给出信号灯值得取值范围,并说明每个取值范围的物理意义。

    答: var mutex: semaphore:=1; begin cobegin process i : begin   // i = 1,2,……,n repeat P(mutex); 对公共变量 ...

  6. wpf 纯样式写按钮

    <!--自定义按钮样式--> <LinearGradientBrush x:Key="LinearGradientBlueBackground" EndPoint ...

  7. Redux教程1:环境搭建,初写Redux

    如果将React比喻成士兵的话,你的程序还需要一位将军,去管理士兵(的状态),而Redux恰好是一位好将军,简单高效: 相比起React的学习曲线,Redux的稍微平坦一些:本系列教程,将以" ...

  8. [Aaronyang]谈谈2015年AY对WPF全面技术总结40多篇WPF,炫到没朋友的AYUI来了

             原著:AY WPF博客- 把wpf推广出去,让那些鄙视的人说不 大家好! 我是AY,首先声明,我在做一件很枯燥的事情,我是个91后程序员,每天熬夜完成计划的过着下班后的生活. 那天有 ...

  9. [Aaronyang] 写给自己的WPF4.5 笔记19[Visual类图文并茂讲解]

    文章虽小,内容还好,且看且珍惜. aaronyang版权所有,不许转载,违者必究 当界面上使用数千个矢量图形,例如实时统计图,粒子碰撞,比如超级玛丽游戏,图像一直在绘,过量的使用WPF的元素系统和Sh ...

随机推荐

  1. Nginx content cache Nginx内容缓存

    原文地址:http://nginx.com/resources/admin-guide/caching/ Nginx content cache Nginx内容缓存 This chapter desc ...

  2. windows下perl使用

    windows下perl使用 windows下perl开发工具 Perl 的官方网址提供下载的windows perl开发环境 ActiveState Perl Strawberry Perl DWI ...

  3. jquery-12 jquery常用动画效果有哪些

    jquery-12 jquery常用动画效果有哪些 一.总结 一句话总结:jquery可以用户animate()自定义动画,也可以slide和fade系列方法来设置动画. 1.动画效果如何设置执行时间 ...

  4. [Angular Unit Testing] Testing Services with dependencies

    import { Http, Response, ResponseOptions } from '@angular/http'; import { TestBed } from '@angular/c ...

  5. linux 安装scrt

    http://www.vandyke.com/products/securecrt/  wget http://download.boll.me/securecrt_linux_crack.pl pe ...

  6. PatentTips - Scheduling compute kernel workgroups to heterogeneous processors based on historical processor execution times and utilizations

    BACKGROUND OF THE INVENTION  1. Field of the Invention  The present invention relates generally to h ...

  7. c#代码01--控制台的简单输入与输出及日期的格式输出

    /* 使用ReadLine()完成控制台的输入输出内容 */ using System; namespace Test { class Test1 { static void Main(string[ ...

  8. Browser security standards via access control

    A computing system is operable to contain a security module within an operating system. This securit ...

  9. git安装使用详解

    Git是分布式版本控制系统,那么它就没有中央服务器的,每个人的电脑就是一个完整的版本库,这样,工作的时候就不 需要联网了,因为版本都是在自己的电脑上.既然每个人的电脑都有一个完整的版本库,那多个人如何 ...

  10. 使用Visual Studio 2010 一步一步创建Powershell Module 和 Cmdlet

    现在就用C#写一个超级简单的Module和Cmdlet 1. 在VS中创建一个Library的项目 文件->新建->项目->C#->Class Library 在这里给我们的C ...