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);
                }
            }
            ;
        }
 public static ProjectsPersistenceManager GetInstance()
 {
     if (instace == null)
     {
         instace = new ProjectsPersistenceManager(new ProjectGroupXmlSerializer());
     }
     return(instace);
 }
Example #3
0
 private void LoadProjectGroup()
 {
     projectGroup = ProjectsPersistenceManager.GetInstance().Load();
     if (projectGroup == null)
     {
         projectGroup = new ProjectGroup();
     }
 }
Example #4
0
        void delButtonClick(object sender, EventArgs e)
        {
            if (activeTask != null)
            {
                currentProject.RemoveTask(activeTask);
                RefreshTasks();
                RefreshDaySummary();

                ProjectsPersistenceManager.GetInstance().SaveAsyncOrShowError(projectGroup);
            }
        }
Example #5
0
        void newButtonClick(object sender, EventArgs e)
        {
            Project newProject = new Project();

            newProject.Name = ProjectNames.GenerateName();
            newProject.Rate = 0;
            projectGroup.Add(newProject);
            SetCurrentProject(newProject);
            RefreshListView();

            ProjectsPersistenceManager.GetInstance().SaveAsyncOrShowError(projectGroup);
        }
Example #6
0
        void removeButtonClick(object sender, EventArgs e)
        {
            if (MessageBox.Show("This will remove project and all of it tasks. Are you sure?", "Removing project",
                                MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                projectGroup.Remove(currentProject);
                SetCurrentProject(null);
                RefreshListView();

                ProjectsPersistenceManager.GetInstance().SaveAsyncOrShowError(projectGroup);
            }
        }
Example #7
0
        void newButtonClick(object sender, EventArgs e)
        {
            TaskEditForm form = new TaskEditForm(null);

            form.ShowDialog(this);
            if (form.Result != null)
            {
                currentProject.AddTask(form.Result);
                RefreshTasks();
                RefreshDaySummary();

                ProjectsPersistenceManager.GetInstance().SaveAsyncOrShowError(projectGroup);
            }
        }
Example #8
0
 private void StopTimer()
 {
     if (taskTimer.Enabled)
     {
         taskTimer.Stop();
         taskNameTextBox.Enabled = currentProject != null;
         saveTimeInterval.Reset();
         increaseDurationInterval.Reset();
         RefreshTimerToggleText();
         timerToggle.Checked = false;
         if (activeTask != null && currentProject != null)
         {
             ProjectsPersistenceManager.GetInstance().SaveAsyncOrShowError(projectGroup);
         }
     }
 }
Example #9
0
 private void OnTimerEvent(object sender, EventArgs e)
 {
     if (activeTask != null)
     {
         activeTask.DurationInMillis += increaseDurationInterval.ElapsedMilliseconds;
         RefreshTimerToggleText();
         RefreshTasks();
         RefreshDaySummary();
         if (saveTimeInterval.ElapsedMilliseconds > SAVE_INTERVAL)
         {
             ProjectsPersistenceManager.GetInstance().SaveAsyncOrShowError(projectGroup);
             saveTimeInterval.Restart();
         }
         increaseDurationInterval.Restart();
     }
     else
     {
         StopTimer();
     }
 }
Example #10
0
        void saveButtonClick(object sender, EventArgs e)
        {
            if (currentProject != null)
            {
                try
                {
                    decimal rate = Decimal.Parse(rateTextBox.Text, CultureInfo.CreateSpecificCulture("en-US"));

                    currentProject.Name = nameTextBox.Text;
                    currentProject.Rate = rate;

                    RefreshListView();

                    ProjectsPersistenceManager.GetInstance().SaveAsyncOrShowError(projectGroup);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Please check entered values.\n\n" + ex.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Example #11
0
 void MainFormFormClosed(object sender, FormClosedEventArgs e)
 {
     ProjectsPersistenceManager.GetInstance().Save(projectGroup);
 }