Winify – Blame information for rev

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System;
2 using System.Drawing;
3 using System.IO;
4 using System.Media;
5 using System.Threading.Tasks;
6 using System.Windows.Forms;
7 using Winify.Utilities;
8  
9 namespace Winify
10 {
11 public partial class NotificationForm : Form
12 {
13 #region Constructors, Destructors and Finalizers
14  
15 public NotificationForm()
16 {
17 InitializeComponent();
18 }
19  
20 public NotificationForm(Image image, string title, string text, int milliseconds) : this()
21 {
22 pictureBox1.InvokeIfRequired(pictureBox => { pictureBox.Image = image; });
23  
24 richTextBox2.InvokeIfRequired(richTextBox => { richTextBox.Text = title; });
25 richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = text; });
26  
27 Task.Delay(milliseconds).ContinueWith(task =>
28 this.InvokeIfRequired(form => form.Close()));
29 }
30  
31 public NotificationForm(Image image, string title, string text, Stream sound, int milliseconds) : this(image,
32 title, text,
33 milliseconds)
34 {
35 using (var soundPlayer = new SoundPlayer(sound))
36 {
37 soundPlayer.Play();
38 }
39 }
40  
41 #endregion
42  
43 #region Private Overrides
44  
45 protected override void OnLoad(EventArgs e)
46 {
47 var screen = Screen.FromPoint(Location);
48 Location = new Point(screen.WorkingArea.Right - Width, screen.WorkingArea.Bottom - Height);
49 base.OnLoad(e);
50 }
51  
52 #endregion
53  
54 #region Event Handlers
55  
56 private void PictureBox2_Click(object sender, EventArgs e)
57 {
58 this.InvokeIfRequired(form => { form.Close(); });
59 }
60  
61 #endregion
62 }
63 }