private void btnOk_Click(object sender, EventArgs e) { try { BLIO.Log("btnOk pressed on ExceptionPopup. textbox text = " + tbFeedback.Text); string logTxtPath = IOVariables.systemLog; string textBoxText = tbFeedback.Text; //Cant access tbNote in a thread. save the text in a variable instead if (string.IsNullOrWhiteSpace(textBoxText) || tbFeedback.ForeColor == Color.Gray) { textBoxText = null; } BLOnlineDatabase.AddException(exception, DateTime.UtcNow, logTxtPath, textBoxText); if (textBoxText != null && tbFeedback.ForeColor != Color.Gray) { RemindMeMessageFormManager.MakeMessagePopup("Feedback sent.\r\nThank you for taking the time!", 5); } //Set this boolean to true so that when this popup closes, we won't try to add another db entry customFeedback = true; btnOk.Enabled = false; this.Close(); this.Dispose(); } catch { } }
private void ErrorPopup_FormClosing(object sender, FormClosingEventArgs e) { try { string mess = "Oops! An error has occured. Here's the details:\r\n\r\n" + ex.ToString(); if (ex is ReminderException) { ReminderException theException = (ReminderException)ex; theException.Reminder.Note = "Removed for privacy reasons"; theException.Reminder.Name = "Removed for privacy reasons"; mess += "\r\n\r\nThis exception is an ReminderException! Let's see if we can figure out what's wrong with it....\r\n"; mess += "ID: " + theException.Reminder.Id + "\r\n"; mess += "Deleted: " + theException.Reminder.Deleted + "\r\n"; mess += "Date: " + theException.Reminder.Date + "\r\n"; mess += "RepeatType: " + theException.Reminder.RepeatType + "\r\n"; mess += "Enabled: " + theException.Reminder.Enabled + "\r\n"; mess += "DayOfMonth: " + theException.Reminder.DayOfMonth + "\r\n"; mess += "EveryXCustom: " + theException.Reminder.EveryXCustom + "\r\n"; mess += "RepeatDays: " + theException.Reminder.RepeatDays + "\r\n"; mess += "SoundFilePath: " + theException.Reminder.SoundFilePath + "\r\n"; mess += "PostponeDate: " + theException.Reminder.PostponeDate + "\r\n"; mess += "Hide: " + theException.Reminder.Hide + "\r\n\r\n"; mess += "=== Displaying date culture info, so you might be able to re-create the reminder ===\r\n"; mess += "Current culture DisplayName: " + CultureInfo.CurrentCulture.DisplayName + "\r\n"; mess += "Current culture ShortTimePattern: " + CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern + "\r\n"; mess += "Current culture ShortDatePattern: " + CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern + "\r\n"; mess += "Current culture ToString(): " + CultureInfo.CurrentCulture.ToString() + "\r\n"; } BLOnlineDatabase.AddException(ex, DateTime.UtcNow, BLIO.GetLogTxtPath()); } catch { } }
private void ExceptionPopup_FormClosing(object sender, FormClosingEventArgs e) { try { string logTxtPath = IOVariables.systemLog; BLIO.Log("Closing ExceptionPopup..."); if (!customFeedback) //If the user didn't leave instructions of how this problem happened, just log the exception / stacktrace and logfile { BLOnlineDatabase.AddException(exception, DateTime.UtcNow, logTxtPath, "None."); } } catch { } }
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"; } } RemindMeMessageFormManager.MakeMessagePopup("Feedback sent.\r\nThank you for taking the time!", 5); BLOnlineDatabase.AddException(ex, DateTime.UtcNow, BLIO.GetLogTxtPath()); 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; }
/// <summary> /// Alternative Form_load method since form_load doesnt get called until you first double-click the RemindMe icon due to override SetVisibleCore /// </summary> private void formLoad() { try { BLIO.Log("RemindMe_Load"); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); RemindMeIcon.Text = "RemindMe " + IOVariables.RemindMeVersion; //set unique user string BLIO.WriteUniqueString(); MaterialMessageFormManager.MakeTodaysRemindersPopup(); BLIO.Log("Today's reminders popup created"); //Create an shortcut in the windows startup folder if it doesn't already exist if (!System.IO.File.Exists(IOVariables.startupFolderPath + "\\RemindMe" + ".lnk")) { FSManager.Shortcuts.CreateShortcut(IOVariables.startupFolderPath, "RemindMe", System.Windows.Forms.Application.StartupPath + "\\" + "RemindMe.exe", "Shortcut of RemindMe"); } else { WshShell shell = new WshShell(); //Create a new WshShell Interface IWshShortcut link = (IWshShortcut)shell.CreateShortcut(IOVariables.startupFolderPath + "\\RemindMe.lnk"); //Link the interface to our shortcut //shortcut does exist, let's see if the target of that shortcut isn't the old RemindMe in the programs files if (link.TargetPath.ToString().Contains("StefanGansevlesPrograms") || link.TargetPath.ToString().Contains("Program Files")) { BLIO.Log("Deleting old .lnk shortcut of RemindMe"); System.IO.File.Delete(IOVariables.startupFolderPath + "\\RemindMe.lnk"); FSManager.Shortcuts.CreateShortcut(IOVariables.startupFolderPath, "RemindMe", IOVariables.applicationFilesFolder + "RemindMe.exe", "Shortcut of RemindMe"); } } //if (Debugger.IsAttached) //Debugging ? show extra option //btnDebugMode.Visible = true; BLLocalDatabase.Song.InsertWindowsSystemSounds(); if (BLLocalDatabase.Setting.Settings.AutoUpdate == 1) //I guess some users don't want it? :( { tmrUpdateRemindMe.Start(); } //If the setup still exists, delete it System.IO.File.Delete(IOVariables.rootFolder + "SetupRemindMe.msi"); Settings set = BLLocalDatabase.Setting.Settings; //Call the timer once Thread tr = new Thread(() => { //wait a bit, then call the update timer once. It then runs every 5 minutes Thread.Sleep(5000); tmrUpdateRemindMe_Tick(null, null); BLOnlineDatabase.InsertOrUpdateUser(set.UniqueString); if (set.LastVersion == null) { set.LastVersion = IOVariables.RemindMeVersion; } BLLocalDatabase.Setting.UpdateSettings(set); }); tr.Start(); this.ShowInTaskbar = true; this.Show(); tmrInitialHide.Start(); //Random r = new Random(); //tmrCheckRemindMeMessages.Interval = (r.Next(60, 300)) * 1000; //Random interval between 1 and 5 minutes //tmrCheckRemindMeMessages.Start(); //BLIO.Log("tmrCheckRemindMeMessages.Interval = " + tmrCheckRemindMeMessages.Interval / 1000 + " seconds."); stopwatch.Stop(); BLIO.Log("formLoad() took " + stopwatch.ElapsedMilliseconds + " ms"); BLIO.Log("RemindMe loaded"); } catch (Exception ex) { BLIO.Log("Exception in formLoadAsync() -> " + ex.GetType().ToString()); BLOnlineDatabase.AddException(ex, DateTime.Now, IOVariables.systemLog); } }
static void Main(string[] args) { string resource1 = "RemindMe.External_DLL.Bunifu_UI_v1.5.3.dll"; EmbeddedAssembly.Load(resource1, "Bunifu_UI_v1.5.3.dll"); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); try { AppDomain.CurrentDomain.SetData("DataDirectory", IOVariables.databaseFile); BLIO.CreateDatabaseIfNotExist(); if (!BLLocalDatabase.HasAllTables()) { isMaterial = true; } else { //See if the user wants Material Design or old RemindMe-Design (Default = Material) Settings set = BLLocalDatabase.Setting.Settings; if (set != null && set.MaterialDesign != null && set.MaterialDesign.HasValue) //not null { isMaterial = Convert.ToBoolean(BLLocalDatabase.Setting.Settings.MaterialDesign.Value); } } if (args.Length > 0) {//The user double-clicked an .remindme file! BLIO.Log("Detected the double clicking of a .remindme file!"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (isMaterial) { Application.Run(new MaterialRemindMeImporter(args[0])); } else { Application.Run(new RemindMeImporter(args[0])); } } } catch (Exception ex) { BLIO.Log("!!!! EXCEPTION IN PROGRAM.CS !!!! (" + ex.GetType() + ")"); BLOnlineDatabase.AddException(ex, DateTime.Now, IOVariables.systemLog); } //This code should always execute!!!! Remember the 3.0.6 disaster? yeahhhhh... using (Mutex mutex = new Mutex(false, "Global\\" + "RemindMe")) { if (!mutex.WaitOne(0, false)) //one instance of remindme already running { return; } // Set the unhandled exception mode to force all Windows Forms errors to go through our handler. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(true); Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); // Add the event handler for handling non-UI thread exceptions to the event. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); if (isMaterial) { Application.Run(new MaterialForm1()); } else { Application.Run(new Form1()); } } }