Beispiel #1
0
        private void UCReminders_DragDrop(object sender, DragEventArgs e)
        {
            object source = e.Data.GetData("DragSource");

            if (source != null && source.ToString() == "lvReminders")
            {
                if (RemindMeBox.Show("Do you want to copy the selected reminders?\n\nYou just dragged reminders and dropped them in RemindMe again.", RemindMeBoxReason.YesNo) == DialogResult.No)
                {
                    return;
                }
                //If the user said no, return; else just continue
            }
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            BLIO.Log("File(s) dropped into RemindMe! ( " + files.Length + " file(s) )");
            BLIO.Log(".remindme files: " + files.Where(file => Path.GetExtension(file) == ".remindme").ToList().Count);
            //Loop through each file that is dragged into RemindMe
            foreach (string file in files.Where(file => Path.GetExtension(file) == ".remindme").ToList())
            {
                List <object> remindersFromFile = BLReminder.DeserializeRemindersFromFile(file); //Objects from the .remindme file

                foreach (object rem in remindersFromFile.Where(rem => rem.GetType() == typeof(Reminder)).ToList())
                {
                    BLReminder.PushReminderToDatabase((Reminder)rem);
                    BLIO.Log("Deserialized reminder and inserted it into RemindMe");
                }
            }
            //finally, refresh the listview
            UpdateCurrentPage();
        }
Beispiel #2
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            BLIO.Log("(UCSupport)bunifuFlatButton1_Click [btnView]");
            if (lvMessages.SelectedItems.Count > 0)
            {
                ListViewItem itm = lvMessages.SelectedItems[0];

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

                if (mess.NotificationType == "REMINDMEBOX")
                {
                    BLIO.Log("Attempting to show the user a RemindMe message(REMINDMEBOX)...");
                    RemindMeBox.Show("A Message from the creator of RemindMe", mess.Message.Replace("¤", Environment.NewLine), RemindMeBoxReason.OK);
                }
                else if (mess.NotificationType == "REMINDMEMESSAGEFORM")
                {
                    BLIO.Log("Attempting to show the user a RemindMe message(REMINDMEMESSAGEFORM)...");
                    RemindMeMessageFormManager.MakeMessagePopup(mess.Message.Replace("¤", Environment.NewLine), mess.NotificationDuration.Value);
                }
                else
                {
                    BLIO.Log("Attempting to show the user a RemindMe message FAILED. Notificationtype=" + mess.NotificationType + "  Message=" + mess.Message + "  Id=" + mess.Id);
                    RemindMeMessageFormManager.MakeMessagePopup("Could not preview this message. Unknown notification type", 4);
                    lvMessages.Items.Remove(itm);
                    BLLocalDatabase.ReadMessage.DeleteMessage(mess.Id);
                }
            }
        }
Beispiel #3
0
 public static DialogResult Show(string text, string title, RemindMeBoxReason buttons, bool showDontRemindOption = false)
 {
     newMessageBox = new RemindMeBox(text, title, buttons, showDontRemindOption);
     newMessageBox.ShowDialog();
     BLIO.Log("Closing RemindMeBox with result " + result);
     return(result);
 }
Beispiel #4
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.");
            }
        }
Beispiel #5
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            BLIO.Log("Toolstrip option clicked: Permanentely delete (" + rem.Id + ")");
            if (RemindMeBox.Show("Are you really sure you wish to permanentely delete \"" + rem.Name + "\" ?", RemindMeBoxReason.YesNo) == DialogResult.Yes)
            {
                BLIO.Log("Permanentely deleting reminder with id " + rem.Id + " ...");
                BLReminder.PermanentelyDeleteReminder(rem);
                BLIO.Log("Reminder permanentely deleted.");

                this.Reminder = null;
                UCReminders.Instance.UpdateCurrentPage();

                new Thread(() =>
                {
                    //Log an entry to the database, for data!
                    try
                    {
                        BLOnlineDatabase.PermanentelyDeleteCount++;
                    }
                    catch (ArgumentException ex)
                    {
                        BLIO.Log("Exception at BLOnlineDatabase.PermanentelyDeleteCount++. -> " + ex.Message);
                        BLIO.WriteError(ex, ex.Message, true);
                    }
                }).Start();
            }
            else
            {
                BLIO.Log("Permanent deletion of reminder " + rem.Id + " cancelled.");
            }
        }
