Initial check-in with email notification showing up for 5 seconds

This commit is contained in:
gamosoft_cp 2013-04-01 16:03:41 +00:00
parent 35a65fc9bb
commit e27556cc8e
6 changed files with 154 additions and 52 deletions

View File

@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Outlook2013TodoAddIn", "Outlook2013TodoAddIn\Outlook2013TodoAddIn.csproj", "{EF0CD4A2-56E1-4C98-BE40-ED2D969F16A8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2FFBC2F9-1F58-40E6-8901-9853C61020E6}"
EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2

View File

@ -12,8 +12,7 @@ namespace Outlook2013TodoAddIn
public partial class AppointmentsControl : UserControl
{
#region "Variables"
/// <summary>
/// <summary>
/// Used to retrieve the email address of a contact
/// </summary>
@ -73,6 +72,14 @@ 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

@ -28,48 +28,29 @@
/// </summary>
private void InitializeComponent()
{
this.lblSender = new System.Windows.Forms.Label();
this.lblSubject = new System.Windows.Forms.Label();
this.txtBody = new System.Windows.Forms.TextBox();
this.btnDelete = new System.Windows.Forms.Button();
this.btnFlag = new System.Windows.Forms.Button();
this.btnEnvelope = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.lnkSender = new System.Windows.Forms.LinkLabel();
this.lnkSubject = new System.Windows.Forms.LinkLabel();
this.SuspendLayout();
//
// lblSender
//
this.lblSender.AutoSize = true;
this.lblSender.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblSender.Location = new System.Drawing.Point(85, 11);
this.lblSender.Name = "lblSender";
this.lblSender.Size = new System.Drawing.Size(52, 17);
this.lblSender.TabIndex = 0;
this.lblSender.Text = "label1";
//
// lblSubject
//
this.lblSubject.AutoSize = true;
this.lblSubject.Location = new System.Drawing.Point(85, 28);
this.lblSubject.Name = "lblSubject";
this.lblSubject.Size = new System.Drawing.Size(46, 17);
this.lblSubject.TabIndex = 1;
this.lblSubject.Text = "label1";
//
// txtBody
//
this.txtBody.Location = new System.Drawing.Point(88, 49);
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(214, 77);
this.txtBody.Size = new System.Drawing.Size(285, 51);
this.txtBody.TabIndex = 2;
//
// btnDelete
//
this.btnDelete.BackgroundImage = global::Outlook2013TodoAddIn.Properties.Resources.Delete;
this.btnDelete.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.btnDelete.Location = new System.Drawing.Point(50, 94);
this.btnDelete.Location = new System.Drawing.Point(50, 66);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(32, 32);
this.btnDelete.TabIndex = 6;
@ -80,7 +61,7 @@
//
this.btnFlag.BackgroundImage = global::Outlook2013TodoAddIn.Properties.Resources.Flag;
this.btnFlag.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.btnFlag.Location = new System.Drawing.Point(12, 94);
this.btnFlag.Location = new System.Drawing.Point(12, 66);
this.btnFlag.Name = "btnFlag";
this.btnFlag.Size = new System.Drawing.Size(32, 32);
this.btnFlag.TabIndex = 5;
@ -91,7 +72,7 @@
//
this.btnEnvelope.BackgroundImage = global::Outlook2013TodoAddIn.Properties.Resources.Envelope;
this.btnEnvelope.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.btnEnvelope.Location = new System.Drawing.Point(16, 17);
this.btnEnvelope.Location = new System.Drawing.Point(19, 5);
this.btnEnvelope.Name = "btnEnvelope";
this.btnEnvelope.Size = new System.Drawing.Size(60, 60);
this.btnEnvelope.TabIndex = 8;
@ -102,32 +83,57 @@
//
this.btnClose.BackgroundImage = global::Outlook2013TodoAddIn.Properties.Resources.Delete;
this.btnClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.btnClose.Location = new System.Drawing.Point(282, 8);
this.btnClose.Location = new System.Drawing.Point(353, 8);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(20, 20);
this.btnClose.TabIndex = 9;
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// lnkSender
//
this.lnkSender.AutoSize = true;
this.lnkSender.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lnkSender.Location = new System.Drawing.Point(85, 5);
this.lnkSender.Name = "lnkSender";
this.lnkSender.Size = new System.Drawing.Size(82, 17);
this.lnkSender.TabIndex = 10;
this.lnkSender.TabStop = true;
this.lnkSender.Text = "linkLabel1";
this.lnkSender.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkSender_LinkClicked);
//
// lnkSubject
//
this.lnkSubject.AutoSize = true;
this.lnkSubject.Location = new System.Drawing.Point(85, 27);
this.lnkSubject.Name = "lnkSubject";
this.lnkSubject.Size = new System.Drawing.Size(72, 17);
this.lnkSubject.TabIndex = 11;
this.lnkSubject.TabStop = true;
this.lnkSubject.Text = "linkLabel2";
this.lnkSubject.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkSubject_LinkClicked);
//
// NewMailAlert
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(314, 140);
this.ClientSize = new System.Drawing.Size(385, 100);
this.Controls.Add(this.lnkSubject);
this.Controls.Add(this.lnkSender);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnEnvelope);
this.Controls.Add(this.btnDelete);
this.Controls.Add(this.btnFlag);
this.Controls.Add(this.txtBody);
this.Controls.Add(this.lblSubject);
this.Controls.Add(this.lblSender);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "NewMailAlert";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "NewMailAlert";
this.TopMost = true;
this.ResumeLayout(false);
this.PerformLayout();
@ -135,12 +141,12 @@
#endregion
private System.Windows.Forms.Label lblSender;
private System.Windows.Forms.Label lblSubject;
private System.Windows.Forms.TextBox txtBody;
private System.Windows.Forms.Button btnFlag;
private System.Windows.Forms.Button btnDelete;
private System.Windows.Forms.Button btnEnvelope;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.LinkLabel lnkSender;
private System.Windows.Forms.LinkLabel lnkSubject;
}
}

