This article presents a digital clock written using C# .Net 3.5 and Windows Presentation Foundation (WPF), with a version supporting styling using the
RibbonStyleHandler from the Ribbon Control Library (and hence allowing styling consistent with
Using the Code
This is VERY simple, to create a new clock window, make a new instance of
DigitalClockWindow! To add a control to an existing window, use
About the Code
DigitalClock class is comprised of
DigitalClockDots class is a
UIElement representing two dots to separate hours from minutes from seconds.
DigitalClockElement represents the following states: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Hence the
DigitalClock is a
DigitalClockElement DigitalClockElement DigitalClockDots DigitalClockElement DigitalClockElement DigitalClockDots DigitalClockElement DigitalClockElement.
DigitalClockWindow classes contain a thread for updating the clock when
AutoUpdate is set to true, otherwise the clock may be updated via the
.CurrentTime property of
DigitalClockControl contains three properties for styling,
Brush used to render the digits (0 to 9),
Brush used to render the separating dots, and
ClockBackground the background of the clock.
DigitalClockDots contains a single property
RenderBrush for setting the brush used to render the dots.
DigitalClockElement contains a similar property
RenderBrush for setting the brush used to render the graphic components. Furthermore it also contains a Value property for setting the value to display (in the range 0 to 9).
Ribbon Styled Clock
In version 220.127.116.11
RibbonClockWindow have been added which inherit from
DigitalControlWindow respectively; they add automatic styling based on the
RibbonStyleChanged event, and can be seen in use in the CIRIP project (a Computational Intelligent Railway Intervention Planner).
ribboncontrol.aspx - The Ribbon Control library used in styling the control.
18.104.22.168 - Initial build
22.214.171.124 - Separated Ribbon styling from clock.
126.96.36.199 - Added
CurrentTime properties to allow display of custom times
188.8.131.52 - Added
Window with Ribbon styling
184.108.40.206 - Refactored controls to allow resizing
220.127.116.11 - Changed clock from
UserControl and added
18.104.22.168 - Fixed bug where update thread kept process alive