C#: Graphical Clock (Beginner level)
Programming requires significiant practices. There are really no better way to learn it. Here lies my documention of the learning process. Enjoy!
Tools:
VS.Net 2002
Goals of this exercise:
-Start with one of the default package
-Allow code to interact with graphical interface (GUI)
-Create a timer invoke event and its handler (Threads)
-Uses Managed Code (FCL)
-Create a simple program
Proposal:
To Create a graphical clock with Hour/Minute/Second that refreshes by the second.
Solution:
-I started out using default Windows Application package
-The graphical end, I've decided to use the Drawing namespace. In particular, Graphics class. Graphics class: this class handles the draw and manipulation related to the graphics produced. In this exercise, I've used RotateTransform, DrawLine, TranslateTransform. Don't forget to set the graphic mode and experience with other interesting drawing abilities.
-For Timer, I just dropped the timer function, modified interval to 1000ms, and the meat of getting GUI to refresh is to use this.Invalidate() as a timer_Elapsed event.
-Managed Code I needed was to retrieve the correct time. In System Namespace, there's this neat class called DateTime, which pretty much solves all my problems.
0 Comments:
Post a Comment
<< Home