Rumyhub

The place where stuff Happens

A Small App for Christmas in C#

Hey Merry Christmas to everyone. I wrote a small application in C# that has a blinking label and it goes down and up in the form.

First I set the form properties

  • BackColor = Black
  • BackgroundImage = set any image you like
  • BackgroundImageLayout = Center
  • FormBorderStyle = FixedSingle
  • MaximizeBox = False
  • Size =540,530
  • StartPosition= CenterScreen
  • Text = Happy Holidays

so the it looks similar to the picture below

Now I inserted a label set its properties

  • BackColor = Transparent
  • Font =Microsoft Sans Serif, 48pt, style=Bold, Italic
  • ForeColor = Green
  • Location =13,10
  • Text = Merry Christmas
And should look similar to this

Then add two timers one interval of 10 milliseconds and the other with 250 milliseconds don't forget to enable the timers.

Now for the coding part. We start by creating an integer for the location of the label and boolean to check whether the label is at the beginning or at the end of the form. Then I set the integer to 2 (the starting point) and the boolean to true(because it is at the top).

 

I used the timer that is set to an interval of 10 seconds to move the label up and down the form.

First the app set the label position with the current position like so

Then the integer is added by one if the label is position is less than the from size therefore the boolean is true, if not the integer is subtracted by one therefore the boolean is false.

And For the other timer that is set to 250 milliseconds will make the label blink

The method checks if the label is visible and if yes the label will be hid for the next 250milliseconds or if no the label is again visible for the 250 milliseconds 

I also added a small video to show you the end result.

AnnimationXMAS.rar (108.93 kb)


blog comments powered by Disqus