示例#1
0
        private void OnPowerChange(object sender, PowerModeChangedEventArgs e)
        {
            BLIO.Log("=== OnPowerChange() ===");

            switch (e.Mode)
            {
            //PC wakes up from sleep. If you're someone that always puts your pc to sleep instead of turning it off, RemindMe won't get "launched" again
            //but instead, resumes.
            case PowerModes.Resume:
                BLIO.Log("=== PC Woke up from sleep! ===");
                Thread t = new Thread(() =>
                {
                    Thread.Sleep(5000);
                    BLIO.Log("Trying to update user after PC Sleep...");
                    BLOnlineDatabase.InsertOrUpdateUser(BLLocalDatabase.Setting.Settings.UniqueString);
                    BLIO.Log("User updated.");
                });
                t.Start();
                break;

            case PowerModes.Suspend:
                BLIO.Log("=== PC Is going to sleep. ZzZzzzZzz... ===");
                break;
            }
        }
        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 { }
        }
示例#3
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                BLIO.Log("Attempting to send a message to the RemindMe developer..");

                //Don't do anything if there's no text
                if (string.IsNullOrWhiteSpace(tbNote.Text))
                {
                    return;
                }

                //Don't do anything without internet
                if (!BLIO.HasInternetAccess())
                {
                    RemindMeMessageFormManager.MakeMessagePopup("You do not currently have an active internet connection", 3);
                    return;
                }

                string email   = tbEmail.Text;
                string subject = tbSubject.Text;
                string note    = tbNote.Text;

                BLOnlineDatabase.InsertEmailAttempt(File.ReadAllText(IOVariables.uniqueString), note, subject, email);
                RemindMeMessageFormManager.MakeMessagePopup("Feedback Sent. Thank you!", 5);
                tbEmail.Text   = "";
                tbSubject.Text = "";
                tbNote.Text    = "";
                BLIO.Log("Message sent!");
            }
            catch
            {
                RemindMeMessageFormManager.MakeMessagePopup("Something went wrong. Could not send the e-mail", 3);
            }
        }
示例#4
0
        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 { }
        }
示例#5
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            BLIO.Log("(UCSupport)bunifuFlatButton1_Click [btnView]");
            if (lvMessages.SelectedItems.Count > 0)
            {
                ListViewItem itm = lvMessages.SelectedItems[0];

                RemindMeMessages mess = BLOnlineDatabase.GetRemindMeMessageById(Convert.ToInt32(itm.Tag));
                if (mess == null)
                {
                    RemindMeMessageFormManager.MakeMessagePopup("Could not show this message. It does not exist anymore", 4);
                    lvMessages.Items.Remove(itm);
                    BLLocalDatabase.ReadMessage.DeleteMessage(Convert.ToInt32(itm.Tag));
                    return; //Doesn't exist in the database anymore
                }

                if (mess.NotificationType == "REMINDMEBOX")
                {
                    BLIO.Log("Attempting to show the user a RemindMe message(REMINDMEBOX)...");
                    RemindMeBox.Show("A Message from the creator of RemindMe", mess.Message.Replace("¤", Environment.NewLine), RemindMeBoxReason.OK);
                }
                else if (mess.NotificationType == "REMINDMEMESSAGEFORM")
                {
                    BLIO.Log("Attempting to show the user a RemindMe message(REMINDMEMESSAGEFORM)...");
                    RemindMeMessageFormManager.MakeMessagePopup(mess.Message.Replace("¤", Environment.NewLine), mess.NotificationDuration.Value);
                }
                else
                {
                    BLIO.Log("Attempting to show the user a RemindMe message FAILED. Notificationtype=" + mess.NotificationType + "  Message=" + mess.Message + "  Id=" + mess.Id);
                    RemindMeMessageFormManager.MakeMessagePopup("Could not preview this message. Unknown notification type", 4);
                    lvMessages.Items.Remove(itm);
                    BLLocalDatabase.ReadMessage.DeleteMessage(mess.Id);
                }
            }
        }
 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 { }
 }
