Winify – Blame information for rev 12

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System;
9 office 2 using System.Diagnostics;
1 office 3 using System.Drawing;
12 office 4 using System.IO;
5 using System.Media;
1 office 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 {
11 office 14 #region Public Enums, Properties and Fields
15  
16 public int Index { get; }
17  
18 #endregion
19  
3 office 20 #region Private Delegates, Events, Enums, Properties, Indexers and Fields
21  
11 office 22 private Point _displayLocation;
23  
3 office 24 private Image _image;
25  
26 #endregion
27  
1 office 28 #region Constructors, Destructors and Finalizers
29  
11 office 30 public NotificationForm()
1 office 31 {
32 InitializeComponent();
33 }
34  
12 office 35 public NotificationForm(int index, Image image, Stream sound, string title, string text, int milliseconds) :
36 this()
1 office 37 {
12 office 38 Index = index;
3 office 39 _image = image;
40  
1 office 41 pictureBox1.InvokeIfRequired(pictureBox => { pictureBox.Image = image; });
42  
43 richTextBox2.InvokeIfRequired(richTextBox => { richTextBox.Text = title; });
44 richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = text; });
45  
12 office 46 using (var soundPlayer = new SoundPlayer(sound))
47 {
48 soundPlayer.Play();
49 }
50  
1 office 51 Task.Delay(milliseconds).ContinueWith(task =>
3 office 52 this.InvokeIfRequired(form => { form.Close(); }));
1 office 53 }
54  
3 office 55 /// <summary>
56 /// Clean up any resources being used.
57 /// </summary>
58 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
59 protected override void Dispose(bool disposing)
60 {
61 if (disposing && components != null)
62 {
63 if (_image != null)
64 {
65 _image.Dispose();
66 _image = null;
67 }
68  
69 components.Dispose();
70 }
71  
72 base.Dispose(disposing);
73 }
74  
1 office 75 #endregion
76  
77 #region Private Overrides
78  
10 office 79 protected override bool ShowWithoutActivation => true;
80  
1 office 81 protected override void OnLoad(EventArgs e)
82 {
11 office 83 Location = _displayLocation;
1 office 84 base.OnLoad(e);
85 }
86  
87 #endregion
88  
89 #region Event Handlers
90  
91 private void PictureBox2_Click(object sender, EventArgs e)
92 {
93 this.InvokeIfRequired(form => { form.Close(); });
94 }
95  
3 office 96 private void NotificationForm_FormClosing(object sender, FormClosingEventArgs e)
97 {
98 if (_image != null)
99 {
100 _image.Dispose();
101 _image = null;
102 }
103 }
104  
9 office 105 private void RichTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
106 {
107 Process.Start(e.LinkText);
108 }
109  
110 private void RichTextBox2_LinkClicked(object sender, LinkClickedEventArgs e)
111 {
112 Process.Start(e.LinkText);
113 }
114  
1 office 115 #endregion
11 office 116  
117 #region Public Methods
118  
119 public void UpdateLocation(int x, int y)
120 {
121 _displayLocation = new Point(x, y);
122 }
123  
124 #endregion
1 office 125 }
126 }