コード例 #1
0
        /*This was testing a custom color scheme
         * private void SetColorScheme()
         * {
         *
         *  string t = BLSettings.Settings.RemindMeTheme;
         *  RemindMeColorScheme colorTheme = BLSettings.GetColorTheme(BLSettings.Settings.RemindMeTheme);
         *  BLIO.Log("Setting RemindMe Color scheme \"" + BLSettings.Settings.RemindMeTheme + "\"");
         *  pnlSide.GradientBottomLeft = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[2]));
         *  pnlSide.GradientBottomRight = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[2]));
         *  pnlSide.GradientTopLeft = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[2]));
         *  pnlSide.GradientTopRight = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[2]));
         *
         *
         *  pnlMain.GradientBottomLeft = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[2]));
         *  pnlMain.GradientBottomRight = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[2]));
         *  pnlMain.GradientTopLeft = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[2]));
         *  pnlMain.GradientTopRight = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[2]));
         * }*/

        protected override void WndProc(ref Message m)
        {
            //This message will be sent when the RemindMeImporter imports reminders.
            if (m.Msg == WM_RELOAD_REMINDERS)
            {
                BLIO.Log("Reloading reminders after import from .remindme file");
                int currentReminderCount = BLReminder.GetReminders().Count;

                BLReminder.NotifyChange();

                if (UCReminders.Instance != null)
                {
                    UCReminders.Instance.UpdateCurrentPage();
                }

                if (!this.Visible) //don't make this message if RemindMe is visible, the user will see the changes if it is visible.
                {
                    RemindMeMessageFormManager.MakeMessagePopup(BLReminder.GetReminders().Count - currentReminderCount + " Reminder(s) succesfully imported!", 3);
                    BLIO.Log("Created reminders succesfully imported message popup (WndProc)");
                }

                if ((BLReminder.GetReminders().Count - currentReminderCount) > 0)
                {
                    new Thread(() =>
                    {
                        //Log an entry to the database, for data!
                        BLOnlineDatabase.ImportCount++;
                    }).Start();
                }
            }

            base.WndProc(ref m);
        }
コード例 #2
0
        /// <summary>
        /// Change this user controls's icons based on the theme
        /// </summary>
        /// <param name="theme"></param>
        public void UpdateTheme(MaterialSkin.MaterialSkinManager.Themes theme)
        {
            if (theme == MaterialSkin.MaterialSkinManager.Themes.DARK)
            {
                btnAddReminder.Icon     = Properties.Resources.Plus_white;
                btnPreviousPage.Icon    = Properties.Resources.PreviousWhite;
                btnNextPage.Icon        = Properties.Resources.NextWhite;
                btnUnhideReminders.Icon = Properties.Resources.eyeWhite;
            }
            else
            {//Light
                btnAddReminder.Icon     = Properties.Resources.plusDark;
                btnPreviousPage.Icon    = Properties.Resources.previousDark;
                btnNextPage.Icon        = Properties.Resources.nextDark;
                btnUnhideReminders.Icon = Properties.Resources.eyeDark;
            }

            //also update each uc in pnlreminders
            foreach (Control c in pnlReminders.Controls)
            {
                if (c is MUCReminderItem)
                {
                    MUCReminderItem m = (MUCReminderItem)c;
                    m.UpdateTheme(null);
                }
            }

            SetPageButtonIcons(BLReminder.GetReminders());
        }
コード例 #3
0
        public UCReminders()
        {
            InitializeComponent();

            instance = this;

            if (BLReminder.GetReminders().Count == 0)
            {
                pnlReminders.BackgroundImage = Properties.Resources.NoReminders2;
            }
        }
コード例 #4
0
        private void panel1_VisibleChanged(object sender, EventArgs e)
        {
            List <Reminder> reminders = BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 1).Where(r => r.Hide == 0).ToList();

            reminders.AddRange(BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 0).Where(r => r.Hide == 0));

            if (this.Visible)
            {
                SetPageButtonIcons(reminders);
            }
        }