View File

@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@ -12,14 +13,45 @@ namespace Outlook2013TodoAddIn
{
public partial class NewMailAlert : Form
{
private Timer timer;
private bool mouseIsOver = false;
public Microsoft.Office.Interop.Outlook.MailItem Email { get; set; }
public NewMailAlert(string sender, string subject, string body)
public NewMailAlert(string sender, string subject, string body, int interval)
{
InitializeComponent();
this.lblSender.Text = sender;
this.lblSubject.Text = subject;
this.lnkSender.Text = sender;
this.lnkSubject.Text = subject;
this.txtBody.Text = body;
this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width - 10;
this.Top = Screen.PrimaryScreen.WorkingArea.Height - this.Height - 10;
this.timer = new Timer();
timer.Interval = interval;
timer.Tick += timer_Tick;
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)
@ -38,13 +70,68 @@ namespace Outlook2013TodoAddIn
private void btnEnvelope_Click(object sender, EventArgs e)
{
this.Email.Display();
this.Close();
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();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal;
}
this.Focus();
this.BringToFront();
}
private void timer_Tick(object sender, EventArgs e)
{
if (!mouseIsOver)
{
timer.Stop();
this.Close();
}
}
//protected override void OnMouseEnter(EventArgs ea)
//{
// base.OnMouseEnter(ea);
// Point clientPos = PointToClient(Cursor.Position);
// if (!ClientRectangle.Contains(clientPos))
// {
// mouseIsOver = true;
// }
//}
//protected override void OnMouseLeave(EventArgs ea)
//{
// base.OnMouseLeave(ea);
// Point clientPos = PointToClient(Cursor.Position);
// if (!ClientRectangle.Contains(clientPos))
// {
// mouseIsOver = false;
// }
//}
}
}

View File

@ -45,6 +45,10 @@
<FriendlyName>Outlook2013TodoAddIn</FriendlyName>
<OfficeApplicationDescription />
<LoadBehavior>3</LoadBehavior>
<SccProjectName>%24/outlook2013addin/Outlook2013TodoAddIn</SccProjectName>
<SccLocalPath>.</SccLocalPath>
<SccAuxPath>https://tfs.codeplex.com/tfs/tfs04</SccAuxPath>
<SccProvider>{4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}</SccProvider>
</PropertyGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
@ -178,7 +182,9 @@
can be found.
-->
<ItemGroup>
<Compile Include="DoubleClickMonthCalendar.cs" />
<Compile Include="DoubleClickMonthCalendar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FormRecurringOpen.cs">
<SubType>Form</SubType>
</Compile>

View File

@ -1,5 +1,6 @@
using Microsoft.Win32;
using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Office = Microsoft.Office.Core;
@ -62,18 +63,11 @@ namespace Outlook2013TodoAddIn
string sender = newMail.Sender.Name;
string subject = newMail.Subject;
string body = newMail.Body;
NewMailAlert nm = new NewMailAlert(sender, subject, body);
NewMailAlert nm = new NewMailAlert(sender, subject, body, 5000);
nm.Email = newMail;
nm.Top = 0;
nm.Left = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - nm.Width;
// this.Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
nm.Show();
if (nm.WindowState == FormWindowState.Minimized)
{
nm.WindowState = FormWindowState.Normal;
}
nm.Focus();
nm.BringToFront();
// nm.Show();
// Show the popup without stealing focus
nm.ShowPopup();
}
}