private void btnDelete_Click(object sender, EventArgs e) { BLIO.Log("Delete button clicked on reminder item (" + rem.Id + ")"); BLReminder.DeleteReminder(rem); Reminder copy = new Reminder(); // copy.Id = rem.Id; copy.Deleted = rem.Deleted; copy.HttpId = rem.HttpId; this.Reminder = null; MUCReminders.Instance.UpdateCurrentPage(copy); copy = null; }
public RemindMeMessageForm(string message, int timeout, Reminder rem) : this(message, timeout) { pnlReminderOptions.Visible = true; theReminder = rem; if (!BLReminder.IsRepeatableReminder(rem)) { btnSkip.Textcolor = Color.Gray; btnSkip.Enabled = false; btnSkip.Cursor = Cursors.Default; } btnDisable.Visible = true; }
private bool RecoverReminders() { int remindersRecovered = 0; List <Reminder> selectedReminders = GetSelectedRemindersFromListview(); if (selectedReminders.Count == 0) { return(false); } BLIO.Log("Attempting to recover " + selectedReminders.Count + " reminders ..."); foreach (Reminder rem in selectedReminders) { if (!File.Exists(rem.SoundFilePath)) //when you import reminders on another device, the path to the file might not exist. remove it. { rem.SoundFilePath = ""; } if (rem.Deleted == 1 || rem.Deleted == 2) //The user wants to recover reminders, instead of importing new ones { BLIO.Log("Reminder deleted: " + rem.Deleted + ". Setting deleted,enabled and hidden to 0"); rem.Deleted = 0; rem.Enabled = 0; //Disable it so the user doesnt instantly get the reminder as an popup, as the reminder was in the past rem.Hide = 0; //Make sure it isn't hidden, since you cant easily re-enable hidden reminders, you first have to unhide all reminders first BLReminder.EditReminder(rem); BLIO.Log("Reminder with id " + rem.Id + " edited"); } remindersRecovered++; } new Thread(() => { //Log an entry to the database, for data! try { BLOnlineDatabase.RecoverCount++; } catch (ArgumentException ex) { BLIO.Log("Exception at BLOnlineDatabase.RecoverCount++. -> " + ex.Message); BLIO.WriteError(ex, ex.Message, true); } }).Start(); BLIO.Log(remindersRecovered + " Reminders recovered"); SetStatusTexts(remindersRecovered, selectedReminders.Count); return(true); }
/// <summary> /// makes the popup that shows howmany reminders are set for today /// </summary> public static void MakeTodaysRemindersPopup() { int reminderCount = BLReminder.GetTodaysReminders().Count; if (BLLocalDatabase.Setting.IsReminderCountPopupEnabled()) { if (reminderCount > 0) { MakeMessagePopup("You have " + reminderCount + " Reminder(s) set for today.", 3); } else { MakeMessagePopup("You have no reminders set for today.", 3); } } }
/// <summary> /// When right-clicking reminder(s), this method will hide the skip to next date option if one of the reminder(s) does not have a next date. /// </summary> private void HideOrShowUnhideReminders() { //Check if there is even a single reminder that is hidden bool showMenuItem = false; if (BLReminder.GetReminders().Where(r => r.Hide == 1).ToList().Count > 0) { showMenuItem = true; //If there's just 1 reminder that is hidden, show the option to un-hide all reminders } //The option ToolStripItem unHideToolStripItem = ReminderMenuStrip.Items.Find("unHideReminderToolStripMenuItem", false)[0]; //determine if we are going to hide the "Remove postpone" option based on the boolean hideMenuItem unHideToolStripItem.Visible = showMenuItem; BLIO.Log("Showing unhide reminders option from right click menu: " + showMenuItem); }
private bool ImportReminders() { int remindersInserted = 0; List <Reminder> selectedReminders = GetSelectedRemindersFromListview(); if (selectedReminders.Count == 0) { return(false); } if (remindersFromRemindMeFile != null) { BLIO.Log("Attempting to import " + selectedReminders.Count + " reminders ..."); foreach (Reminder rem in selectedReminders) { if (!File.Exists(rem.SoundFilePath)) //when you import reminders on another device, the path to the file might not exist. remove it. { rem.SoundFilePath = ""; } BLReminder.PushReminderToDatabase(rem); BLIO.Log("Pushed reminder with id " + rem.Id + " to the database"); remindersInserted++; } new Thread(() => { //Log an entry to the database, for data! try { BLOnlineDatabase.ImportCount++; } catch (ArgumentException ex) { BLIO.Log("Exception at BLOnlineDatabase.ImportCount++ UCImportexport.cs . -> " + ex.Message); BLIO.WriteError(ex, ex.Message, true); } }).Start(); BLIO.Log(remindersInserted + " Reminders inserted"); } SetStatusTexts(remindersInserted, selectedReminders.Count); return(true); }
private void postponeToolStripMenuItem_Click(object sender, EventArgs e) { int minutes = RemindMePrompt.ShowMinutes("Select your postpone time", "(in minutes or in xhxxm format (1h20m) )"); if (rem.PostponeDate == null)//No postpone yet, create it { rem.PostponeDate = Convert.ToDateTime(rem.Date.Split(',')[0]).AddMinutes(minutes).ToString(); } else//Already a postponedate, add the time to that date { rem.PostponeDate = Convert.ToDateTime(rem.PostponeDate).AddMinutes(minutes).ToString(); } BLReminder.EditReminder(rem);//Push changes UCReminders.GetInstance().UpdateCurrentPage(); }
private void btnDisable_Click(object sender, EventArgs e) { if (rem.Enabled == 1) { btnDisable.Image = Properties.Resources.turnedOffTwo; rem.Enabled = 0; } else { btnDisable.Image = Properties.Resources.turnedOn; rem.Enabled = 1; } BLReminder.EditReminder(rem); UCReminders.GetInstance().UpdateCurrentPage(); UCReminders.GetInstance().RefreshPage(); }
private void btnUnhideReminders_Click(object sender, EventArgs e) { int remindersUnhidden = 0; foreach (Reminder rem in BLReminder.GetReminders()) { if (rem.Hide == 1) { rem.Hide = 0; remindersUnhidden++; } BLReminder.EditReminder(rem); } BLIO.Log(remindersUnhidden + " reminders not hidden anymore"); UpdateCurrentPage(); }
private void btnDisable_Click(object sender, EventArgs e) { BLIO.Log("Disable button clicked on reminder item (" + rem.Id + ")"); if (rem.Enabled == 1) { btnDisable.Image = Properties.Resources.turnedOffTwo; rem.Enabled = 0; } else { btnDisable.Image = Properties.Resources.turnedOn; rem.Enabled = 1; } BLReminder.EditReminder(rem); UCReminders.Instance.UpdateCurrentPage(); }
private void AddRemindersToPanel() { Point loc = new Point(10, 10); UCReminderItem itm = null; foreach (Reminder rem in BLReminder.GetReminders()) { if (itm != null) { loc = new Point(loc.X, (itm.Location.Y + itm.Height) + 10); } itm = new UCReminderItem(rem); itm.Location = loc; pnlReminders.Controls.Add(itm); } }
private void skipToNextDateToolStripMenuItem_Click(object sender, EventArgs e) { BLIO.Log("Toolstrip option clicked: Skip (" + rem.Id + ")"); //The reminder object has now been altered. The first date has been removed and has been "skipped" to it's next date BLReminder.SkipToNextReminderDate(rem); //push the altered reminder to the database BLReminder.EditReminder(rem); //Refresh to show changes UCReminders.Instance.UpdateCurrentPage(); new Thread(() => { //Log an entry to the database, for data! BLOnlineDatabase.SkipCount++; }).Start(); }
private List <Reminder> GetSelectedRemindersFromListview() { List <long> checkedIds = new List <long>(); //get all selected id's from the listview reminders foreach (ListViewItem item in lvReminders.CheckedItems) { checkedIds.Add((long)item.Tag); } if (transferType == ReminderTransferType.IMPORT) //Look through the reminders from the .remindme file instead of the database if import. { return(remindersFromRemindMeFile.Where(r => checkedIds.Contains(r.Id)).ToList()); } else { return(BLReminder.GetAllReminders().Where(r => checkedIds.Contains(r.Id)).ToList()); } }
private void btnPreviousPage_Click(object sender, EventArgs e) { BLIO.Log("btnPreviousPage_Click"); if (pageNumber <= 1) //Can't go to the previous page if we're on the first one { return; } List <Reminder> reminders = BLReminder.GetOrderedReminders(); int reminderItemCounter = 0; for (int i = (pageNumber - 2) * 7; i < ((pageNumber - 2) * 7) + 7; i++) { if (reminders.Count - 1 >= i) //Safely within index numbers { //Get the user control item from the panel. There's 7 user controls in the panel, so we have another counter for those MUCReminderItem itm = (MUCReminderItem)pnlReminders.Controls[reminderItemCounter]; itm.Visible = true; //Update the reminder object inside the user control, that's waay faster than removing and re-drawing a new control. itm.Reminder = reminders[i]; } reminderItemCounter++; if (reminderItemCounter == 7) { break; } } pageNumber--; SetPageButtonIcons(reminders); foreach (MUCReminderItem itm in pnlReminders.Controls) { itm.RefreshLabelFont(); } GC.Collect(); }
private void btnDisable_Click(object sender, EventArgs e) { BLIO.Log("btnDisable clicked on reminder " + rem.Id); if (xClose) { xClose = false; } if (rem != null) { rem = BLReminder.GetReminderById(rem.Id); } if (rem == null) { goto close; } if (rem.Id != -1 && rem.Deleted == 0) //Don't do stuff if the id is -1, invalid. the id is set to -1 when the user previews an reminder { if (BLReminder.GetReminderById(rem.Id) == null) { //The reminder popped up, it existed, but when pressing disable it doesn't exist anymore (maybe the user deleted it or tempered with the .db file) BLIO.Log("DETECTED NONEXISTING REMINDER WITH ID " + rem.Id + ", Attempted to press OK on a reminder that somehow doesn't exist"); goto close; } rem.Enabled = 0; BLIO.Log("Reminder marked as disabled"); BLReminder.EditReminder(rem); BLIO.Log("Disabled succesfully."); } close: MUCReminders.Instance.UpdateCurrentPage(); BLIO.Log("Stopping media player & Closing popup"); myPlayer.controls.stop(); this.Close(); GC.Collect(); }
private void btnPostpone_Click(object sender, EventArgs e) { BLIO.Log("RemindMeMessageForm option clicked: Postpone (" + theReminder.Id + ")"); isDialog = true; int minutes = MaterialRemindMePrompt.ShowMinutes("Select your postpone time", "(in minutes or in xhxxm format (1h20m) )"); if (minutes <= 0) { BLIO.Log("Postponing reminder with " + minutes + " minutes DENIED."); return; } if (theReminder.PostponeDate == null)//No postpone yet, create it { theReminder.PostponeDate = Convert.ToDateTime(theReminder.Date.Split(',')[0]).AddMinutes(minutes).ToShortDateString() + " " + Convert.ToDateTime(theReminder.Date.Split(',')[0]).AddMinutes(minutes).ToShortTimeString(); } else//Already a postponedate, add the time to that date { theReminder.PostponeDate = Convert.ToDateTime(theReminder.PostponeDate).AddMinutes(minutes).ToShortDateString() + " " + Convert.ToDateTime(theReminder.PostponeDate).AddMinutes(minutes).ToShortTimeString(); } BLReminder.EditReminder(theReminder);//Push changes MUCReminders.Instance.UpdateCurrentPage(); new Thread(() => { //Log an entry to the database, for data! try { BLOnlineDatabase.PostponeCount++; } catch (ArgumentException ex) { BLIO.Log("Exception at BLOnlineDatabase.PostponeCount++. -> " + ex.Message); BLIO.WriteError(ex, ex.Message, true); } }).Start(); this.Close(); this.Dispose(); }
private void hideReminderToolStripMenuItem_Click(object sender, EventArgs e) { string message = "You can hide reminders with this option. The reminder will not be deleted, you just won't be able to see it" + " in the list of reminders. This creates a sense of surprise.\r\n\r\nDo you wish to hide this reminder?"; BLIO.Log("Attempting to hide reminder(s)"); if (BLSettings.HideReminderOptionEnabled || RemindMeBox.Show(message, RemindMeBoxReason.YesNo, true) == DialogResult.Yes) { //Enable the hide flag here rem.Hide = 1; BLIO.Log("Marked reminder with id " + rem.Id + " as hidden"); BLReminder.EditReminder(rem); UCReminders.GetInstance().UpdateCurrentPage(); UCReminders.GetInstance().RefreshPage(); } else { BLIO.Log("Attempting to hide reminder(s) failed."); } }
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); }
/*This was testing a custom color scheme * private void SetColorScheme() * { * * string t = BLLocalDatabase.Setting.Settings.RemindMeTheme; * RemindMeColorScheme colorTheme = BLLocalDatabase.Setting.GetColorTheme(BLLocalDatabase.Setting.Settings.RemindMeTheme); * BLIO.Log("Setting RemindMe Color scheme \"" + BLLocalDatabase.Setting.Settings.RemindMeTheme + "\""); * pnlSide.GradientBottomLeft = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[2])); * pnlSide.GradientBottomRight = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[2])); * pnlSide.GradientTopLeft = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[2])); * pnlSide.GradientTopRight = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[2])); * * * pnlMain.GradientBottomLeft = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[2])); * pnlMain.GradientBottomRight = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[2])); * pnlMain.GradientTopLeft = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[2])); * pnlMain.GradientTopRight = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[2])); * }*/ 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("Reloading reminders after import from .remindme file"); int currentReminderCount = BLReminder.GetReminders().Count; BLReminder.NotifyChange(); if (MUCReminders.Instance != null) { MUCReminders.Instance.UpdateCurrentPage(); } if (!this.Visible) //don't make this message if RemindMe is visible, the user will see the changes if it is visible. { MaterialMessageFormManager.MakeMessagePopup(BLReminder.GetReminders().Count - currentReminderCount + " Reminder(s) succesfully imported!", 3); BLIO.Log("Created reminders succesfully imported message popup (WndProc)"); } if ((BLReminder.GetReminders().Count - currentReminderCount) > 0) { new Thread(() => { //Log an entry to the database, for data! try { BLOnlineDatabase.ImportCount++; } catch (ArgumentException ex) { BLIO.Log("Exception at BLOnlineDatabase.ImportCount++ Form1.cs . -> " + ex.Message); BLIO.WriteError(ex, ex.Message, true); } }).Start(); } } base.WndProc(ref m); }
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 { RemindMeMessageFormManager.MakeMessagePopup("Error loading reminder(s)", 6); } }
private void hideReminderToolStripMenuItem_Click(object sender, EventArgs e) { BLIO.Log("Toolstrip option clicked: Hide (" + rem.Id + ")"); string message = "You can hide reminders with this option. The reminder will not be deleted, you just won't be able to see it" + " in the list of reminders. This creates a sense of surprise.\r\n\r\nDo you wish to hide this reminder?"; BLIO.Log("Attempting to hide reminder(s)"); if (BLLocalDatabase.Setting.HideReminderOptionEnabled || MaterialRemindMeBox.Show(message, RemindMeBoxReason.YesNo, true) == DialogResult.Yes) { //Enable the hide flag here rem.Hide = 1; BLIO.Log("Marked reminder with id " + rem.Id + " as hidden"); BLReminder.EditReminder(rem); this.Reminder = null; MUCReminders.Instance.UpdateCurrentPage(); new Thread(() => { //Log an entry to the database, for data! try { BLOnlineDatabase.HideCount++; } catch (ArgumentException ex) { BLIO.Log("Exception at BLOnlineDatabase.HideCount++. -> " + ex.Message); BLIO.WriteError(ex, ex.Message, true); } finally { GC.Collect(); } }).Start(); } else { BLIO.Log("Attempting to hide reminder(s) failed."); } }
private void btnDisable_Click(object sender, EventArgs e) { BLIO.Log("Disable button clicked on reminder item (" + rem.Id + ")"); if (rem.Enabled == 1) { btnDisable.Image = Properties.Resources.turnedOffTwo; lblReminderName.Visible = false; lblReminderNameDisabled.Visible = true; lblDate.FontType = MaterialSkin.MaterialSkinManager.fontType.Body2; lblRepeat.FontType = MaterialSkin.MaterialSkinManager.fontType.Body2; rem.Enabled = 0; } else { btnDisable.Image = Properties.Resources.turnedOn; rem.Enabled = 1; } BLReminder.EditReminder(rem); MUCReminders.Instance.UpdateCurrentPage(rem); }
private void btnPreviousPage_Click(object sender, EventArgs e) { BLIO.Log("btnPreviousPage_Click"); if (pageNumber <= 1) //Can't go to the previous page if we're on the first one { return; } List <Reminder> reminders = BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 1).Where(r => r.Hide == 0).ToList(); reminders.AddRange(BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 0).Where(r => r.Hide == 0)); //^ All reminders in one list with the disabled ones at the end of the list int reminderItemCounter = 0; for (int i = (pageNumber - 2) * 7; i < ((pageNumber - 2) * 7) + 7; i++) { if (reminders.Count - 1 >= i) //Safely within index numbers { //Get the user control item from the panel. There's 7 user controls in the panel, so we have another counter for those UCReminderItem itm = (UCReminderItem)pnlReminders.Controls[reminderItemCounter]; itm.Visible = true; //Update the reminder object inside the user control, that's waay faster than removing and re-drawing a new control. itm.Reminder = reminders[i]; } reminderItemCounter++; if (reminderItemCounter == 7) { break; } } pageNumber--; Form1.Instance.UpdatePageNumber(pageNumber); SetPageButtonIcons(reminders); }
private void toolStripMenuItem1_Click(object sender, EventArgs e) { BLIO.Log("Toolstrip option clicked: Permanentely delete (" + rem.Id + ")"); if (RemindMeBox.Show("Are you really sure you wish to permanentely delete \"" + rem.Name + "\" ?", RemindMeBoxReason.YesNo) == DialogResult.Yes) { BLIO.Log("Permanentely deleting reminder with id " + rem.Id + " ..."); BLReminder.PermanentelyDeleteReminder(rem); BLIO.Log("Reminder permanentely deleted."); this.Reminder = null; UCReminders.Instance.UpdateCurrentPage(); new Thread(() => { //Log an entry to the database, for data! BLOnlineDatabase.PermanentelyDeleteCount++; }).Start(); } else { BLIO.Log("Permanent deletion of reminder " + rem.Id + " cancelled."); } }
private void duplicateToolStripMenuItem_Click(object sender, EventArgs e) { BLIO.Log("Toolstrip option clicked: Duplicate (" + rem.Id + ")"); BLIO.Log("Setting up the duplicating process..."); BLIO.Log("duplicating reminder with id " + rem.Id); BLReminder.PushReminderToDatabase(rem); BLIO.Log("reminder duplicated."); UCReminders.Instance.UpdateCurrentPage(); new Thread(() => { //Log an entry to the database, for data! try { BLOnlineDatabase.DuplicateCount++; } catch (ArgumentException ex) { BLIO.Log("Exception at BLOnlineDatabase.DuplicateCount++. -> " + ex.Message); BLIO.WriteError(ex, ex.Message, true); } }).Start(); }
private List <Reminder> OrderPostponedReminders() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); List <Reminder> reminders = BLReminder.GetReminders().Where(r => r.Enabled == 1).Where(r => r.Hide == 0).Where(r => string.IsNullOrWhiteSpace(r.PostponeDate)).ToList(); List <Reminder> postPonedReminders = BLReminder.GetReminders().Where(r => r.Enabled == 1).Where(r => r.Hide == 0).Where(r => !string.IsNullOrWhiteSpace(r.PostponeDate)).ToList(); Dictionary <long, DateTime> orderedReminders = new Dictionary <long, DateTime>(); foreach (Reminder rem in reminders) { orderedReminders.Add(rem.Id, Convert.ToDateTime(rem.Date.Split(',')[0])); } foreach (Reminder rem in postPonedReminders) { orderedReminders.Add(rem.Id, Convert.ToDateTime(rem.PostponeDate)); } //now we have both normal dates and postpone dates List <Reminder> returnValue = new List <Reminder>(); foreach (KeyValuePair <long, DateTime> entry in orderedReminders.OrderBy(x => x.Value)) { returnValue.Add(BLReminder.GetReminderById(entry.Key)); } stopwatch.Stop(); BLIO.Log("OrderPostponedReminders() took " + stopwatch.ElapsedMilliseconds + " ms"); return(returnValue); }
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 { RemindMeMessageFormManager.MakeMessagePopup("Backup failed.", 6); return(false); } } else { return(false); } } else { RemindMeMessageFormManager.MakeMessagePopup("Please select one or more reminder(s)", 6); } return(true); }
//Loads reminder data into the controls private void Enable() { //Enabled icons btnDelete.Image = Properties.Resources.Bin_white; btnEdit.Image = Properties.Resources.Edit_white; btnSettings.Image = Properties.Resources.gearWhite; //Reset location pbRepeat.Location = new Point(168, 26); lblRepeat.Location = new Point(195, 30); DateTime date = Convert.ToDateTime(rem.Date.Split(',')[0]); if (date.ToShortDateString() == DateTime.Now.ToShortDateString()) { lblDate.Text = "Today " + date.ToShortTimeString(); } else { lblDate.Text = date.ToShortDateString() + " " + date.ToShortTimeString(); } //Postpone logic if (rem.PostponeDate != null) { pbDate.BackgroundImage = Properties.Resources.RemindMeZzz; Font font = new Font(lblRepeat.Font, FontStyle.Bold | FontStyle.Italic); lblDate.Font = font; if (Convert.ToDateTime(rem.PostponeDate).ToShortDateString() == DateTime.Now.ToShortDateString()) { lblDate.Text = "Today " + Convert.ToDateTime(rem.PostponeDate).ToShortTimeString(); } else { lblDate.Text = Convert.ToDateTime(rem.PostponeDate).ToShortDateString() + " " + Convert.ToDateTime(rem.PostponeDate).ToShortTimeString(); } } else { pbDate.BackgroundImage = Properties.Resources.RemindMe; Font font = new Font(lblRepeat.Font, FontStyle.Bold); lblDate.Font = font; } //If some country has a longer date string, move the repeat icon/text more to the right so it doesnt overlap while (lblDate.Bounds.IntersectsWith(pbRepeat.Bounds)) { pbRepeat.Location = new Point(pbRepeat.Location.X + 5, pbRepeat.Location.Y); lblRepeat.Location = new Point(lblRepeat.Location.X + 5, lblRepeat.Location.Y); } lblReminderName.Text = rem.Name; lblRepeat.Text = BLReminder.GetRepeatTypeText(rem); if (rem.Enabled == 1) { btnDisable.Image = Properties.Resources.turnedOn; lblReminderName.ForeColor = Color.White; lblDate.ForeColor = Color.White; lblRepeat.ForeColor = Color.White; } else { //Disabled reminder, make text gray btnDisable.Image = Properties.Resources.turnedOffTwo; lblReminderName.ForeColor = Color.Silver; lblDate.ForeColor = Color.Silver; lblRepeat.ForeColor = Color.Silver; } btnSettings.Enabled = true; btnDelete.Enabled = true; btnEdit.Enabled = true; btnDisable.Enabled = true; }
private void Popup2_Load(object sender, EventArgs e) { BLIO.Log("Popup_load"); AdvancedReminderProperties avrProps = BLAVRProperties.GetAVRProperties(rem.Id); List <AdvancedReminderFilesFolders> avrFF = BLAVRProperties.GetAVRFilesFolders(rem.Id); if (avrProps != null) //Not null? this reminder has advanced properties. { BLIO.Log("Reminder " + rem.Id + " has advanced reminder properties!"); if (!string.IsNullOrWhiteSpace(avrProps.BatchScript)) { BLIO.ExecuteBatch(avrProps.BatchScript); } this.Visible = avrProps.ShowReminder == 1; } if (avrFF != null && avrFF.Count > 0) { //Go through each action, for example c:\test , delete. c:\sometest\testFile.txt , open foreach (AdvancedReminderFilesFolders avr in avrFF) { if (avr.Action.ToString() == "Open") { if (File.Exists(avr.Path) || Directory.Exists(avr.Path)) { System.Diagnostics.Process.Start(avr.Path); } } else if (avr.Action.ToString() == "Delete") { FileAttributes attr = File.GetAttributes(avr.Path); //Check if it's a file or a directory if (File.Exists(avr.Path)) { File.Delete(avr.Path); } else if (Directory.Exists(avr.Path)) { Directory.Delete(avr.Path, true); } } } } if (this.Visible) { tmrFadeIn.Start(); } else { btnOk_Click(sender, e); return; } DateTime date = Convert.ToDateTime(rem.Date.Split(',')[0]); lblSmallDate.Text = date.ToShortDateString() + " " + date.ToShortTimeString(); lblRepeat.Text = BLReminder.GetRepeatTypeText(rem); if (!String.IsNullOrWhiteSpace(rem.PostponeDate)) { pbDate.BackgroundImage = Properties.Resources.RemindMeZzz; lblSmallDate.Text = Convert.ToDateTime(rem.PostponeDate) + " (Postponed)"; } //If some country has a longer date string, move the repeat icon/text more to the right so it doesnt overlap while (lblSmallDate.Bounds.IntersectsWith(pbRepeat.Bounds)) { pbRepeat.Location = new Point(pbRepeat.Location.X + 5, pbRepeat.Location.Y); lblRepeat.Location = new Point(lblRepeat.Location.X + 5, lblRepeat.Location.Y); } //Play the sound if (rem.SoundFilePath != null && rem.SoundFilePath != "") { if (System.IO.File.Exists(rem.SoundFilePath)) { BLIO.Log("SoundFilePath not null / empty and exists on the hard drive!"); myPlayer.URL = rem.SoundFilePath; myPlayer.controls.play(); BLIO.Log("Playing sound"); } else { BLIO.Log("SoundFilePath not null / empty but doesn't exist on the hard drive!"); RemindMeBox.Show("Could not play " + Path.GetFileNameWithoutExtension(rem.SoundFilePath) + " located at \"" + rem.SoundFilePath + "\" \r\nDid you move,rename or delete the file ?\r\nThe sound effect has been removed from this reminder. If you wish to re-add it, select it from the drop-down list.", RemindMeBoxReason.OK); //make sure its removed from the reminder rem.SoundFilePath = ""; } } FlashWindowHelper.Start(this); //this.MaximumSize = this.Size; if (BLSettings.IsAlwaysOnTop()) { this.TopMost = true; //Popup will be always on top. no matter what you are doing, playing a game, watching a video, you will ALWAYS see the popup. this.TopLevel = true; } else { this.TopMost = false; this.WindowState = FormWindowState.Minimized; } lblTitle.Text = rem.Name; if (rem.Note != null) { lblNoteText.Text = rem.Note.Replace("\\n", Environment.NewLine); } if (rem.Note == "") { lblNoteText.Text = "( No text set )"; } lblNoteText.Text = Environment.NewLine + Environment.NewLine + lblNoteText.Text; if (rem.Date == null) { rem.Date = DateTime.Now.ToString(); } }
private void btnOk_Click(object sender, EventArgs e) { rem = BLReminder.GetReminderById(rem.Id); if (rem == null) { goto close; } if (rem.Id != -1 && rem.Deleted == 0) //Don't do stuff if the id is -1, invalid. the id is set to -1 when the user previews an reminder { if (BLReminder.GetReminderById(rem.Id) == null) { //The reminder popped up, it existed, but when pressing OK it doesn't exist anymore (maybe the user deleted it or tempered with the .db file) BLIO.Log("DETECTED NONEXISTING REMINDER WITH ID " + rem.Id + ", Attempted to press OK on a reminder that somehow doesn't exist"); goto close; } if (cbPostpone.Checked) { BLIO.Log("Postponing reminder with id " + rem.Id); if (numPostponeTime.Value == 0) { return; } DateTime newReminderTime = new DateTime(); if (cbPostpone.Checked && tbPostpone.ForeColor == Color.White && !string.IsNullOrWhiteSpace(tbPostpone.Text)) //postpone option is x minutes { newReminderTime = DateTime.Now.AddMinutes(BLFormLogic.GetTextboxMinutes(tbPostpone)); rem.PostponeDate = newReminderTime.ToString(); } else { rem.PostponeDate = null; BLReminder.UpdateReminder(rem); } BLIO.Log("Postpone date assigned to reminder"); rem.Enabled = 1; BLReminder.EditReminder(rem); new Thread(() => { //Log an entry to the database, for data! BLOnlineDatabase.PostponeCount++; }).Start(); BLIO.Log("Reminder postponed!"); } else { rem.PostponeDate = null; BLReminder.UpdateReminder(rem); } } close: UCReminders.Instance.UpdateCurrentPage(); BLIO.Log("Stopping media player & Closing popup"); myPlayer.controls.stop(); btnOk.Enabled = false; this.Close(); }