Beispiel #1
0
 private FlowLayoutPanel getSubjectPanel(Subject subject)
 {
     FlowLayoutPanel flp = new FlowLayoutPanel();
     flp.Width = subjectFlowPanel.Width;
     //panel.Dock = DockStyle.Fill;
     flp.BackColor = ColorTranslator.FromHtml(bgcolor_subjectPanel);
     flp.BorderStyle = BorderStyle.Fixed3D;
     flp.Controls.Add(new Label() { Text = subject.title });
     flp.Controls.Add(new Button() { Text = BTN_SHOW_ALL });
     flp.Controls.Add(new Button() { Text = "Delete" });
     return flp;
 }
Beispiel #2
0
        private void saveTodoList()
        {
            string filename = selectFile(new SaveFileDialog(), todoListFilter);

            Task t = new Task();
            t.ID = 9;
            t.dateTime = DateTime.Now;
            t.bCompleted = false;
            t.desc = new List<string>();
            t.desc.Add("the description");
            t.subjectID = 8765;

            Subject tt = new Subject();
            tt.ID = 8765;
            tt.title = "the subject title";
            tt.date = DateTime.Now;

            tt.tasks = new List<Task>();
            tt.tasks.Add(t);

            TodoList ttt = new TodoList();
            ttt.ID = 4321;
            ttt.savePath = filename;
            ttt.lastSaved = DateTime.Now;

            ttt.subjects = new List<Subject>();
            ttt.subjects.Add(tt);

            if (!filename.Equals(String.Empty))
            {
                ListTools.writeTodoList(filename, ttt);
            }
        }
Beispiel #3
0
        internal static TodoList readTodoList(string location)
        {
            //string line = FileTools.readLine(location);
            string line = Regex.Replace(FileTools.readLine(location), "===", "\\r\\n");
            string[] lines = Regex.Split(line, "\\|\\|\\|");

            for(int ii = 0; ii < lines.Length; ii++)
            {
                string d = lines[ii];
                string dd = d;
            }

            List<string> matches = RegexTools.match(headerPattern, lines[0], RegexOptions.Multiline);

            TodoList tdl = new TodoList()
            {
                ID = Int32.Parse(matches[0]),
                savePath = matches[1],
                lastSaved = DateTime.FromBinary(Int64.Parse(matches[2])),
                subjects = new List<Subject>()
            };
            Subject subject = null;
            Task task = null;
            int i = 1;
            while(true)//i < lines.Count - 1)
            {
                matches = RegexTools.match(subjectPattern, lines[i], RegexOptions.Multiline);
                subject = new Subject()
                {
                    ID = Int32.Parse(matches[0]),
                    title = matches[1],
                    date = DateTime.FromBinary(Int64.Parse(matches[2])),
                    tasks = new List<Task>()
                };
                i++;

                if (RegexTools.beginsWith("task\\(", lines[i]))
                {
                    matches = RegexTools.match(taskPattern, lines[i], RegexOptions.Multiline);
                    task = new Task()
                    {
                        ID = Int32.Parse(matches[0]),
                        dateTime = DateTime.FromBinary(Int64.Parse(matches[1])),
                        bCompleted = Boolean.Parse(matches[2]),
                        desc = new List<string>()
                    };
                    bool done = false;
                    if (i != 0)//lines.Count - 1)
                    {
                        i++;
                        while (!RegexTools.beginsWith("subject\\(", lines[i]) && !RegexTools.beginsWith("task(", lines[i]) && !done)
                        {
                            task.desc.Add(lines[i]);

                            if (i != 0)//lines.Count - 1)
                            {
                                i++;
                            }
                            else
                            {
                                done = true;
                            }
                        }
                    }

                }

            }

                return tdl;
        }