Marquee Label

/* Made by Lonami Exo * 22 -January- 2015. * (C) LonamiWebs !*/ using System; using System.Windows.Forms; /// <summary> /// A marquee label /// </summary> public class MarqueeLabel : Label { public int Separation = 20; public int Speed = 200; Timer t; string _Text = ""; public override string Text { get { return GetMarqueeText(); } set { base.Text = _Text = value; } } public MarqueeLabel() { t = new Timer { Interval = Speed, Enabled = true }; t.Tick += t_Tick; } void t_Tick(object sender, EventArgs e) { NextMarquee(); Text = _Text; } int MarqueeStep; int MaxMarquee { get { return _Text.Length + Separation; }} string GetMarqueeText() { string all = _Text + new string(' ', Separation); string part1 = all.Substring(MarqueeStep, MaxMarquee - MarqueeStep); string part2 = all.Substring(0, MarqueeStep); return part1 + part2; } void NextMarquee() { if (MarqueeStep < MaxMarquee - 1) MarqueeStep++; else MarqueeStep = 0; } }
Everybody loves marquees. I do, you do, C# does! Why not adding some marquee labels to your forms project?

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.