

Me.Clock1.UtcOffset = (DateTime.Now)įor more examples, check the demo project. ' If the property has the same value it will do nothing. ' Set UTC offset to the system utc offset every time clock time changes. Object, _īyVal e As System.EventArgs) Handles Clock1.TimeChanged ' Set UTC offset to the system utc offset when the application loads Me.Clock1.UtcOffset = (DateTime.Now)Įnd Sub Private Sub Clock1_TimeChanged( ByVal sender As System. Object, _īyVal e As System.EventArgs) Handles MyBase.Load Private Sub Form1_Load( ByVal sender As System. Basically, you set the Brush property of the hands to a newly created gradient brush object in the hands' paint event. It is very nice to see the clock hand's gradient, so here is how you can do that.

Note, in this fashion, you can paint the elements with any brush. Using the CodeĪlthough you can do almost anything with this control, I will show you only how to paint the hour-hand of the clock with a PathGradientBrush. Shift-Path is the copy of the rotated Base-Path.

On the other hand, the Shift-Path is the actual GrapicsPath of the hand at any given time. The Base-Path of the hands are always positioned at 12 o' clock, and only reshaped if the element's shape (width, length, or style) is modified. The clock's hands have two member variables of type GraphicsPath: Base-Path and Shift-Path. Since it is rotated only once, there is no need fore any other helper objects. For example, the marker's Base-Path represents a GraphicsPath constructed at 12 hour position and than rotated using a Matrix object. These Base-Paths are used differently for each element. They contain a member variable Base-Path which is a GraphicsPath of the element.

Almost all the elements of the clock have been constructed (the core of the element) with the GraphicsPath data type. The clock control is a Windows UserControl. Also, in order to see the descriptions of the properties or methods in the Code Designer, you should copy the " AnalogClockLib.xml" file into your project's folder. This will add the control onto the Toolbox.įinally, you drag and drop the control onto your forms. You go to the directory that contains the " AnalogClockLib.dll" file and select it, then click the OK button. It will then open the "Choose Toolbox Item" window. Right click in the Toolbox area, and select the "Choose Items" menu item. To use the control, you just need to add it into the VS.NET Toolbox. At the beginning, it was a very simple clock, but then it became somewhat advanced after I added many properties, events, and a functionality that makes the clock very flexible. I created this control to help someone in VB Forums. Since this is a control library, you can use it in C++, C#, J#, and VB.NET projects in the. It is a clock control which has almost all the functionality that this type of control can have, and it is fully customizable. Here, an analog clock has been created with a VB.NET control library.
