示例#1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (rem.Id != -1) //Don't do stuff if the id is -1, invalid. the id is set to -1 when the user previews an reminder
            {
                formClosedCorrectly = true;
                if (cbPostpone.Checked)
                {
                    if (numPostponeTime.Value == 0)
                    {
                        return;
                    }

                    DateTime newReminderTime = new DateTime();

                    if (rbMinutes.Checked) //postpone option is x minutes
                    {
                        newReminderTime = DateTime.Now.AddMinutes((double)numPostponeTime.Value);
                    }
                    else //postpone option is x hours
                    {
                        newReminderTime = DateTime.Now.AddHours((double)numPostponeTime.Value);
                    }

                    rem.PostponeDate = newReminderTime.ToString();
                    rem.Enabled      = 1;
                    BLReminder.EditReminder(rem);
                }
                else
                {
                    rem.PostponeDate = null;
                    BLReminder.UpdateReminder(rem);
                }
            }
            this.Close();
        }
示例#2
0
        private void postponeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BLIO.Log("Toolstrip option clicked: Postpone (" + rem.Id + ")");
            int minutes = RemindMePrompt.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 (rem.PostponeDate == null)//No postpone yet, create it
            {
                rem.PostponeDate = Convert.ToDateTime(rem.Date.Split(',')[0]).AddMinutes(minutes).ToShortDateString() + " " + Convert.ToDateTime(rem.Date.Split(',')[0]).AddMinutes(minutes).ToShortTimeString();
            }
            else//Already a postponedate, add the time to that date
            {
                rem.PostponeDate = Convert.ToDateTime(rem.PostponeDate).AddMinutes(minutes).ToShortDateString() + " " + Convert.ToDateTime(rem.PostponeDate).AddMinutes(minutes).ToShortTimeString();
            }

            BLReminder.EditReminder(rem);//Push changes

            UCReminders.Instance.UpdateCurrentPage();

            new Thread(() =>
            {
                //Log an entry to the database, for data!
                BLOnlineDatabase.PostponeCount++;
            }).Start();
        }
示例#3
0
        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!
                try
                {
                    BLOnlineDatabase.SkipCount++;
                }
                catch (ArgumentException ex)
                {
                    BLIO.Log("Exception at BLOnlineDatabase.SkipCount++. -> " + ex.Message);
                    BLIO.WriteError(ex, ex.Message, true);
                }
            }).Start();
        }
示例#4
0
        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++;
            }
            BLIO.Log(remindersRecovered + " Reminders recovered");
            SetStatusTexts(remindersRecovered, selectedReminders.Count);
            return(true);
        }
示例#5
0
文件: Popup.cs 项目: zozolaw/RemindMe
        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();
        }
示例#6
0
        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 (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);
                this.Reminder = null;
                UCReminders.Instance.UpdateCurrentPage();

                new Thread(() =>
                {
                    //Log an entry to the database, for data!
                    BLOnlineDatabase.HideCount++;
                }).Start();
            }
            else
            {
                BLIO.Log("Attempting to hide reminder(s) failed.");
            }
        }
示例#7
0
 private void lblDisable_Click(object sender, EventArgs e)
 {
     theReminder.Enabled = 0;                                   //Set the enabled flag of this reminder to false
     BLReminder.EditReminder(theReminder);                      //Push the edited reminder to the database
     UCReminders.GetInstance().UpdateCurrentPage();             //Show the change in RemindMe's main listview
     BLIO.Log("Reminder with id" + theReminder.Id + " Disabled from the RemindMe message form");
     this.Dispose();
 }
        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);
            long oldRemId = rem.Id;
            long newRemId = BLReminder.PushReminderToDatabase(rem);

            AdvancedReminderProperties props = BLLocalDatabase.AVRProperty.GetAVRProperties(rem.Id);

            if (props != null)
            {
                props.Remid = newRemId;
                BLLocalDatabase.AVRProperty.InsertAVRProperties(props);
            }

            HttpRequests req = BLLocalDatabase.HttpRequest.GetHttpRequestById(oldRemId);

            if (req != null)
            {
                long oldHttpId = req.Id;
                req.reminderId = newRemId;
                long newHttpId = BLLocalDatabase.HttpRequest.InsertHttpRequest(req);
                List <HttpRequestCondition> conditions = BLLocalDatabase.HttpRequestConditions.GetConditions(oldHttpId);
                foreach (HttpRequestCondition cond in conditions)
                {
                    cond.RequestId = newHttpId;
                    BLLocalDatabase.HttpRequestConditions.InsertCondition(cond);
                }

                //Now update the duplicated reminder with the httprequest
                Reminder dup = BLReminder.GetReminderById(newRemId);
                dup.HttpId = req.Id;
                BLReminder.EditReminder(dup);
            }

            BLIO.Log("reminder duplicated.");
            MUCReminders.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);
                }
                finally
                {
                    GC.Collect();
                }
            }).Start();
        }