示例#7
0
 private void tmrEnableDatabaseAccess_Tick(object sender, EventArgs e)
 {
     try
     {
         //If we could not connect to the database, the Data Access Layer will no longer try to connect to the database again.
         //This timer will re-enable this every 10 minutes, just in case the database is no longer available. Then, if it is available again, continue as usual.
         BLOnlineDatabase.ReAllowDatabaseAccess();
     }
     catch (Exception ex)
     {
         BLIO.Log("EnableDatabaseAccess FAILED. " + ex.GetType().ToString());
         BLIO.WriteError(ex, "Error in tmrEnableDatabaseAccess_Tick");
     }
 }
示例#8
0
        private void OnPowerChange(object sender, PowerModeChangedEventArgs e)
        {
            switch (e.Mode)
            {
            //PC wakes up from sleep. If you're someone that always puts your pc to sleep instead of turning it off, RemindMe won't get "launched" again
            //but instead, resumes.
            case PowerModes.Resume:
                BLOnlineDatabase.InsertOrUpdateUser(BLSettings.Settings.UniqueString);
                BLIO.Log("=== PC Woke up from sleep! ===");
                break;

            case PowerModes.Suspend: BLIO.Log("=== PC Is going to sleep. ZzZzzzZzz... ===");
                break;
            }
        }
示例#9
0
        private void PopupRemindMeMessage(RemindMeMessages mess)
        {
            //Update the counter on the message
            BLIO.Log("Attempting to update an message with id " + mess.Id);
            BLOnlineDatabase.UpdateRemindMeMessageCount(mess.Id);

            switch (mess.NotificationType)
            {
            case "REMINDMEBOX":
                RemindMeBox.Show("RemindMe Developer", "This is a message from the developer of RemindMe.\r\n\r\n" + mess.Message.Replace("¤", Environment.NewLine), RemindMeBoxReason.OK);
                break;

            case "REMINDMEMESSAGEFORM":
                RemindMeMessageFormManager.MakeMessagePopup(mess.Message.Replace("¤", Environment.NewLine), mess.NotificationDuration.Value, "RemindMe Developer");
                break;
            }
        }
示例#10
0
        private void tmrPingActivity_Tick(object sender, EventArgs e)
        {
            try
            {
                if (BLIO.LastLogMessage != null && !BLIO.LastLogMessage.Contains("Updating user"))
                {
                    BLIO.Log("Pinging online status");
                }

                //Update LastOnline
                BLOnlineDatabase.InsertOrUpdateUser(BLLocalDatabase.Setting.Settings.UniqueString);
            }
            catch (Exception ex)
            {
                BLIO.Log("PingActivity FAILED. " + ex.GetType().ToString());
                BLIO.WriteError(ex, "Error in tmrPingActivity_Tick");
            }
        }
示例#11
0
        private void SaveNewTheme(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return;
            }

            Themes theme = new Themes();

            theme.Primary      = (int)Enum.Parse(typeof(Primary), cbPrimary.SelectedItem.ToString());
            theme.DarkPrimary  = (int)Enum.Parse(typeof(Primary), cbDarkPrimary.SelectedItem.ToString());
            theme.LightPrimary = (int)Enum.Parse(typeof(Primary), cbLightPrimary.SelectedItem.ToString());

            theme.Accent = (int)Enum.Parse(typeof(Accent), cbAccent.SelectedItem.ToString());

            theme.TextShade = (int)Enum.Parse(typeof(TextShade), cbTextShade.SelectedItem.ToString());

            theme.ThemeName = name;

            theme.Mode = (int)MaterialSkinManager.Instance.Theme;

            BLLocalDatabase.Theme.InsertTheme(theme);
            BLOnlineDatabase.InsertTheme(theme);

            ComboBoxItem item = new ComboBoxItem(theme.ThemeName, theme.Id);

            cbLoadTheme.Items.Add(item);
            cbLoadTheme.SelectedItem = item;

            currentSelectedTheme = theme;
            //Update the settings table
            Settings set = BLLocalDatabase.Setting.Settings;

            set.CurrentTheme = theme.Id;
            BLLocalDatabase.Setting.UpdateSettings(set);



            MaterialMessageFormManager.MakeMessagePopup("Succesfully saved theme \"" + name + "\" under your saved themes.", 5);
        }
