Skip to content

Commit

Permalink
working on windows theme switching, resolving #35 #51 #53 #57 (althou…
Browse files Browse the repository at this point in the history
…ght windows is buggy) #78 and #63
  • Loading branch information
Armin2208 committed Apr 15, 2020
1 parent 1f04729 commit b310860
Show file tree
Hide file tree
Showing 14 changed files with 448 additions and 61 deletions.
15 changes: 15 additions & 0 deletions AutoThemeChanger/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@
<setting name="DarkOffset" serializeAs="String">
<value>0</value>
</setting>
<setting name="Enabled" serializeAs="String">
<value>False</value>
</setting>
<setting name="ThemeLight" serializeAs="String">
<value />
</setting>
<setting name="ThemeDark" serializeAs="String">
<value />
</setting>
<setting name="ThemeSwitch" serializeAs="String">
<value>False</value>
</setting>
<setting name="ThemeInsteadOfWallpaper" serializeAs="String">
<value>False</value>
</setting>
</AutoThemeChanger.Properties.Settings>
</userSettings>
</configuration>
1 change: 1 addition & 0 deletions AutoThemeChanger/AutoThemeChanger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="ThemeHelper.cs" />
<Compile Include="Updater.cs" />
<Compile Include="SunDate.cs" />
<Compile Include="RegeditHandler.cs" />
Expand Down
10 changes: 5 additions & 5 deletions AutoThemeChanger/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
xmlns:fw="clr-namespace:SourceChord.FluentWPF;assembly=FluentWPF"
xmlns:p="clr-namespace:AutoThemeChanger.Properties"
mc:Ignorable="d"
Title="{x:Static p:Resources.Title}" MinHeight="480" Width="528" ResizeMode="NoResize" Closed="Window_Closed" ContentRendered="Window_ContentRendered" fw:AcrylicWindow.AcrylicWindowStyle="NoIcon" fw:ExtendViewIntoTitleBar="false" Background="{x:Null}" SizeToContent="Height" Height="574.55">
Title="{x:Static p:Resources.Title}" MinHeight="480" Width="507" ResizeMode="NoResize" Closed="Window_Closed" ContentRendered="Window_ContentRendered" fw:AcrylicWindow.AcrylicWindowStyle="NoIcon" fw:ExtendViewIntoTitleBar="false" Background="{x:Null}" SizeToContent="Height" Height="543">

<Grid x:Name="mainWin" Background="#10FFFFFF">
<Grid x:Name="mainWin" Background="#10FFFFFF" Margin="0,0,0,48">
<!-- Grid Layout -->
<Grid.RowDefinitions>
<RowDefinition Height="Auto" SharedSizeGroup="Group1"/>
Expand All @@ -29,10 +29,10 @@
</Grid.ColumnDefinitions>

<!-- Navbar -->
<Frame Content="Frame" Name="frameNavbar" Source="/Pages/PageTime.xaml" HorizontalAlignment="Left" Height="470" Margin="10,10,0,0" Grid.Row="2" Grid.RowSpan="8" VerticalAlignment="Top" Width="466" NavigationUIVisibility="Hidden"/>
<Frame Content="Frame" Name="frameNavbar" Source="/Pages/PageTime.xaml" VerticalContentAlignment="Top" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Height="427" Margin="4,10,0,0" Grid.Row="2" Grid.RowSpan="8" VerticalAlignment="Top" Width="497" NavigationUIVisibility="Hidden"/>
<Button Content="Apps" Name="buttonNavbarApps" HorizontalAlignment="Left" Margin="113,4,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75" Click="buttonNavbarApps_Click" Grid.RowSpan="2"/>
<Button Content="Wallpaper" Name="buttonNavbarWallpaper" HorizontalAlignment="Left" Margin="207,5,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75" Click="buttonNavbarWallpaper_Click" Grid.RowSpan="2"/>
<Button Content="Settings" Name="buttonNavbarSettings" HorizontalAlignment="Left" Margin="297,5,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75" Click="buttonNavbarSettings_Click" Grid.RowSpan="2"/>
<Button Content="Wallpaper + Themes" Name="buttonNavbarWallpaper" HorizontalAlignment="Left" Margin="207,5,0,0" Grid.Row="1" VerticalAlignment="Top" Width="132" Click="buttonNavbarWallpaper_Click" Grid.RowSpan="2"/>
<Button Content="Settings" Name="buttonNavbarSettings" HorizontalAlignment="Left" Margin="370,5,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75" Click="buttonNavbarSettings_Click" Grid.RowSpan="2"/>
<Button Content="Time" Name="buttonNavarTime" HorizontalAlignment="Left" Margin="10,5,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75" Click="buttonNavarTime_Click" Grid.RowSpan="2"/>

