Skip to content

Commit

Permalink
Display total time in bottom of window
Browse files Browse the repository at this point in the history
  • Loading branch information
carstengehling committed Apr 9, 2016
1 parent d56a3f4 commit 0a49170
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
5 changes: 5 additions & 0 deletions source/StopWatch/IssueControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public bool TimerEditable

#region public events
public event EventHandler TimerStarted;

public event EventHandler TimerReset;
#endregion


Expand Down Expand Up @@ -297,6 +299,9 @@ private void Reset()
Comment = null;
this.WatchTimer.Reset();
UpdateOutput();

if (this.TimerReset != null)
this.TimerReset(this, new EventArgs());
}


Expand Down
31 changes: 29 additions & 2 deletions source/StopWatch/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 25 additions & 2 deletions source/StopWatch/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ void issue_TimerStarted(object sender, EventArgs e)
}


void Issue_TimerReset(object sender, EventArgs e)
{
UpdateTotalTime();
}


void ticker_Tick(object sender, EventArgs e)
{
bool firstTick = ticker.Interval == firstDelay;
Expand Down Expand Up @@ -280,6 +286,7 @@ private void InitializeIssueControls()
{
var issue = new IssueControl(this.jiraClient, this.settings);
issue.TimerStarted += issue_TimerStarted;
issue.TimerReset += Issue_TimerReset;
this.Controls.Add(issue);
}

Expand All @@ -305,12 +312,18 @@ private void InitializeIssueControls()
lblConnectionHeader.Top = this.ClientSize.Height - 22;
lblConnectionStatus.Top = this.ClientSize.Height - 22;

lblActiveFilter.Left = this.ClientSize.Width - 320;
lblActiveFilter.Left = this.ClientSize.Width - 360;
lblActiveFilter.Top = this.ClientSize.Height - 24;

cbFilters.Left = this.ClientSize.Width - 280;
cbFilters.Left = this.ClientSize.Width - 320;
cbFilters.Top = this.ClientSize.Height - 28;

lblTotalTime.Left = this.ClientSize.Width - 160;
lblTotalTime.Top = this.ClientSize.Height - 24;

tbTotalTime.Left = this.ClientSize.Width - 120;
tbTotalTime.Top = this.ClientSize.Height - 27;

this.TopMost = this.settings.AlwaysOnTop;

this.ResumeLayout(false);
Expand All @@ -322,6 +335,16 @@ private void UpdateIssuesOutput(bool updateSummary = false)
{
foreach (var issue in this.issueControls)
issue.UpdateOutput(updateSummary);
UpdateTotalTime();
}


private void UpdateTotalTime()
{
TimeSpan totalTime = new TimeSpan();
foreach (var issue in this.issueControls)
totalTime += issue.WatchTimer.TimeElapsed;
tbTotalTime.Text = JiraTimeHelpers.TimeSpanToJiraTime(totalTime);
}


Expand Down

0 comments on commit 0a49170

Please sign in to comment.