示例#9
0
        private void removePostponeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BLIO.Log("Toolstrip option clicked: Remove postpone (" + rem.Id + ")");
            rem.PostponeDate = null;
            BLReminder.EditReminder(rem);

            pbRepeat.Location  = new Point(168, 26);
            lblRepeat.Location = new Point(195, 30);
            Enable();
            UCReminders.Instance.UpdateCurrentPage();
        }
示例#10
0
        private void skipToNextDateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BLIO.Log("Skipping reminder with id " + rem.Id + " to its next date");
            //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.GetInstance().UpdateCurrentPage();
        }
示例#11
0
        private void removePostponeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BLIO.Log("Removing postpone from reminder with id " + rem.Id);
            rem.PostponeDate = null;
            BLReminder.EditReminder(rem);

            pbRepeat.Location  = new Point(168, 26);
            lblRepeat.Location = new Point(195, 30);
            LoadReminderData();
            UCReminders.GetInstance().UpdateCurrentPage();
        }
示例#12
0
 private void lblSkip_Click(object sender, EventArgs e)
 {
     //The reminder object has now been altered. The first date has been removed and has been "skipped" to it's next date
     BLReminder.SkipToNextReminderDate(theReminder);
     BLIO.Log("Skipped reminder with id " + theReminder.Id + " to it's next date from the RemindMe message form");
     //push the altered reminder to the database
     BLReminder.EditReminder(theReminder);
     BLIO.Log("Edited reminder with id " + theReminder.Id);
     //Show the change in RemindMe's main listview
     UCReminders.GetInstance().UpdateCurrentPage();
     //Finally, close this message
     this.Dispose();
 }
示例#13
0
        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();
        }
示例#14
0
        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();
        }
示例#15
0
        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();
        }
示例#16
0
        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();
        }
示例#17
0
        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();
        }
示例#18
0
        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();
        }
示例#19
0
        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.");
            }
        }
示例#20
0
        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);
        }
示例#21
0
        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();
        }
示例#22
0
        private void tmrCheckReminder_Tick(object sender, EventArgs e)
        {
            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;
                MessageFormManager.MakeTodaysRemindersPopup();
            }


            //We will check for reminders here every 5 seconds.
            foreach (Reminder rem in BLReminder.GetReminders())
            {
                //Create the popup. Do the other stuff afterwards.
                if ((rem.PostponeDate != null && Convert.ToDateTime(rem.PostponeDate) <= DateTime.Now && rem.Enabled == 1) || (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 (BLSettings.IsHourBeforeNotificationEnabled() && rem.Enabled == 1)
                    {
                        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)
            {
                if (remindersToHappenInAnHour.Count > 1)
                {
                    message += count + ") " + rem.Name + Environment.NewLine;
                }
                else
                {
                    message = rem.Name + " in 60 minutes!";
                }

                count++;
            }

            if (remindersToHappenInAnHour.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
                {
                    MessageFormManager.MakeMessagePopup(message, 8);
                }

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

                popupMessages.Add(message);
            }

            remindersToHappenInAnHour.Clear();
        }
示例#23
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");
            }
        }