Winify – Blame information for rev 1

Subversion Repositories:
Rev:
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 {
80 _gotifyConnection.GotifyNotification -= GotifyConnection_GotifyNotification;
81 _gotifyConnection.Stop();
82 _gotifyConnection.Dispose();
83 _gotifyConnection = null;
84  
85 _gotifyConnection = new GotifyConnection();
86 _gotifyConnection.GotifyNotification += GotifyConnection_GotifyNotification;
87 _gotifyConnection.Start(Settings.Default.Username, Settings.Default.Password, Settings.Default.Host,
88 Settings.Default.Port);
89 }
90  
91 private static void Default_PropertyChanged(object sender, PropertyChangedEventArgs e)
92 {
93 Settings.Default.Save();
94 }
95  
96 private static void Default_SettingsSaving(object sender, CancelEventArgs e)
97 {
98 }
99  
100 private static void Default_SettingsLoaded(object sender, SettingsLoadedEventArgs e)
101 {
102 }
103  
104 private void SettingsToolStripMenuItem_Click(object sender, EventArgs e)
105 {
106 if (_settingsForm != null)
107 {
108 return;
109 }
110  
111 _settingsForm = new SettingsForm();
112 _settingsForm.Closing += SettingsForm_Closing;
113 ;
114 _settingsForm.Show();
115 }
116  
117 private void SettingsForm_Closing(object sender, CancelEventArgs e)
118 {
119 if (_aboutForm == null)
120 {
121 return;
122 }
123  
124 _settingsForm.Closing -= SettingsForm_Closing;
125 _settingsForm.Dispose();
126 _settingsForm = null;
127 }
128  
129 private void AboutToolStripMenuItem_Click(object sender, EventArgs e)
130 {
131 if (_aboutForm != null)
132 {
133 return;
134 }
135  
136 _aboutForm = new AboutForm();
137 _aboutForm.Closing += AboutForm_Closing;
138 _aboutForm.Show();
139 }
140  
141 private void AboutForm_Closing(object sender, CancelEventArgs e)
142 {
143 if (_aboutForm == null)
144 {
145 return;
146 }
147  
148 _aboutForm.Closing -= AboutForm_Closing;
149 _aboutForm.Dispose();
150 _aboutForm = null;
151 }
152  
153 private void QuitToolStripMenuItem_Click(object sender, EventArgs e)
154 {
155 Application.Exit();
156 }
157  
158 #endregion
159 }
160 }