资源简介
wpf led时钟 指针时钟,原创。
代码片段和文件信息
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.Threading;
namespace Clock
{
///
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
///
/// Step 1a) Using this custom control in a XAML file that exists in the current project.
/// Add this xmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace=“clr-namespace:Clock“
///
///
/// Step 1b) Using this custom control in a XAML file that exists in a different project.
/// Add this xmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace=“clr-namespace:Clock;assembly=Clock“
///
/// You will also need to add a project reference from the project where the XAML file lives
/// to this project and Rebuild to avoid compilation errors:
///
/// Right click on the target project in the Solution Explorer and
/// “Add Reference“->“Projects“->[Browse to and select this project]
///
///
/// Step 2)
/// Go ahead and use your control in the XAML file.
///
///
///
///
public class MyClock : Control
{
static MyClock()
{
DefaultstyleKeyProperty.Overridemetadata(typeof(MyClock) new frameworkPropertymetadata(typeof(MyClock)));
}
private DispatcherTimer timer; // NameSpace:System.Windows.Threading
//重载初始化函数OnInitialized,加入初始化计时器代码
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
UpdateDateTime();
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(1000);
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
//计时器事件函数
private void timer_Tick(object sender EventArgs e)
{
UpdateDateTime();
}
//编写UpdateDateTime函数,用于更新时间
private void UpdateDateTime()
{
Time = DateTime.Now;
}
public DateTime Time
{
get { return (DateTime)GetValue(TimeProperty); }
private set { SetValue(TimeProperty value); }
}
public static DependencyProperty TimeProperty = DependencyProperty.Register(
“Time“ typeof(DateTime)
typeof(MyClock)
new Propertymetadata(DateTime.Now new PropertyChangedCallback(OnDateTimeInvalidated)));
private
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9216 2012-08-20 15:34 Clock\Clock\bin\Debug\Clock.dll
文件 28160 2012-08-20 15:34 Clock\Clock\bin\Debug\Clock.pdb
文件 3820 2011-07-20 11:05 Clock\Clock\Clock.csproj
文件 4027 2011-07-20 11:05 Clock\Clock\MyClock.cs
文件 1605 2011-11-18 10:54 Clock\Clock\obj\Debug\Clock.csproj.FileListAbsolute.txt
文件 9216 2012-08-20 15:34 Clock\Clock\obj\Debug\Clock.dll
文件 1364 2012-08-20 15:34 Clock\Clock\obj\Debug\Clock.g.resources
文件 28160 2012-08-20 15:34 Clock\Clock\obj\Debug\Clock.pdb
文件 180 2011-11-18 10:54 Clock\Clock\obj\Debug\Clock.Properties.Resources.resources
文件 187 2012-08-20 15:34 Clock\Clock\obj\Debug\Clock_MarkupCompile.cache
文件 187 2012-08-20 15:33 Clock\Clock\obj\Debug\Clock_MarkupCompile.i.cache
文件 139 2012-08-20 15:33 Clock\Clock\obj\Debug\Clock_MarkupCompile.i.lref
文件 137 2012-08-20 15:34 Clock\Clock\obj\Debug\Clock_MarkupCompile.lref
文件 15146 2012-01-13 14:27 Clock\Clock\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6299 2012-08-20 15:34 Clock\Clock\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 7 2012-08-20 15:34 Clock\Clock\obj\Debug\GeneratedInternalTypeHelper.g.cs
文件 2905 2012-08-20 15:34 Clock\Clock\obj\Debug\GeneratedInternalTypeHelper.g.i.cs
文件 220 2011-11-18 10:54 Clock\Clock\obj\Debug\GenerateResource.read.1.tlog
文件 518 2011-11-18 10:54 Clock\Clock\obj\Debug\GenerateResource.write.1.tlog
文件 757 2011-07-20 11:06 Clock\Clock\obj\Debug\JClock.csproj.FileListAbsolute.txt
文件 4608 2011-07-20 11:05 Clock\Clock\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 1128 2012-08-20 15:34 Clock\Clock\obj\Debug\Themes\Generic.baml
文件 2288 2011-07-20 08:52 Clock\Clock\Properties\AssemblyInfo.cs
文件 2834 2011-07-20 11:05 Clock\Clock\Properties\Resources.Designer.cs
文件 5612 2011-07-20 08:52 Clock\Clock\Properties\Resources.resx
文件 1084 2011-07-20 11:05 Clock\Clock\Properties\Settings.Designer.cs
文件 201 2011-07-20 08:52 Clock\Clock\Properties\Settings.settings
文件 1468 2011-07-20 13:25 Clock\Clock\Themes\Generic.xaml
文件 3529 2011-07-21 12:26 Clock\Clock.sln
..A..H. 84480 2012-08-20 15:35 Clock\Clock.suo
............此处省略137个文件信息
- 上一篇:C#调用API实现录音功能
- 下一篇:NGUI实现Tab键切换Input焦点
相关资源
- WPF流程图 开发
- WPF分页控件
- C#WPF 右键菜单 显示 事件触发 测试
- WPF loading源码合集汇集好几种loading效
- wpf仿QQ好友分组
- WPF:定制Checkbox样式,让“正确”绿得
- 刘铁猛《深入浅出WPF》全套真高清视
- wpf border 边框不同颜色
- WPF复制粘贴剪切功能.rar
- c#设计的 LED 字显示程序,使用方法较
- MVVM,WPF
- C#控制系统声音大小
- wpf 消息提示框仿QQ左下角提示框
-
xm
l文件与WPF中TreeView、Menu交互 -
WPF Application fr
amework (WAF) Nested -
Wpf 样式和模板含 fr
amework 4.5 aero2 - WPF listBox 漂亮的listBOX
- WPF 3D点云显示
- wpf基于TreeView控件的Demo
- WPF分页DataGrid
- wpf动画 - 跟随鼠标移动
- 用WPF自定义CheckBox的样式(框框和钩钩
- WPF数学三角尺三角板
- C# WPF 状态栏图标特效 类似QQ/MSN的状态
- C#编写的图像均衡化、去噪、高斯模糊
- WPF通过UserControl动态生成向导
- WPF Visifire Chart Gauges 5.1.3.0 破解版
- 一个用WPF编写的串口助手
- WPFGRAPHICS.zip
- C# WPF+MVVM+EF+多语言
评论
共有 条评论