C # developing beautiful digital clocks,

Source: Internet
Author: User

C # developing beautiful digital clocks,

Today, I made a beautiful digital clock with C. The interface is as follows.

 

 

Implementation Technology: The Graphics class DrawImage method is used to draw all the numbers in the digital clock. These numbers are some image files found online. The clock uses the Now attribute in DateTime to get different, hour, minute, second, and finally the timer to realize the running status of the clock.

 

 

Main Code:

 

 

[C-sharp]View plaincopy
  1. // Set 0 ~ 9. Save the digital Image to the Image array.
  2. Private Image [] image = new Bitmap [10];
  3. Public Form1 ()
  4. {
  5. InitializeComponent ();
  6. For (int I = 0; I <10; I ++)
  7. {
  8. Image [I] = new Bitmap (@ "D:/programming/C #/Digital Clock/Resources/" + I. ToString () + ". jpg ");
  9. }
  10. }

 

[C-sharp]View plaincopy
  1. Private void Form1_Paint (object sender, PaintEventArgs e)
  2. {
  3. Graphics g = e. Graphics;
  4. Int hh = DateTime. Now. Hour; // obtain the Hour number.
  5. Int hh1 = hh/10;
  6. Int hh2 = hh % 10;
  7. G. DrawImage (image [hh1], 20, 20, 80,180 );
  8. G. DrawImage (image [hh2], 100, 20, 80,180 );
  9. Int mm = DateTime. Now. Minute; // obtain the Minute number.
  10. Int mm1 = mm/10;
  11. Int mm2 = mm % 10;
  12. G. DrawImage (image [mm1], 260, 20, 80,180 );
  13. G. DrawImage (image [mm2], 340, 20, 80,180 );
  14. Int ss = DateTime. Now. Second; // obtain the Second number.
  15. Int ss1 = ss/10;
  16. Int ss2 = ss % 10;
  17. G. DrawImage (image [ss1], 500, 20, 80,180 );
  18. G. DrawImage (image [ss2], 580, 20, 80,180 );
  19. }
  20. Private void timereffectick (object sender, EventArgs e) // redraws the form.
  21. {
  22. This. Invalidate ();
  23. }

 

In addition, set the Interval attribute of Timer to 1000mm and Enable to True!


In the C language, what is the symbol (->) and how to use it?

This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.

In the C language, what is the symbol (->) and how to use it?

This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.