Beispiel #6
0
        private void btnNewUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                BLIO.Log("Installing the new version from github!");

                if (!File.Exists(IOVariables.rootFolder + "SetupRemindMe.msi"))
                {
                    RemindMeBox.Show("Could not update RemindMe. Please try again later");
                    BLIO.Log("SetupRemindMe.msi was not found on the hard drive.. hmmmmm... suspicious.... ;)");
                    return;
                }


                ProcessStartInfo info = new ProcessStartInfo(IOVariables.rootFolder + "install.bat");
                info.Verb = "runas";

                Process process = new Process();
                process.StartInfo = info;
                process.Start();

                Application.Exit();
            }
            catch (Exception ex)
            {
                MessageFormManager.MakeMessagePopup("Cancelled installation.", 2);
                BLIO.Log("Cancelled installation.");
            }
        }
Beispiel #7
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                string email   = tbEmail.Text;
                string subject = tbSubject.Text;
                string note    = tbNote.Text;

                if (tmrAllowMail.Enabled)
                {
                    RemindMeBox.Show("You have recently sent an e-mail. Wait a bit before you do it again!");
                    return;
                }

                if (!string.IsNullOrWhiteSpace(subject) && !string.IsNullOrWhiteSpace(note))
                {
                    lblSending.Visible = true;
                    pbSending.Visible  = true;
                    btnSend.Enabled    = false;



                    // TimeSpan timeout = TimeSpan.FromSeconds(5);
                    if (string.IsNullOrWhiteSpace(email))
                    {
                        sendMailThread = new Thread(() => sendMailException = BLEmail.SendEmail(subject, note, false));
                    }
                    else
                    {
                        try
                        {
                            MailMessage mes = new MailMessage(email, "*****@*****.**", subject, note);
                            sendMailThread = new Thread(() => sendMailException = BLEmail.SendEmail(subject, note, email, false));
                        }
                        catch (FormatException ex)
                        {
                            btnSend.Enabled    = true;
                            lblSending.Visible = false;
                            pbSending.Visible  = false;
                            RemindMeBox.Show("Please enter a valid e-mail address, or leave it empty");
                        }
                    }

                    if (sendMailThread != null)
                    {
                        sendMailThread.Start();
                        tmrSendMail.Start();
                        tbEmail.ResetText();
                        tbNote.ResetText();
                        tbSubject.ResetText();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageFormManager.MakeMessagePopup("Something went wrong. Could not send the e-mail", 3);
            }
        }
Beispiel #8
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (UCTimer.RunningTimers.Count > 0)
     {
         if (RemindMeBox.Show("You have (" + UCTimer.RunningTimers.Count + ") active timers running.\r\n\r\nAre you sure you wish to close RemindMe? These timers will not be saved", RemindMeBoxReason.YesNo) == DialogResult.No)
         {
             e.Cancel = true;
         }
     }
 }
Beispiel #9
0
 private void toolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (RemindMeBox.Show("Are you really sure you wish to permanentely delete \"" + rem.Name + "\" ?", RemindMeBoxReason.YesNo) == DialogResult.Yes)
     {
         BLIO.Log("Permanentely deleting reminder with id " + rem.Id + " ...");
         this.Visible = false;
         BLReminder.PermanentelyDeleteReminder(rem);
         BLIO.Log("Reminder permanentely deleted.");
         UCReminders.GetInstance().UpdateCurrentPage();
         UCReminders.GetInstance().RefreshPage();
     }
 }
