public TimeTracking()
        {
            InitializeComponent();

            //if (!System.Diagnostics.EventLog.SourceExists("TimeTracking"))
            //{
            //    System.Diagnostics.EventLog.CreateEventSource("TimeTracking", "TimeTrackingLog");
            //}
            //else
            //{
            //    System.Diagnostics.EventLog.WriteEntry("TimeTracking", "Error", System.Diagnostics.EventLogEntryType.Error);
            //    System.Diagnostics.EventLog.WriteEntry("TimeTracking", "Testing");
            //}


            if (Data.DatabaseExists())
            {
                this.State = TimeTrackingState.stopped;
                this.SetTreeview();
                this.Width = 666;
                this.UpdatePrevious();
            }
            else
            {
                MessageBox.Show("Error with database, please contact developer");
            }
        }
 private void btnClear_Click(object sender, EventArgs e)
 {
     this.State               = TimeTrackingState.stopped;
     this.Info.CurrentTask    = null;
     this.lblCurrentTask.Text = "";
     this.ResetTimerLabel();
 }
        private void btnStart_Click(object sender, EventArgs e)
        {
            // Check to see if the task is new or was paused and restarted
            if (Info.CurrentTask == null || string.IsNullOrEmpty(this.Info.CurrentTask.Name))
            {
                Info.CurrentTask           = Info.SelectedTask.Clone() as TaskInfo;
                Info.CurrentTask.StartTime = new DateTime();
                Info.CurrentTask.EndTime   = new DateTime();
                Info.CurrentTask.Hours     = 0;
                Info.CurrentTask.Minutes   = 0;
                Info.CurrentTask.Seconds   = 0;

                this.lblCurrentTask.Text = this.lblSelectedTask.Text;
                if (this.chkStartAfterLast.Checked)
                {
                    this.Info.PreviousTask          = Data.Sel_Previous_Task();
                    this.Info.CurrentTask.StartTime = this.Info.PreviousTask.EndTime;
                    TimeSpan elapsedTime = DateTime.Now - this.Info.CurrentTask.StartTime;
                    this.Info.CurrentTask.Hours   = elapsedTime.Hours;
                    this.Info.CurrentTask.Minutes = elapsedTime.Minutes;
                    this.Info.CurrentTask.Seconds = elapsedTime.Seconds;
                }
                else
                {
                    Info.CurrentTask.StartTime = DateTime.Now;
                }
            }
            else
            {
                Info.CurrentTask.StartTime = DateTime.Now.AddHours(-Info.CurrentTask.Hours).AddMinutes(-Info.CurrentTask.Minutes).AddSeconds(-Info.CurrentTask.Seconds);
            }

            //this.UpdateTotalTimeLabel();
            this.State = TimeTrackingState.running;
        }
 private void btnRecord_Click(object sender, EventArgs e)
 {
     this.Info.CurrentTask.RecordTime();
     this.Info.SelectedTask.GetTime();
     UpdateTotalTimeLabel();
     this.Info.PreviousTask   = this.Info.CurrentTask;
     this.Info.CurrentTask    = null;
     this.lblCurrentTask.Text = "";
     this.ResetTimerLabel();
     this.State = TimeTrackingState.stopped;
     this.UpdatePrevious();
 }
        private void btnRecordStartTask_Click(object sender, EventArgs e)
        {
            this.Info.CurrentTask.EndTime = DateTime.Now;
            this.Info.CurrentTask.RecordTime();
            this.Info.SelectedTask.GetTime();
            UpdateTotalTimeLabel();
            this.Info.PreviousTask   = this.Info.CurrentTask.Clone() as TaskInfo;
            this.Info.CurrentTask    = null;
            this.lblCurrentTask.Text = "";
            this.ResetTimerLabel();
            this.State = TimeTrackingState.stopped;
            this.UpdatePrevious();

            Info.CurrentTask           = Info.SelectedTask.Clone() as TaskInfo;
            Info.CurrentTask.StartTime = DateTime.Now;
            Info.CurrentTask.EndTime   = new DateTime();
            Info.CurrentTask.Hours     = 0;
            Info.CurrentTask.Minutes   = 0;
            Info.CurrentTask.Seconds   = 0;
            this.State = TimeTrackingState.running;
            this.lblCurrentTask.Text = this.lblSelectedTask.Text;
        }
 private void btnPause_Click(object sender, EventArgs e)
 {
     this.State = TimeTrackingState.paused;
     this.Info.CurrentTask.EndTime = DateTime.Now;
 }