Example #1
0
        void tasksListViewDoubleClick(object sender, MouseEventArgs e)
        {
            ListViewHitTestInfo hit = tasksListView.HitTest(e.Location);

            if (hit.Item != null)
            {
                Core.Task    oldTask = (Core.Task)hit.Item.Tag;
                TaskEditForm form    = new TaskEditForm(oldTask);
                form.ShowDialog(this);
                if (form.Result != null)
                {
                    currentProject.RemoveTask(oldTask);
                    currentProject.AddTask(form.Result);
                    if (activeTask == oldTask)
                    {
                        SetActiveTask(form.Result);
                    }
                    RefreshTasks();
                    RefreshDaySummary();

                    ProjectsPersistenceManager.GetInstance().SaveAsyncOrShowError(projectGroup);
                }
            }
            ;
        }
Example #2
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(0, 0, 100, 100), "test"))
     {
         if (task != null)
         {
             task.IsCancelled = true;
         }
         task = TestTask();
     }
 }
Example #3
0
 private void SetActiveTask(Core.Task task)
 {
     if (!taskTimer.Enabled)
     {
         activeTask = task;
         RefreshTimerToggleText();
         delButton.Enabled = task != null;
         if (task != null)
         {
             taskNameTextBox.Text = task.Name;
         }
     }
 }
Example #4
0
        private void FindActiveTaskByName()
        {
            String taskName = taskNameTextBox.Text;

            Core.Task foundTask = currentProject.GetTasks().FirstOrDefault(
                t => t.Name.Equals(taskName, StringComparison.CurrentCultureIgnoreCase));
            if (foundTask != null)
            {
                SetActiveTask(foundTask);
            }
            else
            {
                SetActiveTask(null);
            }
        }
Example #5
0
        private void RefreshTasks()
        {
            tasksListView.BeginUpdate();
            Core.Task selectedTask = tasksListView.SelectedItems.Count > 0
                ? (Core.Task)tasksListView.SelectedItems[0].Tag : null;
            tasksListView.Items.Clear();

            taskNameTextBox.AutoCompleteCustomSource.Clear();
            if (currentProject != null)
            {
                List <Core.Task> tasks = currentProject.GetTasks(
                    currentDate.HasValue ? new CreationDateFilter(currentDate.Value) : null);
                tasks.Reverse();
                foreach (Core.Task task in tasks)
                {
                    ListViewItem item = new ListViewItem(new String[] {
                        FormatCreationDate(task.CreationDate),
                        task.Name,
                        TaskUtil.ConvertDurationInSecondsToDHM(task.DurationInSeconds)
                    });
                    item.Tag = task;
                    tasksListView.Items.Add(item);
                }
                if (activeTask != null && !currentProject.GetTasks().Contains(activeTask))
                {
                    StopTimer();
                    SetActiveTask(null);
                }
                int newSelectedIndex = selectedTask != null?tasks.IndexOf(selectedTask) : -1;

                if (newSelectedIndex >= 0)
                {
                    tasksListView.SelectedIndices.Add(newSelectedIndex);
                }
                taskNameTextBox.AutoCompleteCustomSource.AddRange(tasks.Select((el) => el.Name).ToArray());
            }
            else
            {
                StopTimer();
                SetActiveTask(null);
            }
            tasksListView.EndUpdate();
        }
Example #6
0
        private void RefreshTimerToggleText()
        {
            Core.Task currentTask = activeTask;
            if (currentTask != null)
            {
                long[] components = TaskUtil.GetDurationComponents(currentTask.DurationInSeconds);

                components[1] += components[0] * 8;
                String duration = "";
                if (components[1] > 0)
                {
                    duration += components[1] + ":";
                }
                duration        += components[2].ToString("00") + ":" + components[3].ToString("00");
                timerToggle.Text = duration;
            }
            else
            {
                timerToggle.Text = "Start";
            }
        }
Example #7
0
 void timerToggleClick(object sender, EventArgs e)
 {
     if (taskTimer.Enabled)
     {
         StopTimer();
     }
     else
     {
         if (activeTask != null)
         {
             StartTimer();
         }
         else
         {
             Core.Task task = new Core.Task();
             task.Name = taskNameTextBox.Text;
             currentProject.AddTask(task);
             RefreshTasks();
             SetActiveTask(task);
             StartTimer();
         }
     }
 }
Example #8
0
 public void AddTask(int id, [FromBody] Core.Task task)
 {
     //do nothing for now
 }