Beispiel #10
0
        private void Popup_Load(object sender, EventArgs e)
        {
            pnlText.VerticalScroll.Visible = true;

            //Set the maximum width of the panel, so that there won't be a horizontal scrollbar, but only a vertical one(if there is a lot of text)
            lblNoteText.MaximumSize = new Size(pnlText.Width - 20, 0);
            lblTitle.MaximumSize    = new Size(pnlTitle.Width - 20, 0);

            pnlTopGradient.SendToBack();
            FlashWindowHelper.Start(this);
            this.MaximumSize = this.Size;

            if (BLSettings.IsAlwaysOnTop())
            {
                this.TopMost  = true; //Popup will be always on top. no matter what you are doing, playing a game, watching a video, you will ALWAYS see the popup.
                this.TopLevel = true;
            }
            else
            {
                this.TopMost     = false;
                this.WindowState = FormWindowState.Minimized;
            }

            //Show what date this reminder was set for
            if (rem.PostponeDate == null)
            {
                lblDate.Text = "This reminder was set for " + rem.Date.Split(',')[0];
            }
            else
            {
                lblDate.Text = "This reminder was set for " + rem.PostponeDate;
            }


            lblTitle.Text    = rem.Name;
            lblNoteText.Text = rem.Note.Replace("\\n", Environment.NewLine);

            //Play the sound
            if (rem.SoundFilePath != null && rem.SoundFilePath != "")
            {
                if (System.IO.File.Exists(rem.SoundFilePath))
                {
                    myPlayer.URL = rem.SoundFilePath;
                    myPlayer.controls.play();
                }
                else
                {
                    RemindMeBox.Show("Could not play " + Path.GetFileNameWithoutExtension(rem.SoundFilePath) + " located at \"" + rem.SoundFilePath + "\" \r\nDid you move,rename or delete the file ?\r\nThe sound effect has been removed from this reminder. If you wish to re-add it, select it from the drop-down list.", RemindMeBoxReason.OK);
                    //make sure its removed from the reminder
                    rem.SoundFilePath = "";
                }
            }
        }
Beispiel #11
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);
        }
Beispiel #12
0
        private void btnNewUpdate_Click(object sender, EventArgs e)
        {
            string allowUpdate = "";

            try
            {
                if (UCTimer.RunningTimers.Count > 0 && !this.Visible)
                {
                    if (RemindMeBox.Show("You have (" + UCTimer.RunningTimers.Count + ") active timers running.\r\n\r\nAre you sure you wish to update and close RemindMe? These timers will not be saved", RemindMeBoxReason.YesNo) == DialogResult.Yes)
                    {
                        allowUpdate = "Y";
                    }
                    else
                    {
                        allowUpdate = "N";
                    }
                }
                else
                {
                    if (allowUpdate == "" || allowUpdate == "Y")
                    {
                        //make sure the popup wont happen when remindme gets closed by Application.Exit()
                        UCTimer.RunningTimers.Clear();


                        BLIO.Log("Installing the new version from github!");

                        if (!File.Exists(IOVariables.rootFolder + "SetupRemindMe.msi"))
                        {
                            RemindMeBox.Show("Could not update RemindMe. Please try again later");
                            BLIO.Log("SetupRemindMe.msi was not found on the hard drive.. hmmmmm... suspicious.... ;)");
                            return;
                        }


                        ProcessStartInfo info = new ProcessStartInfo(IOVariables.rootFolder + "install.bat");
                        info.Verb = "runas";

                        Process process = new Process();
                        process.StartInfo = info;
                        process.Start();

                        Application.Exit();
                    }
                }
            }
            catch
            {
                RemindMeMessageFormManager.MakeMessagePopup("Cancelled installation.", 2);
                BLIO.Log("Cancelled installation.");
            }
        }
