Created
April 21, 2012 16:07
-
-
Save kieranajp/2438030 to your computer and use it in GitHub Desktop.
My little notification class (:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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