コード例 #1
0
ファイル: DataStorage.cs プロジェクト: reednj/TimeTrack
 public static void SaveTaskList(TimeTask[] TaskList)
 {
     SerializeObject(Application.UserAppDataPath + TASKLIST_FILE, TaskList);
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: reednj/TimeTrack
        private void startNewTask()
        {
            string[] listItems = new string[4];

            // we cannot start a new task unless the user has entered a
            // task name
            if(taskNameTxt.Text == "" || taskNameTxt.ForeColor == Color.Gray)
            {
                // no task name, so flash the text box, and dont start the timer
                chromeTimer.Enabled = true;
                taskNameTxt.BackColor = Color.Salmon;
                return;

            }

            if (currentState == TimerState.Running)
            {
                this.finishCurrentTask();
            }
            else
            {
                currentState = TimerState.Running;
            }

            // add the task to the combobox if its not already in there
            if(taskNameTxt.FindString(taskNameTxt.Text) == -1) {
                taskNameTxt.Items.Insert(0, taskNameTxt.Text);
                DataStorage.SaveCommonTasks(this.GetCommonTasks());
            }

            currentTask = new TimeTask(taskNameTxt.Text, DateTime.Now);
            taskNameTxt.Text = "";

            this.updateControlState();

            // add the currently running task to the bottom row
            timeListView.Items.Add(currentTask.toListViewItem());

            // regenerate the summary list
            this.generateSummaryList();

            // save the new task list to the disk
            DataStorage.SaveTaskList(this.GetTaskList());
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: reednj/TimeTrack
        private void timerMainForm_Load(object sender, EventArgs e)
        {
            this.currentState = TimerState.Stopped;
            summaryListView.Sorting = SortOrder.Descending;

            // load the previously saved results, as well as the common task list
            this.PopulateTaskListView(DataStorage.ReadTaskList());
            this.PopulateCommonTaskList(DataStorage.ReadCommonTasks());
            this.PopulateNotes(DataStorage.ReadNotes());

            // if we have added some tasks then start the timer.
            if(timeListView.Items.Count > 0) {
                currentTask = timeListView.Items[timeListView.Items.Count - 1].Tag as TimeTask;

                // we only want to start the timer if there is a current task in the list
                // and it is running.
                if(currentTask != null && currentTask.EndTime == currentTask.UndefinedDate) {
                    this.currentState = TimerState.Running;
                }

                // calc the summarys
                this.generateSummaryList();
                this.UpdateTotal();
            }

            this.updateControlState();
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: reednj/TimeTrack
        private void PopulateTaskListView(TimeTask[] TaskList)
        {
            timeListView.Items.Clear();

            if(TaskList == null) {
                return;
            }

            foreach(TimeTask currentTask in TaskList) {
                timeListView.Items.Add(currentTask.toListViewItem());
            }
        }