コード例 #5
0
        private bool Exportreminders()
        {
            if (GetSelectedRemindersFromListview().Count > 0)
            {
                string selectedPath = FSManager.Folders.GetSelectedFolderPath();

                if (selectedPath != null)
                {
                    BLIO.Log("User selected a valid path");

                    Exception possibleException = BLReminder.ExportReminders(GetSelectedRemindersFromListview(), selectedPath);
                    if (possibleException == null)
                    {
                        BLIO.Log("No problems encountered (exception null)");
                        SetStatusTexts(GetSelectedRemindersFromListview().Count, BLReminder.GetReminders().Count);
                    }
                    else if (possibleException is UnauthorizedAccessException)
                    {
                        BLIO.Log("Problem encountered: Unauthorized");
                        if (RemindMeBox.Show("Could not save reminders to \"" + selectedPath + "\"\r\nDo you wish to place them on your desktop instead?", RemindMeBoxReason.YesNo) == DialogResult.Yes)
                        {
                            BLIO.Log("Trying to save to desktop instead...");
                            possibleException = BLReminder.ExportReminders(GetSelectedRemindersFromListview(), Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                            if (possibleException != null)
                            {//Did saving to desktop go wrong, too?? just show a message
                                BLIO.Log("Trying to save to desktop didnt work either");
                                RemindMeBox.Show("Something went wrong. Could not save the reminders to your desktop.", RemindMeBoxReason.OK);
                                return(false);
                            }
                            else
                            {//Saving to desktop did not throw an exception
                                BLIO.Log("Saved to desktop");
                                SetStatusTexts(GetSelectedRemindersFromListview().Count, BLReminder.GetReminders().Count);
                            }
                        }
                    }
                    else
                    {
                        RemindMeMessageFormManager.MakeMessagePopup("Backup failed.", 6);
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                RemindMeMessageFormManager.MakeMessagePopup("Please select one or more reminder(s)", 6);
            }
            return(true);
        }
コード例 #6
0
        private void btnNextPage_Click(object sender, EventArgs e)
        {
            BLIO.Log("btnNextPage_Click");
            List <Reminder> reminders = BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 1).Where(r => r.Hide == 0).ToList();

            reminders.AddRange(BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 0).Where(r => r.Hide == 0));
            //^ All reminders in one list with the disabled ones at the end of the list


            if ((pageNumber * 7) + 1 > reminders.Count)
            {
                return; //No reminders left
            }
            int reminderItemCounter = 0;

            for (int i = pageNumber * 7; i < (pageNumber * 7) + 7; i++)
            {
                if (reminders.Count - 1 >= i) //Safely within index numbers
                {
                    //Get the user control item from the panel. There's 7 user controls in the panel, so we have another counter for those
                    UCReminderItem itm = (UCReminderItem)pnlReminders.Controls[reminderItemCounter];
                    itm.Visible = true;
                    //Update the reminder object inside the user control, that's waay faster than removing and re-drawing a new control.
                    itm.Reminder = reminders[i];
                }
                else //Fill all remaining controls that can't be filled with reminders with "empty", since there are no reminders left
                {
                    for (int ii = reminderItemCounter; ii < 7; ii++)
                    {
                        ((UCReminderItem)pnlReminders.Controls[ii]).Reminder = null;
                    }
                }
                reminderItemCounter++;
            }

            pageNumber++;
            if ((pageNumber * 7) + 1 > reminders.Count)
            {
                btnNextPage.Iconimage = Properties.Resources.NextGray1;
            }
            else
            {
                btnNextPage.Iconimage = Properties.Resources.NextWhite;
            }

            if (pageNumber > 1)
            {
                btnPreviousPage.Iconimage = Properties.Resources.PreviousWhite;
            }

            Form1.Instance.UpdatePageNumber(pageNumber);
        }
コード例 #7
0
ファイル: UCReminders.cs プロジェクト: zozolaw/RemindMe
        public UCReminders()
        {
            InitializeComponent();
            sizes = BLListviewColumnSizes.GetcolumnSizes();
            ReminderMenuStrip.Renderer = new MyToolStripMenuRenderer();

            instance = this;

            if (BLReminder.GetReminders().Count == 0)
            {
                pnlReminders.BackgroundImage = Properties.Resources.NoReminders2;
            }
        }
コード例 #8
0
        private void LoadExportReminders()
        {
            BLIO.Log("(MUCImportExport)btnExport_Click");
            lvReminders.Items.Clear();

            BLIO.Log("Export button pressed. Loading reminders into listview");
            if (BLReminder.GetReminders().Count > 0)
            {
                transferType = ReminderTransferType.EXPORT;
                BLFormLogic.AddRemindersToListview(lvReminders, BLReminder.GetReminders(), true);
            }
            BLIO.Log("Added exportable reminders to listview.");
        }
コード例 #9
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            ToggleButton(sender);
            lvReminders.Items.Clear();

            BLIO.Log("Export button pressed. Loading reminders into listview");
            if (BLReminder.GetReminders().Count > 0)
            {
                transferType = ReminderTransferType.EXPORT;
                BLFormLogic.AddRemindersToListview(lvReminders, BLReminder.GetReminders());
            }
            BLIO.Log("Added exportable reminders to listview.");
        }
コード例 #10
0
ファイル: UCReminders.cs プロジェクト: zozolaw/RemindMe
        /// <summary>
        /// When right-clicking reminder(s), this method will hide the skip to next date option if one of the reminder(s) does not have a next date.
        /// </summary>
        private void HideOrShowUnhideReminders()
        {
            //Check if there is even a single reminder that is hidden
            bool showMenuItem = false;

            if (BLReminder.GetReminders().Where(r => r.Hide == 1).ToList().Count > 0)
            {
                showMenuItem = true; //If there's just 1 reminder that is hidden, show the option to un-hide all reminders
            }
            //The option
            ToolStripItem unHideToolStripItem = ReminderMenuStrip.Items.Find("unHideReminderToolStripMenuItem", false)[0];

            //determine if we are going to hide the "Remove postpone" option based on the boolean hideMenuItem
            unHideToolStripItem.Visible = showMenuItem;
            BLIO.Log("Showing unhide reminders option from right click menu: " + showMenuItem);
        }
