Skip to content

Instantly share code, notes, and snippets.

@kieranajp
Created April 21, 2012 16:07
Show Gist options
  • Save kieranajp/2438030 to your computer and use it in GitHub Desktop.
Save kieranajp/2438030 to your computer and use it in GitHub Desktop.
My little notification class (:
/* Create a form, controlBox and everything turned off, so there are no Window controls on it.
* Put a label on it (lblNotification) and a timer, I used a tick of 2500, and you're set!
* Call Notification n = new Notification("Some text", false); - the instance kills itself after 2.5 seconds (with timer tick of 2500)
*/
public partial class Notification : Form
{
public Notification(string txt, bool perma)
{
InitializeComponent();
this.Show();
lblNotification.Text = txt;
this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width;
this.Top = Screen.PrimaryScreen.WorkingArea.Height - this.Height;
this.Opacity = 0.7;
if (!perma) timer.Start();
}
private void timer_Tick(object sender, EventArgs e)
{
this.Dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment