using Microsoft.Win32; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MeetingClock { public class Settings { private readonly string AUTOSTART_REGKEY = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; private readonly string AUTOSTART_VALUE = "Meeting-Clock"; public bool Autostart { get { using (RegistryKey key = Registry.CurrentUser.OpenSubKey(AUTOSTART_REGKEY, false)) { return (string) key.GetValue(AUTOSTART_VALUE) == "\"" + Application.ExecutablePath + "\""; } } set { using (RegistryKey key = Registry.CurrentUser.OpenSubKey(AUTOSTART_REGKEY, true)) { if (value) { key.SetValue(AUTOSTART_VALUE, "\"" + Application.ExecutablePath + "\""); } else { key.DeleteValue(AUTOSTART_VALUE, false); } } } } public bool StartMinimized { get { return Properties.Settings.Default.StartMinimized; } set { Properties.Settings.Default.StartMinimized = value; Properties.Settings.Default.Save(); } } public bool StartBluetooth { get { return Properties.Settings.Default.StartBluetooth; } set { Properties.Settings.Default.StartBluetooth = value; Properties.Settings.Default.Save(); } } public bool IgnoreAllDayAppointments { get { return Properties.Settings.Default.IgnoreAllDayAppointments; } set { Properties.Settings.Default.IgnoreAllDayAppointments = value; Properties.Settings.Default.Save(); } } public bool IgnoreCancelledAppointments { get { return Properties.Settings.Default.IgnoreCancelledAppointments; } set { Properties.Settings.Default.IgnoreCancelledAppointments = value; Properties.Settings.Default.Save(); } } public bool IgnoreFreeAppointments { get { return Properties.Settings.Default.IgnoreFreeAppointments; } set { Properties.Settings.Default.IgnoreFreeAppointments = value; Properties.Settings.Default.Save(); } } public bool IgnoreOutOfOfficeAppointments { get { return Properties.Settings.Default.IgnoreOutOfOfficeAppointments; } set { Properties.Settings.Default.IgnoreOutOfOfficeAppointments = value; Properties.Settings.Default.Save(); } } public bool IgnoreTentativeAppointments { get { return Properties.Settings.Default.IgnoreTentativeAppointments; } set { Properties.Settings.Default.IgnoreTentativeAppointments = value; Properties.Settings.Default.Save(); } } public int ReminderTime { get { return Properties.Settings.Default.ReminderTime; } set { Properties.Settings.Default.ReminderTime = value; Properties.Settings.Default.Save(); } } } }