Added configurable first day of week to the calendar

This commit is contained in:
gamosoft_cp 2013-07-24 15:51:16 +00:00
parent 554677e21f
commit e0489a9e8a
7 changed files with 75 additions and 5 deletions

View File

@ -55,6 +55,11 @@ namespace Outlook2013TodoAddIn
/// </summary>
public bool ShowTasks { get; set; }
/// <summary>
/// Gets/sets the first day of the week for the calendar
/// </summary>
public System.DayOfWeek FirstDayOfWeek { get; set; }
#endregion "Properties"
#region "Methods"
@ -82,6 +87,7 @@ namespace Outlook2013TodoAddIn
/// </summary>
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();
}
}

View File

@ -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;
}
}

View File

@ -76,6 +76,15 @@ namespace Outlook2013TodoAddIn.Forms
set { this.chkShowTasks.Checked = value; }
}
/// <summary>
/// Gets/sets the first day of the week for the calendar
/// </summary>
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();
}
/// <summary>
@ -116,6 +126,15 @@ namespace Outlook2013TodoAddIn.Forms
}
}
/// <summary>
/// Loads the available days of the week in the dropdown
/// </summary>
private void LoadDays()
{
this.cboFirstDayOfWeek.DataSource = Enum.GetValues(typeof(System.DayOfWeek));
this.cboFirstDayOfWeek.SelectedItem = Properties.Settings.Default.FirstDayOfWeek;
}
/// <summary>
/// Clicking the OK button
/// </summary>
@ -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"

View File

@ -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;
}
}
}
}

View File

@ -29,5 +29,8 @@
<Setting Name="ShowTasks" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="FirstDayOfWeek" Type="System.DayOfWeek" Scope="User">
<Value Profile="(Default)">Sunday</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -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");

View File

@ -31,6 +31,9 @@
<setting name="ShowTasks" serializeAs="String">
<value>True</value>
</setting>
<setting name="FirstDayOfWeek" serializeAs="String">
<value>Sunday</value>
</setting>
</Outlook2013TodoAddIn.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>