Beispiel #1
0
        private void load_history()
        {
            string line;

            try {
                using (var file = new StreamReader(history_file_path)) {
                    while ((line = file.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line == "")
                        {
                            continue;
                        }
                        var parts = line.Split('#');
                        if (parts.Length != 3)
                        {
                            MessageBox.Show("Error in history file on line: " + line, "SpentTime error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            continue;
                        }
                        var item = new SpentInterval();
                        item.Task = parts[0];
                        tasks.Add(item.Task);
                        item.Start = DateTime.Parse(parts[1]);
                        item.End   = DateTime.Parse(parts[2]);
                        history.Add(item);
                    }
                }
            }
            catch (FileNotFoundException) {
                // no history, that's OK
            }
        }
Beispiel #2
0
        private void add_history_item(SpentInterval interval)
        {
            var item = new ListViewItem();

            item.Tag  = interval;
            item.Text = interval.Task;
            item.SubItems.Add(interval.Start.ToString());
            item.SubItems.Add(interval.End.ToString());
            item.SubItems.Add(interval.Interval.ToString());
            history_list.Items.Add(item);
        }
Beispiel #3
0
        private void next_button_Click(object sender, EventArgs e)
        {
            var now = DateTime.Now;

            if (current != null)
            {
                current.End  = now;
                current.Task = current_task.Text;
                history.Add(current);
                add_history_item(current);

                tasks.Add(current_task.Text);
                refill_tasks();

                save_history();
                update_overview();
            }
            current       = new SpentInterval();
            current.Start = now;
        }
Beispiel #4
0
 private void stop_button_Click(object sender, EventArgs e)
 {
     next_button_Click(sender, e);
     current = null;
 }