Beispiel #1
0
        public static NotifySettings ReadSettings()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(NotifySettings));

            using (FileStream fs = new FileStream("notifySettings.xml", FileMode.OpenOrCreate))
            {
                try
                {
                    NotifySettings settings = (NotifySettings)serializer.Deserialize(fs);

                    if (settings != null)
                    {
                        return(settings);
                    }
                    else
                    {
                        return(new NotifySettings());
                    }
                }
                catch (InvalidOperationException)
                {
                    return(new EntryControl.NotifySettings());
                }
            }
        }
        private void btnAlwaysNotify_CheckedChanged(object sender, EventArgs e)
        {
            NotifySettings settings = NotifySettings.ReadSettings();

            settings.NotifyAlways = btnAlwaysNotify.Checked;
            settings.SaveSettings();
        }
Beispiel #3
0
        public NotifySettingsForm(Database database)
            : base(database)
        {
            InitializeComponent();

            AddControlImages();

            settings = ReadSettings();
            BindComponent();
        }
        private bool NeedNotify()
        {
            NotifySettings settings = NotifySettings.ReadSettings();

            if (settings.NotifyAlways ||
                DateTime.Now.TimeOfDay <= settings.WorkdayStart.TimeOfDay ||
                DateTime.Now.TimeOfDay >= settings.WorkdayFinish.TimeOfDay ||
                DateTime.Now.DayOfWeek == DayOfWeek.Saturday ||
                DateTime.Now.DayOfWeek == DayOfWeek.Sunday ||
                settings.NotifyDays.Contains(DateTime.Today) ||
                IsVacationDate(DateTime.Today))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void PlayNotifySound()
        {
            string soundFile = NotifySettings.ReadSettings().NotifySoundFile;

            if (soundFile.Length > 0 && File.Exists(soundFile))
            {
                try
                {
                    using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(soundFile))
                        player.Play();
                }
                catch
                {
                    System.Media.SystemSounds.Exclamation.Play();
                }
            }
            else
            {
                System.Media.SystemSounds.Exclamation.Play();
            }
        }
Beispiel #6
0
 private NotifySettings ReadSettings()
 {
     return(NotifySettings.ReadSettings());
 }
 private NotifySettings ReadNotificationSettings()
 {
     return(NotifySettings.ReadSettings());
 }