写了一个整人程序,较简单,有兴趣者可以看看
2011-12-10 00:18
507 查看
程序是基于WPF开发的,动态创建对象和动画。
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Media.Animation; namespace WpfApplication1 { /// <summary> /// Window1.xaml 的交互逻辑 /// </summary> public partial class Window1 : Window { Ellipse[] els1, els2; Storyboard std, std2; int theMax = 100; public Window1() { InitializeComponent(); this.Title = "哈哈,看好了"; this.WindowState = WindowState.Maximized; els1 = new Ellipse[theMax]; els2 = new Ellipse[theMax]; for (int n = 0; n < theMax; n++) { els1 = new Ellipse(); els1 .Fill = Brushes.Transparent; els1 .Stroke = Brushes.Black; els1 .StrokeThickness = 0.55; els1 .Width = 0; els1 .Height = 0; els1 .HorizontalAlignment = HorizontalAlignment.Center; els1 .VerticalAlignment = VerticalAlignment.Center; //els1 .Stretch = Stretch.Fill; this.Root.Children.Add(els1 ); } for (int s = 0; s < theMax; s++) { els2[s] = new Ellipse(); els2[s].Fill = Brushes.Transparent; els2[s].Stroke = Brushes.Black; els2[s].StrokeThickness = 0.45; //els2[s].Width = 1300; //els2[s].Height = 970; els2[s].Margin = new Thickness(-150); this.Root.Children.Add(els2[s]); } std = new Storyboard(); std.RepeatBehavior = RepeatBehavior.Forever; Duration AllDuration = new Duration(TimeSpan.FromSeconds(1.2)); //std.Duration = AllDuration; for (int k = 0; k < theMax; k++) { DoubleAnimation dan = new DoubleAnimation(); dan.BeginTime = TimeSpan.FromSeconds(0.02 * k); dan.Duration = AllDuration; dan.From = 0; dan.To = 1100; dan.RepeatBehavior = RepeatBehavior.Forever; Storyboard.SetTarget(dan, els1[k]); Storyboard.SetTargetProperty(dan, new PropertyPath("(FrameworkElement.Width)")); std.Children.Add(dan); dan = new DoubleAnimation(); dan.BeginTime = TimeSpan.FromSeconds(0.02 * k); dan.Duration = AllDuration; dan.From = 0; dan.To = 1000; dan.RepeatBehavior = RepeatBehavior.Forever; Storyboard.SetTarget(dan, els1[k]); Storyboard.SetTargetProperty(dan, new PropertyPath("(FrameworkElement.Height)")); std.Children.Add(dan); } //2 std2 = new Storyboard(); std2.RepeatBehavior = RepeatBehavior.Forever; for (int e = 0; e < theMax; e++) { DoubleAnimation dan = new DoubleAnimation(); dan.BeginTime = TimeSpan.FromSeconds(0.05 * e); dan.Duration = AllDuration; dan.From = 1100; dan.To = 0; dan.RepeatBehavior = RepeatBehavior.Forever; Storyboard.SetTarget(dan, els2[e]); Storyboard.SetTargetProperty(dan, new PropertyPath("(FrameworkElement.Width)")); std2.Children.Add(dan); dan = new DoubleAnimation(); dan.BeginTime = TimeSpan.FromSeconds(0.03 * e); dan.Duration = AllDuration; dan.From = 1350; dan.To = 0; dan.RepeatBehavior = RepeatBehavior.Forever; Storyboard.SetTarget(dan, els2[e]); Storyboard.SetTargetProperty(dan, new PropertyPath("(FrameworkElement.Height)")); std2.Children.Add(dan); } this.Loaded += new RoutedEventHandler(Window1_Loaded); } void Window1_Loaded(object sender, RoutedEventArgs e) { MessageBox.Show("\n\n注意啊,别把眼睛靠得太近!!\n\n\n"); std.Begin(); std2.Begin(); } } }
相关文章推荐
- 写了一个整人程序,较简单,有兴趣者可以看看
- 写了一个整人程序,较简单,有兴趣者可以看看
- 写了一个整人程序,较简单,有兴趣者可以看看
- 闲来无事,将自己收集到的工具类封装了下,做了一个lib,写了个简单的mvp,初学者可以看看
- 如何使用Python为Hadoop编写一个简单的MapReduce程序(这个人T字还有好几篇精华的可以看)
- ReadDirectoryChangesW 监控文件夹 (一个简单的监控示例程序)(文件被修改了,也可以探测到)
- 例题:计算运费。c#语言基础,比较简单。看代码输入格式和方法。同样方法可以做一个 出租车打车的程序
- 一个简单的可以运行程序之后自动关闭的批处理命令
- 一个比较简单驱动程序初学者可以看看
- 简单写了一个MVP项目,有兴趣可以看看
- 简单的做了一个评分控件,其实还算不上控件,只是用javascript做了一个效果,可以直接放在你的程序中使用。
- 本程序说明了如何建立一个简单的可以接收UDP服务器数据的UDP客户端
- 一个简单的减法程序看看基本功
- 【C语言】没事可以试试这个小程序,使用文件操作,模拟实现一个简单的文件拷贝工具!
- 一个班有n个学生,需要把每个学生的简单资料(姓名和学号)输入计算机保存。然后可以通过输入某一学生的姓名查找其有关资料。当输入一个姓名后程序就查找该班有无此学生,如果有,则输出他的姓名和学号,如果找不到
- 一个简单的多态小例子 初学者可以看看
- 编写一个程序,一行行地读取输入行,直至到达文件尾。算出每行输入行的长度,然后把最长的那行打印出来。为了简单起见,你可以假定所有的输入行均不超过1000个字符
- 一个简单的好玩程序(可以创建进程)
- C# 创建、部署和调用WebService的简单示例 webservice 可以用于分布式应用程序之间的交互,和不同程序之间的交互。 概念性的东西就不说太多,下面开始创建一个简单的webservi
- 编写一个程序,一行行地读取输入行,直至到达文件尾。算出每行输入行的长度,然后把最长的那行打印出来。为了简单起见,你可以假定所有的输入行均不超过1000个字符。