Moved images into a folder, added comments, fixed minor issues after refactoring mail alert

This commit is contained in:
gamosoft_cp 2013-04-01 17:35:28 +00:00
parent b9b4e2ea6f
commit ec14f133fe
13 changed files with 213 additions and 107 deletions

View File

@ -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();
}
/// <summary>

View File

Before

Width:  |  Height:  |  Size: 321 B

After

Width:  |  Height:  |  Size: 321 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -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
//

View File

@ -11,19 +11,66 @@ using System.Windows.Forms;
namespace Outlook2013TodoAddIn
{
/// <summary>
/// New form to display new emai lnotifications
/// </summary>
public partial class NewMailAlert : Form
{
#region "Variables"
/// <summary>
/// To control how long the form displays
/// </summary>
private Timer timer;
/// <summary>
/// Don't close the for if the mouse is over it
/// </summary>
private bool mouseIsOver = false;
/// <summary>
/// Show form
/// </summary>
private const int SW_SHOW = 5;
/// <summary>
/// Fading effect
/// </summary>
private const uint AW_BLEND = 0x00080000;
#endregion "Variables"
#region "Properties"
/// <summary>
/// Attached email message to open or flag
/// </summary>
public Microsoft.Office.Interop.Outlook.MailItem Email { get; set; }
public NewMailAlert(string sender, string subject, string body, int interval)
/// <summary>
/// Whether to show without the form activation
/// </summary>
protected override bool ShowWithoutActivation
{
get { return true; }
}
#endregion "Properties"
#region "Methods"
/// <summary>
/// Default constructor
/// </summary>
/// <param name="newMail">Mail item</param>
/// <param name="interval">Time in ms to keep the alert on</param>
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();
}
/// <summary>
/// Load and bring to fron
/// </summary>
/// <param name="e">EventArgs</param>
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);
/// <summary>
/// Method to display the form and make it topmost
/// </summary>
/// <returns>True or false</returns>
public bool ShowPopup()
{
bool result = ShowWindow(this.Handle, SW_SHOW);
//bool result = AnimateWindow(this.Handle, 200, AW_BLEND);
this.BringToFront();
return result;
}
/// <summary>
/// Button delete clicked
/// </summary>
/// <param name="sender">Sender</param>
/// <param name="e">EventArgs</param>
private void btnDelete_Click(object sender, EventArgs e)
{
this.Email.Delete();
this.Close();
}
/// <summary>
/// Button flag clicked
/// </summary>
/// <param name="sender">Sender</param>
/// <param name="e">EventArgs</param>
private void btnFlag_Click(object sender, EventArgs e)
{
//Microsoft.Office.Interop.Outlook.OlFlagIcon.olYellowFlagIcon
this.Email.FlagRequest = "Follow up";
this.Email.Save();
this.Close();
}
/// <summary>
/// Button envelope clicked
/// </summary>
/// <param name="sender">Sender</param>
/// <param name="e">EventArgs</param>
private void btnEnvelope_Click(object sender, EventArgs e)
{
this.ShowEmail();
}
/// <summary>
/// Button close clicked
/// </summary>
/// <param name="sender">Sender</param>
/// <param name="e">EventArgs</param>
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
/// Sender hyperlink clicked
/// </summary>
/// <param name="sender">Sender</param>
/// <param name="e">LinkLabelLinkClickedEventArgs</param>
private void lnkSender_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.ShowEmail();
}
/// <summary>
/// Subject hyperlink clicked
/// </summary>
/// <param name="sender">Sender</param>
/// <param name="e">LinkLabelLinkClickedEventArgs</param>
private void lnkSubject_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.ShowEmail();
}
/// <summary>
/// Body textbox clicked
/// </summary>
/// <param name="sender">Sender</param>
/// <param name="e">EventArgs</param>
private void txtBody_Click(object sender, EventArgs e)
{
this.ShowEmail();
}
/// <summary>
/// Show the email and close the form
/// </summary>
private void ShowEmail()
{
this.Email.Display();
this.Close();
}
/// <summary>
/// Process timer ticks
/// </summary>
/// <param name="sender">Sender</param>
/// <param name="e">EventArgs</param>
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;
// }
//}
/// <summary>
/// Processed when the mouse enters the form
/// </summary>
/// <param name="ea">EventArgs</param>
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;
// }
//}
/// <summary>
/// Processed when the mouse exits the form
/// </summary>
/// <param name="ea">EventArgs</param>
protected override void OnMouseLeave(EventArgs ea)
{
base.OnMouseLeave(ea);
Point mousePos = PointToClient(Cursor.Position);
mouseIsOver = ClientRectangle.Contains(mousePos);
}
#endregion "Methods"
}
}

View File

@ -38,7 +38,7 @@
<PublishUrl>publish\</PublishUrl>
<InstallUrl />
<TargetCulture>en</TargetCulture>
<ApplicationVersion>1.0.0.7</ApplicationVersion>
<ApplicationVersion>1.0.0.9</ApplicationVersion>
<AutoIncrementApplicationRevision>true</AutoIncrementApplicationRevision>
<UpdateEnabled>false</UpdateEnabled>
<UpdateInterval>0</UpdateInterval>
@ -257,16 +257,16 @@
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="2012-11-20_1546.png" />
<None Include="Images\2012-11-20_1546.png" />
</ItemGroup>
<ItemGroup>
<None Include="Delete.png" />
<None Include="Images\Delete.png" />
</ItemGroup>
<ItemGroup>
<None Include="Flag.png" />
<None Include="Images\Flag.png" />
</ItemGroup>
<ItemGroup>
<None Include="Envelope.png" />
<None Include="Images\Envelope.png" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

View File

@ -119,15 +119,15 @@
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Images\Delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Envelope" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Envelope.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Images\Envelope.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Flag" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Flag.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Images\Flag.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="todoIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\2012-11-20_1546.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Images\2012-11-20_1546.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -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;
}
}
}
}

View File

@ -11,5 +11,8 @@
<Setting Name="NumDays" Type="System.Decimal" Scope="User">
<Value Profile="(Default)">3</Value>
</Setting>
<Setting Name="DisplayTimeOut" Type="System.Int32" Scope="User">
<Value Profile="(Default)">5000</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -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();
}

View File

@ -16,6 +16,9 @@
<setting name="NumDays" serializeAs="String">
<value>3</value>
</setting>
<setting name="DisplayTimeOut" serializeAs="String">
<value>5000</value>
</setting>
</Outlook2013TodoAddIn.Properties.Settings>
</userSettings>
</configuration>