Beispiel #13
0
 private void tmrSendMail_Tick(object sender, EventArgs e)
 {
     try
     {
         if (sendMailThread.IsAlive)
         {
             if (secondsPassed >= timeout)
             {
                 sendMailThread.Abort();
                 btnSend.Enabled    = true;
                 pbSending.Visible  = false;
                 lblSending.Visible = false;
                 MessageFormManager.MakeMessagePopup("Could not send the e-mail from your connection.", 5);
                 tmrSendMail.Stop();
                 secondsPassed = 0;
             }
         }
         else
         {
             lblSending.Visible = false;
             pbSending.Visible  = false;
             tmrSendMail.Stop();
             if (sendMailException == null)
             {
                 tmrAllowMail.Start();
                 sendMailThread = null;
                 MessageFormManager.MakeMessagePopup("E-mail Sent. Thank you!", 5);
             }
             else
             {
                 if (sendMailException is FormatException)
                 {
                     RemindMeBox.Show("Please enter a valid e-mail address, or leave it empty");
                 }
                 else
                 {
                     MessageFormManager.MakeMessagePopup("Could not send the e-mail :(", 3);     //No clue what happened
                 }
                 secondsPassed   = 0;
                 btnSend.Enabled = true;
             }
         }
         secondsPassed++;
     }
     catch (Exception ex)
     {
         BLIO.Log("Exception in tmrSendMail_Tick: " + ex.ToString());
         tmrSendMail.Stop();
     }
 }
Beispiel #14
0
        private void PopupRemindMeMessage(RemindMeMessages mess)
        {
            //Update the counter on the message
            BLIO.Log("Attempting to update an message with id " + mess.Id);
            BLOnlineDatabase.UpdateRemindMeMessageCount(mess.Id);

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

            case "REMINDMEMESSAGEFORM":
                RemindMeMessageFormManager.MakeMessagePopup(mess.Message.Replace("¤", Environment.NewLine), mess.NotificationDuration.Value, "RemindMe Developer");
                break;
            }
        }
Beispiel #15
0
 private void tsExit_Click(object sender, EventArgs e)
 {
     if (UCTimer.RunningTimers.Count > 0 && !this.Visible)
     {
         if (RemindMeBox.Show("You have (" + UCTimer.RunningTimers.Count + ") active timers running.\r\n\r\nAre you sure you wish to close RemindMe? These timers will not be saved", RemindMeBoxReason.YesNo) == DialogResult.Yes)
         {
             BLIO.Log("User had running timers and closed RemindMe(through RemindMeIcon)");
             this.Close();
             Application.Exit();
         }
     }
     else
     {
         BLIO.Log("Closing RemindMe(through RemindMeIcon)");
         this.Close();
         Application.Exit();
     }
 }
Beispiel #16
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.End && !btnDebugMode.Visible)
     {
         tmrDebugMode.Stop();
         tmrDebugMode.Start();
         endKeyPressed++;
         if (endKeyPressed >= 3)
         {
             tmrDebugMode.Stop();
             endKeyPressed = 0;
             BLIO.Log("end key pressed 3 times. Show dialog for debug mode");
             if (RemindMeBox.Show("Enable debug mode?", RemindMeBoxReason.YesNo) == DialogResult.Yes)
             {
                 BLIO.Log("Debug mode enabled");
                 btnDebugMode.Visible = true;
             }
         }
     }
 }
Beispiel #17
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.");
            }
        }
Beispiel #18
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            bool doRestart = true;

            if (UCTimer.RunningTimers.Count > 0)
            {
                if (RemindMeBox.Show("You have (" + UCTimer.RunningTimers.Count + ") active timers running.\r\n\r\nAre you sure you wish to close RemindMe? These timers will not be saved", RemindMeBoxReason.YesNo) == DialogResult.No)
                {
                    doRestart = false;
                }
            }

            if (doRestart)
            {
                Settings set = BLLocalDatabase.Setting.Settings;
                set.MaterialDesign = 1;
                BLLocalDatabase.Setting.UpdateSettings(set);


                UCTimer.RunningTimers.Clear();
                Application.Restart();
            }
        }
