diff --git a/Outlook2013TodoAddIn/AppointmentsControl.cs b/Outlook2013TodoAddIn/AppointmentsControl.cs index 1d4f572..3bc1f20 100644 --- a/Outlook2013TodoAddIn/AppointmentsControl.cs +++ b/Outlook2013TodoAddIn/AppointmentsControl.cs @@ -72,14 +72,6 @@ namespace Outlook2013TodoAddIn private void btnRefresh_Click(object sender, EventArgs e) { this.RetrieveAppointments(); - // Email alert tests - //string senderEmail = "pepe@hotmail.com"; - //string subject = "Subject of the email"; - //string body = "This is the body of the email"; - //NewMailAlert nm = new NewMailAlert(senderEmail, subject, body, 5000); - //nm.Email = null; - //// Show the popup without stealing focus - //nm.ShowPopup(); } /// diff --git a/Outlook2013TodoAddIn/2012-11-20_1546.png b/Outlook2013TodoAddIn/Images/2012-11-20_1546.png similarity index 100% rename from Outlook2013TodoAddIn/2012-11-20_1546.png rename to Outlook2013TodoAddIn/Images/2012-11-20_1546.png diff --git a/Outlook2013TodoAddIn/Delete.png b/Outlook2013TodoAddIn/Images/Delete.png similarity index 100% rename from Outlook2013TodoAddIn/Delete.png rename to Outlook2013TodoAddIn/Images/Delete.png diff --git a/Outlook2013TodoAddIn/Envelope.png b/Outlook2013TodoAddIn/Images/Envelope.png similarity index 100% rename from Outlook2013TodoAddIn/Envelope.png rename to Outlook2013TodoAddIn/Images/Envelope.png diff --git a/Outlook2013TodoAddIn/Flag.png b/Outlook2013TodoAddIn/Images/Flag.png similarity index 100% rename from Outlook2013TodoAddIn/Flag.png rename to Outlook2013TodoAddIn/Images/Flag.png diff --git a/Outlook2013TodoAddIn/NewMailAlert.Designer.cs b/Outlook2013TodoAddIn/NewMailAlert.Designer.cs index a4f3c80..51cfc81 100644 --- a/Outlook2013TodoAddIn/NewMailAlert.Designer.cs +++ b/Outlook2013TodoAddIn/NewMailAlert.Designer.cs @@ -39,12 +39,14 @@ // // txtBody // + this.txtBody.Cursor = System.Windows.Forms.Cursors.Hand; this.txtBody.Location = new System.Drawing.Point(88, 47); this.txtBody.Multiline = true; this.txtBody.Name = "txtBody"; this.txtBody.ReadOnly = true; this.txtBody.Size = new System.Drawing.Size(285, 51); this.txtBody.TabIndex = 2; + this.txtBody.Click += new System.EventHandler(this.txtBody_Click); // // btnDelete // diff --git a/Outlook2013TodoAddIn/NewMailAlert.cs b/Outlook2013TodoAddIn/NewMailAlert.cs index 88bd367..30ed6d1 100644 --- a/Outlook2013TodoAddIn/NewMailAlert.cs +++ b/Outlook2013TodoAddIn/NewMailAlert.cs @@ -11,19 +11,66 @@ using System.Windows.Forms; namespace Outlook2013TodoAddIn { + /// + /// New form to display new emai lnotifications + /// public partial class NewMailAlert : Form { + #region "Variables" + + /// + /// To control how long the form displays + /// private Timer timer; + + /// + /// Don't close the for if the mouse is over it + /// private bool mouseIsOver = false; + /// + /// Show form + /// + private const int SW_SHOW = 5; + + /// + /// Fading effect + /// + private const uint AW_BLEND = 0x00080000; + + #endregion "Variables" + + #region "Properties" + + /// + /// Attached email message to open or flag + /// public Microsoft.Office.Interop.Outlook.MailItem Email { get; set; } - public NewMailAlert(string sender, string subject, string body, int interval) + /// + /// Whether to show without the form activation + /// + protected override bool ShowWithoutActivation + { + get { return true; } + } + + #endregion "Properties" + + #region "Methods" + + /// + /// Default constructor + /// + /// Mail item + /// Time in ms to keep the alert on + public NewMailAlert(Microsoft.Office.Interop.Outlook.MailItem newMail, int interval) { InitializeComponent(); - this.lnkSender.Text = sender; - this.lnkSubject.Text = subject; - this.txtBody.Text = body; + this.Email = newMail; // Assign it to open or flag later + this.lnkSender.Text = newMail.Sender.Name; + this.lnkSubject.Text = newMail.Subject; + this.txtBody.Text = newMail.Body; this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width - 10; this.Top = Screen.PrimaryScreen.WorkingArea.Height - this.Height - 10; this.timer = new Timer(); @@ -32,68 +79,10 @@ namespace Outlook2013TodoAddIn timer.Start(); } - [DllImport("user32.dll")] - private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); - - [DllImport("user32.dll")] - private static extern bool AnimateWindow(IntPtr hWnd, uint dwTime, uint dwFlags); - - private const int SW_SHOW = 5; - private const uint AW_BLEND = 0x00080000; - - public bool ShowPopup() - { - bool result = ShowWindow(this.Handle, SW_SHOW); - //bool result = AnimateWindow(this.Handle, 200, AW_BLEND); - this.BringToFront(); - return result; - } - - protected override bool ShowWithoutActivation - { - get { return true; } - } - - private void btnDelete_Click(object sender, EventArgs e) - { - this.Email.Delete(); - this.Close(); - } - - private void btnFlag_Click(object sender, EventArgs e) - { - //Microsoft.Office.Interop.Outlook.OlFlagIcon.olYellowFlagIcon - this.Email.FlagRequest = "Follow up"; - this.Email.Save(); - this.Close(); - } - - private void btnEnvelope_Click(object sender, EventArgs e) - { - this.ShowEmail(); - } - - private void btnClose_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void ShowEmail() - { - this.Email.Display(); - this.Close(); - } - - private void lnkSender_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - this.ShowEmail(); - } - - private void lnkSubject_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - this.ShowEmail(); - } - + /// + /// Load and bring to fron + /// + /// EventArgs protected override void OnLoad(EventArgs e) { base.OnLoad(e); @@ -105,6 +94,112 @@ namespace Outlook2013TodoAddIn this.BringToFront(); } + [DllImport("user32.dll")] + private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); + + [DllImport("user32.dll")] + private static extern bool AnimateWindow(IntPtr hWnd, uint dwTime, uint dwFlags); + + /// + /// Method to display the form and make it topmost + /// + /// True or false + public bool ShowPopup() + { + bool result = ShowWindow(this.Handle, SW_SHOW); + //bool result = AnimateWindow(this.Handle, 200, AW_BLEND); + this.BringToFront(); + return result; + } + + /// + /// Button delete clicked + /// + /// Sender + /// EventArgs + private void btnDelete_Click(object sender, EventArgs e) + { + this.Email.Delete(); + this.Close(); + } + + /// + /// Button flag clicked + /// + /// Sender + /// EventArgs + private void btnFlag_Click(object sender, EventArgs e) + { + //Microsoft.Office.Interop.Outlook.OlFlagIcon.olYellowFlagIcon + this.Email.FlagRequest = "Follow up"; + this.Email.Save(); + this.Close(); + } + + /// + /// Button envelope clicked + /// + /// Sender + /// EventArgs + private void btnEnvelope_Click(object sender, EventArgs e) + { + this.ShowEmail(); + } + + /// + /// Button close clicked + /// + /// Sender + /// EventArgs + private void btnClose_Click(object sender, EventArgs e) + { + this.Close(); + } + + /// + /// Sender hyperlink clicked + /// + /// Sender + /// LinkLabelLinkClickedEventArgs + private void lnkSender_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + this.ShowEmail(); + } + + /// + /// Subject hyperlink clicked + /// + /// Sender + /// LinkLabelLinkClickedEventArgs + private void lnkSubject_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + this.ShowEmail(); + } + + /// + /// Body textbox clicked + /// + /// Sender + /// EventArgs + private void txtBody_Click(object sender, EventArgs e) + { + this.ShowEmail(); + } + + /// + /// Show the email and close the form + /// + private void ShowEmail() + { + this.Email.Display(); + this.Close(); + } + + /// + /// Process timer ticks + /// + /// Sender + /// EventArgs private void timer_Tick(object sender, EventArgs e) { if (!mouseIsOver) @@ -114,24 +209,28 @@ namespace Outlook2013TodoAddIn } } - //protected override void OnMouseEnter(EventArgs ea) - //{ - // base.OnMouseEnter(ea); - // Point clientPos = PointToClient(Cursor.Position); - // if (!ClientRectangle.Contains(clientPos)) - // { - // mouseIsOver = true; - // } - //} + /// + /// Processed when the mouse enters the form + /// + /// EventArgs + protected override void OnMouseEnter(EventArgs ea) + { + base.OnMouseEnter(ea); + Point mousePos = PointToClient(Cursor.Position); + mouseIsOver = ClientRectangle.Contains(mousePos); + } - //protected override void OnMouseLeave(EventArgs ea) - //{ - // base.OnMouseLeave(ea); - // Point clientPos = PointToClient(Cursor.Position); - // if (!ClientRectangle.Contains(clientPos)) - // { - // mouseIsOver = false; - // } - //} + /// + /// Processed when the mouse exits the form + /// + /// EventArgs + protected override void OnMouseLeave(EventArgs ea) + { + base.OnMouseLeave(ea); + Point mousePos = PointToClient(Cursor.Position); + mouseIsOver = ClientRectangle.Contains(mousePos); + } + + #endregion "Methods" } } \ No newline at end of file diff --git a/Outlook2013TodoAddIn/Outlook2013TodoAddIn.csproj b/Outlook2013TodoAddIn/Outlook2013TodoAddIn.csproj index 63dd9bd..7e4062a 100644 --- a/Outlook2013TodoAddIn/Outlook2013TodoAddIn.csproj +++ b/Outlook2013TodoAddIn/Outlook2013TodoAddIn.csproj @@ -38,7 +38,7 @@ publish\ en - 1.0.0.7 + 1.0.0.9 true false 0 @@ -257,16 +257,16 @@ - + - + - + - + 10.0 diff --git a/Outlook2013TodoAddIn/Properties/Resources.resx b/Outlook2013TodoAddIn/Properties/Resources.resx index 286d282..8969b27 100644 --- a/Outlook2013TodoAddIn/Properties/Resources.resx +++ b/Outlook2013TodoAddIn/Properties/Resources.resx @@ -119,15 +119,15 @@ - ..\Delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Images\Delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Envelope.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Images\Envelope.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Flag.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Images\Flag.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\2012-11-20_1546.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Images\2012-11-20_1546.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/Outlook2013TodoAddIn/Properties/Settings.Designer.cs b/Outlook2013TodoAddIn/Properties/Settings.Designer.cs index 3fd554d..c851434 100644 --- a/Outlook2013TodoAddIn/Properties/Settings.Designer.cs +++ b/Outlook2013TodoAddIn/Properties/Settings.Designer.cs @@ -58,5 +58,17 @@ namespace Outlook2013TodoAddIn.Properties { this["NumDays"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("5000")] + public int DisplayTimeOut { + get { + return ((int)(this["DisplayTimeOut"])); + } + set { + this["DisplayTimeOut"] = value; + } + } } } diff --git a/Outlook2013TodoAddIn/Properties/Settings.settings b/Outlook2013TodoAddIn/Properties/Settings.settings index 93b26d9..c8ce3ed 100644 --- a/Outlook2013TodoAddIn/Properties/Settings.settings +++ b/Outlook2013TodoAddIn/Properties/Settings.settings @@ -11,5 +11,8 @@ 3 + + 5000 + \ No newline at end of file diff --git a/Outlook2013TodoAddIn/ThisAddIn.cs b/Outlook2013TodoAddIn/ThisAddIn.cs index 7568d3e..25aba2a 100644 --- a/Outlook2013TodoAddIn/ThisAddIn.cs +++ b/Outlook2013TodoAddIn/ThisAddIn.cs @@ -60,12 +60,7 @@ namespace Outlook2013TodoAddIn Microsoft.Office.Interop.Outlook.MailItem newMail = Globals.ThisAddIn.Application.Session.GetItemFromID(EntryIDCollection) as Microsoft.Office.Interop.Outlook.MailItem; if (newMail != null) { - string sender = newMail.Sender.Name; - string subject = newMail.Subject; - string body = newMail.Body; - NewMailAlert nm = new NewMailAlert(sender, subject, body, 5000); - nm.Email = newMail; - // nm.Show(); + NewMailAlert nm = new NewMailAlert(newMail, Properties.Settings.Default.DisplayTimeOut); // Show the popup without stealing focus nm.ShowPopup(); } diff --git a/Outlook2013TodoAddIn/app.config b/Outlook2013TodoAddIn/app.config index 1dc6f0b..e9e77e9 100644 --- a/Outlook2013TodoAddIn/app.config +++ b/Outlook2013TodoAddIn/app.config @@ -16,6 +16,9 @@ 3 + + 5000 + \ No newline at end of file