2013-03-30 01:35:37 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
2013-04-01 18:03:41 +02:00
|
|
|
|
using System.Runtime.InteropServices;
|
2013-03-30 01:35:37 +01:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Outlook2013TodoAddIn
|
|
|
|
|
{
|
|
|
|
|
public partial class NewMailAlert : Form
|
|
|
|
|
{
|
2013-04-01 18:03:41 +02:00
|
|
|
|
private Timer timer;
|
|
|
|
|
private bool mouseIsOver = false;
|
|
|
|
|
|
2013-03-30 01:35:37 +01:00
|
|
|
|
public Microsoft.Office.Interop.Outlook.MailItem Email { get; set; }
|
|
|
|
|
|
2013-04-01 18:03:41 +02:00
|
|
|
|
public NewMailAlert(string sender, string subject, string body, int interval)
|
2013-03-30 01:35:37 +01:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2013-04-01 18:03:41 +02:00
|
|
|
|
this.lnkSender.Text = sender;
|
|
|
|
|
this.lnkSubject.Text = subject;
|
2013-03-30 01:35:37 +01:00
|
|
|
|
this.txtBody.Text = body;
|
2013-04-01 18:03:41 +02:00
|
|
|
|
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; }
|
2013-03-30 01:35:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2013-04-01 18:03:41 +02:00
|
|
|
|
this.ShowEmail();
|
2013-03-30 01:35:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
2013-04-01 18:03:41 +02:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2013-03-30 01:35:37 +01:00
|
|
|
|
}
|
|
|
|
|
}
|