Skip to content

Commit

Permalink
- Pressing enter will now start the counter
Browse files Browse the repository at this point in the history
- Fixed bug where the counter start eventhough option is not selected.
  • Loading branch information
mozram committed May 23, 2017
1 parent 0960f23 commit d2b5025
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sleep-Timer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBox Name="txtboxMinutes" Margin="3,3,3,3" Background="#FFB9B9B9" Text="Enter time in minutes" GotFocus="txtboxMinutes_GotFocus" LostFocus="txtboxMinutes_LostFocus"/>
<TextBox Name="txtboxMinutes" Margin="3,3,3,3" Background="#FFB9B9B9" Text="Enter time in minutes" GotFocus="txtboxMinutes_GotFocus" LostFocus="txtboxMinutes_LostFocus" KeyUp="txtboxMinutes_KeyUp"/>
<RadioButton Name="rdbtnSleep" Content="Sleep" Grid.Column="1" VerticalAlignment="Center" Margin="3,3,3,3" Foreground="#FFDEDEDE"/>
<RadioButton Name="rdbtnHibernate" Content="Hibernate" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Margin="3,3,3,3" Foreground="#FFDEDEDE"/>
<RadioButton Name="rdbtnShutdown" Content="Shutdown" Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Margin="3,3,3,3" Foreground="#FFDEDEDE"/>
Expand Down
10 changes: 10 additions & 0 deletions Sleep-Timer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
rdbtnSleep.IsChecked = true;
}

private void btnStart_Click(object sender, RoutedEventArgs e)
Expand All @@ -50,6 +51,7 @@ private void btnStart_Click(object sender, RoutedEventArgs e)
if(command == "error")
{
MessageBox.Show("Failed to set command!");
return;
}

int minutes = 0;
Expand Down Expand Up @@ -124,6 +126,14 @@ private void txtboxMinutes_LostFocus(object sender, RoutedEventArgs e)
txtboxMinutes.Text = "Enter time in minutes";
}
}

private void txtboxMinutes_KeyUp(object sender, KeyEventArgs e)
{
if(e.Key == Key.Enter)
{
btnStart_Click(sender, e);
}
}
}


Expand Down

0 comments on commit d2b5025

Please sign in to comment.