Added week numbers table that shows/hides depending on configuration
This commit is contained in:
		
							parent
							
								
									6d54b8a784
								
							
						
					
					
						commit
						3d3e97dc4b
					
				
							
								
								
									
										24
									
								
								Outlook2013TodoAddIn/CustomCalendar.Designer.cs
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										24
									
								
								Outlook2013TodoAddIn/CustomCalendar.Designer.cs
									
									
									
										generated
									
									
									
								
							@ -36,6 +36,7 @@
 | 
				
			|||||||
            this.lnkToday = new System.Windows.Forms.LinkLabel();
 | 
					            this.lnkToday = new System.Windows.Forms.LinkLabel();
 | 
				
			||||||
            this.btnConfig = new System.Windows.Forms.Button();
 | 
					            this.btnConfig = new System.Windows.Forms.Button();
 | 
				
			||||||
            this.toolTipCalendar = new System.Windows.Forms.ToolTip(this.components);
 | 
					            this.toolTipCalendar = new System.Windows.Forms.ToolTip(this.components);
 | 
				
			||||||
 | 
					            this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
 | 
				
			||||||
            this.SuspendLayout();
 | 
					            this.SuspendLayout();
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            // btnPrevious
 | 
					            // 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.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.Margin = new System.Windows.Forms.Padding(0);
 | 
				
			||||||
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
 | 
					            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
 | 
				
			||||||
            this.tableLayoutPanel1.RowCount = 7;
 | 
					            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.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;
 | 
					            this.tableLayoutPanel1.TabIndex = 3;
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            // lnkCurrentRange
 | 
					            // lnkCurrentRange
 | 
				
			||||||
@ -125,10 +126,28 @@
 | 
				
			|||||||
            this.btnConfig.UseVisualStyleBackColor = true;
 | 
					            this.btnConfig.UseVisualStyleBackColor = true;
 | 
				
			||||||
            this.btnConfig.Click += new System.EventHandler(this.btnConfig_Click);
 | 
					            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
 | 
					            // CustomCalendar
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
 | 
					            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
 | 
				
			||||||
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
 | 
					            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
 | 
				
			||||||
 | 
					            this.Controls.Add(this.tableLayoutPanel2);
 | 
				
			||||||
            this.Controls.Add(this.btnConfig);
 | 
					            this.Controls.Add(this.btnConfig);
 | 
				
			||||||
            this.Controls.Add(this.lnkToday);
 | 
					            this.Controls.Add(this.lnkToday);
 | 
				
			||||||
            this.Controls.Add(this.lnkCurrentRange);
 | 
					            this.Controls.Add(this.lnkCurrentRange);
 | 
				
			||||||
@ -152,5 +171,6 @@
 | 
				
			|||||||
        private System.Windows.Forms.LinkLabel lnkToday;
 | 
					        private System.Windows.Forms.LinkLabel lnkToday;
 | 
				
			||||||
        private System.Windows.Forms.Button btnConfig;
 | 
					        private System.Windows.Forms.Button btnConfig;
 | 
				
			||||||
        private System.Windows.Forms.ToolTip toolTipCalendar;
 | 
					        private System.Windows.Forms.ToolTip toolTipCalendar;
 | 
				
			||||||
 | 
					        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -8,6 +8,7 @@ using System.Text;
 | 
				
			|||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using System.Windows.Forms;
 | 
					using System.Windows.Forms;
 | 
				
			||||||
using Outlook = Microsoft.Office.Interop.Outlook;
 | 
					using Outlook = Microsoft.Office.Interop.Outlook;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Outlook2013TodoAddIn
 | 
					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.btnPrevious.FlatAppearance.MouseOverBackColor = this.HoverBackColor;
 | 
				
			||||||
            this.btnNext.FlatAppearance.MouseOverBackColor = this.HoverBackColor;
 | 
					            this.btnNext.FlatAppearance.MouseOverBackColor = this.HoverBackColor;
 | 
				
			||||||
            this.btnConfig.FlatAppearance.MouseOverBackColor = this.HoverBackColor;
 | 
					            this.btnConfig.FlatAppearance.MouseOverBackColor = this.HoverBackColor;
 | 
				
			||||||
@ -307,12 +324,39 @@ namespace Outlook2013TodoAddIn
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (this.ShowWeekNumbers)
 | 
					            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
 | 
					            // Row 0 is for days of week
 | 
				
			||||||
            for (int row = 1; row < this.tableLayoutPanel1.RowCount; row++)
 | 
					            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++)
 | 
					                for (int col = 0; col < this.tableLayoutPanel1.ColumnCount; col++)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Label lblCtrl = this.tableLayoutPanel1.GetControlFromPosition(col, row) as Label;
 | 
					                    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;
 | 
				
			||||||
 | 
					        } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Returns to the previous month
 | 
					        /// Returns to the previous month
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
 | 
				
			|||||||
@ -120,4 +120,7 @@
 | 
				
			|||||||
  <metadata name="toolTipCalendar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
 | 
					  <metadata name="toolTipCalendar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
 | 
				
			||||||
    <value>17, 17</value>
 | 
					    <value>17, 17</value>
 | 
				
			||||||
  </metadata>
 | 
					  </metadata>
 | 
				
			||||||
 | 
					  <metadata name="toolTipCalendar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
 | 
				
			||||||
 | 
					    <value>17, 17</value>
 | 
				
			||||||
 | 
					  </metadata>
 | 
				
			||||||
</root>
 | 
					</root>
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user