private void btnImport_Click(object sender, EventArgs e) { try { if (lvReminders.CheckedItems.Count > 0) { foreach (Reminder rem in GetSelectedRemindersFromListview()) { if (!File.Exists(rem.SoundFilePath)) //when you import reminders on another device, the path to the file might not exist. remove it. { rem.SoundFilePath = ""; } BLIO.Log("Pushing reminder with id " + rem.Id + " To the database"); BLReminder.PushReminderToDatabase(rem); } //Let remindme know that the listview should be refreshed BLIO.Log("Sending message WM_RELOAD_REMINDERS ...."); PostMessage((IntPtr)HWND_BROADCAST, WM_RELOAD_REMINDERS, new IntPtr(0xCDCD), new IntPtr(0xEFEF)); this.Close(); } else { MessageFormManager.MakeMessagePopup("Please select at least one reminder.", 3); } } catch (Exception ex) { ErrorPopup pop = new ErrorPopup("Error inserting reminders", ex); pop.Show(); BLIO.WriteError(ex, "Error inserting reminders"); } }
private void btnNewUpdate_Click(object sender, EventArgs e) { try { BLIO.Log("Installing the new version from github!"); if (!File.Exists(IOVariables.rootFolder + "SetupRemindMe.msi")) { RemindMeBox.Show("Could not update RemindMe. Please try again later"); BLIO.Log("SetupRemindMe.msi was not found on the hard drive.. hmmmmm... suspicious.... ;)"); return; } ProcessStartInfo info = new ProcessStartInfo(IOVariables.rootFolder + "install.bat"); info.Verb = "runas"; Process process = new Process(); process.StartInfo = info; process.Start(); Application.Exit(); } catch (Exception ex) { MessageFormManager.MakeMessagePopup("Cancelled installation.", 2); BLIO.Log("Cancelled installation."); } }
private void btnReset_Click(object sender, EventArgs e) { BLPopupDimensions.ResetToDefaults(); MessageFormManager.MakeMessagePopup("Succesfully reset settings.", 4); FillValues(); ApplyPreviewChanges(); }
private void btnSend_Click(object sender, EventArgs e) { try { string email = tbEmail.Text; string subject = tbSubject.Text; string note = tbNote.Text; if (tmrAllowMail.Enabled) { RemindMeBox.Show("You have recently sent an e-mail. Wait a bit before you do it again!"); return; } if (!string.IsNullOrWhiteSpace(subject) && !string.IsNullOrWhiteSpace(note)) { lblSending.Visible = true; pbSending.Visible = true; btnSend.Enabled = false; // TimeSpan timeout = TimeSpan.FromSeconds(5); if (string.IsNullOrWhiteSpace(email)) { sendMailThread = new Thread(() => sendMailException = BLEmail.SendEmail(subject, note, false)); } else { try { MailMessage mes = new MailMessage(email, "*****@*****.**", subject, note); sendMailThread = new Thread(() => sendMailException = BLEmail.SendEmail(subject, note, email, false)); } catch (FormatException ex) { btnSend.Enabled = true; lblSending.Visible = false; pbSending.Visible = false; RemindMeBox.Show("Please enter a valid e-mail address, or leave it empty"); } } if (sendMailThread != null) { sendMailThread.Start(); tmrSendMail.Start(); tbEmail.ResetText(); tbNote.ResetText(); tbSubject.ResetText(); } } } catch (Exception ex) { MessageFormManager.MakeMessagePopup("Something went wrong. Could not send the e-mail", 3); } }
private void SetStatusTexts(int completedReminders, int totalReminders) { foreach (ListViewItem item in lvReminders.CheckedItems) { lvReminders.Items.Remove(item); } if (completedReminders > 0) { MessageFormManager.MakeMessagePopup("Succesfully " + this.transferType.ToString().ToLower() + "ed " + completedReminders + " reminders.", 4); } }
private bool Exportreminders() { if (GetSelectedRemindersFromListview().Count > 0) { string selectedPath = FSManager.Folders.GetSelectedFolderPath(); if (selectedPath != null) { BLIO.Log("User selected a valid path"); Exception possibleException = BLReminder.ExportReminders(GetSelectedRemindersFromListview(), selectedPath); if (possibleException == null) { BLIO.Log("No problems encountered (exception null)"); SetStatusTexts(GetSelectedRemindersFromListview().Count, BLReminder.GetReminders().Count); } else if (possibleException is UnauthorizedAccessException) { BLIO.Log("Problem encountered: Unauthorized"); if (RemindMeBox.Show("Could not save reminders to \"" + selectedPath + "\"\r\nDo you wish to place them on your desktop instead?", RemindMeBoxReason.YesNo) == DialogResult.Yes) { BLIO.Log("Trying to save to desktop instead..."); possibleException = BLReminder.ExportReminders(GetSelectedRemindersFromListview(), Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); if (possibleException != null) {//Did saving to desktop go wrong, too?? just show a message BLIO.Log("Trying to save to desktop didnt work either"); RemindMeBox.Show("Something went wrong. Could not save the reminders to your desktop.", RemindMeBoxReason.OK); return(false); } else {//Saving to desktop did not throw an exception BLIO.Log("Saved to desktop"); SetStatusTexts(GetSelectedRemindersFromListview().Count, BLReminder.GetReminders().Count); } } } else { MessageFormManager.MakeMessagePopup("Backup failed.", 6); return(false); } } else { return(false); } } else { MessageFormManager.MakeMessagePopup("Please select one or more reminder(s)", 6); } return(true); }
private void tmrSendMail_Tick(object sender, EventArgs e) { try { if (sendMailThread.IsAlive) { if (secondsPassed >= timeout) { sendMailThread.Abort(); btnSend.Enabled = true; pbSending.Visible = false; lblSending.Visible = false; MessageFormManager.MakeMessagePopup("Could not send the e-mail from your connection.", 5); tmrSendMail.Stop(); secondsPassed = 0; } } else { lblSending.Visible = false; pbSending.Visible = false; tmrSendMail.Stop(); if (sendMailException == null) { tmrAllowMail.Start(); sendMailThread = null; MessageFormManager.MakeMessagePopup("E-mail Sent. Thank you!", 5); } else { if (sendMailException is FormatException) { RemindMeBox.Show("Please enter a valid e-mail address, or leave it empty"); } else { MessageFormManager.MakeMessagePopup("Could not send the e-mail :(", 3); //No clue what happened } secondsPassed = 0; btnSend.Enabled = true; } } secondsPassed++; } catch (Exception ex) { BLIO.Log("Exception in tmrSendMail_Tick: " + ex.ToString()); tmrSendMail.Stop(); } }
private void btnPreview_Click(object sender, EventArgs e) { if (lvSoundFiles.SelectedItems.Count == 1) { Songs selectedSong = BLSongs.GetSongById((long)lvSoundFiles.SelectedItems[0].Tag); BLIO.Log("Attempting to preview sound file with id " + selectedSong.Id); if (btnPreview.Iconimage == imgPlay) { if (System.IO.File.Exists(selectedSong.SongFilePath)) { BLIO.Log("Sound file exists on the hard drive"); btnPreview.Iconimage = imgStop; myPlayer.URL = selectedSong.SongFilePath; mediaInfo = myPlayer.newMedia(myPlayer.URL); //Start the timer. the timer ticks when the song ends. The timer will then reset the picture of the play button if (mediaInfo.duration > 0) { tmrMusic.Interval = (int)(mediaInfo.duration * 1000); } else { tmrMusic.Interval = 1000; } tmrMusic.Start(); myPlayer.controls.play(); BLIO.Log("Playing sound."); } else { MessageFormManager.MakeMessagePopup("Could not preview the selected song. Does it still exist?", 4); } } else { BLIO.Log("Stopping sound"); btnPreview.Iconimage = imgPlay; myPlayer.controls.stop(); tmrMusic.Stop(); } } }
private void btnRemoveFiles_Click(object sender, EventArgs e) { List <Songs> toRemoveSongs = new List <Songs>(); foreach (ListViewItem selectedItem in lvSoundFiles.SelectedItems) { toRemoveSongs.Add(BLSongs.GetSongById(Convert.ToInt32(selectedItem.Tag))); lvSoundFiles.Items.Remove(selectedItem); } BLSongs.RemoveSongs(toRemoveSongs); if (toRemoveSongs.Count > 0) { MessageFormManager.MakeMessagePopup(toRemoveSongs.Count + " Files removed from RemindMe.", 4); } }
private void SaveChanges() { try { PopupDimensions dimension = new PopupDimensions(); dimension.FontNoteSize = (long)trbNoteFont.Value; dimension.FontTitleSize = (long)trbTitleFont.Value; dimension.FormWidth = (long)trbWidth.Value; dimension.FormHeight = (long)trbHeight.Value; BLPopupDimensions.UpdatePopupDimensions(dimension); MessageFormManager.MakeMessagePopup("Succesfully changed settings.", 4); } catch { MessageFormManager.MakeMessagePopup("Changing settings failed", 4); } }
protected override void WndProc(ref Message m) { //This message will be sent when the RemindMeImporter imports reminders. if (m.Msg == WM_RELOAD_REMINDERS) { BLIO.Log("Received message WM_RELOAD_REMINDERS"); int currentReminderCount = BLReminder.GetReminders().Count; BLReminder.NotifyChange(); UCReminders.GetInstance().UpdateCurrentPage(); if (!this.Visible) //don't make this message if RemindMe is visible, the user will see the changes if it is visible. { MessageFormManager.MakeMessagePopup(BLReminder.GetReminders().Count - currentReminderCount + " Reminder(s) succesfully imported!", 3); BLIO.Log("Created reminders succesfully imported message popup (WndProc)"); } } base.WndProc(ref m); }
private void btnSubmit_Click(object sender, EventArgs e) { try { string textBoxText = tbNote.Text; //Cant access tbNote in a thread. save the text in a variable instead string customMess = "[CUSTOM USER INPUT]\r\n" + textBoxText + "\r\n\r\n---------------Default below--------------------\r\nOops! An error has occured. Here's the details:\r\n\r\n" + ex.ToString(); if (ex is ReminderException) { ReminderException theException = (ReminderException)ex; if (theException.Reminder != null) { theException.Reminder.Note = "Removed for privacy reasons"; theException.Reminder.Name = "Removed for privacy reasons"; customMess += "\r\n\r\nThis exception is an ReminderException! Let's see if we can figure out what's wrong with it....\r\n"; customMess += "ID: " + theException.Reminder.Id + "\r\n"; customMess += "Deleted: " + theException.Reminder.Deleted + "\r\n"; customMess += "Date: " + theException.Reminder.Date + "\r\n"; customMess += "RepeatType: " + theException.Reminder.RepeatType + "\r\n"; customMess += "Enabled: " + theException.Reminder.Enabled + "\r\n"; customMess += "DayOfMonth: " + theException.Reminder.DayOfMonth + "\r\n"; customMess += "EveryXCustom: " + theException.Reminder.EveryXCustom + "\r\n"; customMess += "RepeatDays: " + theException.Reminder.RepeatDays + "\r\n"; customMess += "SoundFilePath: " + theException.Reminder.SoundFilePath + "\r\n"; customMess += "PostponeDate: " + theException.Reminder.PostponeDate + "\r\n"; customMess += "Hide: " + theException.Reminder.Hide + "\r\n"; } } Thread sendMailThread = new Thread(() => BLEmail.SendEmail("[CUSTOM] | Error Report: " + ex.GetType().ToString(), customMess)); sendMailThread.Start(); MessageFormManager.MakeMessagePopup("Feedback sent.\r\nThank you for taking the time!", 5); this.Dispose(); } catch { } //Set this boolean to true so that when this popup closes, we won't try to send another e-mail sentCustomEmail = true; }
private void btnImport_Click(object sender, EventArgs e) { BLIO.Log("Import button pressed. Loading reminders into listview"); remindersFromRemindMeFile.Clear(); ToggleButton(sender); lvReminders.Items.Clear(); string remindmeFile = FSManager.Files.GetSelectedFileWithPath("RemindMe backup file", "*.remindme"); if (remindmeFile == null || remindmeFile == "") {//user pressed cancel btnImport.selected = false; return; } BLIO.Log("Valid .remindme file selected"); try { List <object> toImportReminders = BLReminder.DeserializeRemindersFromFile(remindmeFile).Cast <object>().ToList(); if (toImportReminders != null) { BLIO.Log(toImportReminders.Count - 1 + " reminders in this .remindme file"); transferType = ReminderTransferType.IMPORT; foreach (object rem in toImportReminders) { if (rem.GetType() == typeof(Reminder)) { BLFormLogic.AddReminderToListview(lvReminders, (Reminder)rem); remindersFromRemindMeFile.Add((Reminder)rem); } } } } catch (Exception ex) { MessageFormManager.MakeMessagePopup("Error loading reminder(s)", 6); } }
private void btnAddFiles_Click(object sender, EventArgs e) { int songsAdded = 0; List <string> songPaths = FSManager.Files.GetSelectedFilesWithPath("", "*.mp3; *.wav;").ToList(); if (songPaths.Count == 1 && songPaths[0] == "")//The user canceled out { return; } BLIO.Log("user selected " + songPaths.Count + " mp3 / wav files."); List <Songs> songs = new List <Songs>(); foreach (string songPath in songPaths) { Songs song = new Songs(); song.SongFileName = Path.GetFileName(songPath); song.SongFilePath = songPath; songs.Add(song); } BLSongs.InsertSongs(songs); BLIO.Log("Inserted " + songs.Count + " sound files into RemindME"); foreach (Songs song in songs) { if (!ListViewContains(song.SongFilePath)) { songsAdded++; ListViewItem item = new ListViewItem(song.SongFilePath); item.Tag = song.Id; lvSoundFiles.Items.Add(item); } } MessageFormManager.MakeMessagePopup(songsAdded + " Files added to RemindMe.", 4); LoadSongs(); }
private void DownloadMsi() { new Thread(() => { try { this.BeginInvoke((MethodInvoker)async delegate { try { BLIO.Log("New version on github! starting download..."); updater = new RemindMeUpdater(); updater.startDownload(); while (!updater.Completed) { await Task.Delay(500); } MessageFormManager.MakeMessagePopup("RemindMe has a new version available to update!\r\nClick the update button on RemindMe on the left panel!", 10); btnNewUpdate.Visible = true; BLIO.Log("Completed downloading the new .msi from github!"); } catch { BLIO.Log("Downloading new version of RemindMe failed! :("); } }); } catch (Exception ex) { BLIO.Log("Failed downloading MSI. " + ex.ToString()); } }).Start(); }
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(); }
private void bunifuFlatButton2_Click(object sender, EventArgs e) { MessageFormManager.MakeMessagePopup("This is a test.", 4); }
private void btnConfirm_Click(object sender, EventArgs e) { BLIO.Log("(AVR) Saving & hiding AVR form"); MessageFormManager.MakeMessagePopup("Advanced settings applied to this reminder!", 5); Hide(); }