コード例 #11
0
ファイル: UCReminders.cs プロジェクト: zozolaw/RemindMe
        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();
        }
コード例 #12
0
ファイル: UCReminders.cs プロジェクト: zozolaw/RemindMe
        private void AddRemindersToPanel()
        {
            Point          loc = new Point(10, 10);
            UCReminderItem itm = null;

            foreach (Reminder rem in BLReminder.GetReminders())
            {
                if (itm != null)
                {
                    loc = new Point(loc.X, (itm.Location.Y + itm.Height) + 10);
                }

                itm          = new UCReminderItem(rem);
                itm.Location = loc;
                pnlReminders.Controls.Add(itm);
            }
        }
コード例 #13
0
        protected override void WndProc(ref Message m)
        {
            //This message will be sent when the RemindMeImporter imports reminders.
            if (m.Msg == WM_RELOAD_REMINDERS)
            {
                BLIO.Log("Received message WM_RELOAD_REMINDERS");
                int currentReminderCount = BLReminder.GetReminders().Count;

                BLReminder.NotifyChange();
                UCReminders.GetInstance().UpdateCurrentPage();

                if (!this.Visible) //don't make this message if RemindMe is visible, the user will see the changes if it is visible.
                {
                    MessageFormManager.MakeMessagePopup(BLReminder.GetReminders().Count - currentReminderCount + " Reminder(s) succesfully imported!", 3);
                    BLIO.Log("Created reminders succesfully imported message popup (WndProc)");
                }
            }

            base.WndProc(ref m);
        }
コード例 #14
0
        private void btnPreviousPage_Click(object sender, EventArgs e)
        {
            BLIO.Log("btnPreviousPage_Click");
            if (pageNumber <= 1) //Can't go to the previous page if we're on the first one
            {
                return;
            }

            List <Reminder> reminders = BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 1).Where(r => r.Hide == 0).ToList();

            reminders.AddRange(BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 0).Where(r => r.Hide == 0));
            //^ All reminders in one list with the disabled ones at the end of the list

            int reminderItemCounter = 0;

            for (int i = (pageNumber - 2) * 7; i < ((pageNumber - 2) * 7) + 7; i++)
            {
                if (reminders.Count - 1 >= i) //Safely within index numbers
                {
                    //Get the user control item from the panel. There's 7 user controls in the panel, so we have another counter for those
                    UCReminderItem itm = (UCReminderItem)pnlReminders.Controls[reminderItemCounter];
                    itm.Visible = true;
                    //Update the reminder object inside the user control, that's waay faster than removing and re-drawing a new control.
                    itm.Reminder = reminders[i];
                }

                reminderItemCounter++;

                if (reminderItemCounter == 7)
                {
                    break;
                }
            }

            pageNumber--;
            Form1.Instance.UpdatePageNumber(pageNumber);

            SetPageButtonIcons(reminders);
        }
コード例 #15
0
        private List <Reminder> OrderPostponedReminders()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            List <Reminder> reminders          = BLReminder.GetReminders().Where(r => r.Enabled == 1).Where(r => r.Hide == 0).Where(r => string.IsNullOrWhiteSpace(r.PostponeDate)).ToList();
            List <Reminder> postPonedReminders = BLReminder.GetReminders().Where(r => r.Enabled == 1).Where(r => r.Hide == 0).Where(r => !string.IsNullOrWhiteSpace(r.PostponeDate)).ToList();

            Dictionary <long, DateTime> orderedReminders = new Dictionary <long, DateTime>();

            foreach (Reminder rem in reminders)
            {
                orderedReminders.Add(rem.Id, Convert.ToDateTime(rem.Date.Split(',')[0]));
            }

            foreach (Reminder rem in postPonedReminders)
            {
                orderedReminders.Add(rem.Id, Convert.ToDateTime(rem.PostponeDate));
            }


            //now we have both normal dates and postpone dates


            List <Reminder> returnValue = new List <Reminder>();

            foreach (KeyValuePair <long, DateTime> entry in orderedReminders.OrderBy(x => x.Value))
            {
                returnValue.Add(BLReminder.GetReminderById(entry.Key));
            }

            stopwatch.Stop();
            BLIO.Log("OrderPostponedReminders() took " + stopwatch.ElapsedMilliseconds + " ms");

            return(returnValue);
        }
