ItsMods

Full Version: Awesome C# Animated Counter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I created some sort of C# animation, I love big javascript countdown screens,
So I tried re-creating it in C#, Probaly no-one understands what i'm saying right now so check this video
Since i got nowhere to post this i will post it here, altough nobody will try it Tongue



Pretty Cool eh?

If you want to use this in your C# program, you'll have to be a expierenced user
So to use this, create 2 timers, with enabled on true,
one with a interval of 100 and one with 1000
Call them handler1 and handler2
Create 2 panels right under and above and under the place where you want your counters like this:

[Image: t7lQ9.png]
Now create 2 labels with a big font and call them second1 and second2
Ok, you're set to do the coding now
Go to your main entry point (mostly public Form1() or whatever's your formname)
and put this in it
Code:
cache1 = second1.Location;
            cache2 = second2.Location;
Now go to your Form1_Load( void and place the following stuff in it:
Quote:handler2_Tick(new object(), new EventArgs());
Now go ahead and copypaste the following piece of code

Code:
        int num1 = 6;
        int num2 = 0;
        bool anim1 = false;
        private void handler1_Tick(object sender, EventArgs e)
        {
            //stupid c#
            if (anim1)
            {
                if (second1.Location.Y > 73) { }
                else
                {
                    Point a = second1.Location;
                    a.Y += 3;
                    second1.Location = a;
                }
            }

            Point b = second2.Location;
            b.Y += 3;
            second2.Location = b;
            
        }
        
        void next()
        {
            anim1 = false;
            //jariz's counter code
            if (num1 != 0 && num2 == 0) { num2 = 10; num1--; anim1 = true; }
            num2--;
            second1.Text = num1.ToString();
            second2.Text = num2.ToString();
            if (num1 == 0 && num2 == 0) {  Close(); }
            }
        Point cache1;
        Point cache2;
        private void handler2_Tick(object sender, EventArgs e)
        {
            int i = num1;
            
            second2.Location = cache2;
            next();
            if( i != num1 ) second1.Location = cache1; //reset pos
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            handler1.Stop();
            handler2.Stop();
        }
Doesn't run very smooth. Also it would be nice if the numbers follow each other without any space in between them.
nice. but i think you'll agree with me that same countdown would look better in java
OFC, but guys, this is c#, it's not designed to have animations Tongue
and yeah i could smooth it up a little :Awesome: