示例#1
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();
        }
示例#2
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();
        }
示例#3
0
 private void lblExit_Click(object sender, EventArgs e)
 {
     if (rem.Id != -1)
     {
         rem.PostponeDate = null;
         BLReminder.UpdateReminder(rem);
         //RefreshMainFormListView();
     }
     this.Close();
     this.Dispose();
 }
示例#4
0
        private void Popup_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Try to update the reminder before the form unexpectedly closes
            if (rem.Id != -1 && !formClosedCorrectly)
            {
                rem.PostponeDate = null;
                BLReminder.UpdateReminder(rem);
                //RefreshMainFormListView();
            }

            //Stop the sound from playing when the popup closes. You don't want it to keep playing, especially if it is a soundtrack that is quite long
            myPlayer.controls.stop();
        }
示例#5
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();
        }