开发者

.NET - Are there any flip clock controls?

开发者 https://www.devze.com 2022-12-31 13:53 出处:网络
For a .NET (Winforms) application are there any flip clock controls? Ideally it would look something like the one found on the BlackBerry Bold:

For a .NET (Winforms) application are there any flip clock controls?

Ideally it would look something like the one found on the BlackBerry Bold:

alt text http://images.crac开发者_运维技巧kberry.com/files/u3/reviewimages/blackberry9000c/lgclock3.jpg

UPDATE 1:

Following this SO link I have added an element host to my project to host the WPF retroclock that @Shane mentioned.

UPDATE 2:

A few steps that I followed:

  • Compile RetroClock
  • Add DLL reference to WinForm App
  • Add 'using WPFControls.Clocks;'
  • Add 'elementHost' to Form
  • In Form Load event add:

    //create retroclock

    RetroClock rc = new RetroClock();

    //add retroclock to element host

    elementHost1.Child = rc;

UPDATE 3:

Styling the clock

//style clock
rc.Height = 30;
rc.IncludeLeadingZero = true;
rc.IsAmPmVisible = true;
rc.FontSize = 60;
rc.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
rc.TimeFormat = TimeFormats.Hour12;


Going along with Joel's answer, there's a simple one for WPF here.


That would be a little out of place for winforms, the main point of which is to expose the common controls to .Net to help developers build windows applications that use the "standard" look and feel. This doesn't mean you won't find one, but that you should think 3rd party first here. Anything provided by Microsoft is going to be at best an afterthought.

WPF, on the other hand, is a much better fit for this kind of thing.


It's pretty easy to make one yourself. Add a class, derive it from Control. You'll need a Timer that keeps it going, have its Tick method call Invalidate(). Override OnPaint() to draw the digits and am/pm indicator. You'll want the TextRenderer.DrawText() overload that draws inside a rectangle to get the digits centered. Draw a black line through the center.

Ought to be fun.

0

精彩评论

暂无评论...
验证码 换一张
取 消