コード例 #16
0
ファイル: UCReminders.cs プロジェクト: zozolaw/RemindMe
        public void Initialize()
        {
            BLIO.Log("Loading reminders from database");
            //Give initial value to newReminderUc
            newReminderUc           = new UCNewReminder(this);
            newReminderUc.Visible   = false;
            newReminderUc.saveState = false;
            this.Parent.Controls.Add(newReminderUc);


            Form1.Instance.ucNewReminder = newReminderUc;
            //BLFormLogic.AddRemindersToListview(lvReminders, BLReminder.GetReminders().Where(r => r.Hide == 0).ToList()); //Get all "active" reminders);

            BLIO.Log("Starting the reminder timer");
            tmrCheckReminder.Start();

            pnlReminders.Visible = true;

            pnlReminders.DragDrop  += UCReminders_DragDrop;
            pnlReminders.DragEnter += UCReminders_DragEnter;


            int counter = 0;

            foreach (Reminder rem in BLReminder.GetReminders().Where(r => r.Hide == 0).OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 1).Where(r => r.Hide == 0))
            {
                if (pnlReminders.Controls.Count >= 7)
                {
                    break;                                   //Only 7 reminders on 1 page
                }
                pnlReminders.Controls.Add(new UCReminderItem(rem));

                if (counter > 0)
                {
                    pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height);
                }

                counter++;
            }

            foreach (Reminder rem in BLReminder.GetReminders().Where(r => r.Hide == 0).OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 0).Where(r => r.Hide == 0))
            {
                if (pnlReminders.Controls.Count >= 7)
                {
                    break;
                }

                pnlReminders.Controls.Add(new UCReminderItem(rem));

                if (counter > 0)
                {
                    pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height);
                }

                counter++;
            }

            if (BLReminder.GetReminders().Count < 7) //Less than 7 reminders, let's fit in some invisible UCReminderItem 's
            {
                for (int i = BLReminder.GetReminders().Count; i < 7; i++)
                {
                    pnlReminders.Controls.Add(new UCReminderItem(null));

                    if (counter > 0)
                    {
                        pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height);
                    }

                    counter++;
                }
            }
            int test = pnlReminders.Controls.Count;

            if (BLReminder.GetReminders().Where(r => r.Hide == 0).ToList().Count <= 7)
            {
                Form1.Instance.UpdatePageNumber(-1); //Tell form1 that there are not more than 1 pages
            }
            else
            {
                btnNextPage.Iconimage = Properties.Resources.NextWhite;
                Form1.Instance.UpdatePageNumber(pageNumber);
            }
        }
コード例 #17
0
        //Display changes on the current page. (For example a deleted or enabled/disabled reminder)
        public void UpdateCurrentPage()
        {
            BLIO.Log("Starting UpdateCurrentPage()...");
            List <Reminder> reminders = BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 1).Where(r => r.Hide == 0).ToList();

            reminders.AddRange(BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 0).Where(r => r.Hide == 0));
            //^ All reminders in one list with the disabled ones at the end of the list
            BLIO.Log(reminders.Count + " reminders loaded");

startMethod:
            if ((pageNumber * 7) + 1 > reminders.Count)
            {
                btnNextPage.Iconimage = Properties.Resources.NextGray1;
            }
            else
            {
                btnNextPage.Iconimage = Properties.Resources.NextWhite;
            }

            int reminderItemCounter = 0;

            for (int i = (pageNumber - 1) * 7; i < ((pageNumber) * 7); i++)
            {
                if (reminders.Count - 1 >= i) //Safely within index numbers
                {
                    if (reminderItemCounter >= pnlReminders.Controls.Count)
                    {
                        return;
                    }

                    //Get the user control item from the panel. There's 7 user controls in the panel, so we have another counter for those
                    UCReminderItem itm = (UCReminderItem)pnlReminders.Controls[reminderItemCounter];
                    //Update the reminder object inside the user control, that's waay faster than removing and re-drawing a new control.
                    itm.Reminder = reminders[i];
                }
                else
                {
                    //User deleted a reminder, which was the last one out of the list from that page. Navigate to the previous page.
                    if (i % 7 == 0 && pageNumber > 1)
                    {
                        BLIO.Log("navigating to the previous page after deletion of an reminder...");
                        pageNumber--;
                        goto startMethod;
                    }

                    for (int ii = i; ii < 7; ii++)
                    {
                        if (ii >= pnlReminders.Controls.Count)
                        {
                            break;
                        }

                        UCReminderItem itm = (UCReminderItem)pnlReminders.Controls[ii];
                        itm.Reminder = null;
                    }

                    //This happens when an reminder has been deleted, and there are less than 7 reminders on that page. Empty out the remaining reminder items.
                    while (reminderItemCounter <= 6)
                    {
                        BLIO.Log("Detected the deletion of an reminder on the current page.");
                        //Get the user control item from the panel. There's 7 user controls in the panel, so we have another counter for those
                        UCReminderItem itm = (UCReminderItem)pnlReminders.Controls[reminderItemCounter];

                        if (itm.Reminder != null)
                        {
                            BLIO.Log("Emptying ReminderItem with ID " + itm.Reminder.Id);
                        }
                        //Update the reminder object inside the user control, that's waay faster than removing and re-drawing a new control.
                        itm.Reminder = null;

                        reminderItemCounter++;
                    }

                    break;
                }

                reminderItemCounter++;

                if (reminderItemCounter == 7)
                {
                    break;
                }
            }



            if (reminders.Count <= 7)
            {
                Form1.Instance.UpdatePageNumber(-1);
            }
            else
            {
                Form1.Instance.UpdatePageNumber(pageNumber);
            }

            if (Instance != null)
            {
                Instance.tmrCheckReminder.Start();
            }

            BLIO.Log("UpdateCurrentPage() completed.");
        }
