From e0489a9e8ae2b594ba13b2e11f542d1fa2544906 Mon Sep 17 00:00:00 2001 From: gamosoft_cp Date: Wed, 24 Jul 2013 15:51:16 +0000 Subject: [PATCH] Added configurable first day of week to the calendar --- Outlook2013TodoAddIn/AppointmentsControl.cs | 7 ++++ .../Forms/FormConfiguration.Designer.cs | 34 ++++++++++++++++--- .../Forms/FormConfiguration.cs | 20 +++++++++++ .../Properties/Settings.Designer.cs | 12 +++++++ .../Properties/Settings.settings | 3 ++ Outlook2013TodoAddIn/ThisAddIn.cs | 1 + Outlook2013TodoAddIn/app.config | 3 ++ 7 files changed, 75 insertions(+), 5 deletions(-) diff --git a/Outlook2013TodoAddIn/AppointmentsControl.cs b/Outlook2013TodoAddIn/AppointmentsControl.cs index 2fd0842..09e7353 100644 --- a/Outlook2013TodoAddIn/AppointmentsControl.cs +++ b/Outlook2013TodoAddIn/AppointmentsControl.cs @@ -55,6 +55,11 @@ namespace Outlook2013TodoAddIn /// public bool ShowTasks { get; set; } + /// + /// Gets/sets the first day of the week for the calendar + /// + public System.DayOfWeek FirstDayOfWeek { get; set; } + #endregion "Properties" #region "Methods" @@ -82,6 +87,7 @@ namespace Outlook2013TodoAddIn /// public void RetrieveData() { + this.apptCalendar.FirstDayOfWeek = this.FirstDayOfWeek; this.RetrieveAppointments(); if (this.ShowTasks) { @@ -438,6 +444,7 @@ namespace Outlook2013TodoAddIn this.Accounts = cfg.Accounts; this.ShowFriendlyGroupHeaders = cfg.ShowFriendlyGroupHeaders; this.ShowTasks = cfg.ShowTasks; + this.FirstDayOfWeek = cfg.FirstDayOfWeek; this.RetrieveData(); } } diff --git a/Outlook2013TodoAddIn/Forms/FormConfiguration.Designer.cs b/Outlook2013TodoAddIn/Forms/FormConfiguration.Designer.cs index bf54685..85a79ba 100644 --- a/Outlook2013TodoAddIn/Forms/FormConfiguration.Designer.cs +++ b/Outlook2013TodoAddIn/Forms/FormConfiguration.Designer.cs @@ -38,6 +38,8 @@ this.lblAccounts = new System.Windows.Forms.Label(); this.chkFriendlyGroupHeaders = new System.Windows.Forms.CheckBox(); this.chkShowTasks = new System.Windows.Forms.CheckBox(); + this.cboFirstDayOfWeek = new System.Windows.Forms.ComboBox(); + this.lblFirstDayOfWeek = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.numRangeDays)).BeginInit(); this.SuspendLayout(); // @@ -85,7 +87,7 @@ // btnCancel // this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(168, 314); + this.btnCancel.Location = new System.Drawing.Point(168, 374); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(87, 37); this.btnCancel.TabIndex = 11; @@ -95,7 +97,7 @@ // btnOK // this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.btnOK.Location = new System.Drawing.Point(26, 314); + this.btnOK.Location = new System.Drawing.Point(26, 374); this.btnOK.Name = "btnOK"; this.btnOK.Size = new System.Drawing.Size(87, 37); this.btnOK.TabIndex = 10; @@ -116,7 +118,7 @@ // chkListCalendars // this.chkListCalendars.FormattingEnabled = true; - this.chkListCalendars.Location = new System.Drawing.Point(26, 199); + this.chkListCalendars.Location = new System.Drawing.Point(26, 259); this.chkListCalendars.Name = "chkListCalendars"; this.chkListCalendars.Size = new System.Drawing.Size(229, 106); this.chkListCalendars.TabIndex = 13; @@ -124,7 +126,7 @@ // lblAccounts // this.lblAccounts.AutoSize = true; - this.lblAccounts.Location = new System.Drawing.Point(23, 179); + this.lblAccounts.Location = new System.Drawing.Point(23, 239); this.lblAccounts.Name = "lblAccounts"; this.lblAccounts.Size = new System.Drawing.Size(70, 17); this.lblAccounts.TabIndex = 14; @@ -150,13 +152,33 @@ this.chkShowTasks.Text = "Show Tasks"; this.chkShowTasks.UseVisualStyleBackColor = true; // + // cboFirstDayOfWeek + // + this.cboFirstDayOfWeek.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboFirstDayOfWeek.FormattingEnabled = true; + this.cboFirstDayOfWeek.Location = new System.Drawing.Point(45, 201); + this.cboFirstDayOfWeek.Name = "cboFirstDayOfWeek"; + this.cboFirstDayOfWeek.Size = new System.Drawing.Size(186, 24); + this.cboFirstDayOfWeek.TabIndex = 17; + // + // lblFirstDayOfWeek + // + this.lblFirstDayOfWeek.AutoSize = true; + this.lblFirstDayOfWeek.Location = new System.Drawing.Point(42, 181); + this.lblFirstDayOfWeek.Name = "lblFirstDayOfWeek"; + this.lblFirstDayOfWeek.Size = new System.Drawing.Size(124, 17); + this.lblFirstDayOfWeek.TabIndex = 18; + this.lblFirstDayOfWeek.Text = "First Day of Week:"; + // // 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, 383); + this.ClientSize = new System.Drawing.Size(282, 452); + this.Controls.Add(this.lblFirstDayOfWeek); + this.Controls.Add(this.cboFirstDayOfWeek); this.Controls.Add(this.chkShowTasks); this.Controls.Add(this.chkFriendlyGroupHeaders); this.Controls.Add(this.lblAccounts); @@ -193,5 +215,7 @@ private System.Windows.Forms.Label lblAccounts; private System.Windows.Forms.CheckBox chkFriendlyGroupHeaders; private System.Windows.Forms.CheckBox chkShowTasks; + private System.Windows.Forms.ComboBox cboFirstDayOfWeek; + private System.Windows.Forms.Label lblFirstDayOfWeek; } } \ No newline at end of file diff --git a/Outlook2013TodoAddIn/Forms/FormConfiguration.cs b/Outlook2013TodoAddIn/Forms/FormConfiguration.cs index e703455..57e1c43 100644 --- a/Outlook2013TodoAddIn/Forms/FormConfiguration.cs +++ b/Outlook2013TodoAddIn/Forms/FormConfiguration.cs @@ -76,6 +76,15 @@ namespace Outlook2013TodoAddIn.Forms set { this.chkShowTasks.Checked = value; } } + /// + /// Gets/sets the first day of the week for the calendar + /// + public System.DayOfWeek FirstDayOfWeek + { + get { return (System.DayOfWeek)Enum.Parse(typeof(System.DayOfWeek), this.cboFirstDayOfWeek.SelectedValue.ToString()); } + set { this.cboFirstDayOfWeek.SelectedValue = value; } + } + #endregion "Properties" #region "Methods" @@ -101,6 +110,7 @@ namespace Outlook2013TodoAddIn.Forms this.chkFriendlyGroupHeaders.Checked = Properties.Settings.Default.ShowFriendlyGroupHeaders; this.chkShowTasks.Checked = Properties.Settings.Default.ShowTasks; this.LoadStores(); + this.LoadDays(); } /// @@ -116,6 +126,15 @@ namespace Outlook2013TodoAddIn.Forms } } + /// + /// Loads the available days of the week in the dropdown + /// + private void LoadDays() + { + this.cboFirstDayOfWeek.DataSource = Enum.GetValues(typeof(System.DayOfWeek)); + this.cboFirstDayOfWeek.SelectedItem = Properties.Settings.Default.FirstDayOfWeek; + } + /// /// Clicking the OK button /// @@ -129,6 +148,7 @@ namespace Outlook2013TodoAddIn.Forms Properties.Settings.Default.Accounts = this.Accounts; Properties.Settings.Default.ShowFriendlyGroupHeaders = this.chkFriendlyGroupHeaders.Checked; Properties.Settings.Default.ShowTasks = this.chkShowTasks.Checked; + Properties.Settings.Default.FirstDayOfWeek = (System.DayOfWeek)Enum.Parse(typeof(System.DayOfWeek), this.cboFirstDayOfWeek.SelectedValue.ToString()); } #endregion "Methods" diff --git a/Outlook2013TodoAddIn/Properties/Settings.Designer.cs b/Outlook2013TodoAddIn/Properties/Settings.Designer.cs index 2ce36a6..a642b45 100644 --- a/Outlook2013TodoAddIn/Properties/Settings.Designer.cs +++ b/Outlook2013TodoAddIn/Properties/Settings.Designer.cs @@ -129,5 +129,17 @@ namespace Outlook2013TodoAddIn.Properties { this["ShowTasks"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Sunday")] + public global::System.DayOfWeek FirstDayOfWeek { + get { + return ((global::System.DayOfWeek)(this["FirstDayOfWeek"])); + } + set { + this["FirstDayOfWeek"] = value; + } + } } } diff --git a/Outlook2013TodoAddIn/Properties/Settings.settings b/Outlook2013TodoAddIn/Properties/Settings.settings index 853dd48..0b8224a 100644 --- a/Outlook2013TodoAddIn/Properties/Settings.settings +++ b/Outlook2013TodoAddIn/Properties/Settings.settings @@ -29,5 +29,8 @@ True + + Sunday + \ No newline at end of file diff --git a/Outlook2013TodoAddIn/ThisAddIn.cs b/Outlook2013TodoAddIn/ThisAddIn.cs index 568872a..f4cf2c7 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.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 ToDoTaskPane = this.CustomTaskPanes.Add(this.AppControl, "Appointments"); diff --git a/Outlook2013TodoAddIn/app.config b/Outlook2013TodoAddIn/app.config index bcdff4c..506b707 100644 --- a/Outlook2013TodoAddIn/app.config +++ b/Outlook2013TodoAddIn/app.config @@ -31,6 +31,9 @@ True + + Sunday +