Winify – Blame information for rev
?pathlinks?
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 | { |
||
3 | office | 13 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
14 | |||
15 | private Image _image; |
||
16 | |||
17 | #endregion |
||
18 | |||
1 | office | 19 | #region Constructors, Destructors and Finalizers |
20 | |||
3 | office | 21 | private NotificationForm() |
1 | office | 22 | { |
23 | InitializeComponent(); |
||
24 | } |
||
25 | |||
26 | public NotificationForm(Image image, string title, string text, int milliseconds) : this() |
||
27 | { |
||
3 | office | 28 | _image = image; |
29 | |||
1 | office | 30 | pictureBox1.InvokeIfRequired(pictureBox => { pictureBox.Image = image; }); |
31 | |||
32 | richTextBox2.InvokeIfRequired(richTextBox => { richTextBox.Text = title; }); |
||
33 | richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = text; }); |
||
34 | |||
35 | Task.Delay(milliseconds).ContinueWith(task => |
||
3 | office | 36 | this.InvokeIfRequired(form => { form.Close(); })); |
1 | office | 37 | } |
38 | |||
39 | public NotificationForm(Image image, string title, string text, Stream sound, int milliseconds) : this(image, |
||
40 | title, text, |
||
41 | milliseconds) |
||
42 | { |
||
43 | using (var soundPlayer = new SoundPlayer(sound)) |
||
44 | { |
||
45 | soundPlayer.Play(); |
||
46 | } |
||
47 | } |
||
48 | |||
3 | office | 49 | /// <summary> |
50 | /// Clean up any resources being used. |
||
51 | /// </summary> |
||
52 | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
||
53 | protected override void Dispose(bool disposing) |
||
54 | { |
||
55 | if (disposing && components != null) |
||
56 | { |
||
57 | if (_image != null) |
||
58 | { |
||
59 | _image.Dispose(); |
||
60 | _image = null; |
||
61 | } |
||
62 | |||
63 | components.Dispose(); |
||
64 | } |
||
65 | |||
66 | base.Dispose(disposing); |
||
67 | } |
||
68 | |||
1 | office | 69 | #endregion |
70 | |||
71 | #region Private Overrides |
||
72 | |||
73 | protected override void OnLoad(EventArgs e) |
||
74 | { |
||
75 | var screen = Screen.FromPoint(Location); |
||
76 | Location = new Point(screen.WorkingArea.Right - Width, screen.WorkingArea.Bottom - Height); |
||
77 | base.OnLoad(e); |
||
78 | } |
||
79 | |||
80 | #endregion |
||
81 | |||
82 | #region Event Handlers |
||
83 | |||
84 | private void PictureBox2_Click(object sender, EventArgs e) |
||
85 | { |
||
86 | this.InvokeIfRequired(form => { form.Close(); }); |
||
87 | } |
||
88 | |||
3 | office | 89 | private void NotificationForm_FormClosing(object sender, FormClosingEventArgs e) |
90 | { |
||
91 | if (_image != null) |
||
92 | { |
||
93 | _image.Dispose(); |
||
94 | _image = null; |
||
95 | } |
||
96 | } |
||
97 | |||
1 | office | 98 | #endregion |
99 | } |
||
100 | } |