コード例 #18
0
        public void Initialize()
        {
            try
            {
                List <Reminder> corruptedReminders = BLReminder.CheckForCorruptedReminders();

                if (corruptedReminders != null)
                {
                    string message = "RemindMe has detected";
                    if (corruptedReminders.Count > 1)
                    {
                        message += " problems with the following reminders: \r\n";

                        foreach (Reminder rem in corruptedReminders)
                        {
                            message += "- " + rem.Name + "\r\n";
                        }

                        message += "\r\nThey have been removed from your list of reminders.";
                    }
                    else
                    {
                        message += " a problem with the reminder:\r\n\"" + corruptedReminders[0].Name + "\". \r\nIt has been removed from your list of reminders.";
                    }

                    RemindMeMessageFormManager.MakeMessagePopup(message, 0);
                }

                BLIO.Log("Loading reminders from database");
                //Give initial value to newReminderUc
                newReminderUc           = new UCNewReminder(this);
                newReminderUc.Visible   = false;
                newReminderUc.saveState = false;
                this.Parent.Controls.Add(newReminderUc);


                Form1.Instance.ucNewReminder = newReminderUc;
                //BLFormLogic.AddRemindersToListview(lvReminders, BLReminder.GetReminders().Where(r => r.Hide == 0).ToList()); //Get all "active" reminders);

                BLIO.Log("Starting the reminder timer");
                tmrCheckReminder.Start();

                pnlReminders.Visible = true;

                pnlReminders.DragDrop  += UCReminders_DragDrop;
                pnlReminders.DragEnter += UCReminders_DragEnter;


                int             counter           = 0;
                List <Reminder> activeReminders   = BLReminder.GetReminders().Where(r => r.Hide == 0).OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 1).ToList();
                List <Reminder> disabledReminders = BLReminder.GetReminders().Where(r => r.Hide == 0).OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 0).ToList();

                foreach (Reminder rem in activeReminders)
                {
                    if (pnlReminders.Controls.Count >= 7)
                    {
                        break;                                   //Only 7 reminders on 1 page
                    }
                    pnlReminders.Controls.Add(new UCReminderItem(rem));

                    if (counter > 0)
                    {
                        pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height);
                    }

                    counter++;
                }

                foreach (Reminder rem in disabledReminders)
                {
                    if (pnlReminders.Controls.Count >= 7)
                    {
                        break;
                    }

                    pnlReminders.Controls.Add(new UCReminderItem(rem));

                    if (counter > 0)
                    {
                        pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height);
                    }

                    counter++;
                }

                if (activeReminders.Count + disabledReminders.Count < 7) //Less than 7 reminders, let's fit in some empty UCReminderItem 's
                {
                    for (int i = (activeReminders.Count + disabledReminders.Count); i < 7; i++)
                    {
                        pnlReminders.Controls.Add(new UCReminderItem(null));

                        if (counter > 0)
                        {
                            pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height);
                        }

                        counter++;
                    }
                }

                if (BLReminder.GetReminders().Where(r => r.Hide == 0).ToList().Count <= 7)
                {
                    Form1.Instance.UpdatePageNumber(-1); //Tell form1 that there are not more than 1 pages
                }
                else
                {
                    btnNextPage.Iconimage = Properties.Resources.NextWhite;
                    Form1.Instance.UpdatePageNumber(pageNumber);
                }
            }
            catch (Exception ex)
            {
                BLIO.Log("UCReminders.Initialize() FAILED. Type -> " + ex.GetType().ToString());
                BLIO.Log("Message -> " + ex.Message);
            }
        }
コード例 #19
0
 private void MUCReminders_Load(object sender, EventArgs e)
 {
     tmrCheckForUpdates.Start();
     SetPageButtonIcons(BLReminder.GetReminders());
 }
コード例 #20
0
ファイル: UCReminders.cs プロジェクト: zozolaw/RemindMe
        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();
        }