Beispiel #19
0
        private void Popup2_Load(object sender, EventArgs e)
        {
            BLIO.Log("Popup_load");
            AdvancedReminderProperties          avrProps = BLAVRProperties.GetAVRProperties(rem.Id);
            List <AdvancedReminderFilesFolders> avrFF    = BLAVRProperties.GetAVRFilesFolders(rem.Id);

            if (avrProps != null) //Not null? this reminder has advanced properties.
            {
                BLIO.Log("Reminder " + rem.Id + " has advanced reminder properties!");
                if (!string.IsNullOrWhiteSpace(avrProps.BatchScript))
                {
                    BLIO.ExecuteBatch(avrProps.BatchScript);
                }

                this.Visible = avrProps.ShowReminder == 1;
            }

            if (avrFF != null && avrFF.Count > 0)
            {
                //Go through each action, for example c:\test , delete. c:\sometest\testFile.txt , open
                foreach (AdvancedReminderFilesFolders avr in avrFF)
                {
                    if (avr.Action.ToString() == "Open")
                    {
                        if (File.Exists(avr.Path) || Directory.Exists(avr.Path))
                        {
                            System.Diagnostics.Process.Start(avr.Path);
                        }
                    }
                    else if (avr.Action.ToString() == "Delete")
                    {
                        FileAttributes attr = File.GetAttributes(avr.Path);
                        //Check if it's a file or a directory
                        if (File.Exists(avr.Path))
                        {
                            File.Delete(avr.Path);
                        }
                        else if (Directory.Exists(avr.Path))
                        {
                            Directory.Delete(avr.Path, true);
                        }
                    }
                }
            }

            if (this.Visible)
            {
                tmrFadeIn.Start();
            }
            else
            {
                btnOk_Click(sender, e);
                return;
            }

            DateTime date = Convert.ToDateTime(rem.Date.Split(',')[0]);

            lblSmallDate.Text = date.ToShortDateString() + " " + date.ToShortTimeString();
            lblRepeat.Text    = BLReminder.GetRepeatTypeText(rem);

            if (!String.IsNullOrWhiteSpace(rem.PostponeDate))
            {
                pbDate.BackgroundImage = Properties.Resources.RemindMeZzz;
                lblSmallDate.Text      = Convert.ToDateTime(rem.PostponeDate) + " (Postponed)";
            }

            //If some country has a longer date string, move the repeat icon/text more to the right so it doesnt overlap
            while (lblSmallDate.Bounds.IntersectsWith(pbRepeat.Bounds))
            {
                pbRepeat.Location  = new Point(pbRepeat.Location.X + 5, pbRepeat.Location.Y);
                lblRepeat.Location = new Point(lblRepeat.Location.X + 5, lblRepeat.Location.Y);
            }

            //Play the sound
            if (rem.SoundFilePath != null && rem.SoundFilePath != "")
            {
                if (System.IO.File.Exists(rem.SoundFilePath))
                {
                    BLIO.Log("SoundFilePath not null / empty and exists on the hard drive!");
                    myPlayer.URL = rem.SoundFilePath;
                    myPlayer.controls.play();
                    BLIO.Log("Playing sound");
                }
                else
                {
                    BLIO.Log("SoundFilePath not null / empty but doesn't exist on the hard drive!");
                    RemindMeBox.Show("Could not play " + Path.GetFileNameWithoutExtension(rem.SoundFilePath) + " located at \"" + rem.SoundFilePath + "\" \r\nDid you move,rename or delete the file ?\r\nThe sound effect has been removed from this reminder. If you wish to re-add it, select it from the drop-down list.", RemindMeBoxReason.OK);
                    //make sure its removed from the reminder
                    rem.SoundFilePath = "";
                }
            }

            FlashWindowHelper.Start(this);
            //this.MaximumSize = this.Size;

            if (BLSettings.IsAlwaysOnTop())
            {
                this.TopMost  = true; //Popup will be always on top. no matter what you are doing, playing a game, watching a video, you will ALWAYS see the popup.
                this.TopLevel = true;
            }
            else
            {
                this.TopMost     = false;
                this.WindowState = FormWindowState.Minimized;
            }


            lblTitle.Text = rem.Name;

            if (rem.Note != null)
            {
                lblNoteText.Text = rem.Note.Replace("\\n", Environment.NewLine);
            }

            if (rem.Note == "")
            {
                lblNoteText.Text = "( No text set )";
            }

            lblNoteText.Text = Environment.NewLine + Environment.NewLine + lblNoteText.Text;



            if (rem.Date == null)
            {
                rem.Date = DateTime.Now.ToString();
            }
        }
