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