Winify – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using System; |
2 | using System.ComponentModel; |
||
3 | using System.Configuration; |
||
4 | using System.Windows.Forms; |
||
5 | using AutoUpdaterDotNET; |
||
6 | using Winify.Gotify; |
||
7 | using Winify.Properties; |
||
8 | |||
9 | namespace Winify |
||
10 | { |
||
11 | public partial class Form1 : Form |
||
12 | { |
||
13 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
||
14 | |||
15 | private AboutForm _aboutForm; |
||
16 | |||
17 | private GotifyConnection _gotifyConnection; |
||
18 | |||
19 | private NotificationForm _notificationForm; |
||
20 | |||
21 | private SettingsForm _settingsForm; |
||
22 | |||
23 | #endregion |
||
24 | |||
25 | #region Constructors, Destructors and Finalizers |
||
26 | |||
27 | public Form1() |
||
28 | { |
||
29 | InitializeComponent(); |
||
30 | |||
31 | AutoUpdater.Start("http://winify.grimore.org/update/winify.xml"); |
||
32 | |||
33 | // Upgrade settings if required. |
||
34 | if (!ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).HasFile) |
||
35 | { |
||
36 | Settings.Default.Upgrade(); |
||
37 | } |
||
38 | |||
39 | // Bind to settings changed event. |
||
40 | Settings.Default.SettingsLoaded += Default_SettingsLoaded; |
||
41 | Settings.Default.SettingsSaving += Default_SettingsSaving; |
||
42 | Settings.Default.PropertyChanged += Default_PropertyChanged; |
||
43 | |||
44 | Settings.Default.PropertyChanged += Default_PropertyChanged1; |
||
45 | |||
46 | _gotifyConnection = new GotifyConnection(); |
||
47 | _gotifyConnection.GotifyNotification += GotifyConnection_GotifyNotification; |
||
48 | _gotifyConnection.Start(Settings.Default.Username, Settings.Default.Password, Settings.Default.Host, |
||
49 | Settings.Default.Port); |
||
50 | } |
||
51 | |||
52 | /// <summary> |
||
53 | /// Clean up any resources being used. |
||
54 | /// </summary> |
||
55 | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
||
56 | protected override void Dispose(bool disposing) |
||
57 | { |
||
58 | if (disposing && components != null) |
||
59 | { |
||
60 | _gotifyConnection.GotifyNotification -= GotifyConnection_GotifyNotification; |
||
61 | |||
62 | components.Dispose(); |
||
63 | } |
||
64 | |||
65 | base.Dispose(disposing); |
||
66 | } |
||
67 | |||
68 | #endregion |
||
69 | |||
70 | #region Event Handlers |
||
71 | |||
72 | private void GotifyConnection_GotifyNotification(object sender, GotifyNotificationEventArgs e) |
||
73 | { |
||
74 | _notificationForm = new NotificationForm(e.Image, e.Notification.Title, e.Notification.Message, 5000); |
||
75 | _notificationForm.Show(); |
||
76 | } |
||
77 | |||
78 | private void Default_PropertyChanged1(object sender, PropertyChangedEventArgs e) |
||
79 | { |
||
3 | office | 80 | if (_gotifyConnection != null) |
81 | { |
||
82 | _gotifyConnection.GotifyNotification -= GotifyConnection_GotifyNotification; |
||
83 | _gotifyConnection.Stop(); |
||
84 | _gotifyConnection.Dispose(); |
||
85 | _gotifyConnection = null; |
||
86 | } |
||
1 | office | 87 | |
88 | _gotifyConnection = new GotifyConnection(); |
||
89 | _gotifyConnection.GotifyNotification += GotifyConnection_GotifyNotification; |
||
90 | _gotifyConnection.Start(Settings.Default.Username, Settings.Default.Password, Settings.Default.Host, |
||
91 | Settings.Default.Port); |
||
92 | } |
||
93 | |||
94 | private static void Default_PropertyChanged(object sender, PropertyChangedEventArgs e) |
||
95 | { |
||
96 | Settings.Default.Save(); |
||
97 | } |
||
98 | |||
99 | private static void Default_SettingsSaving(object sender, CancelEventArgs e) |
||
100 | { |
||
101 | } |
||
102 | |||
103 | private static void Default_SettingsLoaded(object sender, SettingsLoadedEventArgs e) |
||
104 | { |
||
105 | } |
||
106 | |||
107 | private void SettingsToolStripMenuItem_Click(object sender, EventArgs e) |
||
108 | { |
||
109 | if (_settingsForm != null) |
||
110 | { |
||
111 | return; |
||
112 | } |
||
113 | |||
114 | _settingsForm = new SettingsForm(); |
||
115 | _settingsForm.Closing += SettingsForm_Closing; |
||
116 | ; |
||
117 | _settingsForm.Show(); |
||
118 | } |
||
119 | |||
120 | private void SettingsForm_Closing(object sender, CancelEventArgs e) |
||
121 | { |
||
122 | if (_aboutForm == null) |
||
123 | { |
||
124 | return; |
||
125 | } |
||
126 | |||
127 | _settingsForm.Closing -= SettingsForm_Closing; |
||
128 | _settingsForm.Dispose(); |
||
129 | _settingsForm = null; |
||
130 | } |
||
131 | |||
132 | private void AboutToolStripMenuItem_Click(object sender, EventArgs e) |
||
133 | { |
||
134 | if (_aboutForm != null) |
||
135 | { |
||
136 | return; |
||
137 | } |
||
138 | |||
139 | _aboutForm = new AboutForm(); |
||
140 | _aboutForm.Closing += AboutForm_Closing; |
||
141 | _aboutForm.Show(); |
||
142 | } |
||
143 | |||
144 | private void AboutForm_Closing(object sender, CancelEventArgs e) |
||
145 | { |
||
146 | if (_aboutForm == null) |
||
147 | { |
||
148 | return; |
||
149 | } |
||
150 | |||
151 | _aboutForm.Closing -= AboutForm_Closing; |
||
152 | _aboutForm.Dispose(); |
||
153 | _aboutForm = null; |
||
154 | } |
||
155 | |||
156 | private void QuitToolStripMenuItem_Click(object sender, EventArgs e) |
||
157 | { |
||
158 | Application.Exit(); |
||
159 | } |
||
160 | |||
161 | #endregion |
||
162 | } |
||
163 | } |