Beispiel #20
0
        private void RemindMeImporter_Load(object sender, EventArgs e)
        {
            BLIO.Log("RemindmeImporter_load");
            this.MaximumSize = this.Size;


            if (!HasFileAccess(this.remindmeFile)) //Do not attempt to launch the importer form if we can't open the file
            {
                BLIO.Log("Error opening .remindme file, no rights");
                RemindMeBox.Show("Can not open this .remindme file from " + Path.GetDirectoryName(this.remindmeFile) + ". Insufficient rights.", RemindMeBoxReason.OK);
                this.Close();
            }
            else
            {
                try
                {
                    BLIO.Log("Deserializing reminders.....");
                    List <object> deSerializedReminders = BLReminder.DeserializeRemindersFromFile(remindmeFile);
                    BLIO.Log(deSerializedReminders.Count - 1 + " reminders deserialized!");
                    lblAmountOfReminders.Text = deSerializedReminders.Count - 1 + " Reminders"; //-1 because of country code
                    foreach (object rem in deSerializedReminders)
                    {
                        if (rem.GetType() == typeof(Reminder))
                        {
                            Reminder reminder = (Reminder)rem;
                            BLIO.Log(reminder.Name + " Loaded into RemindMeImporter from the .remindme file.");
                            remindersFromRemindMeFile.Add((Reminder)rem);
                        }
                        else
                        {
                            BLIO.Log("Language code" + languageCode + " read from the .remindme file!");
                            languageCode = rem.ToString(); //The language code stored in the .remindme file, "en-Us" for example
                        }
                    }

                    if (languageCode != "") //Don't need to do this when exporting.
                    {
                        BLIO.Log("Going through the reminder list once more....");
                        foreach (object rem in remindersFromRemindMeFile)
                        {
                            if (rem.GetType() == typeof(Reminder))
                            {
                                Reminder remm = (Reminder)rem;
                                //Fix the date if the .remindme file has a different time format than the current system
                                BLIO.Log("(" + remm.Name + ") Fixing the date to match the language code " + languageCode);
                                remm.Date = BLDateTime.ConvertDateTimeStringToCurrentCulture(remm.Date, languageCode);
                            }
                        }
                    }

                    if (remindersFromRemindMeFile != null)
                    {
                        BLIO.Log("Adding the reminders from the .remindme file to the listview....");
                        BLFormLogic.AddRemindersToListview(lvReminders, remindersFromRemindMeFile);
                        BLIO.Log("Done!");
                    }
                    else
                    {
                        BLIO.Log("Failed to load reminders.");
                        lblTitle.Text = "Failed to load reminders.";
                    }
                }
                catch (Exception ex)
                {
                    RemindMeBox.Show("Something has gone wrong loading reminders from this .remindme file.\r\nThe file might be corrupt", RemindMeBoxReason.OK);
                    BLIO.Log("Error loading reminders from .remindme file written to error log");
                    BLIO.WriteError(ex, "Error loading reminders from .remindme file");
                    Application.Exit();
                }
            }
            BLIO.Log("RemindmeImporter loaded !");
        }