-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nick Spreitzer
committed
Jun 23, 2019
1 parent
8410c99
commit c91b7f2
Showing
9 changed files
with
552 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Windows.Forms; | ||
using NodaTime; | ||
|
||
namespace NoDoz | ||
{ | ||
public partial class FormDurationEdit : Form | ||
{ | ||
public FormDurationEdit() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public Duration? Timeout { get; private set; } | ||
|
||
private void buttonCancel_Click(object sender, EventArgs e) => DialogResult = DialogResult.Cancel; | ||
|
||
private void buttonDone_Click(object sender, EventArgs e) | ||
{ | ||
DialogResult = DialogResult.OK; | ||
|
||
if (!checkBoxIndefinite.Checked) | ||
Timeout = Duration.FromTimeSpan(new TimeSpan((int)numericUpDownHours.Value, (int)numericUpDownMinutes.Value, (int)numericUpDownSeconds.Value)); | ||
} | ||
|
||
private void numericUpDownHours_Enter(object sender, EventArgs e) => numericUpDownHours.Select(0, 10); | ||
|
||
private void numericUpDownMinutes_Enter(object sender, EventArgs e) => numericUpDownMinutes.Select(0, 10); | ||
|
||
private void numericUpDownSeconds_Enter(object sender, EventArgs e) => numericUpDownSeconds.Select(0, 10); | ||
|
||
private void checkBoxIndefinite_CheckedChanged(object sender, EventArgs e) | ||
{ | ||
numericUpDownHours.Enabled = !checkBoxIndefinite.Checked; | ||
numericUpDownMinutes.Enabled = !checkBoxIndefinite.Checked; | ||
numericUpDownSeconds.Enabled = !checkBoxIndefinite.Checked; | ||
} | ||
|
||
private void FormDurationEdit_KeyUp(object sender, KeyEventArgs e) | ||
{ | ||
if (e.KeyCode == Keys.Escape) | ||
{ | ||
DialogResult = DialogResult.Cancel; | ||
e.Handled = true; | ||
e.SuppressKeyPress = true; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.