From e4d6c82ef64faee297dc98470af5f815a466efe1 Mon Sep 17 00:00:00 2001 From: gamosoft_cp Date: Wed, 1 May 2013 20:22:27 +0000 Subject: [PATCH] Added setting to enable/disable email notifications --- .../AppointmentsControl.Designer.cs | 20 ++++++++++++++++--- Outlook2013TodoAddIn/AppointmentsControl.cs | 20 ++++++++++++++++++- .../Properties/Settings.Designer.cs | 12 +++++++++++ .../Properties/Settings.settings | 3 +++ Outlook2013TodoAddIn/ThisAddIn.cs | 4 ++-- Outlook2013TodoAddIn/app.config | 3 +++ 6 files changed, 56 insertions(+), 6 deletions(-) diff --git a/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs b/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs index b617820..e634d8a 100644 --- a/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs +++ b/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs @@ -40,6 +40,7 @@ this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.grpRefresh = new System.Windows.Forms.GroupBox(); this.apptCalendar = new Outlook2013TodoAddIn.CustomCalendar(); + this.chkMailAlerts = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.numRangeDays)).BeginInit(); this.ctxMenuAppointments.SuspendLayout(); this.panel1.SuspendLayout(); @@ -124,11 +125,11 @@ this.listView1.Font = new System.Drawing.Font("Segoe UI", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.listView1.FullRowSelect = true; this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.listView1.Location = new System.Drawing.Point(0, 308); + this.listView1.Location = new System.Drawing.Point(0, 334); this.listView1.MultiSelect = false; this.listView1.Name = "listView1"; this.listView1.ShowItemToolTips = true; - this.listView1.Size = new System.Drawing.Size(226, 507); + this.listView1.Size = new System.Drawing.Size(226, 481); this.listView1.TabIndex = 4; this.listView1.TileSize = new System.Drawing.Size(300, 38); this.listView1.UseCompatibleStateImageBehavior = false; @@ -147,13 +148,14 @@ // // grpRefresh // + this.grpRefresh.Controls.Add(this.chkMailAlerts); this.grpRefresh.Controls.Add(this.btnRefresh); this.grpRefresh.Controls.Add(this.lblRangeDays); this.grpRefresh.Controls.Add(this.numRangeDays); this.grpRefresh.Dock = System.Windows.Forms.DockStyle.Top; this.grpRefresh.Location = new System.Drawing.Point(0, 242); this.grpRefresh.Name = "grpRefresh"; - this.grpRefresh.Size = new System.Drawing.Size(226, 66); + this.grpRefresh.Size = new System.Drawing.Size(226, 92); this.grpRefresh.TabIndex = 3; this.grpRefresh.TabStop = false; this.grpRefresh.Text = "Configuration:"; @@ -181,6 +183,17 @@ this.apptCalendar.CellDoubleClick += new System.EventHandler(this.apptCalendar_CellDoubleClick); this.apptCalendar.SelectedDateChanged += new System.EventHandler(this.apptCalendar_SelectedDateChanged); // + // chkMailAlerts + // + this.chkMailAlerts.AutoSize = true; + this.chkMailAlerts.Location = new System.Drawing.Point(36, 63); + this.chkMailAlerts.Name = "chkMailAlerts"; + this.chkMailAlerts.Size = new System.Drawing.Size(140, 23); + this.chkMailAlerts.TabIndex = 5; + this.chkMailAlerts.Text = "Enable Mail Alerts"; + this.chkMailAlerts.UseVisualStyleBackColor = true; + this.chkMailAlerts.CheckedChanged += new System.EventHandler(this.chkMailAlerts_CheckedChanged); + // // AppointmentsControl // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); @@ -211,6 +224,7 @@ private System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.ColumnHeader columnHeader2; private System.Windows.Forms.GroupBox grpRefresh; + private System.Windows.Forms.CheckBox chkMailAlerts; } diff --git a/Outlook2013TodoAddIn/AppointmentsControl.cs b/Outlook2013TodoAddIn/AppointmentsControl.cs index a9e057a..3da92eb 100644 --- a/Outlook2013TodoAddIn/AppointmentsControl.cs +++ b/Outlook2013TodoAddIn/AppointmentsControl.cs @@ -31,6 +31,15 @@ namespace Outlook2013TodoAddIn set { this.numRangeDays.Value = value; } } + /// + /// Gets/sets whether mail notifications are enabled or not + /// + public bool MailAlertsEnabled + { + get { return this.chkMailAlerts.Checked; } + set { this.chkMailAlerts.Checked = value; } + } + #endregion "Properties" #region "Methods" @@ -74,6 +83,16 @@ namespace Outlook2013TodoAddIn this.RetrieveAppointments(); } + /// + /// Enables/disables email notifications + /// + /// Sender + /// EventArgs + private void chkMailAlerts_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.MailAlertsEnabled = this.chkMailAlerts.Checked; + } + /// /// Retrieve all appointments for the current configurations /// @@ -298,6 +317,5 @@ namespace Outlook2013TodoAddIn } #endregion "Methods" - } } \ No newline at end of file diff --git a/Outlook2013TodoAddIn/Properties/Settings.Designer.cs b/Outlook2013TodoAddIn/Properties/Settings.Designer.cs index 0e5eb8d..f3e62de 100644 --- a/Outlook2013TodoAddIn/Properties/Settings.Designer.cs +++ b/Outlook2013TodoAddIn/Properties/Settings.Designer.cs @@ -70,5 +70,17 @@ namespace Outlook2013TodoAddIn.Properties { this["DisplayTimeOut"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool MailAlertsEnabled { + get { + return ((bool)(this["MailAlertsEnabled"])); + } + set { + this["MailAlertsEnabled"] = value; + } + } } } diff --git a/Outlook2013TodoAddIn/Properties/Settings.settings b/Outlook2013TodoAddIn/Properties/Settings.settings index 32a3d2f..318b188 100644 --- a/Outlook2013TodoAddIn/Properties/Settings.settings +++ b/Outlook2013TodoAddIn/Properties/Settings.settings @@ -14,5 +14,8 @@ 6000 + + True + \ No newline at end of file diff --git a/Outlook2013TodoAddIn/ThisAddIn.cs b/Outlook2013TodoAddIn/ThisAddIn.cs index a0c852e..312aace 100644 --- a/Outlook2013TodoAddIn/ThisAddIn.cs +++ b/Outlook2013TodoAddIn/ThisAddIn.cs @@ -39,6 +39,7 @@ namespace Outlook2013TodoAddIn this.AddRegistryNotification(); this.AppControl = new AppointmentsControl(); + this.AppControl.MailAlertsEnabled = Properties.Settings.Default.MailAlertsEnabled; this.AppControl.NumDays = Properties.Settings.Default.NumDays; // Setting the value will load the appointments this.AppControl.RetrieveAppointments(); @@ -61,8 +62,7 @@ namespace Outlook2013TodoAddIn /// ID of the email private void Application_NewMailEx(string EntryIDCollection) { - // TODO: Make this optional, still hook the event as this setting will be able to be enabled/disabled by user - if (true) + if (Properties.Settings.Default.MailAlertsEnabled) { Microsoft.Office.Interop.Outlook.MailItem newMail = Globals.ThisAddIn.Application.Session.GetItemFromID(EntryIDCollection) as Microsoft.Office.Interop.Outlook.MailItem; diff --git a/Outlook2013TodoAddIn/app.config b/Outlook2013TodoAddIn/app.config index cc147bb..0b513ed 100644 --- a/Outlook2013TodoAddIn/app.config +++ b/Outlook2013TodoAddIn/app.config @@ -19,6 +19,9 @@ 6000 + + True +