コード例 #21
0
        /// <summary>
        /// Display changes on the current page. (For example a deleted or enabled/disabled reminder)
        /// </summary>
        /// <param name="editedReminder">If a reminder has been edited, this object will contain that reminder</param>
        public void UpdateCurrentPage(Reminder editedReminder = null)
        {
            MaterialSkin.MaterialSkinManager.Themes theme = MaterialSkin.MaterialSkinManager.Instance.Theme;

            BLIO.Log("Starting UpdateCurrentPage()...");

            //Reminder list containing normal reminders and conditional reminders, enabled and disabled
            List <Reminder> reminders = BLReminder.GetOrderedReminders();

            //^ All reminders in one list with the disabled ones at the end of the list
            BLIO.Log(reminders.Count + " reminders loaded");

startMethod:
            if ((pageNumber * 7) + 1 > reminders.Count)
            {
                if (theme == MaterialSkin.MaterialSkinManager.Themes.DARK)
                {
                    btnNextPage.Icon = Properties.Resources.nextDisabledDark;
                }
                else
                {
                    btnNextPage.Icon = Properties.Resources.nextDisabledDark;
                }
            }
            else
            {
                if (theme == MaterialSkin.MaterialSkinManager.Themes.DARK)
                {
                    btnNextPage.Icon = Properties.Resources.NextWhite;
                }
                else
                {
                    btnNextPage.Icon = Properties.Resources.nextDark;
                }
            }

            int reminderItemCounter = 0;

            for (int i = (pageNumber - 1) * 7; i < ((pageNumber) * 7); i++)
            {
                if (reminders.Count - 1 >= i) //Safely within index numbers
                {
                    if (reminderItemCounter >= pnlReminders.Controls.Count)
                    {
                        return;
                    }

                    //Get the user control item from the panel. There's 7 user controls in the panel, so we have another counter for those
                    MUCReminderItem itm = (MUCReminderItem)pnlReminders.Controls[reminderItemCounter];
                    //Update the reminder object inside the user control, that's waay faster than removing and re-drawing a new control.
                    itm.Reminder = reminders[i];
                    itm.RefreshLabelFont();
                }
                else
                {
                    //User deleted a reminder, which was the last one out of the list from that page. Navigate to the previous page.
                    if (i % 7 == 0 && pageNumber > 1)
                    {
                        BLIO.Log("navigating to the previous page after deletion of an reminder...");
                        pageNumber--;
                        goto startMethod;
                    }

                    for (int ii = i; ii < 7; ii++)
                    {
                        if (ii >= pnlReminders.Controls.Count)
                        {
                            break;
                        }

                        MUCReminderItem itm = (MUCReminderItem)pnlReminders.Controls[ii];
                        itm.Reminder = null;
                    }

                    //This happens when an reminder has been deleted, and there are less than 7 reminders on that page. Empty out the remaining reminder items.
                    while (reminderItemCounter <= 6)
                    {
                        BLIO.Log("Detected the deletion of an reminder on the current page.");
                        //Get the user control item from the panel. There's 7 user controls in the panel, so we have another counter for those
                        try
                        {
                            MUCReminderItem itm = (MUCReminderItem)pnlReminders.Controls[reminderItemCounter];

                            if (itm.Reminder != null)
                            {
                                BLIO.Log("Emptying ReminderItem with ID " + itm.Reminder.Id);
                            }
                            //Update the reminder object inside the user control, that's waay faster than removing and re-drawing a new control.
                            itm.Reminder = null;

                            reminderItemCounter++;
                        }
                        catch (Exception ex)
                        {
                            BLIO.Log("Setting new Reminder value failed. -> " + ex.GetType().ToString());
                        }
                    }

                    break;
                }

                reminderItemCounter++;

                if (reminderItemCounter == 7)
                {
                    break;
                }
            }



            if (reminders.Count <= 7)
            {
                MaterialForm1.Instance.UpdatePageNumber(-1);
            }
            else
            {
                MaterialForm1.Instance.UpdatePageNumber(pageNumber);
            }

            if (Instance != null)
            {
                Instance.tmrCheckReminder.Start();
            }


            if (editedReminder != null && editedReminder.HttpId != null)
            {
                //This object has been altered. Deleted, Perma-deleted, edited OR disabled
                if (BLReminder.GetReminderById(editedReminder.Id) == null || editedReminder.Deleted > 0 || editedReminder.Enabled == 0)
                {
                    //perma-deleted, soft-deleted or turned off
                    if (GetTimer(editedReminder) != null)
                    {
                        GetTimer(editedReminder).Stop();
                    }
                    RemoveTimer(editedReminder);
                }
                else //Reminder is still active, so it probably has been edited
                {
                    HttpRequests httpObj = BLLocalDatabase.HttpRequest.GetHttpRequestById((long)editedReminder.Id);
                    var          kvp     = httpTimers.Where(r => r.Key.Id == editedReminder.Id).FirstOrDefault();
                    if (kvp.Key != null)
                    {
                        //Already exist, stop timer, change & restart
                        RemoveTimer(editedReminder);
                        var timer = new System.Windows.Forms.Timer();
                        timer.Interval = Convert.ToInt32(httpObj.Interval * 60000);
                        timer.Tick    += (object s, EventArgs a) => ExecuteHttpRequest(s, a, httpObj, editedReminder);
                        timer.Start();
                        httpTimers.Add(editedReminder, timer);
                    }
                    else if (editedReminder.Enabled == 1) //Reminder has been re-enabled
                    {
                        System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                        httpTimers.Add(editedReminder, timer);
                        timer.Interval = Convert.ToInt32(httpObj.Interval * 60000);
                        timer.Tick    += (object s, EventArgs a) => ExecuteHttpRequest(s, a, httpObj, editedReminder);
                        timer.Start();
                    }
                }
            }
            else
            {
                //Http requests
                foreach (Reminder rem in BLReminder.GetReminders(true).Where(r => r.HttpId != null).Where(r => r.Enabled == 1))
                {
                    HttpRequests httpObj = BLLocalDatabase.HttpRequest.GetHttpRequestById((long)rem.Id);

                    if (GetTimer(rem) == null)
                    {
                        //Don't add duplicates
                        System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                        httpTimers.Add(rem, timer);
                        timer.Interval = Convert.ToInt32(httpObj.Interval * 60000);
                        timer.Tick    += (object s, EventArgs a) => ExecuteHttpRequest(s, a, httpObj, rem);
                        timer.Start();
                    }
                }
            }



            BLIO.Log("UpdateCurrentPage() completed.");
        }
