private void AddTimeManually()
        {
            addTimeToProject = EditorGUILayout.Toggle("Add To Project", addTimeToProject);
            addTimeToTask    = EditorGUILayout.Toggle("Add To Task", addTimeToTask);
            addTimeToDay     = EditorGUILayout.Toggle("Add To Day", addTimeToDay);
            EditorGUILayout.BeginHorizontal();
            Int32.TryParse(EditorGUILayout.TextField(new GUIContent("Minutes To Add"), minutesToAdd.ToString()), out minutesToAdd);
            var timeToAdd = new TimeSpan(0, minutesToAdd, 0);


            if (GUILayout.Button("Add Time"))
            {
                if (addTimeToProject)
                {
                    TimeTracker.TimeTrackerInfo.TotalTimeSpendOnProject = new TimeSpan(TimeTracker.TimeTrackerInfo.TotalTimeSpendOnProject).Add(timeToAdd).Ticks;
                }
                if (addTimeToTask)
                {
                    TimeTracker.TimeTrackerInfo.CurrentTask.TimeSpendOnTask = new TimeSpan(TimeTracker.TimeTrackerInfo.CurrentTask.TimeSpendOnTask).Add(timeToAdd).Ticks;
                }
                if (addTimeToDay)
                {
                    TimeTracker.TimeTrackerInfo.CurrentDailyTask.TimeSpendOnTask = new TimeSpan(TimeTracker.TimeTrackerInfo.CurrentDailyTask.TimeSpendOnTask).Add(timeToAdd).Ticks;
                }
                TimeTracker.SaveTimeTrackerInfo();
            }

            EditorGUILayout.EndHorizontal();
        }
        private static void ShowSelectedTask()
        {
            var index = TimeTracker.TimeTrackerInfo.AllTasks.Select(x => x.TaskName).ToList().IndexOf(TimeTracker.TimeTrackerInfo.CurrentTask.TaskName);

            EditorGUILayout.BeginHorizontal();
            var newIndex = EditorGUILayout.Popup(new GUIContent("Selected Task"), index, TimeTracker.TimeTrackerInfo.AllTasks.Select(x => x.TaskName).ToArray());

            if (GUILayout.Button("X", EditorStyles.miniButton))
            {
                TimeTracker.TimeTrackerInfo.AllTasks.Remove(TimeTracker.TimeTrackerInfo.CurrentTask);

                TimeTracker.SaveTimeTrackerInfo();
            }
            EditorGUILayout.EndHorizontal();
            if (index != newIndex)
            {
                TimeTracker.TimeTrackerInfo.CurrentTask = TimeTracker.TimeTrackerInfo.AllTasks[newIndex];

                TimeTracker.SaveTimeTrackerInfo();
            }

            if (TimeTracker.TimeTrackerInfo.CurrentTask != null)
            {
                var timeOnTask = TimeTracker.TimeTrackerInfo.CurrentTask.GetTimeSpendOnTask();
                EditorGUI.indentLevel++;
                EditorGUILayout.LabelField("Days: " + timeOnTask.Days);
                EditorGUILayout.LabelField("Hours: " + timeOnTask.Hours);
                EditorGUILayout.LabelField("Minutes: " + timeOnTask.Minutes);
                EditorGUILayout.LabelField("Seconds: " + timeOnTask.Seconds);
                EditorGUI.indentLevel--;
            }
        }
