MarqueeLabel.cs
changeset 8 5129c03ab7ba
parent 6 70b26a1ae93b
child 11 de55741d90f0
     1.1 --- a/MarqueeLabel.cs	Tue Jul 08 16:41:29 2014 +0200
     1.2 +++ b/MarqueeLabel.cs	Tue Jul 08 18:59:07 2014 +0200
     1.3 @@ -17,6 +17,13 @@
     1.4          private StringFormat iStringFormat;
     1.5          private SolidBrush iBrush;
     1.6          private SizeF iTextSize;
     1.7 +        private SizeF iSeparatorSize;
     1.8 +
     1.9 +        [Category("Appearance")]
    1.10 +        [Description("Separator in our scrolling loop.")]
    1.11 +        [DefaultValue(" | ")]
    1.12 +        [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
    1.13 +        public string Separator { get; set; }
    1.14  
    1.15          [Category("Behavior")]
    1.16          [Description("How fast is our text scrolling, in pixels per second.")]
    1.17 @@ -80,9 +87,9 @@
    1.18                  return;
    1.19              }
    1.20  
    1.21 -            while (CurrentPosition > (iTextSize.Width))
    1.22 +            while (CurrentPosition > (iTextSize.Width + iSeparatorSize.Width))
    1.23              {
    1.24 -                CurrentPosition -= ((int)iTextSize.Width);
    1.25 +                CurrentPosition -= ((int)(iTextSize.Width + iSeparatorSize.Width));
    1.26              }
    1.27  
    1.28              PixelsLeft += aNewTickTime.Subtract(aLastTickTime).TotalSeconds * PixelsPerSecond;
    1.29 @@ -194,6 +201,7 @@
    1.30              Graphics g = this.CreateGraphics();
    1.31              g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
    1.32              iTextSize = g.MeasureString(Text, Font);
    1.33 +            iSeparatorSize = g.MeasureString(Separator, Font);
    1.34              iStringFormat = GetStringFormatFromContentAllignment(TextAlign);
    1.35  
    1.36              if (NeedToScroll())
    1.37 @@ -234,8 +242,11 @@
    1.38                  //Draw the first one
    1.39                  e.Graphics.TranslateTransform(-(float)CurrentPosition, 0);
    1.40                  e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
    1.41 +                //Draw separator
    1.42 +                e.Graphics.TranslateTransform(iTextSize.Width, 0);
    1.43 +                e.Graphics.DrawString(Separator, Font, iBrush, ClientRectangle, iStringFormat);
    1.44                  //Draw the last one
    1.45 -                e.Graphics.TranslateTransform(iTextSize.Width, 0);
    1.46 +                e.Graphics.TranslateTransform(iSeparatorSize.Width, 0);
    1.47                  e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
    1.48              }
    1.49              else