|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionThis is simple to use Marquee implementation for windows forms using .Net 2.0. This control allows you to customize itself easily and within seconds. BackgroundI was looking for Marquee control for window forms. I found a couple but they were very restricted in features and moreover they were very restricted in events. I decided to write control which will fullfill all of my needs. Further it should be generic enough to be used by others also. FeaturesMorquee control has following features
Using CodeYou can use this control in two ways Via DesignerUse dragdrop feature of visual studio. I will recommend to use the compiled assembly for references. Otherwise if recompiling of assembly is done you will need to restart visual studio.
Use designer of SuperMorquee for to modify the control.
Use Properties of control to fine tune the rest properties
Use Element collection editor to modify TextElement collection
Use element designer to set element properties.
Via Code MarqueControl.Controls.SuperMarquee superMarquee1 = new MarqueControl.Controls.SuperMarquee();
Use following code to add element to the control
TextElement element = new TextElement("Element text");
element.LeftImageIndex = 0;
element.RightImageIndex = 1;
element.IsLink = true;
element.ForeColor = Color.Red;
element.Tag = "Tag for element";
element.Font = new Font("Microsoft Sans Serif", 8.25F);
element.ToolTipText = "Tool tip for element";
superMarquee1.Elements.Add(element);
Alternatively you can use the following code snippent to add new range of elements MarqueControl.Entity.TextElement textElement1 = new MarqueControl.Entity.TextElement("TextElement 1"); MarqueControl.Entity.TextElement textElement2 = new MarqueControl.Entity.TextElement("TextElement 2"); MarqueControl.Entity.TextElement textElement3 = new MarqueControl.Entity.TextElement("TextElement 3"); superMarquee1.Elements.AddRange(new MarqueControl.Entity.TextElement[] { textElement1, textElement2, textElement3 } ); Events Description
This event is fired when user presses mouse button on the element text area. private void superMarquee1_ItemClicked(object sender, ItemClickEventArgs e) { MessageBox.Show("Item clicked :" + e.Index); }Note
This event is fired when user double clicks on the element text area. This has similar features as of
private void superMarquee1_ItemDoubleClicked(object sender, ItemClickEventArgs e)
{
MessageBox.Show("Item double clicked :" + e.Index);
}
This event is fired when a lap is completed. Applicable only if private void superMarquee1_LapCompleted(object sender, System.EventArgs e) { MessageBox.Show("Lap completed."); }
This event is fired before tooltip is popped. It supports cancellation of the tooltip being displayed. Apart from cancel feature it supports following
HitTest and HitTestInfo object
HitTestInfo test = superMarquee1.HitTest(PointToClient(MousePosition));
switch(test.Area)
{
case HitTestArea.Item:
break;
case HitTestArea.LeftImage:
break;
case HitTestArea.RightImage:
break;
case HitTestArea.Strip:
break;
case HitTestArea.Control:
break;
case HitTestArea.None:
break;
}
Alternatively you can create new instance of the HitTestInfo test = new HitTestInfo(superMarquee1, PointToClient(MousePosition)); switch(test.Area) { case HitTestArea.Item: break; case HitTestArea.LeftImage: break; case HitTestArea.RightImage: break; case HitTestArea.Strip: break; case HitTestArea.Control: break; case HitTestArea.None: break; } ToolTip and ToolTipData object
To use tooltip Property Following code snippet illustrates how to add dynamic tooltip to the element. private void superMarquee1_BeforeToolTip(object sender, GenericCancelEventArgs <ToolTipData> tArgs) { tArgs.Value.ToolTipText = "New dynamic text based on condition."; } Code below will illustrates how to change position of the tooltip being displayed. private void superMarquee1_BeforeToolTip(object sender, GenericCancelEventArgs<ToolTipData> tArgs) { tArgs.Value.Location = new Point(tArgs.Value.Location.X + 10, tArgs.Value.Location.Y + 20); } This is how you tooltip display can be cancelled. private void superMarquee1_BeforeToolTip(object sender, GenericCancelEventArgs Points of InterestSuperMarqueeProperties
Events
Methods
TextElementProperties
Methods
Known Issues
History24 March 2008 : Initial Draft of the control.
|
||||||||||||||||||||||