Added setting to enable/disable email notifications

This commit is contained in:
gamosoft_cp 2013-05-01 20:22:27 +00:00
parent 614e17605b
commit e4d6c82ef6
6 changed files with 56 additions and 6 deletions

View File

@ -40,6 +40,7 @@
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.grpRefresh = new System.Windows.Forms.GroupBox(); this.grpRefresh = new System.Windows.Forms.GroupBox();
this.apptCalendar = new Outlook2013TodoAddIn.CustomCalendar(); this.apptCalendar = new Outlook2013TodoAddIn.CustomCalendar();
this.chkMailAlerts = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.numRangeDays)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numRangeDays)).BeginInit();
this.ctxMenuAppointments.SuspendLayout(); this.ctxMenuAppointments.SuspendLayout();
this.panel1.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.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.FullRowSelect = true;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; 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.MultiSelect = false;
this.listView1.Name = "listView1"; this.listView1.Name = "listView1";
this.listView1.ShowItemToolTips = true; 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.TabIndex = 4;
this.listView1.TileSize = new System.Drawing.Size(300, 38); this.listView1.TileSize = new System.Drawing.Size(300, 38);
this.listView1.UseCompatibleStateImageBehavior = false; this.listView1.UseCompatibleStateImageBehavior = false;
@ -147,13 +148,14 @@
// //
// grpRefresh // grpRefresh
// //
this.grpRefresh.Controls.Add(this.chkMailAlerts);
this.grpRefresh.Controls.Add(this.btnRefresh); this.grpRefresh.Controls.Add(this.btnRefresh);
this.grpRefresh.Controls.Add(this.lblRangeDays); this.grpRefresh.Controls.Add(this.lblRangeDays);
this.grpRefresh.Controls.Add(this.numRangeDays); this.grpRefresh.Controls.Add(this.numRangeDays);
this.grpRefresh.Dock = System.Windows.Forms.DockStyle.Top; this.grpRefresh.Dock = System.Windows.Forms.DockStyle.Top;
this.grpRefresh.Location = new System.Drawing.Point(0, 242); this.grpRefresh.Location = new System.Drawing.Point(0, 242);
this.grpRefresh.Name = "grpRefresh"; 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.TabIndex = 3;
this.grpRefresh.TabStop = false; this.grpRefresh.TabStop = false;
this.grpRefresh.Text = "Configuration:"; this.grpRefresh.Text = "Configuration:";
@ -181,6 +183,17 @@
this.apptCalendar.CellDoubleClick += new System.EventHandler(this.apptCalendar_CellDoubleClick); this.apptCalendar.CellDoubleClick += new System.EventHandler(this.apptCalendar_CellDoubleClick);
this.apptCalendar.SelectedDateChanged += new System.EventHandler(this.apptCalendar_SelectedDateChanged); 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 // AppointmentsControl
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
@ -211,6 +224,7 @@
private System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2; private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.GroupBox grpRefresh; private System.Windows.Forms.GroupBox grpRefresh;
private System.Windows.Forms.CheckBox chkMailAlerts;
} }

View File

@ -31,6 +31,15 @@ namespace Outlook2013TodoAddIn
set { this.numRangeDays.Value = value; } set { this.numRangeDays.Value = value; }
} }
/// <summary>
/// Gets/sets whether mail notifications are enabled or not
/// </summary>
public bool MailAlertsEnabled
{
get { return this.chkMailAlerts.Checked; }
set { this.chkMailAlerts.Checked = value; }
}
#endregion "Properties" #endregion "Properties"
#region "Methods" #region "Methods"
@ -74,6 +83,16 @@ namespace Outlook2013TodoAddIn
this.RetrieveAppointments(); this.RetrieveAppointments();
} }
/// <summary>
/// Enables/disables email notifications
/// </summary>
/// <param name="sender">Sender</param>
/// <param name="e">EventArgs</param>
private void chkMailAlerts_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.MailAlertsEnabled = this.chkMailAlerts.Checked;
}
/// <summary> /// <summary>
/// Retrieve all appointments for the current configurations /// Retrieve all appointments for the current configurations
/// </summary> /// </summary>
@ -298,6 +317,5 @@ namespace Outlook2013TodoAddIn
} }
#endregion "Methods" #endregion "Methods"
} }
} }

View File

@ -70,5 +70,17 @@ namespace Outlook2013TodoAddIn.Properties {
this["DisplayTimeOut"] = value; 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;
}
}
} }
} }

View File

@ -14,5 +14,8 @@
<Setting Name="DisplayTimeOut" Type="System.Int32" Scope="User"> <Setting Name="DisplayTimeOut" Type="System.Int32" Scope="User">
<Value Profile="(Default)">6000</Value> <Value Profile="(Default)">6000</Value>
</Setting> </Setting>
<Setting Name="MailAlertsEnabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -39,6 +39,7 @@ namespace Outlook2013TodoAddIn
this.AddRegistryNotification(); this.AddRegistryNotification();
this.AppControl = new AppointmentsControl(); 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.NumDays = Properties.Settings.Default.NumDays; // Setting the value will load the appointments
this.AppControl.RetrieveAppointments(); this.AppControl.RetrieveAppointments();
@ -61,8 +62,7 @@ namespace Outlook2013TodoAddIn
/// <param name="EntryIDCollection">ID of the email</param> /// <param name="EntryIDCollection">ID of the email</param>
private void Application_NewMailEx(string EntryIDCollection) 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 (Properties.Settings.Default.MailAlertsEnabled)
if (true)
{ {
Microsoft.Office.Interop.Outlook.MailItem newMail = Globals.ThisAddIn.Application.Session.GetItemFromID(EntryIDCollection) as Microsoft.Office.Interop.Outlook.MailItem; Microsoft.Office.Interop.Outlook.MailItem newMail = Globals.ThisAddIn.Application.Session.GetItemFromID(EntryIDCollection) as Microsoft.Office.Interop.Outlook.MailItem;

View File

@ -19,6 +19,9 @@
<setting name="DisplayTimeOut" serializeAs="String"> <setting name="DisplayTimeOut" serializeAs="String">
<value>6000</value> <value>6000</value>
</setting> </setting>
<setting name="MailAlertsEnabled" serializeAs="String">
<value>True</value>
</setting>
</Outlook2013TodoAddIn.Properties.Settings> </Outlook2013TodoAddIn.Properties.Settings>
</userSettings> </userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>