c# wpf定时器的一种用法
1、xaml页面
<Window x:Class="EssentialWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button
Name="_button1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="9pt">
Hello World
</Button>
</Grid>
</Window> 2、后台 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Threading; namespace EssentialWPF
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
long _start;
public MainWindow()
{
InitializeComponent(); DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(50);
_start = Environment.TickCount;
timer.Tick += timer_Tick;
timer.IsEnabled = true;
} void timer_Tick(object sender, EventArgs e)
{
long elapsed = Environment.TickCount - _start;
if (elapsed >= 5000)
{
_button1.FontSize = 18.0;
((DispatcherTimer)sender).IsEnabled = false;
return;
}
_button1.FontSize = 9.0 + (9.0 / (5000.0 / elapsed));
}
}
}
c# wpf定时器的一种用法的更多相关文章
- (转) java定时器的几种用法
package com.lid; import java.util.Calendar; import java.util.Date; import java.util.Timer; import ja ...
- java定时器的几种用法[转]
Timer timer = timer.schedule( Sy ...
- java定时器的几种用法
package com.lid; import java.util.Calendar; import java.util.Date; import java.util.Timer; import ja ...
- WPF编程,C#中弹出式对话框 MessageBox 的几种用法。
原文:WPF编程,C#中弹出式对话框 MessageBox 的几种用法. 1.MessageBox.Show("Hello~~~~"); 最简单的,只显示提示信息. 2.Mes ...
- WPF中InkCanvas(墨水面板)用法
原文:WPF中InkCanvas(墨水面板)用法 WPF中InkCanvas(墨水面板)用法 ...
- using 的三种用法
using 有哪三种用法? 1)引入命名空间. 2)给命名空间或者类型起别名. 3)划定作用域.自动释放资源,使用该方法的类型必须实现了 System.IDisposable接口,当对象脱离作用域之后 ...
- c++ operator操作符的两种用法:重载和隐式类型转换,string转其他基本数据类型的简洁实现string_cast
C++中的operator主要有两个作用,一是操作符的重载,一是自定义对象类型的隐式转换.对于操作符的重载,许多人都不陌生,但是估计不少人都不太熟悉operator的第二种用法,即自定义对象类型的隐式 ...
- Wix 安装部署教程(十五) --CustomAction的七种用法
在WIX中,CustomAction用来在安装过程中执行自定义行为.比如注册.修改文件.触发其他可执行文件等.这一节主要是介绍一下CustomAction的7种用法. 在此之前要了解InstallEx ...
- Android Intent的几种用法全面总结
Android Intent的几种用法全面总结 Intent, 用法 Intent应该算是Android中特有的东西.你可以在Intent中指定程序要执行的动作(比如:view,edit,dial), ...
随机推荐
- Sublime Text的心得经验。 全面
Sublime Text的心得经验.jikeytang/sublime-text · GitHub
- yii2.0场景的使用
- bash shell + python简单教程,让你的mac/linux终端灰起来~
前提条件:已经安装python,命令行支持bash 在bash_profile中添加 function ccolor { python /Users/xirtam/Documents/tools/cc ...
- weblogic启动受管服务器报错Authentication for user weblogic denied (weblogic 11g 域账号密码不生效的解决方法)
或者 解决方法:
- Java提高篇——设计模式
设计模式简介 设计模式(Design pattern)代表了最佳的实践,通常被有经验的面向对象的软件开发人员所采用.设计模式是软件开发人员在软件开发过程中面临的一般问题的解决方案.这些解决方案是众多软 ...
- CentOS进不了mysql
在tty1里输入命令:“mysql -uroot -p+密码” 可以正常进入mysql,但在tty2里就不行了, 提示:Error 1045(28000): Access denied for use ...
- spring cloud的主要组成部分
服务发现:Eureka断路器: Hystrix 客户端和控制面板客户端负载均衡: Ribbon声明式REST客户端: Feign外部化配置: Archaius路由和过滤器: Zuul RxJava w ...
- sourceTreee设置忽略的文件
1.忽略不想要的目录,比如bin.obj目录(每次运行本机程序都会变化) 这个在右上角的Settings的Advanced下面的Repository-specific ignore list,点击Ed ...
- lua协程一则报错解决“attempt to yield across metamethod/C-call boundary”
问题 attempt to yield across metamethod/C-call boundary 需求跟如下帖子中描述一致: http://bbs.chinaunix.net/forum.p ...
- leetcode bugfree note
463. Island Perimeterhttps://leetcode.com/problems/island-perimeter/就是逐一遍历所有的cell,用分离的cell总的的边数减去重叠的 ...