</Grid>
Expand Down
8 changes: 8 additions & 0 deletions AutoThemeChanger/Pages/PageApps.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ private void ThemeChange(object sender, EventArgs e)

private void UiHandler()
{
if (!Properties.Settings.Default.Enabled)
{
AccentColorCheckBox.IsEnabled = false;
SystemComboBox.IsEnabled = false;
AppComboBox.IsEnabled = false;
EdgeComboBox.IsEnabled = false;
}

if (int.Parse(regEditHandler.GetOSversion()).CompareTo(1900) > 0) is1903 = true;
if (!is1903)
{
Expand Down
5 changes: 5 additions & 0 deletions AutoThemeChanger/Pages/PageSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public PageSettings()
}
private void UiHandler()
{
if (!Properties.Settings.Default.Enabled)
{
conStandByCB.IsEnabled = false;
}

LangComBox.SelectedValue = Properties.Settings.Default.Language.ToString();

if (Properties.Settings.Default.AlterTime)
Expand Down
8 changes: 4 additions & 4 deletions AutoThemeChanger/Pages/PageTime.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" SharedSizeGroup="Group1"/>
<RowDefinition Height="Auto" SharedSizeGroup="Group2" MinHeight="20"/>
<RowDefinition Height="Auto" SharedSizeGroup="Group2" MinHeight="25"/>
<RowDefinition Height="Auto" SharedSizeGroup="Group3" MinHeight="20"/>
<RowDefinition Height="Auto" SharedSizeGroup="Group4" MinHeight="30"/>
<RowDefinition Height="Auto" SharedSizeGroup="Group2" MinHeight="50"/>
<RowDefinition Height="Auto" SharedSizeGroup="Group2" MinHeight="30"/>
<RowDefinition Height="Auto" SharedSizeGroup="Group3" MinHeight="25"/>
<RowDefinition Height="Auto" SharedSizeGroup="Group4" MinHeight="35"/>
<RowDefinition Height="Auto" SharedSizeGroup="Group5" MinHeight="0"/>
<RowDefinition Height="Auto" SharedSizeGroup="Group6" MinHeight="0"/>
<RowDefinition Height="Auto" SharedSizeGroup="Group7" MinHeight="0"/>
Expand Down
14 changes: 3 additions & 11 deletions AutoThemeChanger/Pages/PageTime.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ private void DoesTaskExists()
}
}


private void PopulateOffsetFields(int offsetDark, int offsetLight)
{
if (offsetLight < 0)
Expand Down Expand Up @@ -356,6 +355,7 @@ private void TextBox_TabNext_TextChanged(object sender, System.Windows.Controls.
ue.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
}
}

