Example #1
0
        private void TasksCheckedListBox_SelectedIndexChanged(object sender, EventArgs e)//freroam tasks
        {
            try
            {
                if (TasksCheckedListBox.SelectedIndex != -1)
                {
                    string key = TasksCheckedListBox.SelectedItem.ToString();
                    switch (Tasks.ContainsKey(key))
                    {
                    case true:
                        DescriptionRichTextBox.LoadFile(Tasks[key].RTFPath, RichTextBoxStreamType.RichText);
                        //DescriptionRichTextBox.AppendText("\n******\nSaved at: " + Tasks[key].TimeOfCreated.ToShortDateString() +
                        //"\nTarget date picked: " + Tasks[key].TimeTarget.ToShortDateString());
                        break;

                    case false:
                        MessageBox.Show("Task didnt found in TasksList. \nTIP: try to load previously saved tasks");
                        //DescriptionRichTextBox.LoadFile(UsersRTFPath + @"\" + key + ".rtf", RichTextBoxStreamType.RichText
                        break;
                    }
                }
                else
                {
                    DescriptionRichTextBox.Clear();
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
                DescriptionRichTextBox.Clear();
                InWorkTxtBox.Text = (ex.ToString());
            }
        }
Example #2
0
        private void ButtonSave_Click(object sender, EventArgs e)//save selected task
        {
            try
            {
                if (TasksCheckedListBox.SelectedIndex != -1)
                {
                    currentTime = DateTime.Now;
                    string key = TasksCheckedListBox.SelectedItem.ToString();

                    if (!Tasks.ContainsKey(key))                                                                                 //if key not found
                    {
                        string tmpRTFPath = CreateRTF(key);                                                                      //create new rtf file
                        DescriptionRichTextBox.AppendText("\n******\nSaved at: " + currentTime.ToShortDateString() +
                                                          "\nTarget date picked: " + dateTimePicker1.Value.ToShortDateString()); //add date info
                        DescriptionRichTextBox.SaveFile(tmpRTFPath);                                                             //save content to created file
                        Tasks.Add(key, new Task(key, tmpRTFPath, currentTime, dateTimePicker1.Value));                           //create new Task object
                    }
                    else
                    {
                        DescriptionRichTextBox.AppendText("\n******\nSaved at: " + currentTime.ToShortDateString() +
                                                          "\nTarget date picked: " + dateTimePicker1.Value.ToShortDateString());
                        DescriptionRichTextBox.SaveFile(Tasks[key].RTFPath);//else save content to RTF file with correct key of Task object
                    }
                    TaskSaved(key);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }