diff --git a/Outlook2013TodoAddIn/CustomCalendar.Designer.cs b/Outlook2013TodoAddIn/CustomCalendar.Designer.cs
index c0219ba..36aa941 100644
--- a/Outlook2013TodoAddIn/CustomCalendar.Designer.cs
+++ b/Outlook2013TodoAddIn/CustomCalendar.Designer.cs
@@ -36,6 +36,7 @@
this.lnkToday = new System.Windows.Forms.LinkLabel();
this.btnConfig = new System.Windows.Forms.Button();
this.toolTipCalendar = new System.Windows.Forms.ToolTip(this.components);
+ this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.SuspendLayout();
//
// btnPrevious
@@ -74,7 +75,7 @@
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, 34);
+ this.tableLayoutPanel1.Location = new System.Drawing.Point(31, 34);
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 7;
@@ -85,7 +86,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.Size = new System.Drawing.Size(234, 161);
+ this.tableLayoutPanel1.Size = new System.Drawing.Size(212, 161);
this.tableLayoutPanel1.TabIndex = 3;
//
// lnkCurrentRange
@@ -125,10 +126,28 @@
this.btnConfig.UseVisualStyleBackColor = true;
this.btnConfig.Click += new System.EventHandler(this.btnConfig_Click);
//
+ // tableLayoutPanel2
+ //
+ this.tableLayoutPanel2.ColumnCount = 1;
+ this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 34);
+ this.tableLayoutPanel2.Name = "tableLayoutPanel2";
+ this.tableLayoutPanel2.RowCount = 7;
+ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
+ this.tableLayoutPanel2.Size = new System.Drawing.Size(28, 161);
+ this.tableLayoutPanel2.TabIndex = 6;
+ //
// CustomCalendar
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.tableLayoutPanel2);
this.Controls.Add(this.btnConfig);
this.Controls.Add(this.lnkToday);
this.Controls.Add(this.lnkCurrentRange);
@@ -152,5 +171,6 @@
private System.Windows.Forms.LinkLabel lnkToday;
private System.Windows.Forms.Button btnConfig;
private System.Windows.Forms.ToolTip toolTipCalendar;
+ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
}
}
diff --git a/Outlook2013TodoAddIn/CustomCalendar.cs b/Outlook2013TodoAddIn/CustomCalendar.cs
index 4b1865a..a1efbe3 100644
--- a/Outlook2013TodoAddIn/CustomCalendar.cs
+++ b/Outlook2013TodoAddIn/CustomCalendar.cs
@@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;
+using System.Globalization;
namespace Outlook2013TodoAddIn
{
@@ -173,6 +174,22 @@ namespace Outlook2013TodoAddIn
}
}
+ // This piece controls the week numbers
+ this.tableLayoutPanel2.CellBorderStyle = TableLayoutPanelCellBorderStyle.None;
+ for (int row = 0; row < this.tableLayoutPanel2.RowCount; row++)
+ {
+ Label lblCtrl = new Label() { Text = "#" };
+ lblCtrl.Name = String.Format("lbl_{0}", row.ToString());
+ lblCtrl.Dock = DockStyle.Fill;
+ lblCtrl.TextAlign = ContentAlignment.MiddleRight;
+ lblCtrl.Margin = Padding.Empty;
+ lblCtrl.Padding = Padding.Empty;
+ lblCtrl.Font = new Font(this.Font.FontFamily, this.Font.Size-2, FontStyle.Italic);
+ lblCtrl.FlatStyle = FlatStyle.Flat;
+ this.tableLayoutPanel2.Controls.Add(lblCtrl);
+ this.tableLayoutPanel2.SetCellPosition(lblCtrl, new TableLayoutPanelCellPosition(0, row));
+ }
+
this.btnPrevious.FlatAppearance.MouseOverBackColor = this.HoverBackColor;
this.btnNext.FlatAppearance.MouseOverBackColor = this.HoverBackColor;
this.btnConfig.FlatAppearance.MouseOverBackColor = this.HoverBackColor;
@@ -307,12 +324,39 @@ namespace Outlook2013TodoAddIn
if (this.ShowWeekNumbers)
{
- // TODO: Show the week numbers
+ this.tableLayoutPanel1.Left = 31;
+ this.tableLayoutPanel1.Width = 212;
+ this.tableLayoutPanel2.Visible = true;
}
+ else
+ {
+ this.tableLayoutPanel1.Left = 9;
+ this.tableLayoutPanel1.Width = 234;
+ this.tableLayoutPanel2.Visible = false;
+ }
// Row 0 is for days of week
for (int row = 1; row < this.tableLayoutPanel1.RowCount; row++)
{
+ if (this.ShowWeekNumbers)
+ {
+ Label lblDoW = this.tableLayoutPanel2.GetControlFromPosition(0, row) as Label;
+ DateTime dateForWeek;
+ if (previousMonthVisible)
+ {
+ dateForWeek = new DateTime(previousMonth.Year, previousMonth.Month, dayCurrent);
+ }
+ else if (nextMonthVisible)
+ {
+ dateForWeek = new DateTime(nextMonth.Year, nextMonth.Month, dayCurrent);
+ }
+ else
+ {
+ dateForWeek = new DateTime(this.SelectedDate.Year, this.SelectedDate.Month, dayCurrent);
+ }
+ lblDoW.Text = GetWeekForDate(dateForWeek).ToString();
+ }
+
for (int col = 0; col < this.tableLayoutPanel1.ColumnCount; col++)
{
Label lblCtrl = this.tableLayoutPanel1.GetControlFromPosition(col, row) as Label;
@@ -383,6 +427,13 @@ namespace Outlook2013TodoAddIn
}
}
+ private int GetWeekForDate(DateTime time)
+ {
+ // Add 6 days since we want the date at the "last" column of the calendar to be more precise
+ int weekNumber = CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(time.AddDays(6), CalendarWeekRule.FirstDay, this.FirstDayOfWeek);
+ return weekNumber;
+ }
+
///
/// Returns to the previous month
///
diff --git a/Outlook2013TodoAddIn/CustomCalendar.resx b/Outlook2013TodoAddIn/CustomCalendar.resx
index 2a51f90..29b8f78 100644
--- a/Outlook2013TodoAddIn/CustomCalendar.resx
+++ b/Outlook2013TodoAddIn/CustomCalendar.resx
@@ -120,4 +120,7 @@
17, 17
+
+ 17, 17
+
\ No newline at end of file