private void Popup_Load(object sender, EventArgs e) { try { BLIO.Log("Popup_load"); if (BLLocalDatabase.Setting.Settings.PopupType == "SoundOnly") { //Dont initialize, just play sound PlayReminderSound(); if (rem.Id != -1) //Dont stop logic when the user is previewing an reminder { btnOk_Click(sender, e); return; } } string reminderText = rem.Note != null?rem.Note.Replace("\n", "<br>") : "( No text set )"; //White font if dark theme, Black text if light theme string color = MaterialSkin.MaterialSkinManager.Instance.Theme == MaterialSkin.MaterialSkinManager.Themes.DARK ? "#e6e6e6" : "#323232"; if (rem.Note.Contains("API{")) { TransformAPITextToValue(color, reminderText); } else { htmlLblText.Text = GetPopupHTMLText(color, reminderText); } AdvancedReminderProperties avrProps = BLLocalDatabase.AVRProperty.GetAVRProperties(rem.Id); List <AdvancedReminderFilesFolders> avrFF = BLLocalDatabase.AVRProperty.GetAVRFilesFolders(rem.Id); if (avrProps != null) //Not null? this reminder has advanced properties. { BLIO.Log("Reminder " + rem.Id + " has advanced reminder properties!"); this.Visible = avrProps.ShowReminder == 1; if (!string.IsNullOrWhiteSpace(avrProps.BatchScript)) { //if (!this.Visible) MaterialMessageFormManager.MakeMessagePopup("Activating script of Reminder:\r\n \"" + rem.Name + "\"", 3); BLIO.ExecuteBatch(avrProps.BatchScript); } } else { BLIO.Log("Reminder " + rem.Id + " does not have advanced reminder properties"); } 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") { BLIO.Log("Executing advanced reminder action \"Open\""); if (File.Exists(avr.Path) || Directory.Exists(avr.Path)) { System.Diagnostics.Process.Start(avr.Path); } } else if (avr.Action.ToString() == "Delete") { BLIO.Log("Executing advanced reminder action \"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; } if (rem.HttpId == null) { BLIO.Log("Attempting to parse date..."); DateTime date = Convert.ToDateTime(rem.Date.Split(',')[0]); BLIO.Log("Date succesfully converted (" + date + ")"); lblSmallDate.Text = date.ToShortDateString() + " " + date.ToShortTimeString(); } else { lblSmallDate.Text = "Conditional"; } lblRepeat.Text = BLReminder.GetRepeatTypeText(rem); if (!string.IsNullOrWhiteSpace(rem.PostponeDate)) { BLIO.Log("Reminder has a postpone date."); pbDate.BackgroundImage = Properties.Resources.RemindMeZzz; lblSmallDate.Text = Convert.ToDateTime(rem.PostponeDate) + ""; } //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); } PlayReminderSound(); FlashWindowHelper.Start(this); //this.MaximumSize = this.Size; if (BLLocalDatabase.Setting.Settings.PopupType == "AlwaysOnTop") { 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 { if (rem.Id != -1) //previewreminders should be topmost { this.TopMost = false; this.WindowState = FormWindowState.Minimized; } } this.Text = rem.Name; string hexColor = ColorToHex(MaterialSkin.MaterialSkinManager.Instance.ColorScheme.AccentColor); foreach (string link in GetLinks(htmlLblText.Text)) //Add <a href> to make it into an actual link { htmlLblText.Text = htmlLblText.Text.Replace(link, "<a href=\"" + link + "\" style=\"color: " + hexColor + "\"> " + link + "</a>"); } if (rem.Date == null && rem.HttpId == null) { rem.Date = DateTime.Now.ToString(); } } catch (Exception ex) { ReminderException remEx = new ReminderException(BLReminder.ToString(rem), rem); remEx.StackTrace = ex.StackTrace; //Copy the stacktrace BLIO.WriteError(remEx, "Error loading reminder popup"); BLIO.Log("Popup_load FAILED. Exception -> " + ex.Message); } }
private void Popup2_Load(object sender, EventArgs e) { try { BLIO.Log("Popup_load"); AdvancedReminderProperties avrProps = BLLocalDatabase.AVRProperty.GetAVRProperties(rem.Id); List <AdvancedReminderFilesFolders> avrFF = BLLocalDatabase.AVRProperty.GetAVRFilesFolders(rem.Id); if (avrProps != null) //Not null? this reminder has advanced properties. { BLIO.Log("Reminder " + rem.Id + " has advanced reminder properties!"); this.Visible = avrProps.ShowReminder == 1; if (!string.IsNullOrWhiteSpace(avrProps.BatchScript)) { if (!this.Visible) { RemindMeMessageFormManager.MakeMessagePopup("Activating script of Reminder:\r\n \"" + rem.Name + "\"", 3); } BLIO.ExecuteBatch(avrProps.BatchScript); } } else { BLIO.Log("Reminder " + rem.Id + " does not have advanced reminder properties"); } 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") { BLIO.Log("Executing advanced reminder action \"Open\""); if (File.Exists(avr.Path) || Directory.Exists(avr.Path)) { System.Diagnostics.Process.Start(avr.Path); } } else if (avr.Action.ToString() == "Delete") { BLIO.Log("Executing advanced reminder action \"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; } BLIO.Log("Attempting to parse date..."); DateTime date = Convert.ToDateTime(rem.Date.Split(',')[0]); BLIO.Log("Date succesfully converted (" + date + ")"); lblSmallDate.Text = date.ToShortDateString() + " " + date.ToShortTimeString(); lblRepeat.Text = BLReminder.GetRepeatTypeText(rem); if (!string.IsNullOrWhiteSpace(rem.PostponeDate)) { BLIO.Log("Reminder has a postpone date."); 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 (BLLocalDatabase.Setting.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 + lblNoteText.Text; if (rem.Date == null) { rem.Date = DateTime.Now.ToString(); } } catch (Exception ex) { ReminderException remEx = new ReminderException(BLReminder.ToString(rem), rem); remEx.StackTrace = ex.StackTrace; //Copy the stacktrace BLIO.WriteError(remEx, "Error loading reminder popup"); BLIO.Log("Popup_load FAILED. Exception -> " + ex.Message); } }