From 6d54b8a784ad5621c93379273de6f9b01b9544c8 Mon Sep 17 00:00:00 2001 From: gamosoft_cp Date: Thu, 16 Oct 2014 21:22:50 +0000 Subject: [PATCH] Added work in progress for showing week numbers --- Outlook2013TodoAddIn/AppointmentsControl.cs | 12 ++++++++ Outlook2013TodoAddIn/CustomCalendar.cs | 10 +++++++ .../Forms/FormConfiguration.Designer.cs | 29 ++++++++++++++----- .../Forms/FormConfiguration.cs | 11 +++++++ .../Properties/Settings.Designer.cs | 16 ++++++++-- .../Properties/Settings.settings | 3 ++ Outlook2013TodoAddIn/ThisAddIn.cs | 1 + Outlook2013TodoAddIn/app.config | 3 ++ 8 files changed, 75 insertions(+), 10 deletions(-) diff --git a/Outlook2013TodoAddIn/AppointmentsControl.cs b/Outlook2013TodoAddIn/AppointmentsControl.cs index 2dfa066..cd8f14d 100644 --- a/Outlook2013TodoAddIn/AppointmentsControl.cs +++ b/Outlook2013TodoAddIn/AppointmentsControl.cs @@ -46,6 +46,11 @@ namespace Outlook2013TodoAddIn /// public bool ShowDayNames { get; set; } + /// + /// Gets/sets whether to show week numbers + /// + public bool ShowWeekNumbers { get; set; } + /// /// Gets/sets the selected calendar date /// @@ -303,6 +308,7 @@ namespace Outlook2013TodoAddIn this.lstAppointments.Items.Clear(); this.lstAppointments.Items.AddRange(lstCol.ToArray()); + this.apptCalendar.ShowWeekNumbers = this.ShowWeekNumbers; this.apptCalendar.UpdateCalendar(); } @@ -484,6 +490,7 @@ namespace Outlook2013TodoAddIn this.Accounts = cfg.Accounts; this.ShowFriendlyGroupHeaders = cfg.ShowFriendlyGroupHeaders; this.ShowDayNames = cfg.ShowDayNames; + this.ShowWeekNumbers = cfg.ShowWeekNumbers; this.ShowTasks = cfg.ShowTasks; this.FirstDayOfWeek = cfg.FirstDayOfWeek; this.RetrieveData(); @@ -593,6 +600,11 @@ namespace Outlook2013TodoAddIn e.Graphics.DrawString(appt.Location, this.Font, colorBrush, locationRectangle, leftFormat); } + /// + /// The color scheme for Outlook is not the same as of Windows Forms, so this method tries to do a best effor in matching them + /// + /// Color of the category + /// Resulting color to be displayed private Color TranslateCategoryColor(Outlook.OlCategoryColor col) { Color result = Color.Black; diff --git a/Outlook2013TodoAddIn/CustomCalendar.cs b/Outlook2013TodoAddIn/CustomCalendar.cs index b688201..4b1865a 100644 --- a/Outlook2013TodoAddIn/CustomCalendar.cs +++ b/Outlook2013TodoAddIn/CustomCalendar.cs @@ -99,6 +99,11 @@ namespace Outlook2013TodoAddIn /// public Color HoverBackColor { get; set; } + /// + /// Gets/sets whether to show week numbers + /// + public bool ShowWeekNumbers { get; set; } + #endregion "Properties" #region "Methods" @@ -300,6 +305,11 @@ namespace Outlook2013TodoAddIn bool previousMonthVisible = (dayCurrent != 1); bool nextMonthVisible = false; + if (this.ShowWeekNumbers) + { + // TODO: Show the week numbers + } + // Row 0 is for days of week for (int row = 1; row < this.tableLayoutPanel1.RowCount; row++) { diff --git a/Outlook2013TodoAddIn/Forms/FormConfiguration.Designer.cs b/Outlook2013TodoAddIn/Forms/FormConfiguration.Designer.cs index 05c5935..b18faff 100644 --- a/Outlook2013TodoAddIn/Forms/FormConfiguration.Designer.cs +++ b/Outlook2013TodoAddIn/Forms/FormConfiguration.Designer.cs @@ -41,6 +41,7 @@ this.cboFirstDayOfWeek = new System.Windows.Forms.ComboBox(); this.lblFirstDayOfWeek = new System.Windows.Forms.Label(); this.chkShowDayNames = new System.Windows.Forms.CheckBox(); + this.chkShowWeekNumbers = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.numRangeDays)).BeginInit(); this.SuspendLayout(); // @@ -88,7 +89,7 @@ // btnCancel // this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(168, 403); + this.btnCancel.Location = new System.Drawing.Point(168, 432); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(87, 37); this.btnCancel.TabIndex = 11; @@ -98,7 +99,7 @@ // btnOK // this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.btnOK.Location = new System.Drawing.Point(26, 403); + this.btnOK.Location = new System.Drawing.Point(26, 432); this.btnOK.Name = "btnOK"; this.btnOK.Size = new System.Drawing.Size(87, 37); this.btnOK.TabIndex = 10; @@ -119,7 +120,7 @@ // chkListCalendars // this.chkListCalendars.FormattingEnabled = true; - this.chkListCalendars.Location = new System.Drawing.Point(26, 288); + this.chkListCalendars.Location = new System.Drawing.Point(26, 317); this.chkListCalendars.Name = "chkListCalendars"; this.chkListCalendars.Size = new System.Drawing.Size(229, 106); this.chkListCalendars.TabIndex = 13; @@ -127,7 +128,7 @@ // lblAccounts // this.lblAccounts.AutoSize = true; - this.lblAccounts.Location = new System.Drawing.Point(23, 268); + this.lblAccounts.Location = new System.Drawing.Point(23, 297); this.lblAccounts.Name = "lblAccounts"; this.lblAccounts.Size = new System.Drawing.Size(70, 17); this.lblAccounts.TabIndex = 14; @@ -146,7 +147,7 @@ // chkShowTasks // this.chkShowTasks.AutoSize = true; - this.chkShowTasks.Location = new System.Drawing.Point(45, 177); + this.chkShowTasks.Location = new System.Drawing.Point(45, 206); this.chkShowTasks.Name = "chkShowTasks"; this.chkShowTasks.Size = new System.Drawing.Size(106, 21); this.chkShowTasks.TabIndex = 16; @@ -158,7 +159,7 @@ // this.cboFirstDayOfWeek.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cboFirstDayOfWeek.FormattingEnabled = true; - this.cboFirstDayOfWeek.Location = new System.Drawing.Point(45, 230); + this.cboFirstDayOfWeek.Location = new System.Drawing.Point(45, 259); this.cboFirstDayOfWeek.Name = "cboFirstDayOfWeek"; this.cboFirstDayOfWeek.Size = new System.Drawing.Size(186, 24); this.cboFirstDayOfWeek.TabIndex = 17; @@ -166,7 +167,7 @@ // lblFirstDayOfWeek // this.lblFirstDayOfWeek.AutoSize = true; - this.lblFirstDayOfWeek.Location = new System.Drawing.Point(42, 210); + this.lblFirstDayOfWeek.Location = new System.Drawing.Point(42, 239); this.lblFirstDayOfWeek.Name = "lblFirstDayOfWeek"; this.lblFirstDayOfWeek.Size = new System.Drawing.Size(124, 17); this.lblFirstDayOfWeek.TabIndex = 18; @@ -182,13 +183,24 @@ this.chkShowDayNames.Text = "Show Day Names"; this.chkShowDayNames.UseVisualStyleBackColor = true; // + // chkShowWeekNumbers + // + this.chkShowWeekNumbers.AutoSize = true; + this.chkShowWeekNumbers.Location = new System.Drawing.Point(45, 178); + this.chkShowWeekNumbers.Name = "chkShowWeekNumbers"; + this.chkShowWeekNumbers.Size = new System.Drawing.Size(165, 21); + this.chkShowWeekNumbers.TabIndex = 20; + this.chkShowWeekNumbers.Text = "Show Week Numbers"; + this.chkShowWeekNumbers.UseVisualStyleBackColor = true; + // // FormConfiguration // this.AcceptButton = this.btnOK; this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(282, 452); + this.ClientSize = new System.Drawing.Size(282, 482); + this.Controls.Add(this.chkShowWeekNumbers); this.Controls.Add(this.chkShowDayNames); this.Controls.Add(this.lblFirstDayOfWeek); this.Controls.Add(this.cboFirstDayOfWeek); @@ -231,5 +243,6 @@ private System.Windows.Forms.ComboBox cboFirstDayOfWeek; private System.Windows.Forms.Label lblFirstDayOfWeek; private System.Windows.Forms.CheckBox chkShowDayNames; + private System.Windows.Forms.CheckBox chkShowWeekNumbers; } } \ No newline at end of file diff --git a/Outlook2013TodoAddIn/Forms/FormConfiguration.cs b/Outlook2013TodoAddIn/Forms/FormConfiguration.cs index efdf208..6eeb7a1 100644 --- a/Outlook2013TodoAddIn/Forms/FormConfiguration.cs +++ b/Outlook2013TodoAddIn/Forms/FormConfiguration.cs @@ -76,6 +76,15 @@ namespace Outlook2013TodoAddIn.Forms set { this.chkShowDayNames.Checked = value; } } + /// + /// Gets/sets whether to show week numbers + /// + public bool ShowWeekNumbers + { + get { return this.chkShowWeekNumbers.Checked; } + set { this.chkShowWeekNumbers.Checked = value; } + } + /// /// Gets/sets whether to show the tasks list /// @@ -118,6 +127,7 @@ namespace Outlook2013TodoAddIn.Forms this.chkShowPastAppointments.Checked = Properties.Settings.Default.ShowPastAppointments; this.chkFriendlyGroupHeaders.Checked = Properties.Settings.Default.ShowFriendlyGroupHeaders; this.chkShowDayNames.Checked = Properties.Settings.Default.ShowDayNames; + this.chkShowWeekNumbers.Checked = Properties.Settings.Default.ShowWeekNumbers; this.chkShowTasks.Checked = Properties.Settings.Default.ShowTasks; this.LoadStores(); this.LoadDays(); @@ -158,6 +168,7 @@ namespace Outlook2013TodoAddIn.Forms Properties.Settings.Default.Accounts = this.Accounts; Properties.Settings.Default.ShowFriendlyGroupHeaders = this.chkFriendlyGroupHeaders.Checked; Properties.Settings.Default.ShowDayNames = this.chkShowDayNames.Checked; + Properties.Settings.Default.ShowWeekNumbers = this.chkShowWeekNumbers.Checked; Properties.Settings.Default.ShowTasks = this.chkShowTasks.Checked; Properties.Settings.Default.FirstDayOfWeek = (System.DayOfWeek)Enum.Parse(typeof(System.DayOfWeek), this.cboFirstDayOfWeek.SelectedValue.ToString()); } diff --git a/Outlook2013TodoAddIn/Properties/Settings.Designer.cs b/Outlook2013TodoAddIn/Properties/Settings.Designer.cs index e279aab..0e575ba 100644 --- a/Outlook2013TodoAddIn/Properties/Settings.Designer.cs +++ b/Outlook2013TodoAddIn/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18051 +// Runtime Version:4.0.30319.34014 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,7 +12,7 @@ namespace Outlook2013TodoAddIn.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -165,5 +165,17 @@ namespace Outlook2013TodoAddIn.Properties { this["ShowDayNames"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool ShowWeekNumbers { + get { + return ((bool)(this["ShowWeekNumbers"])); + } + set { + this["ShowWeekNumbers"] = value; + } + } } } diff --git a/Outlook2013TodoAddIn/Properties/Settings.settings b/Outlook2013TodoAddIn/Properties/Settings.settings index 5076c34..a5fd121 100644 --- a/Outlook2013TodoAddIn/Properties/Settings.settings +++ b/Outlook2013TodoAddIn/Properties/Settings.settings @@ -38,5 +38,8 @@ True + + False + \ No newline at end of file diff --git a/Outlook2013TodoAddIn/ThisAddIn.cs b/Outlook2013TodoAddIn/ThisAddIn.cs index cbe3e40..d1a98ca 100644 --- a/Outlook2013TodoAddIn/ThisAddIn.cs +++ b/Outlook2013TodoAddIn/ThisAddIn.cs @@ -45,6 +45,7 @@ namespace Outlook2013TodoAddIn this.AppControl.Accounts = Properties.Settings.Default.Accounts; this.AppControl.ShowFriendlyGroupHeaders = Properties.Settings.Default.ShowFriendlyGroupHeaders; this.AppControl.ShowDayNames = Properties.Settings.Default.ShowDayNames; + this.AppControl.ShowWeekNumbers = Properties.Settings.Default.ShowWeekNumbers; this.AppControl.ShowTasks = Properties.Settings.Default.ShowTasks; this.AppControl.FirstDayOfWeek = Properties.Settings.Default.FirstDayOfWeek; this.AppControl.NumDays = Properties.Settings.Default.NumDays; // Setting the value will load the appointments diff --git a/Outlook2013TodoAddIn/app.config b/Outlook2013TodoAddIn/app.config index ba8b03e..f85f66b 100644 --- a/Outlook2013TodoAddIn/app.config +++ b/Outlook2013TodoAddIn/app.config @@ -40,6 +40,9 @@ True + + False +