// set starttime based on user location
private void LocationCheckBox_Checked(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -432,18 +432,14 @@ private void LocationCheckBox_Unchecked(object sender, RoutedEventArgs e)
//automatic theme switch checkbox
private void AutoCheckBox_Checked(object sender, RoutedEventArgs e)
{
//if (is1903) SystemComboBox.IsEnabled = true;
//if (is1903 && !SystemComboBox.SelectedIndex.Equals(1)) AccentColorCheckBox.IsEnabled = true;
//AppComboBox.IsEnabled = true;
//EdgeComboBox.IsEnabled = true;
locationCheckBox.IsEnabled = true;
applyButton.IsEnabled = true;
darkStartBox.IsEnabled = true;
DarkStartMinutesBox.IsEnabled = true;
lightStartBox.IsEnabled = true;
LightStartMinutesBox.IsEnabled = true;
//BGWinButton.IsEnabled = true;
userFeedback.Text = Properties.Resources.msgClickApply;//Click on apply to save changes
Properties.Settings.Default.Enabled = true;
}
private void AutoCheckBox_Unchecked(object sender, RoutedEventArgs e)
{
Expand All @@ -457,19 +453,15 @@ private void AutoCheckBox_Unchecked(object sender, RoutedEventArgs e)
Properties.Settings.Default.WallpaperLight = "";
Properties.Settings.Default.WallpaperDark = "";

//AccentColorCheckBox.IsEnabled = false;
//SystemComboBox.IsEnabled = false;
//AppComboBox.IsEnabled = false;
//EdgeComboBox.IsEnabled = false;
locationCheckBox.IsEnabled = false;
locationCheckBox.IsChecked = false;
applyButton.IsEnabled = false;
darkStartBox.IsEnabled = false;
DarkStartMinutesBox.IsEnabled = false;
lightStartBox.IsEnabled = false;
LightStartMinutesBox.IsEnabled = false;
//BGWinButton.IsEnabled = false;
userFeedback.Text = Properties.Resources.welcomeText; //Activate the checkbox to enable automatic theme switching
Properties.Settings.Default.Enabled = false;
}
private void AlterTime(bool enable)
{
Expand Down
39 changes: 32 additions & 7 deletions AutoThemeChanger/Pages/PageWallpaper.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,39 @@
xmlns:fw="clr-namespace:SourceChord.FluentWPF;assembly=FluentWPF"
xmlns:p="clr-namespace:AutoThemeChanger.Properties"
mc:Ignorable="d"
Title="PageWallpaper" Height="100.165" Width="257.846" Foreground="{DynamicResource SystemBaseHighColorBrush}">
Title="PageWallpaper" Height="350.052" Width="383.729" Foreground="{DynamicResource SystemBaseHighColorBrush}">

<Grid Margin="0,0,-116,-50">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition MinHeight="0" Height="Auto"/>
<RowDefinition MinHeight="150" Height="Auto"/>
</Grid.RowDefinitions>

<ComboBox HorizontalAlignment="Left" Name="cbSelection" Margin="10,10,0,0" Grid.Row="0" VerticalAlignment="Top" Width="349" SelectionChanged="CbSelection_SelectionChanged">
<ComboBoxItem Content="Desktop Wallpaper (recommended)" Name="admwallpaper"/>
<ComboBoxItem Content="Windows Theme (more features)" Name="wintheme"/>
</ComboBox>

<Grid>
<!-- Desktop Background -->
<TextBlock Grid.Row="3" Grid.ColumnSpan="5" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="{x:Static p:Resources.dbMainHeader}" VerticalAlignment="Top" FontWeight="Bold" FontSize="16" Height="Auto" Width="Auto"/>
<TextBlock Grid.Row="3" Grid.ColumnSpan="5" HorizontalAlignment="Left" Margin="14,36,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontFamily="Segoe MDL2 Assets" Text="&#xEB9F;" Height="29" Width="32" FontSize="25"/>
<Button Grid.Row="3" Grid.ColumnSpan="5" x:Name="BGWinButton" Content="{x:Static p:Resources.dbTitle}" HorizontalAlignment="Left" Margin="51,36,0,0" VerticalAlignment="Top" MinWidth="180" Width="Auto" Click="BGWinButton_Click" Height="20"/>
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" Margin="55,59,0,0" TextWrapping="Wrap" Text="{x:Static p:Resources.dbCurrently}" VerticalAlignment="Top" FontWeight="Bold" Height="16" Width="Auto"/>
<TextBlock x:Name="DeskBGStatus" HorizontalAlignment="Left" Margin="179,59,0,0" TextWrapping="Wrap" Text="{x:Static p:Resources.disabled}" VerticalAlignment="Top" Height="16" Width="Auto"/>
<TextBlock Name="wallpaperHeading" HorizontalAlignment="Left" Margin="6,10,0,0" Grid.Row="1" TextWrapping="Wrap" Text="{x:Static p:Resources.dbMainHeader}" VerticalAlignment="Top" FontWeight="Bold" FontSize="16" Height="Auto" Width="Auto"/>
<TextBlock Name="wallpaperIcon" HorizontalAlignment="Left" Margin="10,36,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" FontFamily="Segoe MDL2 Assets" Text="&#xEB9F;" Height="29" Width="32" FontSize="25"/>
<Button x:Name="BGWinButton" Content="{x:Static p:Resources.dbTitle}" HorizontalAlignment="Left" Margin="47,36,0,0" Grid.Row="1" VerticalAlignment="Top" MinWidth="180" Width="Auto" Click="BGWinButton_Click" Height="20"/>
<TextBlock Name="wallpaperCurrent" Grid.Column="0" HorizontalAlignment="Left" Margin="51,59,0,0" Grid.Row="1" TextWrapping="Wrap" Text="{x:Static p:Resources.dbCurrently}" VerticalAlignment="Top" FontWeight="Bold" Height="16" Width="Auto"/>
<TextBlock x:Name="DeskBGStatus" HorizontalAlignment="Left" Margin="175,59,0,0" Grid.Row="1" TextWrapping="Wrap" Text="{x:Static p:Resources.disabled}" VerticalAlignment="Top" Height="16" Width="Auto"/>

<!-- Windows Theme-->
<Button Content="Select Light Theme" Name="buttonLightTheme" CommandParameter="LightTheme" HorizontalAlignment="Left" Margin="5,141,0,0" Grid.Row="2" VerticalAlignment="Top" Width="153" Click="buttonSelectTheme_Click"/>
<Button Content="Select Dark Theme" Name="buttonDarkTheme" CommandParameter="DarkTheme" HorizontalAlignment="Left" Margin="6,173,0,-10" Grid.Row="2" VerticalAlignment="Top" Width="153" Click="buttonSelectTheme_Click"/>
<Button Content="Save + Enable" Name="buttonSaveTheme" IsEnabled="False" HorizontalAlignment="Left" Margin="4,206,0,-40" Grid.Row="2" VerticalAlignment="Top" Width="98" Click="buttonSaveTheme_Click"/>
<TextBox HorizontalAlignment="Left" Height="20" Margin="163,141,0,0" Grid.Row="2" TextWrapping="NoWrap" Text="Please select a File with the button" IsReadOnly="True" Name="TextBoxLightTheme" VerticalAlignment="Top" Width="270" />
<TextBox HorizontalAlignment="Left" Height="20" Margin="163,173,0,-10" Grid.Row="2" TextWrapping="NoWrap" Text="Please select a File with the button" IsReadOnly="True" Name="TextBoxDarkTheme" VerticalAlignment="Top" Width="270" RenderTransformOrigin="0.5,0.5"/>
<Button Content="Disable" HorizontalAlignment="Left" Margin="107,206,0,-41" Grid.Row="2" VerticalAlignment="Top" Width="102" Name="ButtonDisableTheme" Click="ButtonDisableTheme_Click"/>
<TextBlock HorizontalAlignment="Left" Margin="7,29,0,0" Grid.Row="2" TextWrapping="Wrap" Name="TbOpenThemeCP" Foreground="Blue" Text="Step 1) Click here to open the Windows Theme Settings." VerticalAlignment="Top" MouseEnter="TextBlock_MouseEnter" MouseLeave="TextBlock_MouseLeave" MouseDown="TextBlock_MouseDown"/>
<TextBlock HorizontalAlignment="Left" Margin="7,47,0,0" Grid.Row="2" TextWrapping="Wrap" Name="TbTheme1" Text="Step 2) Select your favorite Wallpaper, Mouse Cursor and Accent Color." VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="7,66,0,0" Grid.Row="2" TextWrapping="Wrap" Name="TbTheme2" Text="Step 3) Go back to theme settings and save your theme." VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="6,87,0,0" Grid.Row="2" TextWrapping="Wrap" Name="TbTheme3" Text="Step 4) Repeat the process for the second theme and then pick your theme files:" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="7,115,0,0" Grid.Row="2" TextWrapping="Wrap" Name="TbTheme4" Text="Select created themes" FontSize="14" FontWeight="Bold" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="7,6,0,0" Grid.Row="2" TextWrapping="Wrap" Name="TbTheme5" Text="Set up a theme" FontWeight="Bold" FontSize="14" VerticalAlignment="Top"/>
</Grid>
</Page>
Loading

0 comments on commit b310860

Please sign in to comment.