Winify – Rev
?pathlinks?
using System;
using System.Drawing;
using System.IO;
using System.Media;
using System.Threading.Tasks;
using System.Windows.Forms;
using Winify.Utilities;
namespace Winify
{
public partial class NotificationForm : Form
{
#region Private Delegates, Events, Enums, Properties, Indexers and Fields
private Image _image;
#endregion
#region Constructors, Destructors and Finalizers
private NotificationForm()
{
InitializeComponent();
}
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; });
richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = text; });
Task.Delay(milliseconds).ContinueWith(task =>
this.InvokeIfRequired(form => { form.Close(); }));
}
public NotificationForm(Image image, string title, string text, Stream sound, int milliseconds) : this(image,
title, text,
milliseconds)
{
using (var soundPlayer = new SoundPlayer(sound))
{
soundPlayer.Play();
}
}
/// <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
protected override void OnLoad(EventArgs e)
{
var screen = Screen.FromPoint(Location);
Location = new Point(screen.WorkingArea.Right - Width, screen.WorkingArea.Bottom - Height);
base.OnLoad(e);
}
#endregion
#region Event Handlers
private void PictureBox2_Click(object sender, EventArgs e)
{
this.InvokeIfRequired(form => { form.Close(); });
}
private void NotificationForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (_image != null)
{
_image.Dispose();
_image = null;
}
}
#endregion
}
}
Generated by GNU Enscript 1.6.5.90.