コード例 #22
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");
            }
        }
コード例 #23
0
ファイル: UCReminders.cs プロジェクト: zozolaw/RemindMe
        //Display changes on the current page. (For example a deleted or enabled/disabled reminder)
        public void UpdateCurrentPage()
        {
            List <Reminder> reminders = BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 1).Where(r => r.Hide == 0).ToList();

            reminders.AddRange(BLReminder.GetReminders().OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 0).Where(r => r.Hide == 0));
            //^ All reminders in one list with the disabled ones at the end of the list

startMethod:
            if ((pageNumber * 7) + 1 > reminders.Count)
            {
                btnNextPage.Iconimage = Properties.Resources.NextGray1;
            }
            else
            {
                btnNextPage.Iconimage = Properties.Resources.NextWhite;
            }


            int reminderItemCounter = 0;

            for (int i = (pageNumber - 1) * 7; i < ((pageNumber) * 7); i++)
            {
                if (reminders.Count - 1 >= i) //Safely within index numbers
                {
                    if (reminderItemCounter >= pnlReminders.Controls.Count)
                    {
                        return;
                    }

                    //Get the user control item from the panel. There's 7 user controls in the panel, so we have another counter for those
                    UCReminderItem itm = (UCReminderItem)pnlReminders.Controls[reminderItemCounter];
                    itm.Visible = true;
                    //Update the reminder object inside the user control, that's waay faster than removing and re-drawing a new control.
                    itm.UpdateReminder(reminders[i]);
                }
                else
                {
                    //User deleted a reminder, which was the last one out of the list from that page. Navigate to the previous page.
                    if (i % 7 == 0 && pageNumber > 1)
                    {
                        pageNumber--;
                        goto startMethod;
                    }

                    for (int ii = i; ii < 7; ii++)
                    {
                        if (ii >= pnlReminders.Controls.Count)
                        {
                            break;
                        }

                        UCReminderItem itm = (UCReminderItem)pnlReminders.Controls[ii];
                        itm.Visible = false;
                    }
                    break;
                }

                reminderItemCounter++;

                if (reminderItemCounter == 7)
                {
                    break;
                }
            }
            if (reminders.Count <= 7)
            {
                Form1.Instance.UpdatePageNumber(-1);
            }
            else
            {
                Form1.Instance.UpdatePageNumber(pageNumber);
            }

            if (GetInstance() != null)
            {
                GetInstance().tmrCheckReminder.Start();
            }


            //Change background if there are no reminders left
            if (BLReminder.GetReminders().Where(r => r.Hide == 0).ToList().Count == 0)
            {
                pnlReminders.BackgroundImage = Properties.Resources.NoReminders2;
            }
            else
            {
                pnlReminders.BackgroundImage = Properties.Resources.RemindMeGradient;
            }
        }
