Skip to content

Commit

Permalink
Fixed sleep timer and cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianlungu committed Jun 27, 2020
1 parent 21545d0 commit 20834df
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 306 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
packages/
.vs/
/ScreenSleep/bin
/ScreenSleep/obj
6 changes: 3 additions & 3 deletions ScreenSleep/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ScreenSleep")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyCopyright("Copyright © Adrian Lungu 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.2")]
6 changes: 3 additions & 3 deletions ScreenSleep/ScreenSleep.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -26,11 +29,8 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
2 changes: 1 addition & 1 deletion ScreenSleep/Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="50"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBox DockPanel.Dock="Left" Name="TimerTextBox" PreviewKeyDown="TimerTextBox_PreviewKeyDown" Height="26" Margin="0,0,10,0" PreviewTextInput="TimerTextBox_PreviewTextInput"></TextBox>
<TextBox DockPanel.Dock="Left" Name="TimerTextBox" Height="26" Margin="0,0,10,0" PreviewTextInput="TimerTextBox_PreviewTextInput"></TextBox>
<TextBlock Grid.Column="1" DockPanel.Dock="Right" TextAlignment="Left" Margin="0,4,0,0">seconds</TextBlock>
</Grid>

Expand Down
20 changes: 9 additions & 11 deletions ScreenSleep/Settings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,24 @@ private void RunCheckbox_OnChecked(object sender, RoutedEventArgs e)
SetupStartup();
}

private void TimerTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
private void TimerTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
var timerText = TimerTextBox.Text;
int timer;

var isNumeric = int.TryParse(timerText, out timer);
var isNumeric = int.TryParse(e.Text, out timer);

if (!isNumeric) {
Properties.Settings.Default.SleepTimer = 1;
} else {
if (!isNumeric)
{
Properties.Settings.Default.SleepTimer = 1;
}
else
{
Properties.Settings.Default.SleepTimer = timer;
}

Properties.Settings.Default.Save();
}

private void TimerTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
var isNumeric = int.TryParse(e.Text, out _);
e.Handled = isNumeric;
e.Handled = !isNumeric;
}
}
}
Empty file.
4 changes: 0 additions & 4 deletions ScreenSleep/obj/Debug/ScreenSleep_MarkupCompile.i.lref

This file was deleted.

140 changes: 0 additions & 140 deletions ScreenSleep/obj/Debug/Settings.g.i.cs

This file was deleted.

4 changes: 0 additions & 4 deletions ScreenSleep/obj/Release/ScreenSleep_MarkupCompile.i.lref

This file was deleted.

140 changes: 0 additions & 140 deletions ScreenSleep/obj/Release/Settings.g.i.cs

This file was deleted.

0 comments on commit 20834df

Please sign in to comment.