示例#12
0
        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;
        }
示例#13
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            BLIO.Log("(UCSupport)btnSend_Click");
            try
            {
                BLIO.Log("Attempting to send a message to the RemindMe developer..");

                //Don't do anything if there's no text
                if (string.IsNullOrWhiteSpace(tbNote.Text) || tbNote.Text == "Type your message here...")
                {
                    return;
                }

                //Don't do anything without internet
                if (!BLIO.HasInternetAccess())
                {
                    RemindMeMessageFormManager.MakeMessagePopup("You do not currently have an active internet connection", 3);
                    return;
                }

                string email   = tbEmail.Text;
                string subject = tbSubject.Text;
                string note    = tbNote.Text;

                BLOnlineDatabase.InsertEmailAttempt(BLLocalDatabase.Setting.Settings.UniqueString, note, subject, email);
                RemindMeMessageFormManager.MakeMessagePopup("Feedback Sent. Thank you!", 5);
                tbEmail.Text   = "";
                tbSubject.Text = "";
                tbNote.Text    = "";
                label3.Focus();
                BLIO.Log("Message sent!");
            }
            catch (Exception ex)
            {
                BLIO.Log("Error in UCSUpport.btnSend_Click. Could not send the message! Exception type: " + ex.GetType().ToString() + "   Stacktrace:\r\n" + ex.StackTrace);
                RemindMeMessageFormManager.MakeMessagePopup("Something went wrong. Could not send the e-mail", 3);
            }
        }
示例#14
0
 private void tmrResetExceptionInserts_Tick(object sender, EventArgs e)
 {
     //A maximum of 5 exceptiosn can be inserted into the db every 5 minutes to prevent spam
     BLOnlineDatabase.ResetExceptionInserts();
 }
示例#15
0
        /// <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 async Task formLoadAsync()
        {
            BLIO.Log("RemindMe_Load");

            BLIO.WriteUpdateBatch(Application.StartupPath);

            lblVersion.Text = "Version " + IOVariables.RemindMeVersion;

            Settings set = BLSettings.Settings;

            //set unique user string
            if (string.IsNullOrWhiteSpace(set.UniqueString))
            {
                if (File.Exists(IOVariables.uniqueString))
                {
                    set.UniqueString = File.ReadAllText(IOVariables.uniqueString);
                    BLSettings.UpdateSettings(set);
                }

                File.Delete(IOVariables.uniqueString);
            }
            BLIO.WriteUniqueString();

            if (set.LastVersion != null && (new Version(set.LastVersion) < new Version(IOVariables.RemindMeVersion)))
            {
                BLIO.Log("[VERSION CHECK] New version! last version: " + set.LastVersion + "  New version: " + IOVariables.RemindMeVersion);
                //User has a new RemindMe version!
                string releaseNotesString = "";

                foreach (KeyValuePair <string, string> entry in UpdateInformation.ReleaseNotes)
                {
                    if (new Version(entry.Key) > new Version(set.LastVersion))
                    {
                        releaseNotesString += "Version " + entry.Key + "\r\n" + entry.Value + "\r\n\r\n\r\n";
                    }
                }
                WhatsNew wn = new WhatsNew(set.LastVersion, releaseNotesString);
                wn.Show();


                //Before updating the lastVersion, log the update in the db
                BLOnlineDatabase.AddNewUpgrade(DateTime.Now, set.LastVersion, IOVariables.RemindMeVersion);

                //Update the lastVersion
                set.LastVersion = IOVariables.RemindMeVersion;
            }
            else
            {
                BLIO.Log("[VERSION CHECK] No new version! lastVersion: " + set.LastVersion + "  New version: " + IOVariables.RemindMeVersion);
            }

            //Default view should be reminders
            pnlMain.Controls.Add(ucReminders);

            RemindMeMessageFormManager.MakeTodaysRemindersPopup();
            BLIO.Log("Today's reminders popup created");

            //Create an shortcut in the windows startup folder if it doesn't already exist
            if (!File.Exists(IOVariables.startupFolderPath + "\\RemindMe" + ".lnk"))
            {
                FSManager.Shortcuts.CreateShortcut(IOVariables.startupFolderPath, "RemindMe", System.Windows.Forms.Application.StartupPath + "\\" + "RemindMe.exe", "Shortcut of RemindMe");
            }


            if (Debugger.IsAttached) //Debugging ? show extra option
            {
                btnDebugMode.Visible = true;
            }


            BLSongs.InsertWindowsSystemSounds();

            tmrUpdateRemindMe.Start();

            //If the setup still exists, delete it
            File.Delete(IOVariables.rootFolder + "SetupRemindMe.msi");

            //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);
                Thread.Sleep(1500);
                if (set.LastVersion == null)
                {
                    //First time user! log it in the db
                    BLOnlineDatabase.InsertFirstTimeUser(set.UniqueString);
                    set.LastVersion = IOVariables.RemindMeVersion;
                }
                BLSettings.UpdateSettings(set);
            });

            tr.Start();



            this.Opacity       = 0;
            this.ShowInTaskbar = true;
            this.Show();
            tmrInitialHide.Start();

            //Insert the errorlog.txt into the DB if it is not empty
            if (new FileInfo(IOVariables.errorLog).Length > 0)
            {
                BLOnlineDatabase.InsertLocalErrorLog(set.UniqueString, File.ReadAllText(IOVariables.errorLog), File.ReadLines(IOVariables.errorLog).Count());
                File.WriteAllText(IOVariables.errorLog, "");
            }

            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.");
            BLIO.Log("RemindMe loaded");
            Cleanup();
        }