コード例 #24
0
        public void Initialize()
        {
            try
            {
                MaterialSkin.MaterialSkinManager.Themes theme = MaterialSkin.MaterialSkinManager.Instance.Theme;

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                List <Reminder> corruptedReminders = BLReminder.CheckForCorruptedReminders();

                if (corruptedReminders != null)
                {
                    string message = "RemindMe has detected";
                    if (corruptedReminders.Count > 1)
                    {
                        message += " problems with the following reminders: \r\n";

                        foreach (Reminder rem in corruptedReminders)
                        {
                            message += "- " + rem.Name + "\r\n";
                        }

                        message += "\r\nThey have been removed from your list of reminders.";
                    }
                    else
                    {
                        message += " a problem with the reminder:\r\n\"" + corruptedReminders[0].Name + "\". \r\nIt has been removed from your list of reminders.";
                    }

                    MaterialMessageFormManager.MakeMessagePopup(message, 0);
                }

                BLIO.Log("Loading reminders from database");
                //Give initial value to newReminderUc
                newReminderUc           = new MUCNewReminder(this);
                newReminderUc.Visible   = false;
                newReminderUc.saveState = false;
                this.Parent.Controls.Add(newReminderUc);


                //MaterialForm1.Instance.ucNewReminder = newReminderUc;
                //BLFormLogic.AddRemindersToListview(lvReminders, BLReminder.GetReminders().Where(r => r.Hide == 0).ToList()); //Get all "active" reminders);

                BLIO.Log("Starting the reminder timer");
                tmrCheckReminder.Start();

                pnlReminders.Visible = true;

                pnlReminders.DragDrop  += MUCReminders_DragDrop;
                pnlReminders.DragEnter += MUCReminders_DragEnter;


                int counter = 0;
                //List<Reminder> reminders = BLReminder.GetOrderedReminders();
                List <Reminder> conditionalReminders = BLReminder.GetReminders(true).Where(r => r.HttpId != null).Where(r => r.Hide == 0).Where(r => r.Enabled == 1).ToList();
                List <Reminder> activeReminders      = BLReminder.GetReminders().Where(r => r.Hide == 0).OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 1).ToList();
                List <Reminder> disabledReminders    = BLReminder.GetReminders().Where(r => r.Hide == 0).OrderBy(r => Convert.ToDateTime(r.Date.Split(',')[0])).Where(r => r.Enabled == 0).ToList();

                //we've got postponed reminders, now do this
                if (BLReminder.GetReminders().Where(r => !string.IsNullOrWhiteSpace(r.PostponeDate)).ToList().Count > 0)
                {
                    activeReminders = OrderPostponedReminders();
                }

                foreach (Reminder rem in activeReminders)
                {
                    if (pnlReminders.Controls.Count >= 7)
                    {
                        break;                                   //Only 7 reminders on 1 page
                    }
                    pnlReminders.Controls.Add(new MUCReminderItem(rem));

                    if (counter > 0)
                    {
                        pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height);
                    }

                    counter++;
                }
                foreach (Reminder rem in conditionalReminders)
                {
                    if (pnlReminders.Controls.Count >= 7)
                    {
                        break;                                   //Only 7 reminders on 1 page
                    }
                    pnlReminders.Controls.Add(new MUCReminderItem(rem));

                    if (counter > 0)
                    {
                        pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height);
                    }

                    counter++;
                }
                foreach (Reminder rem in disabledReminders)
                {
                    if (pnlReminders.Controls.Count >= 7)
                    {
                        break;
                    }

                    pnlReminders.Controls.Add(new MUCReminderItem(rem));

                    if (counter > 0)
                    {
                        pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height);
                    }

                    counter++;
                }

                if (activeReminders.Count + disabledReminders.Count < 7) //Less than 7 reminders, let's fit in some empty MUCReminderItem 's
                {
                    for (int i = (activeReminders.Count + disabledReminders.Count); i < 7; i++)
                    {
                        pnlReminders.Controls.Add(new MUCReminderItem(null));

                        if (counter > 0)
                        {
                            pnlReminders.Controls[counter].Location = new Point(0, pnlReminders.Controls[counter - 1].Location.Y + pnlReminders.Controls[counter - 1].Size.Height);
                        }

                        counter++;
                    }
                }

                if (BLReminder.GetReminders().Where(r => r.Hide == 0).ToList().Count <= 7)
                {
                    MaterialForm1.Instance.UpdatePageNumber(-1); //Tell MaterialForm1 that there are not more than 1 pages
                }
                else
                {
                    if (theme == MaterialSkin.MaterialSkinManager.Themes.DARK)
                    {
                        btnNextPage.Icon = Properties.Resources.NextWhite;
                    }
                    else
                    {
                        btnNextPage.Icon = Properties.Resources.nextDark;
                    }

                    MaterialForm1.Instance.UpdatePageNumber(pageNumber);
                }

                //Just design, no logic here. Drags the color panel a bit down and shrink it so it doesnt overlap over the shadow
                MUCReminderItem itm = (MUCReminderItem)pnlReminders.Controls[0];
                itm.pnlSideColor.Size     = new Size(itm.pnlSideColor.Width, itm.pnlSideColor.Height - 4);
                itm.pnlSideColor.Location = new Point(itm.pnlSideColor.Location.X, itm.pnlSideColor.Location.Y + 4);


                //Http requests
                foreach (Reminder rem in conditionalReminders)
                {
                    HttpRequests httpObj = BLLocalDatabase.HttpRequest.GetHttpRequestById((long)rem.Id);

                    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                    timer.Interval = Convert.ToInt32(httpObj.Interval * 60000);
                    timer.Tick    += (object s, EventArgs a) => ExecuteHttpRequest(s, a, httpObj, rem);

                    httpTimers.Add(rem, timer);
                    timer.Start();
                }

                stopwatch.Stop();
                BLIO.Log("MUCReminders Initialize took " + stopwatch.ElapsedMilliseconds + " ms");
            }
            catch (Exception ex)
            {
                BLIO.Log("MUCReminders.Initialize() FAILED. Type -> " + ex.GetType().ToString());
                BLIO.Log("Message -> " + ex.Message);
            }
        }