Skip to content

Commit

Permalink
Added basic always on support
Browse files Browse the repository at this point in the history
  • Loading branch information
banksio committed Jan 15, 2019
1 parent d60429d commit 0906312
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
12 changes: 12 additions & 0 deletions KeyboardDisplay/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="KeyboardDisplay.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<userSettings>
<KeyboardDisplay.Properties.Settings>
<setting name="alwaysOn" serializeAs="String">
<value>False</value>
</setting>
</KeyboardDisplay.Properties.Settings>
</userSettings>
</configuration>
4 changes: 2 additions & 2 deletions KeyboardDisplay/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void ChangeDisplay()
ShowChange(tokenSource.Token);
}

private async void ShowChange(CancellationToken token, bool alwaysOn = true)
private async void ShowChange(CancellationToken token)
{
Storyboard sb = FindResource("FadeIn") as Storyboard;
Storyboard.SetTarget(sb, this);
Expand All @@ -160,7 +160,7 @@ private async void ShowChange(CancellationToken token, bool alwaysOn = true)
{
//tokenSource.Dispose();
}
if (alwaysOn == false)
if (Properties.Settings.Default.alwaysOn == false)
{
Storyboard sb2 = FindResource("FadeOut") as Storyboard;
Storyboard.SetTarget(sb2, this);
Expand Down
12 changes: 12 additions & 0 deletions KeyboardDisplay/Properties/Settings.Designer.cs

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

12 changes: 7 additions & 5 deletions KeyboardDisplay/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="KeyboardDisplay.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="alwaysOn" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
4 changes: 2 additions & 2 deletions KeyboardDisplay/Window1.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:KeyboardDisplay"
mc:Ignorable="d"
Title="Keyboard Display Settings" Icon="Resources/KBDDisp.ico" SizeToContent="Height" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Width="300">
Title="Keyboard Display Settings" Icon="Resources/KBDDisp.ico" SizeToContent="Height" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Width="424.413" Loaded="Window_Loaded">

<StackPanel Margin="10,0,10,10" VerticalAlignment="Top">
<Label Padding="0,0,0,20" Content="Settings" FontFamily="Segoe UI Light" FontSize="48" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<CheckBox x:Name="startupCheckbox" Content="Start at sign in (current user)" HorizontalAlignment="Left" VerticalAlignment="Top" Click="StartupCheckbox_Click"/>
<CheckBox x:Name="startupCheckbox_AllUsers" Content="Start at sign in (all users)" HorizontalAlignment="Left" VerticalAlignment="Top" Click="StartupCheckbox_AllUsers_Click" IsEnabled="False"/>
<CheckBox x:Name="alwaysOnCheckbox" Content="Always show lock status" HorizontalAlignment="Left" VerticalAlignment="Top" Click="alwaysOnCheckbox_Click" Margin="0,15,0,0"/>
<CheckBox x:Name="alwaysOnCheckbox" Content="Always show lock status (active on next lock change)" HorizontalAlignment="Left" VerticalAlignment="Top" Click="alwaysOnCheckbox_Click" Margin="0,15,0,0"/>
<Button Margin="10" Content="OK" Width="73" HorizontalAlignment="Right" VerticalAlignment="Bottom" Height="21" Click="Button_Click"/>
</StackPanel>
</Window>
8 changes: 8 additions & 0 deletions KeyboardDisplay/Window1.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public Window1()
//set checkbox
startupCheckbox.IsChecked = Functions.GetStartupRegistryKeyStatus("currentUser");
startupCheckbox_AllUsers.IsChecked = Functions.GetStartupRegistryKeyStatus("localMachine");
alwaysOnCheckbox.IsChecked = Properties.Settings.Default.alwaysOn;
}

private void StartupCheckbox_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -63,7 +64,14 @@ private void Button_Click(object sender, RoutedEventArgs e)

private void alwaysOnCheckbox_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.alwaysOn = alwaysOnCheckbox.IsChecked.Value;
Properties.Settings.Default.Save();

}

private void Window_Loaded(object sender, RoutedEventArgs e)
{

}
}
}

0 comments on commit 0906312

Please sign in to comment.