Exemple #3
0
 private void DailyTimes()
 {
     dailyTimeFoldout = EditorGUILayout.Foldout(dailyTimeFoldout, "Daily Time", true);
     if (dailyTimeFoldout)
     {
         EditorGUI.indentLevel++;
         int oldIndex = TimeTracker.TimeTrackerInfo.CurrentDailyTaskIndex;
         EditorGUILayout.BeginHorizontal();
         TimeTracker.TimeTrackerInfo.CurrentDailyTaskIndex = EditorGUILayout.Popup(new GUIContent("Selected Day"), TimeTracker.TimeTrackerInfo.CurrentDailyTaskIndex, TimeTracker.TimeTrackerInfo.DailyTasks.Select(x => x.TaskName).ToArray());
         if (GUILayout.Button("X", EditorStyles.miniButton))
         {
             TimeTracker.TimeTrackerInfo.DailyTasks.Remove(TimeTracker.TimeTrackerInfo.CurrentDailyTask);
             TimeTracker.SaveTimeTrackerInfo();
         }
         EditorGUILayout.EndHorizontal();
         if (oldIndex != TimeTracker.TimeTrackerInfo.CurrentDailyTaskIndex)
         {
             TimeTracker.SaveTimeTrackerInfo();
         }
         var dailyTime = TimeTracker.TimeTrackerInfo.GetCurrentDailyTimeOnProject();
         EditorGUILayout.LabelField("Days: " + dailyTime.Days);
         EditorGUILayout.LabelField("Hours: " + dailyTime.Hours);
         EditorGUILayout.LabelField("Minutes: " + dailyTime.Minutes);
         EditorGUILayout.LabelField("Seconds: " + dailyTime.Seconds);
         EditorGUI.indentLevel--;
     }
 }
Exemple #4
0
        private void StopWatchTracker()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Stopwatch Tracker");

            if (TimeTracker.TimeTrackerInfo.StopWatchRunning)
            {
                EditorGUILayout.LabelField("Time in minutes: " + Math.Round((DateTime.Now - TimeTracker.TimeTrackerInfo.StopWatchStart).TotalMinutes, 2));
                if (GUILayout.Button("Stop and Add Time"))
                {
                    var timeToAdd = (DateTime.Now - TimeTracker.TimeTrackerInfo.StopWatchStart);
                    if (addTimeToProject)
                    {
                        TimeTracker.TimeTrackerInfo.TotalTimeSpendOnProject = new TimeSpan(TimeTracker.TimeTrackerInfo.TotalTimeSpendOnProject).Add(timeToAdd).Ticks;
                    }
                    if (addTimeToTask)
                    {
                        TimeTracker.TimeTrackerInfo.CurrentTask.TimeSpendOnTask = new TimeSpan(TimeTracker.TimeTrackerInfo.CurrentTask.TimeSpendOnTask).Add(timeToAdd).Ticks;
                    }
                    if (addTimeToDay)
                    {
                        TimeTracker.TimeTrackerInfo.CurrentDailyTask.TimeSpendOnTask = new TimeSpan(TimeTracker.TimeTrackerInfo.CurrentDailyTask.TimeSpendOnTask).Add(timeToAdd).Ticks;
                    }
                    TimeTracker.TimeTrackerInfo.StopWatchRunning = false;
                    TimeTracker.SaveTimeTrackerInfo();
                }

                if (GUILayout.Button("Cancel"))
                {
                    TimeTracker.TimeTrackerInfo.StopWatchRunning = false;
                    TimeTracker.SaveTimeTrackerInfo();
                }
            }
            else
            {
                if (GUILayout.Button("Start"))
                {
                    TimeTracker.TimeTrackerInfo.StopWatchRunning = true;
                    TimeTracker.TimeTrackerInfo.StopWatchStart   = DateTime.Now;
                    TimeTracker.SaveTimeTrackerInfo();
                }
            }

            EditorGUILayout.EndHorizontal();
            if (TimeTracker.TimeTrackerInfo.StopWatchRunning)
            {
                EditorGUILayout.LabelField("While the stopwatch is running no other time is tracked!", EditorStyles.boldLabel);
            }
        }
Exemple #5
0
        private void AddTask()
        {
            EditorGUILayout.BeginHorizontal();
            newTaskName = EditorGUILayout.TextField("Name", newTaskName);
            if (GUILayout.Button("Add Task"))
            {
                if (TimeTracker.TimeTrackerInfo.AllTasks.Any(x => x.TaskName == newTaskName))
                {
                    newTaskName = "selected task name already exists";
                }
                else
                {
                    TimeTracker.TimeTrackerInfo.AllTasks.Add(new TimeTrackerTask()
                    {
                        TaskName = newTaskName
                    });
                    TimeTracker.TimeTrackerInfo.CurrentTask = TimeTracker.TimeTrackerInfo.AllTasks.Last();
                    TimeTracker.SaveTimeTrackerInfo();
                }
            }


            EditorGUILayout.EndHorizontal();
        }