示例#16
0
        /// <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);
            }
        }
示例#17
0
        private void tmrCheckReminder_Tick(object sender, EventArgs e)
        {
            try
            {
                bool isHourBeforeNotificationEnabled = BLLocalDatabase.Setting.IsHourBeforeNotificationEnabled();
                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;
                    MaterialMessageFormManager.MakeTodaysRemindersPopup();
                    //Update lastOnline. If you keep RemindMe running and put your pc to sleep instead of turning it off, it would never get updated without this
                    BLOnlineDatabase.InsertOrUpdateUser(BLLocalDatabase.Setting.Settings.UniqueString);
                }


                //We will check for reminders here every 5 seconds.
                foreach (Reminder rem in BLReminder.GetReminders().Where(r => r.Enabled == 1).ToList())
                {
                    //Create the popup. Do the other stuff afterwards.
                    if ((rem.PostponeDate != null && Convert.ToDateTime(rem.PostponeDate) <= DateTime.Now) || (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 (isHourBeforeNotificationEnabled)
                        {
                            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)
                {
                    //Don't show "reminderName in 60 minutes!" if the reminder doesn't "Show" when popped up, silent reminders.
                    if (BLLocalDatabase.AVRProperty.GetAVRProperties(rem.Id) != null && BLLocalDatabase.AVRProperty.GetAVRProperties(rem.Id).ShowReminder != 1)
                    {
                        continue;
                    }

                    if (remindersToHappenInAnHour.Count > 1)
                    {
                        message += count + ") " + rem.Name + Environment.NewLine;
                    }
                    else
                    {
                        message = rem.Name + " in 60 minutes!";
                    }

                    count++;
                }

                if (remindersToHappenInAnHour.Count > 1 && 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
                    {
                        MaterialMessageFormManager.MakeMessagePopup(message, 6);
                    }

                    popupMessages.Add(message);
                }
                else if (remindersToHappenInAnHour.Count > 0 && count > 1)
                {
                    if (!popupMessages.Contains(message)) //Don't create this popup if we have already created it once before
                    {
                        MaterialMessageFormManager.MakeMessagePopup(message, 6, remindersToHappenInAnHour[0]);
                    }

                    popupMessages.Add(message);
                }

                remindersToHappenInAnHour.Clear();
            }
            catch (Exception ex)
            {
                BLIO.Log("CheckReminder FAILED!!! " + ex.GetType().ToString());
                BLIO.WriteError(ex, "!!! Error in tmrCheckReminder_Tick");
            }
        }
示例#18
0
        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());
                }
            }
        }