diff --git a/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs b/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs
index 76fabda..49738ad 100644
--- a/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs
+++ b/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs
@@ -31,24 +31,24 @@
this.components = new System.ComponentModel.Container();
this.numRangeDays = new System.Windows.Forms.NumericUpDown();
this.lblRangeDays = new System.Windows.Forms.Label();
- this.apptCalendar = new Outlook2013TodoAddIn.DoubleClickMonthCalendar();
this.ctxMenuAppointments = new System.Windows.Forms.ContextMenuStrip(this.components);
this.mnuItemReplyAllEmail = new System.Windows.Forms.ToolStripMenuItem();
- this.hdrDate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.hdrSubject = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.listView1 = new System.Windows.Forms.ListView();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnRefresh = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
+ this.listView1 = new System.Windows.Forms.ListView();
+ this.columnHeader1 = ((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.apptCalendar = new Outlook2013TodoAddIn.CustomCalendar();
((System.ComponentModel.ISupportInitialize)(this.numRangeDays)).BeginInit();
this.ctxMenuAppointments.SuspendLayout();
- this.groupBox1.SuspendLayout();
this.panel1.SuspendLayout();
+ this.grpRefresh.SuspendLayout();
this.SuspendLayout();
//
// numRangeDays
//
- this.numRangeDays.Location = new System.Drawing.Point(60, 21);
+ this.numRangeDays.Location = new System.Drawing.Point(53, 28);
this.numRangeDays.Maximum = new decimal(new int[] {
15,
0,
@@ -60,7 +60,7 @@
0,
0});
this.numRangeDays.Name = "numRangeDays";
- this.numRangeDays.Size = new System.Drawing.Size(55, 22);
+ this.numRangeDays.Size = new System.Drawing.Size(48, 25);
this.numRangeDays.TabIndex = 2;
this.numRangeDays.Value = new decimal(new int[] {
3,
@@ -72,23 +72,12 @@
// lblRangeDays
//
this.lblRangeDays.AutoSize = true;
- this.lblRangeDays.Location = new System.Drawing.Point(10, 23);
+ this.lblRangeDays.Location = new System.Drawing.Point(10, 30);
this.lblRangeDays.Name = "lblRangeDays";
- this.lblRangeDays.Size = new System.Drawing.Size(44, 17);
+ this.lblRangeDays.Size = new System.Drawing.Size(42, 19);
this.lblRangeDays.TabIndex = 3;
this.lblRangeDays.Text = "Days:";
//
- // apptCalendar
- //
- this.apptCalendar.Dock = System.Windows.Forms.DockStyle.Top;
- this.apptCalendar.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.apptCalendar.Location = new System.Drawing.Point(0, 0);
- this.apptCalendar.MaxSelectionCount = 1;
- this.apptCalendar.Name = "apptCalendar";
- this.apptCalendar.TabIndex = 4;
- this.apptCalendar.DoubleClickEx += new System.EventHandler(this.apptCalendar_DoubleClickEx);
- this.apptCalendar.DateChanged += new System.Windows.Forms.DateRangeEventHandler(this.monthCalendar1_DateChanged);
- //
// ctxMenuAppointments
//
this.ctxMenuAppointments.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -103,54 +92,11 @@
this.mnuItemReplyAllEmail.Text = "Reply All With Email";
this.mnuItemReplyAllEmail.Click += new System.EventHandler(this.mnuItemReplyAllEmail_Click);
//
- // hdrDate
- //
- this.hdrDate.Text = "Date";
- this.hdrDate.Width = 78;
- //
- // hdrSubject
- //
- this.hdrSubject.Text = "Subject";
- this.hdrSubject.Width = 163;
- //
- // listView1
- //
- this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.hdrDate,
- this.hdrSubject});
- this.listView1.ContextMenuStrip = this.ctxMenuAppointments;
- this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.listView1.Font = new System.Drawing.Font("Calibri", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.listView1.FullRowSelect = true;
- this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
- this.listView1.Location = new System.Drawing.Point(0, 0);
- this.listView1.MultiSelect = false;
- this.listView1.Name = "listView1";
- this.listView1.ShowItemToolTips = true;
- this.listView1.Size = new System.Drawing.Size(289, 507);
- this.listView1.TabIndex = 0;
- this.listView1.UseCompatibleStateImageBehavior = false;
- this.listView1.View = System.Windows.Forms.View.Details;
- this.listView1.DoubleClick += new System.EventHandler(this.listView1_DoubleClick);
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.btnRefresh);
- this.groupBox1.Controls.Add(this.lblRangeDays);
- this.groupBox1.Controls.Add(this.numRangeDays);
- this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
- this.groupBox1.Location = new System.Drawing.Point(0, 207);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(289, 53);
- this.groupBox1.TabIndex = 7;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "Days:";
- //
// btnRefresh
//
- this.btnRefresh.Location = new System.Drawing.Point(162, 20);
+ this.btnRefresh.Location = new System.Drawing.Point(110, 28);
this.btnRefresh.Name = "btnRefresh";
- this.btnRefresh.Size = new System.Drawing.Size(75, 23);
+ this.btnRefresh.Size = new System.Drawing.Size(66, 24);
this.btnRefresh.TabIndex = 4;
this.btnRefresh.Text = "Refresh";
this.btnRefresh.UseVisualStyleBackColor = true;
@@ -159,26 +105,93 @@
// panel1
//
this.panel1.Controls.Add(this.listView1);
+ this.panel1.Controls.Add(this.grpRefresh);
+ this.panel1.Controls.Add(this.apptCalendar);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.panel1.Location = new System.Drawing.Point(0, 260);
+ this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(289, 507);
+ this.panel1.Size = new System.Drawing.Size(226, 815);
this.panel1.TabIndex = 8;
//
+ // listView1
+ //
+ this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.columnHeader1,
+ this.columnHeader2});
+ this.listView1.ContextMenuStrip = this.ctxMenuAppointments;
+ this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
+ 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.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
+ this.listView1.Location = new System.Drawing.Point(0, 308);
+ this.listView1.MultiSelect = false;
+ this.listView1.Name = "listView1";
+ this.listView1.ShowItemToolTips = true;
+ this.listView1.Size = new System.Drawing.Size(226, 507);
+ this.listView1.TabIndex = 4;
+ this.listView1.UseCompatibleStateImageBehavior = false;
+ this.listView1.View = System.Windows.Forms.View.Details;
+ this.listView1.DoubleClick += new System.EventHandler(this.listView1_DoubleClick);
+ //
+ // columnHeader1
+ //
+ this.columnHeader1.Text = "Date";
+ this.columnHeader1.Width = 78;
+ //
+ // columnHeader2
+ //
+ this.columnHeader2.Text = "Subject";
+ this.columnHeader2.Width = 163;
+ //
+ // grpRefresh
+ //
+ this.grpRefresh.Controls.Add(this.btnRefresh);
+ this.grpRefresh.Controls.Add(this.lblRangeDays);
+ this.grpRefresh.Controls.Add(this.numRangeDays);
+ this.grpRefresh.Dock = System.Windows.Forms.DockStyle.Top;
+ this.grpRefresh.Location = new System.Drawing.Point(0, 242);
+ this.grpRefresh.Name = "grpRefresh";
+ this.grpRefresh.Size = new System.Drawing.Size(226, 66);
+ this.grpRefresh.TabIndex = 3;
+ this.grpRefresh.TabStop = false;
+ this.grpRefresh.Text = "Days:";
+ //
+ // apptCalendar
+ //
+ this.apptCalendar.BoldedDates = null;
+ this.apptCalendar.CurrentMonthForeColor = System.Drawing.Color.Black;
+ this.apptCalendar.Dock = System.Windows.Forms.DockStyle.Top;
+ this.apptCalendar.FirstDayOfWeek = System.DayOfWeek.Sunday;
+ this.apptCalendar.Font = new System.Drawing.Font("Segoe UI", 7.8F);
+ this.apptCalendar.HoverBackColor = System.Drawing.Color.LightCyan;
+ this.apptCalendar.HoverForeColor = System.Drawing.Color.Black;
+ this.apptCalendar.Location = new System.Drawing.Point(0, 0);
+ this.apptCalendar.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.apptCalendar.Name = "apptCalendar";
+ this.apptCalendar.OtherMonthForeColor = System.Drawing.Color.LightGray;
+ this.apptCalendar.SelectedBackColor = System.Drawing.Color.LightBlue;
+ this.apptCalendar.SelectedDate = new System.DateTime(2013, 4, 26, 0, 0, 0, 0);
+ this.apptCalendar.SelectedForeColor = System.Drawing.Color.Blue;
+ this.apptCalendar.Size = new System.Drawing.Size(226, 242);
+ this.apptCalendar.TabIndex = 1;
+ this.apptCalendar.TodayBackColor = System.Drawing.Color.Blue;
+ this.apptCalendar.TodayForeColor = System.Drawing.Color.White;
+ this.apptCalendar.CellDoubleClick += new System.EventHandler(this.apptCalendar_CellDoubleClick);
+ this.apptCalendar.SelectedDateChanged += new System.EventHandler(this.apptCalendar_SelectedDateChanged);
+ //
// AppointmentsControl
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel1);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.apptCalendar);
+ this.Font = new System.Drawing.Font("Segoe UI", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "AppointmentsControl";
- this.Size = new System.Drawing.Size(289, 767);
+ this.Size = new System.Drawing.Size(226, 815);
((System.ComponentModel.ISupportInitialize)(this.numRangeDays)).EndInit();
this.ctxMenuAppointments.ResumeLayout(false);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
this.panel1.ResumeLayout(false);
+ this.grpRefresh.ResumeLayout(false);
+ this.grpRefresh.PerformLayout();
this.ResumeLayout(false);
}
@@ -187,15 +200,15 @@
private System.Windows.Forms.NumericUpDown numRangeDays;
private System.Windows.Forms.Label lblRangeDays;
- private DoubleClickMonthCalendar apptCalendar;
private System.Windows.Forms.ContextMenuStrip ctxMenuAppointments;
private System.Windows.Forms.ToolStripMenuItem mnuItemReplyAllEmail;
- private System.Windows.Forms.ColumnHeader hdrDate;
- private System.Windows.Forms.ColumnHeader hdrSubject;
- private System.Windows.Forms.ListView listView1;
- private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button btnRefresh;
+ private CustomCalendar apptCalendar;
+ private System.Windows.Forms.ListView listView1;
+ private System.Windows.Forms.ColumnHeader columnHeader1;
+ private System.Windows.Forms.ColumnHeader columnHeader2;
+ private System.Windows.Forms.GroupBox grpRefresh;
}
diff --git a/Outlook2013TodoAddIn/AppointmentsControl.cs b/Outlook2013TodoAddIn/AppointmentsControl.cs
index 3bc1f20..f5c456a 100644
--- a/Outlook2013TodoAddIn/AppointmentsControl.cs
+++ b/Outlook2013TodoAddIn/AppointmentsControl.cs
@@ -48,7 +48,7 @@ namespace Outlook2013TodoAddIn
///
/// Sender
/// DateRangeEventArgs
- private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
+ private void apptCalendar_SelectedDateChanged(object sender, EventArgs e)
{
this.RetrieveAppointments();
}
@@ -85,8 +85,8 @@ namespace Outlook2013TodoAddIn
Outlook.OlDefaultFolders.olFolderCalendar)
as Outlook.Folder;
- int selectedMonth = this.apptCalendar.SelectionStart.Month;
- int selectedYear = this.apptCalendar.SelectionStart.Year;
+ int selectedMonth = this.apptCalendar.SelectedDate.Month;
+ int selectedYear = this.apptCalendar.SelectedDate.Year;
// To get all the appointments for the current month (so it displays nicely bolded even for past events)
DateTime start = new DateTime(selectedYear, selectedMonth, 1); // MM-01-YYYY
@@ -107,10 +107,10 @@ namespace Outlook2013TodoAddIn
}
// Highlight dates with appointments in the current calendar
- this.apptCalendar.BoldedDates = appts.Select(a => a.Start).ToArray();
+ this.apptCalendar.BoldedDates = appts.Select(a => a.Start.Date).Distinct().ToArray();
// Now display the actual appointments below the calendar
- DateTime startRange = this.apptCalendar.SelectionStart;
+ DateTime startRange = this.apptCalendar.SelectedDate;
DateTime endRange = startRange.AddDays((int)this.numRangeDays.Value);
// Get items in range
@@ -169,6 +169,8 @@ namespace Outlook2013TodoAddIn
this.listView1.Items.Clear();
this.listView1.Items.AddRange(lstCol.ToArray());
+
+ this.apptCalendar.UpdateCalendar();
}
///
@@ -291,7 +293,7 @@ namespace Outlook2013TodoAddIn
///
/// Sender
/// EventArgs
- private void apptCalendar_DoubleClickEx(object sender, EventArgs e)
+ private void apptCalendar_CellDoubleClick(object sender, EventArgs e)
{
// Clicking in days outside of the current month will cause the calendar to refresh to that day
// reposition all days and select the wrong one
@@ -299,9 +301,10 @@ namespace Outlook2013TodoAddIn
Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder = f;
Outlook.CalendarView cv = (Outlook.CalendarView)(Globals.ThisAddIn.Application.ActiveExplorer().CurrentView);
cv.CalendarViewMode = Outlook.OlCalendarViewMode.olCalendarViewDay;
- cv.GoToDate(this.apptCalendar.SelectionStart);
+ cv.GoToDate(this.apptCalendar.SelectedDate);
}
#endregion "Methods"
+
}
}
\ No newline at end of file
diff --git a/Outlook2013TodoAddIn/CustomCalendar.Designer.cs b/Outlook2013TodoAddIn/CustomCalendar.Designer.cs
new file mode 100644
index 0000000..97ed7b8
--- /dev/null
+++ b/Outlook2013TodoAddIn/CustomCalendar.Designer.cs
@@ -0,0 +1,133 @@
+namespace Outlook2013TodoAddIn
+{
+ partial class CustomCalendar
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.btnPrevious = new System.Windows.Forms.Button();
+ this.btnNext = new System.Windows.Forms.Button();
+ this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
+ this.lnkCurrentRange = new System.Windows.Forms.LinkLabel();
+ this.lnkToday = new System.Windows.Forms.LinkLabel();
+ this.SuspendLayout();
+ //
+ // btnPrevious
+ //
+ this.btnPrevious.Location = new System.Drawing.Point(9, 8);
+ this.btnPrevious.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.btnPrevious.Name = "btnPrevious";
+ this.btnPrevious.Size = new System.Drawing.Size(31, 26);
+ this.btnPrevious.TabIndex = 0;
+ this.btnPrevious.Text = "<";
+ this.btnPrevious.UseVisualStyleBackColor = true;
+ this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);
+ //
+ // btnNext
+ //
+ this.btnNext.Location = new System.Drawing.Point(213, 8);
+ this.btnNext.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.btnNext.Name = "btnNext";
+ this.btnNext.Size = new System.Drawing.Size(31, 26);
+ this.btnNext.TabIndex = 2;
+ this.btnNext.Text = ">";
+ this.btnNext.UseVisualStyleBackColor = true;
+ this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
+ //
+ // tableLayoutPanel1
+ //
+ this.tableLayoutPanel1.ColumnCount = 7;
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28572F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28572F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28572F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28572F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28572F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28572F));
+ this.tableLayoutPanel1.Location = new System.Drawing.Point(9, 38);
+ this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
+ this.tableLayoutPanel1.Name = "tableLayoutPanel1";
+ this.tableLayoutPanel1.RowCount = 7;
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel1.Size = new System.Drawing.Size(234, 181);
+ this.tableLayoutPanel1.TabIndex = 3;
+ //
+ // lnkCurrentRange
+ //
+ this.lnkCurrentRange.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline;
+ this.lnkCurrentRange.Location = new System.Drawing.Point(47, 8);
+ this.lnkCurrentRange.Name = "lnkCurrentRange";
+ this.lnkCurrentRange.Size = new System.Drawing.Size(159, 26);
+ this.lnkCurrentRange.TabIndex = 0;
+ this.lnkCurrentRange.TabStop = true;
+ this.lnkCurrentRange.Text = "lnkCurrentRange";
+ this.lnkCurrentRange.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // lnkToday
+ //
+ this.lnkToday.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline;
+ this.lnkToday.Location = new System.Drawing.Point(9, 221);
+ this.lnkToday.Name = "lnkToday";
+ this.lnkToday.Size = new System.Drawing.Size(234, 26);
+ this.lnkToday.TabIndex = 4;
+ this.lnkToday.TabStop = true;
+ this.lnkToday.Text = "lnkToday";
+ this.lnkToday.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.lnkToday.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkToday_LinkClicked);
+ //
+ // CustomCalendar
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.lnkToday);
+ this.Controls.Add(this.lnkCurrentRange);
+ this.Controls.Add(this.tableLayoutPanel1);
+ this.Controls.Add(this.btnNext);
+ this.Controls.Add(this.btnPrevious);
+ this.Font = new System.Drawing.Font("Calibri", 9F);
+ this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.Name = "CustomCalendar";
+ this.Size = new System.Drawing.Size(256, 257);
+ this.Load += new System.EventHandler(this.CustomCalendar_Load);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button btnPrevious;
+ private System.Windows.Forms.Button btnNext;
+ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
+ private System.Windows.Forms.LinkLabel lnkCurrentRange;
+ private System.Windows.Forms.LinkLabel lnkToday;
+ }
+}
diff --git a/Outlook2013TodoAddIn/CustomCalendar.cs b/Outlook2013TodoAddIn/CustomCalendar.cs
new file mode 100644
index 0000000..c226d78
--- /dev/null
+++ b/Outlook2013TodoAddIn/CustomCalendar.cs
@@ -0,0 +1,428 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Outlook2013TodoAddIn
+{
+ ///
+ /// Custom calendar control with more flexibility and better skinning control
+ ///
+ public partial class CustomCalendar : UserControl
+ {
+ #region "Variables"
+
+ ///
+ /// Used to keep track of the currently selected Date
+ ///
+ DateTime _selectedDate = DateTime.Today;
+
+ #endregion "Variables"
+
+ #region "Properties"
+
+ ///
+ /// Gets/sets the current date
+ ///
+ public DateTime SelectedDate
+ {
+ get
+ {
+ return _selectedDate;
+ }
+ set
+ {
+ if (_selectedDate != value)
+ {
+ _selectedDate = value;
+ // this.UpdateCalendar();
+ this.OnSelectedDateChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ ///
+ /// Gets/sets the first day of week
+ ///
+ public DayOfWeek FirstDayOfWeek { get; set; }
+
+ ///
+ /// Set of dates to display in BOLD
+ ///
+ public DateTime[] BoldedDates { get; set; }
+
+ ///
+ /// Gets/sets font color of dates for current month
+ ///
+ public Color CurrentMonthForeColor { get; set; }
+
+ ///
+ /// Gets/sets font color of dates for other months (previous/next)
+ ///
+ public Color OtherMonthForeColor { get; set; }
+
+ ///
+ /// Gets/sets font color for today's date
+ ///
+ public Color TodayForeColor { get; set; }
+
+ ///
+ /// Gets/sets back color for today's date
+ ///
+ public Color TodayBackColor { get; set; }
+
+ ///
+ /// Gets/sets font color for selected's date
+ ///
+ public Color SelectedForeColor { get; set; }
+
+ ///
+ /// Gets/sets back color for selected's date
+ ///
+ public Color SelectedBackColor { get; set; }
+
+ ///
+ /// Gets/sets font color when mouse over a cell
+ ///
+ public Color HoverForeColor { get; set; }
+
+ ///
+ /// Gets/sets back color when mouse over a cell
+ ///
+ public Color HoverBackColor { get; set; }
+
+ #endregion "Properties"
+
+ #region "Methods"
+
+ ///
+ /// Default constructor
+ ///
+ public CustomCalendar()
+ {
+ InitializeComponent();
+ //this.SelectedDate = DateTime.Today;
+ this.FirstDayOfWeek = DayOfWeek.Sunday;
+ //TODO: Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek
+ this.CurrentMonthForeColor = Color.Black;
+ this.OtherMonthForeColor = Color.LightGray;
+ this.TodayForeColor = Color.White;
+ this.TodayBackColor = Color.Blue;
+
+ this.SelectedForeColor = Color.Blue;
+ this.SelectedBackColor = Color.LightBlue;
+
+ this.HoverForeColor = Color.Black;
+ this.HoverBackColor = Color.LightCyan;
+ this.CreateTableControls();
+ }
+
+ ///
+ /// Paint the month upon initial load
+ ///
+ /// Sender
+ /// EventArgs
+ private void CustomCalendar_Load(object sender, EventArgs e)
+ {
+ // TODO: check initial double firing
+ // TODO: Mark dates with colors from outlook
+ this.UpdateCalendar();
+ }
+
+ ///
+ /// Creates all inner labels once to be updated when the calendar changes
+ ///
+ private void CreateTableControls()
+ {
+ this.tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.None;
+ for (int row = 0; row < this.tableLayoutPanel1.RowCount; row++)
+ {
+ for (int col = 0; col < this.tableLayoutPanel1.ColumnCount; col++)
+ {
+ Label lblCtrl = new Label() { Text = "xx" };
+ lblCtrl.Name = String.Format("lbl_{0}_{1}", col.ToString(), row.ToString());
+ lblCtrl.Dock = DockStyle.Fill;
+ lblCtrl.TextAlign = ContentAlignment.MiddleCenter;
+ lblCtrl.Margin = Padding.Empty;
+ lblCtrl.Padding = Padding.Empty;
+ lblCtrl.FlatStyle = FlatStyle.Flat;
+ if (row != 0)
+ {
+ lblCtrl.MouseEnter += lblCtrl_MouseEnter;
+ lblCtrl.MouseLeave += lblCtrl_MouseLeave;
+ lblCtrl.Click += lblCtrl_Click; // TODO: If we disable this, then we can't select a date...
+ lblCtrl.DoubleClick += lblCtrl_DoubleClick;
+ }
+ this.tableLayoutPanel1.Controls.Add(lblCtrl);
+ this.tableLayoutPanel1.SetCellPosition(lblCtrl, new TableLayoutPanelCellPosition(col, row));
+ }
+ }
+ }
+
+ ///
+ /// Changes labels according to the currently displayed month
+ ///
+ public void UpdateCalendar()
+ {
+ // All controls are previously created, just need to update labels, etc...
+ this.lnkCurrentRange.Text = this.SelectedDate.ToString("MMM yyyy");
+ this.lnkToday.Text = "Today: " + DateTime.Today.ToShortDateString();
+
+ string[] daysOfWeek = Enum.GetNames(typeof(DayOfWeek));
+ string sFirstDayOfWeek = Enum.GetName(typeof(DayOfWeek), this.FirstDayOfWeek);
+ List sortedDays = new List();
+ sortedDays.AddRange(daysOfWeek.SkipWhile(ow => ow != sFirstDayOfWeek));
+ sortedDays.AddRange(daysOfWeek.TakeWhile(ow => ow != sFirstDayOfWeek));
+
+ int dayCurrent = 0;
+ int firstIndex = 0;
+ DateTime firstOfCurrentMonth = new DateTime(this.SelectedDate.Year, this.SelectedDate.Month, 1);
+ DateTime previousMonth = firstOfCurrentMonth.AddMonths(-1);
+ DateTime nextMonth = firstOfCurrentMonth.AddMonths(1);
+ int daysInPreviousMonth = DateTime.DaysInMonth(previousMonth.Year, previousMonth.Month);
+ int daysInCurrentMonth = DateTime.DaysInMonth(this.SelectedDate.Year, this.SelectedDate.Month);
+
+ for (int col = 0; col < this.tableLayoutPanel1.ColumnCount; col++)
+ {
+ if (sortedDays[col] == Enum.GetName(typeof(DayOfWeek), firstOfCurrentMonth.DayOfWeek))
+ {
+ firstIndex = col; // Get the position of day 1 of the current month
+ }
+ Label lblDay = this.tableLayoutPanel1.GetControlFromPosition(col, 0) as Label;
+ lblDay.Text = sortedDays[col].Substring(0, 2).ToUpper();
+ }
+
+ dayCurrent = daysInPreviousMonth - firstIndex + 1;
+ if (dayCurrent > daysInPreviousMonth)
+ {
+ dayCurrent = daysInPreviousMonth - 6;
+ }
+ bool previousMonthVisible = (dayCurrent != 1);
+ bool nextMonthVisible = false;
+
+ // Row 0 is for days of week
+ for (int row = 1; row < this.tableLayoutPanel1.RowCount; row++)
+ {
+ for (int col = 0; col < this.tableLayoutPanel1.ColumnCount; col++)
+ {
+ Label lblCtrl = this.tableLayoutPanel1.GetControlFromPosition(col, row) as Label;
+ lblCtrl.Text = dayCurrent.ToString();
+
+ DateTime embeddedDate;
+ Font displayFont;
+ Color foreColor;
+ Color backColor = this.BackColor;
+ BorderStyle borderStyle = BorderStyle.None;
+
+ // Customize the days
+ if (previousMonthVisible)
+ {
+ embeddedDate = new DateTime(previousMonth.Year, previousMonth.Month, dayCurrent);
+ displayFont = this.Font;
+ foreColor = this.OtherMonthForeColor;
+ }
+ else if (nextMonthVisible)
+ {
+ embeddedDate = new DateTime(nextMonth.Year, nextMonth.Month, dayCurrent);
+ displayFont = this.Font;
+ foreColor = this.OtherMonthForeColor;
+ }
+ else // Current month
+ {
+ embeddedDate = new DateTime(this.SelectedDate.Year, this.SelectedDate.Month, dayCurrent);
+ displayFont = this.Font;
+ foreColor = this.CurrentMonthForeColor;
+ }
+
+ if (this.BoldedDates != null && this.BoldedDates.Contains(embeddedDate))
+ {
+ displayFont = new Font(this.Font, FontStyle.Bold);
+ }
+
+ if (embeddedDate == DateTime.Today)
+ {
+ foreColor = this.TodayForeColor;
+ backColor = this.TodayBackColor;
+ }
+ else if (embeddedDate == this.SelectedDate)
+ {
+ borderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ foreColor = this.SelectedForeColor;
+ backColor = this.SelectedBackColor;
+ }
+
+ lblCtrl.Tag = embeddedDate;
+ lblCtrl.Font = displayFont;
+ lblCtrl.ForeColor = foreColor;
+ lblCtrl.BackColor = backColor;
+ lblCtrl.BorderStyle = borderStyle;
+
+ dayCurrent++;
+
+ if (previousMonthVisible && dayCurrent > daysInPreviousMonth)
+ {
+ dayCurrent = 1; // Start current month
+ previousMonthVisible = false;
+ }
+ if (!previousMonthVisible && dayCurrent > daysInCurrentMonth)
+ {
+ dayCurrent = 1; // Start next month
+ nextMonthVisible = true;
+ }
+ }
+ }
+ }
+
+ ///
+ /// Returns to the previous month
+ ///
+ /// Sender
+ /// EventArgs
+ private void btnPrevious_Click(object sender, EventArgs e)
+ {
+ this.SelectedDate = this.SelectedDate.AddMonths(-1);
+ //this.UpdateCalendar();
+ }
+
+ ///
+ /// Advances to the next month
+ ///
+ /// Sender
+ /// EventArgs
+ private void btnNext_Click(object sender, EventArgs e)
+ {
+ this.SelectedDate = this.SelectedDate.AddMonths(1);
+ //this.UpdateCalendar();
+ }
+
+ ///
+ /// Change background color of the label
+ ///
+ /// Sender
+ /// EventArgs
+ private void lblCtrl_MouseEnter(object sender, EventArgs e)
+ {
+ Label lblCtrl = sender as Label;
+ DateTime curDate = (DateTime)lblCtrl.Tag;
+ if (curDate.Month == this.SelectedDate.Month && curDate.Year == this.SelectedDate.Year)
+ {
+ lblCtrl.ForeColor = this.HoverForeColor;
+ }
+ else
+ {
+ lblCtrl.ForeColor = this.OtherMonthForeColor;
+ }
+ //lblCtrl.ForeColor = this.HoverForeColor;
+ lblCtrl.BackColor = this.HoverBackColor;
+ }
+
+ ///
+ /// Change background color of the label
+ ///
+ /// Sender
+ /// EventArgs
+ private void lblCtrl_MouseLeave(object sender, EventArgs e)
+ {
+ Label lblCtrl = sender as Label;
+ DateTime curDate = (DateTime)lblCtrl.Tag;
+ if (curDate == DateTime.Today)
+ {
+ lblCtrl.ForeColor = this.TodayForeColor;
+ lblCtrl.BackColor = this.TodayBackColor;
+ }
+ else if (curDate == this.SelectedDate)
+ {
+ lblCtrl.ForeColor = this.SelectedForeColor;
+ lblCtrl.BackColor = this.SelectedBackColor;
+ }
+ else
+ {
+ if (curDate.Month == this.SelectedDate.Month && curDate.Year == this.SelectedDate.Year)
+ {
+ lblCtrl.ForeColor = this.CurrentMonthForeColor;
+ }
+ else
+ {
+ lblCtrl.ForeColor = this.OtherMonthForeColor;
+ }
+ lblCtrl.BackColor = this.BackColor;
+ }
+ }
+
+ ///
+ /// Sets the currently selected day
+ ///
+ /// Sender
+ /// EventArgs
+ private void lblCtrl_Click(object sender, EventArgs e)
+ {
+ this.SelectedDate = (DateTime)(sender as Label).Tag;
+ //this.UpdateCalendar();
+ }
+
+ ///
+ /// Event handler to subscribe to
+ ///
+ public event EventHandler CellDoubleClick;
+
+ ///
+ /// Fires the attached event handler
+ ///
+ /// EventArgs
+ protected virtual void OnCellDoubleClick(EventArgs e)
+ {
+ EventHandler handler = CellDoubleClick;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ ///
+ /// Fires the double-click event on any given day label
+ ///
+ /// Sender
+ /// EventArgs
+ private void lblCtrl_DoubleClick(object sender, EventArgs e)
+ {
+ this.SelectedDate = (DateTime)(sender as Label).Tag;
+ OnCellDoubleClick(EventArgs.Empty);
+ }
+
+ ///
+ /// Event handler to subscribe to
+ ///
+ public event EventHandler SelectedDateChanged;
+
+ ///
+ /// Fires the attached event handler
+ ///
+ /// EventArgs
+ protected virtual void OnSelectedDateChanged(EventArgs e)
+ {
+ EventHandler handler = SelectedDateChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ ///
+ /// Select today's date in the calendar
+ ///
+ /// Sender
+ /// LinkLabelLinkClickedEventArgs
+ private void lnkToday_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ {
+ this.SelectedDate = DateTime.Today;
+ //this.UpdateCalendar();
+ }
+
+ #endregion "Methods"
+ }
+}
\ No newline at end of file
diff --git a/Outlook2013TodoAddIn/CustomCalendar.resx b/Outlook2013TodoAddIn/CustomCalendar.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/Outlook2013TodoAddIn/CustomCalendar.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Outlook2013TodoAddIn/DoubleClickMonthCalendar.cs b/Outlook2013TodoAddIn/DoubleClickMonthCalendar.cs
deleted file mode 100644
index e4261be..0000000
--- a/Outlook2013TodoAddIn/DoubleClickMonthCalendar.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace Outlook2013TodoAddIn
-{
- public class DoubleClickMonthCalendar : MonthCalendar
- {
- public event EventHandler DoubleClickEx;
-
- public DoubleClickMonthCalendar()
- {
- lastClickTick = Environment.TickCount - SystemInformation.DoubleClickTime;
- }
-
- protected override void OnMouseDown(MouseEventArgs e)
- {
- int tick = Environment.TickCount;
- if (tick - lastClickTick <= SystemInformation.DoubleClickTime)
- {
- EventHandler handler = DoubleClickEx;
- if (handler != null) handler(this, EventArgs.Empty);
- }
- else
- {
- base.OnMouseDown(e);
- lastClickTick = tick;
- }
- }
-
- private int lastClickTick;
- }
-}
\ No newline at end of file
diff --git a/Outlook2013TodoAddIn/Outlook2013TodoAddIn.csproj b/Outlook2013TodoAddIn/Outlook2013TodoAddIn.csproj
index 82f0451..b90b25c 100644
--- a/Outlook2013TodoAddIn/Outlook2013TodoAddIn.csproj
+++ b/Outlook2013TodoAddIn/Outlook2013TodoAddIn.csproj
@@ -183,8 +183,11 @@
can be found.
-->
-
- Component
+
+ UserControl
+
+
+ CustomCalendar.cs
Form
@@ -214,6 +217,9 @@
TodoRibbonAddIn.cs
+
+ CustomCalendar.cs
+
FormRecurringOpen.cs