using System; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Outlook = Microsoft.Office.Interop.Outlook; namespace Outlook2013TodoAddIn.Forms { public partial class FormConfiguration : Form { #region "Properties" /// /// Number of days (including today) to retrieve appointments from in the future /// public decimal NumDays { get { return this.numRangeDays.Value; } set { this.numRangeDays.Value = value; } } /// /// Gets/sets whether mail notifications are enabled or not /// public bool MailAlertsEnabled { get { return this.chkMailAlerts.Checked; } set { this.chkMailAlerts.Checked = value; } } /// /// Gets/sets whether to show past appointments in the current day or not /// public bool ShowPastAppointments { get { return this.chkShowPastAppointments.Checked; } set { this.chkShowPastAppointments.Checked = value; } } /// /// Gets/sets a list of all stores/accounts to retrieve information from /// public StringCollection Accounts { get { StringCollection col = new StringCollection(); foreach (object item in this.chkListCalendars.CheckedItems) { col.Add(item.ToString()); } return col; } } /// /// Gets/sets whether to show friendly group headers (yesterday, today, tomorrow) /// public bool ShowFriendlyGroupHeaders { get { return this.chkFriendlyGroupHeaders.Checked; } set { this.chkFriendlyGroupHeaders.Checked = value; } } #endregion "Properties" #region "Methods" /// /// Default constructor /// public FormConfiguration() { InitializeComponent(); } /// /// On load, display saved configuration /// /// Sender /// EventArgs private void FormConfiguration_Load(object sender, EventArgs e) { this.numRangeDays.Value = Properties.Settings.Default.NumDays; this.chkMailAlerts.Checked = Properties.Settings.Default.MailAlertsEnabled; this.chkShowPastAppointments.Checked = Properties.Settings.Default.ShowPastAppointments; this.chkFriendlyGroupHeaders.Checked = Properties.Settings.Default.ShowFriendlyGroupHeaders; this.LoadStores(); } /// /// Loads all the stores (accounts) in the current session /// private void LoadStores() { foreach (Outlook.Store store in Globals.ThisAddIn.Application.Session.Stores) { bool itemChecked = Properties.Settings.Default.Accounts != null && Properties.Settings.Default.Accounts.Contains(store.DisplayName); int index = this.chkListCalendars.Items.Add(store.DisplayName, itemChecked); // TODO: Use StoreID instead? } } /// /// Clicking the OK button /// /// Sender /// EventArgs private void btnOK_Click(object sender, EventArgs e) { Properties.Settings.Default.NumDays = this.numRangeDays.Value; Properties.Settings.Default.MailAlertsEnabled = this.chkMailAlerts.Checked; Properties.Settings.Default.ShowPastAppointments = this.chkShowPastAppointments.Checked; Properties.Settings.Default.Accounts = this.Accounts; Properties.Settings.Default.ShowFriendlyGroupHeaders = this.chkFriendlyGroupHeaders.Checked; } #endregion "Methods" } }