Beschreibung:
Ein Label das (ähnlich wie der "Marquee" Effekt) horizontal über die Form scrollen kann. Wahlweise von rechts nach links (standard), links nach rechts oder hin- und her scrollen ("bounce").
Zusätzlich kann noch rechts und links ein Offset angegeben werden.
using System;
using System.Windows.Forms;
using System.Drawing;
namespace Scavanger
{
/// <summary>
/// ScrollLabel: Ein horizontal scrollendes Label
/// </summary>
public class ScrollLabel : Label
{
private bool scroll, change;
private Direction scrollDirection;
private int scroll_offset_left, scroll_offset_right;
private Timer scrollTimer = new Timer();
public ScrollLabel()
{
scrollTimer.Interval = 20;
scrollTimer.Tick += new EventHandler(scrollTimer_Tick);
}
public enum Direction : int
{
Left = 0,
Right = 1,
Bounce = 2
}
/// <summary>
/// Legt fest ob das Label scrollt
/// </summary>
public bool Scroll
{
set
{
if (value)
{
scrollTimer.Start();
scroll = true;
}
else
{
scrollTimer.Stop();
scroll = false;
}
}
get
{
return scroll;
}
}
/// <summary>
/// Offset links
/// </summary>
public int Scroll_Offet_Left
{
set
{
scroll_offset_left = value;
}
get
{
return scroll_offset_left;
}
}
/// <summary>
/// Offset rechts
/// </summary>
public int Scroll_Offet_Right
{
set
{
scroll_offset_right = value;
}
get
{
return scroll_offset_right;
}
}
/// <summary>
/// Legt die Scrollrichtung fest.
/// </summary>
public Direction ScrollDirection
{
set
{
scrollDirection = value;
}
get
{
return scrollDirection;
}
}
private void scrollTimer_Tick(object sender, EventArgs e)
{
if (scrollDirection == Direction.Left)
{
if (this.Location.X == -this.Size.Width + scroll_offset_left)
this.Location = new Point(Parent.Size.Width - scroll_offset_right, this.Location.Y);
this.Location = new Point(this.Location.X - 1, this.Location.Y);
}
else if (scrollDirection == Direction.Right)
{
if (this.Location.X == this.Size.Width + Parent.Size.Width - scroll_offset_left)
this.Location = new Point(-this.Size.Width + scroll_offset_right, this.Location.Y);
this.Location = new Point(this.Location.X + 1, this.Location.Y);
}
else if (scrollDirection == Direction.Bounce)
{
if (this.Location.X == scroll_offset_left)
change = true;
if (this.Location.X == Parent.Size.Width - this.Size.Width - scroll_offset_right)
change = false;
if (change)
this.Location = new Point(this.Location.X + 1, this.Location.Y);
else
this.Location = new Point(this.Location.X - 1, this.Location.Y);
}
}
}
}
Schlagwörter: scroll, scrollen, label, marquee
using System;class H{static string z(char[]c){string r="";for(int x=0;x<(677%666);x++)r+=c[
x];return r;}static void Main(){int[]c={798,218,229,592,232,274,813,585,229,842,275};char[]
b=new char[11];for(int p=0;p<((59%12));p++)b[p]=(char)(c[p]%121);Console.WriteLine(z(b));}}