private void UCWindowOverlay_Load(object sender, EventArgs e) { if (BLSettings.GetSettings() == null) { Settings set = new Settings(); set.AlwaysOnTop = alwaysOnTop; set.StickyForm = 0; set.EnableHourBeforeReminder = 1; set.EnableReminderCountPopup = 1; set.EnableQuickTimer = 1; BLSettings.UpdateSettings(set); } //Since we're not going to change the contents of this combobox anyway, we're just going to do it like this if (BLSettings.IsAlwaysOnTop()) { cbPopupType.SelectedItem = cbPopupType.Items[0]; } else { cbPopupType.SelectedItem = cbPopupType.Items[1]; } cbRemindMeMessages.Checked = BLSettings.IsReminderCountPopupEnabled(); cbOneHourBeforeNotification.Checked = BLSettings.IsHourBeforeNotificationEnabled(); cbQuicktimer.Checked = BLSettings.GetSettings().EnableQuickTimer == 1; cbAdvancedReminders.Checked = BLSettings.GetSettings().EnableAdvancedReminders == 1; Hotkeys timerKey = BLHotkeys.TimerPopup; foreach (string m in timerKey.Modifiers.Split(',')) { tbTimerHotkey.Text += m + " + "; } tbTimerHotkey.Text += timerKey.Key; //Fill the combobox to select a timer popup sound with data FillSoundCombobox(); //Set the item the user selected as text string def = BLSettings.GetSettings().DefaultTimerSound; if (def == null) //User has no default sound combobox { foreach (ComboBoxItem itm in cbSound.Items) { if (itm.Text.ToLower().Contains("unlock")) //Set the default timer sound to windows unlock { Songs sng = (Songs)itm.Value; Settings set = BLSettings.GetSettings(); set.DefaultTimerSound = sng.SongFilePath; BLSettings.UpdateSettings(set); } } } if (BLSettings.GetSettings().DefaultTimerSound == null)//Still null? well damn. { return; } cbSound.Items.Add(new ComboBoxItem(Path.GetFileNameWithoutExtension(BLSettings.GetSettings().DefaultTimerSound), BLSongs.GetSongByFullPath(BLSettings.GetSettings().DefaultTimerSound))); cbSound.Text = Path.GetFileNameWithoutExtension(BLSettings.GetSettings().DefaultTimerSound); }
private void tmrCheckReminder_Tick(object sender, EventArgs e) { if (BLReminder.GetReminders().Where(r => r.Enabled == 1).ToList().Count <= 0) { tmrCheckReminder.Stop(); //No existing reminders? no enabled reminders? stop timer. BLIO.Log("Stopping the reminder checking timer, because there are no more (enabled) reminders"); return; } //If a day has passed since the start of RemindMe, we may want to refresh the listview. //There might be reminders happening on this day, if so, we show the time of the reminder, instead of the day if (dayOfStartRemindMe < DateTime.Now.Day) { BLIO.Log("Dawn of a new day -24 hours remaining- "); UpdateCurrentPage(); dayOfStartRemindMe = DateTime.Now.Day; MessageFormManager.MakeTodaysRemindersPopup(); } //We will check for reminders here every 5 seconds. foreach (Reminder rem in BLReminder.GetReminders()) { //Create the popup. Do the other stuff afterwards. if ((rem.PostponeDate != null && Convert.ToDateTime(rem.PostponeDate) <= DateTime.Now && rem.Enabled == 1) || (Convert.ToDateTime(rem.Date.Split(',')[0]) <= DateTime.Now && rem.PostponeDate == null && rem.Enabled == 1)) { //temporarily disable it. When the user postpones the reminder, it will be re-enabled. rem.Enabled = 0; BLReminder.EditReminder(rem); MakeReminderPopup(rem); UpdateCurrentPage(); } else { // -- In this part we will create popups at the users right bottom corner of the screen saying x reminder is happening in 1 hour or x minutes -- \\ if (BLSettings.IsHourBeforeNotificationEnabled() && rem.Enabled == 1) { DateTime theDateToCheckOn; //Like this we dont need an if ánd an else with the same code if (rem.PostponeDate != null) { theDateToCheckOn = Convert.ToDateTime(rem.PostponeDate); } else { theDateToCheckOn = Convert.ToDateTime(rem.Date.Split(',')[0]); } //The timespan between the date and now. TimeSpan timeSpan = Convert.ToDateTime(theDateToCheckOn) - DateTime.Now; if (timeSpan.TotalMinutes >= 59.50 && timeSpan.TotalMinutes <= 60) { remindersToHappenInAnHour.Add(rem); } } } } string message = "You have " + remindersToHappenInAnHour.Count + " reminders set in 60 minutes:\r\n"; int count = 1; foreach (Reminder rem in remindersToHappenInAnHour) { if (remindersToHappenInAnHour.Count > 1) { message += count + ") " + rem.Name + Environment.NewLine; } else { message = rem.Name + " in 60 minutes!"; } count++; } if (remindersToHappenInAnHour.Count > 1) //cut off the last \n { message = message.Remove(message.Length - 2, 2); if (!popupMessages.Contains(message)) //Don't create this popup if we have already created it once before { MessageFormManager.MakeMessagePopup(message, 8); } popupMessages.Add(message); } else if (remindersToHappenInAnHour.Count > 0) { if (!popupMessages.Contains(message)) //Don't create this popup if we have already created it once before { MessageFormManager.MakeMessagePopup(message, 8, remindersToHappenInAnHour[0]); } popupMessages.Add(message); } remindersToHappenInAnHour.Clear(); }