[C#] - Animated label

Discussion in 'Mixed Languages' started by Josh Cell, Oct 13, 2011.

  1. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,106
    120
    #1 Josh Cell, Oct 13, 2011
    Last edited by a moderator: Apr 20, 2017
    Well, creating a small function, you can enable an animated label for shown in progress forms or others developments ...

    [ IMAGE ]

    [​IMG]

    [ EXAMPLE ]

    http://www.datafilehost.com/download-f8c6a31b.html

    [ SOURCE ]

    http://www.datafilehost.com/download-57a0f422.html

    [ CODE ]

    Well, you will add a timer in the form, enable, and with your time of speed in the text, I've changed to 100 :

    The Function:

    Code:
            private void timer1_Tick(object sender, EventArgs e)
            {
                //Animated is a animated label
                animated.Text = animated.Text + ".";
                if (animated.Text.Length > 10)
                {
                    animated.Text = ".";
                }
            }
    Click 2 times in the created timer and put the code ...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. jlgager

    jlgager MDL Developer

    Oct 30, 2009
    362
    3,179
    10
    #2 jlgager, Oct 13, 2011
    Last edited by a moderator: Apr 20, 2017
    thanks i was looking for something like this but ended up using this script as well!

    Text Blinking Script (ThreeSecondTimer is a Background Worker and BlinkingTimer is a Timer Object)
    Code:
            private void blinklabel()
            {
                //500 is equal to half a second.
                BlinkingTimer.Interval = 500;
                BlinkingTimer.Enabled = true;
                BlinkingTimer.Start();
                if (ThreeSecondTimer.IsBusy != true)
                {
                    ThreeSecondTimer.RunWorkerAsync();
                }
                else
                {
                    ThreeSecondTimer.CancelAsync();
                    ThreeSecondTimer.RunWorkerAsync();
                }
            }
    
            private void BlinkingTimer_Tick(object sender, EventArgs e)
            {
                if (lblStatus.Visible)
                {
                    lblStatus.Visible = false;
                }
                else
                {
                    lblStatus.Visible = true;
                }
            }
    
            private void ThreeSecondTimer_DoWork(object sender, DoWorkEventArgs e)
            {
                for (int i = 1; i <= 100; i++)
                {
                    if (ThreeSecondTimer.CancellationPending == true)
                    {
                        e.Cancel = true;
                    }
                    else
                    {
                        // Wait 100 milliseconds.
                        Thread.Sleep(50);
                    }
                }
            }
    
            private void ThreeSecondTimer_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
            {
                BlinkingTimer.Stop();
                lblStatus.Visible = false;
            }
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,106
    120
    Yeah, great code ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...