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 && tbtime.ForeColor == Color.White && !string.IsNullOrWhiteSpace(tbtime.Text)) //postpone option is x minutes { newReminderTime = DateTime.Now.AddMinutes(BLFormLogic.GetTextboxMinutes(tbtime)); rem.PostponeDate = newReminderTime.ToString(); } else { rem.PostponeDate = null; BLReminder.UpdateReminder(rem); } BLIO.Log("Postpone date assigned to reminder"); rem.Enabled = 1; BLReminder.EditReminder(rem); BLIO.Log("Reminder postponed!"); } else { rem.PostponeDate = null; BLReminder.UpdateReminder(rem); } } close: UCReminders.GetInstance().UpdateCurrentPage(); BLIO.Log("Stopping media player & Closing popup"); myPlayer.controls.stop(); btnOk.Enabled = false; this.Close(); }
/// <summary> /// Change this user controls's icons based on the theme /// </summary> /// <param name="theme"></param> public void UpdateTheme(object sender) { if (this.Reminder == null) { btnDelete.Image = Properties.Resources.Bin_Disabled; btnEdit.Image = Properties.Resources.Edit_Disabled; btnSettings.Image = Properties.Resources.gearDisabled; btnDisable.Image = Properties.Resources.turnedOffTwo; } else if (MaterialSkin.MaterialSkinManager.Instance.Theme == MaterialSkin.MaterialSkinManager.Themes.DARK) { btnEdit.Image = Properties.Resources.EditPenWhite; btnDelete.Image = Properties.Resources.Bin_white; btnDisable.Image = Properties.Resources.disableWhite; btnSettings.Image = Properties.Resources.gearWhite; //toolstrip previewToolStripMenuItem.Image = Properties.Resources.eyeWhite; duplicateToolStripMenuItem.Image = Properties.Resources.duplicateWhite; hideReminderToolStripMenuItem.Image = Properties.Resources.hideWhite; postponeToolStripMenuItem.Image = Properties.Resources.zzzWhite; removePostponeToolStripMenuItem.Image = Properties.Resources.zzzCancelWhite; skipToNextDateToolStripMenuItem.Image = Properties.Resources.skipWhite; toolStripMenuItem1.Image = Properties.Resources.permanentelyWhite; //permanentelydelete toolstrip pbConditionalReminder.Image = Properties.Resources.wwwLight; } else if (MaterialSkin.MaterialSkinManager.Instance.Theme == MaterialSkin.MaterialSkinManager.Themes.LIGHT) {//Light btnEdit.Image = Properties.Resources.editPenDark; btnDelete.Image = Properties.Resources.binDark; btnDisable.Image = Properties.Resources.disableDark; btnSettings.Image = Properties.Resources.gearDark; //toolstrip previewToolStripMenuItem.Image = Properties.Resources.eyeDark; duplicateToolStripMenuItem.Image = Properties.Resources.duplicateDark; hideReminderToolStripMenuItem.Image = Properties.Resources.hideDark; postponeToolStripMenuItem.Image = Properties.Resources.zzzDark; removePostponeToolStripMenuItem.Image = Properties.Resources.zzzCancelDark; skipToNextDateToolStripMenuItem.Image = Properties.Resources.skipForwardDark; toolStripMenuItem1.Image = Properties.Resources.permanentelyDark; pbConditionalReminder.Image = Properties.Resources.wwwDark; } BLFormLogic.SetImageAlpha(pbConditionalReminder, 50); if (this.Reminder != null && this.Reminder.Enabled == 0) { btnDisable.Image = Properties.Resources.turnedOffTwo; lblReminderName.Visible = false; lblReminderNameDisabled.Visible = true; lblDate.FontType = MaterialSkin.MaterialSkinManager.fontType.Body2; lblRepeat.FontType = MaterialSkin.MaterialSkinManager.fontType.Body2; } }
private void LoadDeletedReminders() { BLIO.Log("Recover deleted button pressed. Loading reminders into listview"); lvReminders.Items.Clear(); transferType = ReminderTransferType.RECOVER; BLFormLogic.AddRemindersToListview(lvReminders, BLReminder.GetDeletedReminders().OrderBy(rem => rem.Name).ToList(), true); BLIO.Log("Added deleted reminders to listview."); }
private void btnRecoverOld_Click(object sender, EventArgs e) { BLIO.Log("Recover old button pressed. Loading reminders into listview"); lvReminders.Items.Clear(); ToggleButton(sender); transferType = ReminderTransferType.RECOVER; BLFormLogic.AddRemindersToListview(lvReminders, BLReminder.GetArchivedReminders().OrderBy(rem => rem.Name).ToList()); BLIO.Log("Added old reminders to listview."); }
private void tbPrompt_KeyUp(object sender, KeyEventArgs e) { //Show the user that whatever it is they are inputting is invalid if (tbPostpone.Text == "" || BLFormLogic.GetTextboxMinutes(tbPostpone) != -1) { tbPostpone.BorderColorFocused = Color.FromArgb(64, 64, 64); } else { tbPostpone.BorderColorFocused = Color.Red; } }
private void btnExport_Click(object sender, EventArgs e) { ToggleButton(sender); lvReminders.Items.Clear(); BLIO.Log("Export button pressed. Loading reminders into listview"); if (BLReminder.GetReminders().Count > 0) { transferType = ReminderTransferType.EXPORT; BLFormLogic.AddRemindersToListview(lvReminders, BLReminder.GetReminders()); } BLIO.Log("Added exportable reminders to listview."); }
private void LoadExportReminders() { BLIO.Log("(MUCImportExport)btnExport_Click"); lvReminders.Items.Clear(); BLIO.Log("Export button pressed. Loading reminders into listview"); if (BLReminder.GetReminders().Count > 0) { transferType = ReminderTransferType.EXPORT; BLFormLogic.AddRemindersToListview(lvReminders, BLReminder.GetReminders(), true); } BLIO.Log("Added exportable reminders to listview."); }
private void tbPostpone_TextChanged(object sender, EventArgs e) { if (!tbPostpone.ContainsFocus) { return; } cbPostpone.Checked = true; if (BLFormLogic.GetTextboxMinutes(tbPostpone) == -1) { cbPostpone.Checked = false; } }
public MaterialPopup(Reminder rem) { BLIO.Log("Constructing Popup reminderId = " + rem.Id); AddFont(Properties.Resources.Roboto_Medium); InitializeComponent(); if (MaterialForm1.Instance.Visible) { BLFormLogic.CenterFormToParent(this, MaterialForm1.Instance); } this.Opacity = 0; this.rem = rem; this.Size = new Size((int)BLLocalDatabase.PopupDimension.GetPopupDimensions().FormWidth, (int)BLLocalDatabase.PopupDimension.GetPopupDimensions().FormHeight); //lblNoteText.Font = new Font(lblNoteText.Font.FontFamily, BLLocalDatabase.PopupDimension.GetPopupDimensions().FontNoteSize, FontStyle.Bold); this.Text = rem.Name; //lblNoteText.MaximumSize = new Size((pnlText.Width - lblNoteText.Location.X) - 20, 0); htmlLblText.AutoSizeHeightOnly = true; htmlLblText.Width = this.Width - 8; htmlLblText.Height = pnlText.Height; htmlLblText.MaximumSize = new Size(htmlLblText.Width - 30, 0); htmlLblText.Location = new Point(8, -5); pnlText.Controls.Add(htmlLblText); tbPostpone.KeyDown += numericOnly_KeyDown; tbPostpone.KeyPress += numericOnly_KeyPress; //Assign the events that the user can raise while doing something on the popup. The stopflash event stops the taskbar icon from flashing this.MouseClick += stopFlash_Event; this.MouseClick += stopFlash_Event; this.ResizeEnd += stopFlash_Event; //TODO: #53521 ? Color t = MaterialSkin.MaterialSkinManager.Instance.ColorScheme.AccentColor; //lblNoteText.LinkColor = MaterialSkin.MaterialSkinManager.Instance.ColorScheme.AccentColor; //lblNoteText.ActiveLinkColor = MaterialSkin.MaterialSkinManager.Instance.ColorScheme.LightPrimaryColor; BLIO.Log("Popup constructed"); }
private void lvCopiedText_KeyDown(object sender, KeyEventArgs e) { //Select all items in the listview (Ctrl+A) if (e.KeyCode == Keys.Control | e.KeyCode == Keys.A) { foreach (ListViewItem itm in lvCopiedText.Items) { itm.Selected = true; } } //Copy the selected text to the clipboard (Ctrl+C) if (e.KeyCode == Keys.Control | e.KeyCode == Keys.C) { //allowClipboard = false; BLFormLogic.CopyListviewTextToClipboard(lvCopiedText); } }
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 RemindMeImporter_Load(object sender, EventArgs e) { BLIO.Log("RemindmeImporter_load"); this.MaximumSize = this.Size; if (!HasFileAccess(this.remindmeFile)) //Do not attempt to launch the importer form if we can't open the file { BLIO.Log("Error opening .remindme file, no rights"); RemindMeBox.Show("Can not open this .remindme file from " + Path.GetDirectoryName(this.remindmeFile) + ". Insufficient rights.", RemindMeBoxReason.OK); this.Close(); } else { try { BLIO.Log("Deserializing reminders....."); List <object> deSerializedReminders = BLReminder.DeserializeRemindersFromFile(remindmeFile); BLIO.Log(deSerializedReminders.Count - 1 + " reminders deserialized!"); lblAmountOfReminders.Text = deSerializedReminders.Count - 1 + " Reminders"; //-1 because of country code foreach (object rem in deSerializedReminders) { if (rem.GetType() == typeof(Reminder)) { Reminder reminder = (Reminder)rem; BLIO.Log(reminder.Name + " Loaded into RemindMeImporter from the .remindme file."); remindersFromRemindMeFile.Add((Reminder)rem); } else { BLIO.Log("Language code" + languageCode + " read from the .remindme file!"); languageCode = rem.ToString(); //The language code stored in the .remindme file, "en-Us" for example } } if (languageCode != "") //Don't need to do this when exporting. { BLIO.Log("Going through the reminder list once more...."); foreach (object rem in remindersFromRemindMeFile) { if (rem.GetType() == typeof(Reminder)) { Reminder remm = (Reminder)rem; //Fix the date if the .remindme file has a different time format than the current system BLIO.Log("(" + remm.Name + ") Fixing the date to match the language code " + languageCode); remm.Date = BLDateTime.ConvertDateTimeStringToCurrentCulture(remm.Date, languageCode); } } } if (remindersFromRemindMeFile != null) { BLIO.Log("Adding the reminders from the .remindme file to the listview...."); BLFormLogic.AddRemindersToListview(lvReminders, remindersFromRemindMeFile); BLIO.Log("Done!"); } else { BLIO.Log("Failed to load reminders."); lblTitle.Text = "Failed to load reminders."; } } catch (Exception ex) { RemindMeBox.Show("Something has gone wrong loading reminders from this .remindme file.\r\nThe file might be corrupt", RemindMeBoxReason.OK); BLIO.Log("Error loading reminders from .remindme file written to error log"); BLIO.WriteError(ex, "Error loading reminders from .remindme file"); Application.Exit(); } } BLIO.Log("RemindmeImporter loaded !"); }
private void btnOk_Click(object sender, EventArgs e) { if (xClose) { xClose = false; } if (rem != null) { rem = BLReminder.GetReminderById(rem.Id); } if (rem == null) { goto close; } if (rem.HttpId != null) { //Conditional reminder HttpRequests req = BLLocalDatabase.HttpRequest.GetHttpRequestById(rem.Id); if (req.AfterPopup == "Stop") { rem.Deleted = 1; BLReminder.EditReminder(rem); goto close; } else if (req.AfterPopup == "Repeat") { goto close; } //else .... ? } 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 (BLFormLogic.GetTextboxMinutes(tbPostpone) <= 0) { return; } DateTime newReminderTime = new DateTime(); if (!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! try { BLOnlineDatabase.PostponeCount++; } catch (ArgumentException ex) { BLIO.Log("Exception at BLOnlineDatabase.PostponeCount++. -> " + ex.Message); BLIO.WriteError(ex, ex.Message, true); } }).Start(); BLIO.Log("Reminder postponed!"); } else { rem.PostponeDate = null; BLReminder.UpdateReminder(rem); } } close: MUCReminders.Instance.UpdateCurrentPage(rem); BLIO.Log("Stopping media player & Closing popup"); if (BLLocalDatabase.Setting.Settings.PopupType != "SoundOnly") { myPlayer.controls.stop(); } this.Close(); GC.Collect(); }
//Loads reminder data into the controls private void Enable() { MaterialSkin.MaterialSkinManager.Themes theme = MaterialSkin.MaterialSkinManager.Instance.Theme; lblReminderName.Visible = true; lblReminderNameDisabled.Visible = false; lblRepeat.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle2; lblDate.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle2; //Enabled icons if (theme == MaterialSkin.MaterialSkinManager.Themes.DARK) { btnDelete.Image = Properties.Resources.Bin_white; btnEdit.Image = Properties.Resources.EditPenWhite; btnSettings.Image = Properties.Resources.gearWhite; btnDisable.Image = Properties.Resources.disableWhite; pbConditionalReminder.Image = Properties.Resources.wwwLight; } else { btnDelete.Image = Properties.Resources.binDark; btnEdit.Image = Properties.Resources.editPenDark; btnSettings.Image = Properties.Resources.gearDark; btnDisable.Image = Properties.Resources.disableDark; pbConditionalReminder.Image = Properties.Resources.wwwDark; } BLFormLogic.SetImageAlpha(pbConditionalReminder, 50); //if the reminder is disabled, use this icon instead if (rem.Enabled == 0) { btnDisable.Image = Properties.Resources.turnedOffTwo; lblReminderName.Visible = false; lblReminderNameDisabled.Visible = true; lblDate.FontType = MaterialSkin.MaterialSkinManager.fontType.Body2; lblRepeat.FontType = MaterialSkin.MaterialSkinManager.fontType.Body2; } //Reset location pbRepeat.Location = new Point(168, pbRepeat.Location.Y); lblRepeat.Location = new Point(195, lblRepeat.Location.Y); if (rem.HttpId == null) { pbConditionalReminder.Visible = false; 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 && !string.IsNullOrWhiteSpace(rem.PostponeDate)) { 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; } } else { pbConditionalReminder.Visible = true; lblDate.Text = "Conditional"; pbDate.BackgroundImage = Properties.Resources.RemindMe; } AdvancedReminderProperties props = BLLocalDatabase.AVRProperty.GetAVRProperties(rem.Id); if (props != null && !string.IsNullOrWhiteSpace(props.BatchScript)) { pbDate.BackgroundImage = Properties.Resources.terminal1; } //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); SetTooltips(); /*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 * * lblReminderName.ForeColor = Color.Silver; * lblDate.ForeColor = Color.Silver; * lblRepeat.ForeColor = Color.Silver; * }*/ btnSettings.Enabled = true; btnDelete.Enabled = true; btnEdit.Enabled = true; btnDisable.Enabled = true; }