Introduction
I've always admired the way movies end, especially when they put a good music that could make up for the stupid movie and lets me forget the bitterness of thinking about the time I wasted watching this movie!!
Well, hopefully I'm making a good movie cast now, but hey, I ain't making up nothing!!
Explanation
Three main events were declared on the form level for this cast:
Load: To load the music and start off the scrolling process
MouseEnter: To pause the scrolling
MouseLeave: To resume scrolling
For the two mouse events, I've attached two timers to be triggered.
Oh, just two ordinary timers to scroll/pause the cast text.
tmrScroller would control the text movement and determine it has reached an end and if so, it's dead!! That is using the kill_Scroller method.
tmrPause to show the blinking pause sign at the bottom.
Notice that real pausing was already carried out in the MouseEnter event that in turn launched the tmrPause.
Well, I think that's it for the explanation. Let's go and take a peek at the code.
The Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using tonysound;
namespace Movie_Cast
{
public partial class Cast : Form
{
public Cast()
{
InitializeComponent();
}
private void Cast_Load(object sender, EventArgs e)
{
tmrScroller.Start();
Sound.Play("0X07.wav", PlaySoundFlags.SND_ASYNC);
}
private void tmrScroller_Tick(object sender, EventArgs e)
{
if (txtCast.Location.Y > (txtCast.Height * -1))
txtCast.Location = new Point(txtCast.Location.X,
txtCast.Location.Y - 1);
else
kill_Scroller(); }
private void kill_Scroller()
{
tmrScroller.Stop();
label1.Visible = true;
lnk_website.Visible = true;
panel2.BringToFront();
}
private void Cast_FormClosed(object sender,
FormClosedEventArgs e)
{
Sound.Play(@"C:\WINDOWS\Media\start.wav",
PlaySoundFlags.SND_ASYNC);
}
private void lnk_website_LinkClicked(object sender,
LinkLabelLinkClickedEventArgs e)
{
this.Close();
System.Diagnostics.Process.Start("http://" +
"www.uncdf.org/english/countries/yemen/index.php");
}
private void Cast_MouseEnter(object sender,
EventArgs e) {
tmrScroller.Stop();
tmrPause.Start();
lbl_Pause.Visible = false;
}
private void Cast_MouseLeave(object sender,
EventArgs e) {
tmrScroller.Start();
tmrPause.Stop();
lbl_Paused.Visible = false;
panel3.Visible = false;
panel4.Visible = false;
lbl_Pause.Visible = true;
}
private void tmrPause_Tick(object sender, EventArgs e)
{
if (lbl_Paused.Visible == false)
{
lbl_Paused.Visible = true;
panel3.Visible = true;
panel4.Visible = true;
}
else
{
lbl_Paused.Visible = false;
panel3.Visible = false;
panel4.Visible = false;
}
}
}
}