Exemplo n.º 1
0
        private void ToggleTimer()
        {
            if (!TaskWatch.IsRunning)
            {
                startToolStripMenuItem.Text = "Pause Task";
                StartPauseButton.Text       = ";";
                StartPauseButton.Font       = new Font("Webdings", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(2)));
                if (!MainWatch.IsRunning)
                {
                    MainWatch.Start();
                }
                TaskWatch.Start();
                AddQuarterProgress(0.0f);

                if (FirstStart)
                {
                    TaskTracker.StartNewDay();
                    TaskTracker.StartNewTask();
                    FirstStart = false;
                    if (TaskTracker.GetCurrentDay.TotalUsedTime != null)
                    {
                        AddQuarterProgress(float.Parse(TaskTracker.GetCurrentDay.TotalUsedTime));
                        try
                        {
                            MainWatch.Offset = TimeSpan.ParseExact(TaskTracker.GetCurrentDay.TotalTime, "hh\\:mm\\:ss\\.ff", CultureInfo.InvariantCulture);
                        } catch { }
                    }
                }
                else
                {
                    if (TaskTracker.isCurrentTaskNull)
                    {
                        TaskTracker.StartNewTask();
                    }
                }
            }
            else
            {
                startToolStripMenuItem.Text = "Resume Task";
                StartPauseButton.Text       = "w";
                StartPauseButton.Font       = new Font("Wingdings 3", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(2)));
                //MainWatch.Stop();
                TaskWatch.Stop();
            }
        }
Exemplo n.º 2
0
        private void UseTime()
        {
            string IssueText = "";

            if (IssueNumber.Visible)
            {
                IssueText = IssueNumber.Text.Trim();
            }
            else
            {
                IssueText = IssueNumberCombo.Text.Trim();
            }
            if (IssueText == "")
            {
                MessageBox.Show("You need to fill out an issue number");
                return;
            }

            if (TaskTracker.isCurrentTaskNull)
            {
                TaskTracker.StartNewTask();
            }

            if (UseComboBox.Items.Count <= 0)
            {
                return;
            }
            LeftoverTransfer = 0.0f;

            string sendTime = UseComboBox.SelectedItem.ToString();

            if (sendTime.StartsWith("."))
            {
                sendTime = "0" + sendTime;
            }
            float useAmount = float.Parse(sendTime);

            float leftover = CurrentTask - useAmount;

            if (leftover >= 0.25f)
            {
                Leftover += leftover;
            }

            if (Leftover > 0f)
            {
                MoveLeftOverButton.Enabled = true;
            }
            else
            {
                MoveLeftOverButton.Enabled = false;
            }

            LastTaskLabel.Text = sendTime;
            AddQuarterProgress(useAmount);
            TaskTracker.EndCurrentTask(IssueText, Task_Hour.Text + ":" + Task_Minute.Text + ":" + Task_Second.Text + "." + Task_Millisecond.Text, DateTime.Now.ToLongTimeString(), sendTime, APSCheckbox.Checked);

            APSCheckbox.Checked = false;

            RecentIssuesAutoCompleteSource.Add(IssueText);

            UpdateRecentIssues();
            IssueNumber.Text      = "";
            IssueNumberCombo.Text = "";

            extraTaskTime = 0.0f;
            UseComboBox.Items.Clear();
            UseComboBox.ResetText();
            UseComboBox.Text          = "Use";
            UseComboBox.SelectedIndex = -1;
            if (TaskWatch.IsRunning)
            {
                TaskWatch.Restart();
                TaskTracker.StartNewTask();
            }
            else
            {
                TaskWatch.Reset();
            }

            SetGlobalTimer();
            SetTaskTimer();
            CalculateCurrentTaskLabel();
        }