|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionBackground processes, applications that run from tray and many other types of applications frequently need to show notifications/alerts to the user. One of the common examples is Outlook 2003 which shows an email notification just over the system tray. This article is about a base class Using the codeThe project contains the following three forms/classes:
If you are just interested in adding the fade in/out effect, you can derive any form from public class Notification : TransDialog
{
#region Ctor, init code and dispose
public Notification()
: base(true)
{
InitializeComponent();
}
/* ... */
}
Passing How does TransDialog work
private void TransDialog_Load(object sender, EventArgs e)
{
this.Opacity = 0.0;
m_bShowing = true;
m_clock.Start();
}
On every if (m_bShowing)
{
if (this.Opacity < 1)
{
this.Opacity += 0.1;
}
else
{
m_clock.Stop();
}
}
This gives the fade in effect. On form closing event, the private void TransDialog_Closing(object sender, CancelEventArgs e)
{
/* ... */
m_origDialogResult = this.DialogResult;
e.Cancel = true;
m_bShowing = false;
m_clock.Start();
/* ... */
}
How does Notification workThe fade in/out effect on the notification works just by deriving from private void Notification_Load(object sender, System.EventArgs e)
{
/* ... */
int screenWidth = Screen.PrimaryScreen.WorkingArea.Width;
int screenHeight = Screen.PrimaryScreen.WorkingArea.Height;
this.Left = screenWidth - this.Width;
this.Top = screenHeight - this.Height;
/* ... */
}
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||