Skip to content

Commit

Permalink
Added Timer Offset
Browse files Browse the repository at this point in the history
iRacing is about 30 seconds behind real time, the offset helps you stay
closer to iRacing's race start times.
  • Loading branch information
Mike Bethany committed Feb 15, 2014
1 parent abaa804 commit 922231a
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 61 deletions.
Binary file added OBS_Timer/1380_wall_clockFINAL.ico
Binary file not shown.
104 changes: 47 additions & 57 deletions OBS_Timer/Form1.Designer.cs

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

42 changes: 38 additions & 4 deletions OBS_Timer/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ public partial class OBS_Timer : Form

private String _textFilePath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\obs_timer_text.txt";


public OBS_Timer()
{
InitializeComponent();
Debug.WriteLine(_textFilePath);
writeMessageFile("");
addButtonEvents();
setOutputText();
initCountdownOffsetScroller();
}

private void timerClock_Tick(object sender, EventArgs e)
Expand All @@ -44,12 +43,12 @@ private void addButtonEvents()
{
iterateButtons((button) =>
{
button.Click += new EventHandler(setCountdown);
button.Click += new EventHandler(setCountdownText);
}
);
}

private void setCountdown(object button_object, EventArgs args)
private void setCountdownText(object button_object, EventArgs args)
{
_countdownTime = futureTime((Button)button_object);
this.btnStop.Enabled = true;
Expand All @@ -70,6 +69,8 @@ private void updateCountdown()

if (countDown > _zeroTime)
{
int countdownOffsetSeconds = readCountdownOffsetSeconds();
countDown = countDown.Add(new TimeSpan(0, 0, countdownOffsetSeconds));
countdownText = countDown.ToString(@"hh\:mm\:ss");
writeMessageFile(countdownText);
}
Expand Down Expand Up @@ -172,7 +173,40 @@ private void btnStop_Click(object sender, EventArgs e)
stopCountdown();
}

private void initCountdownOffsetScroller()
{
this.scrollCountOffset.Value = readCountdownOffsetSeconds() / 15;
setCountdownOffsetSecondsText();
}

private void scrollCountdownOffset_Scroll(object sender, ScrollEventArgs e)
{
int seconds = e.NewValue * 15;
updateCountdownOffsetSeconds(seconds);

}

private void updateCountdownOffsetSeconds(int seconds)
{
saveCountdownOffsetSeconds(seconds);
setCountdownOffsetSecondsText();
}

private int readCountdownOffsetSeconds()
{
return (int)Properties.Settings.Default.CountdownOffsetSeconds;
}

private void saveCountdownOffsetSeconds(int seconds)
{
Properties.Settings.Default["CountdownOffsetSeconds"] = seconds;
Properties.Settings.Default.Save();
}

private void setCountdownOffsetSecondsText()
{
this.lblCountOffset.Text = readCountdownOffsetSeconds().ToString();
}

}
}
12 changes: 12 additions & 0 deletions OBS_Timer/Properties/Settings.Designer.cs

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

3 changes: 3 additions & 0 deletions OBS_Timer/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
<Setting Name="TimerMessage" Type="System.String" Scope="User">
<Value Profile="(Default)">Countdown:</Value>
</Setting>
<Setting Name="CountdownOffsetSeconds" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>
3 changes: 3 additions & 0 deletions OBS_Timer/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<setting name="TimerMessage" serializeAs="String">
<value>Countdown:</value>
</setting>
<setting name="CountdownOffsetSeconds" serializeAs="String">
<value>0</value>
</setting>
</OBS_Timer.Properties.Settings>
</userSettings>
</configuration>
Binary file modified OBS_Timer_Setup/Release/OBS_Timer_Setup.msi
Binary file not shown.

0 comments on commit 922231a

Please sign in to comment.