Winify

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 2  →  ?path2? @ 3
/trunk/Winify/NotificationForm.cs
@@ -10,9 +10,15 @@
{
public partial class NotificationForm : Form
{
#region Private Delegates, Events, Enums, Properties, Indexers and Fields
 
private Image _image;
 
#endregion
 
#region Constructors, Destructors and Finalizers
 
public NotificationForm()
private NotificationForm()
{
InitializeComponent();
}
@@ -19,6 +25,8 @@
 
public NotificationForm(Image image, string title, string text, int milliseconds) : this()
{
_image = image;
 
pictureBox1.InvokeIfRequired(pictureBox => { pictureBox.Image = image; });
 
richTextBox2.InvokeIfRequired(richTextBox => { richTextBox.Text = title; });
@@ -25,7 +33,7 @@
richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = text; });
 
Task.Delay(milliseconds).ContinueWith(task =>
this.InvokeIfRequired(form => form.Close()));
this.InvokeIfRequired(form => { form.Close(); }));
}
 
public NotificationForm(Image image, string title, string text, Stream sound, int milliseconds) : this(image,
@@ -38,6 +46,26 @@
}
}
 
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
if (_image != null)
{
_image.Dispose();
_image = null;
}
 
components.Dispose();
}
 
base.Dispose(disposing);
}
 
#endregion
 
#region Private Overrides
@@ -58,6 +86,15 @@
this.InvokeIfRequired(form => { form.Close(); });
}
 
private void NotificationForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (_image != null)
{
_image.Dispose();
_image = null;
}
}
 
#endregion
}
}