mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
System Theme now works
This commit is contained in:
parent
7195ebe9cf
commit
b2aa3455a5
2 changed files with 122 additions and 98 deletions
|
@ -16,97 +16,95 @@
|
|||
<RowDefinition Height="1*"
|
||||
MinHeight="{StaticResource HamburgerHeight}"
|
||||
MaxHeight="52"/>
|
||||
<RowDefinition Height="4*"/>
|
||||
<RowDefinition Height="Auto" MaxHeight="32"/>
|
||||
<RowDefinition Height="4*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel x:Name="SettingsStack"
|
||||
Grid.Row="1"
|
||||
AutomationProperties.LabeledBy="{Binding ElementName=SettingsAppTheme}"
|
||||
Orientation="Vertical">
|
||||
<StackPanel Grid.Row="1">
|
||||
<StackPanel x:Name="SettingsStack"
|
||||
AutomationProperties.LabeledBy="{Binding ElementName=SettingsAppTheme}"
|
||||
Orientation="Vertical">
|
||||
|
||||
<TextBlock x:Name="SettingsAppTheme"
|
||||
x:Uid="SettingsAppTheme"
|
||||
Style="{StaticResource SubtitleTextBlockStyle}"
|
||||
AutomationProperties.HeadingLevel="Level1"
|
||||
TextTrimming="Clip"/>
|
||||
<TextBlock x:Name="SettingsAppTheme"
|
||||
x:Uid="SettingsAppTheme"
|
||||
Style="{StaticResource SubtitleTextBlockStyle}"
|
||||
AutomationProperties.HeadingLevel="Level1"
|
||||
TextTrimming="Clip"/>
|
||||
|
||||
<TextBlock x:Name="SettingsRestartApp" Style="{StaticResource BodyTextBlockStyle}"/>
|
||||
<TextBlock x:Name="SettingsRestartApp"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Foreground="{StaticResource SystemColorGrayTextColor}"/>
|
||||
|
||||
<RadioButton x:Name="SettingsDarkTheme"
|
||||
x:Uid="SettingsDarkTheme"
|
||||
Grid.Row="2"
|
||||
Checked="DarkChecked"/>
|
||||
<RadioButton x:Name="SettingsDarkTheme"
|
||||
x:Uid="SettingsDarkTheme"
|
||||
Grid.Row="2"
|
||||
Checked="DarkChecked"/>
|
||||
|
||||
<RadioButton x:Name="SettingsLightTheme"
|
||||
x:Uid="SettingsLightTheme"
|
||||
Grid.Row="3"
|
||||
Checked="LightChecked"/>
|
||||
<RadioButton x:Name="SettingsLightTheme"
|
||||
x:Uid="SettingsLightTheme"
|
||||
Grid.Row="3"
|
||||
Checked="LightChecked"/>
|
||||
|
||||
<RadioButton x:Name="SettingsSystemTheme"
|
||||
x:Uid="SettingsSystemTheme"
|
||||
Grid.Row="4"
|
||||
Checked="SystemChecked"/>
|
||||
<RadioButton x:Name="SettingsSystemTheme"
|
||||
x:Uid="SettingsSystemTheme"
|
||||
Grid.Row="4"
|
||||
Checked="SystemChecked"/>
|
||||
|
||||
<HyperlinkButton x:Name="ColorSettingsButton"
|
||||
Margin="0,-2"
|
||||
HorizontalAlignment="Left"
|
||||
Click="ColorSettingsButtonClicked">
|
||||
<TextBlock x:Uid="ColorSettingsButton" TextWrapping="Wrap"/>
|
||||
</HyperlinkButton>
|
||||
<HyperlinkButton x:Name="ColorSettingsButton"
|
||||
Margin="0,-2"
|
||||
HorizontalAlignment="Left"
|
||||
Click="ColorSettingsButtonClicked">
|
||||
<TextBlock x:Uid="ColorSettingsButton" TextWrapping="Wrap"/>
|
||||
</HyperlinkButton>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel x:Name="AboutStack"
|
||||
Margin="0,32,0,0"
|
||||
AutomationProperties.LabeledBy="{Binding ElementName=SettingsAboutLabel}"
|
||||
Orientation="Vertical">
|
||||
|
||||
<TextBlock x:Name="SettingsAboutLabel"
|
||||
x:Uid="SettingsAboutLabel"
|
||||
Style="{StaticResource SubtitleTextBlockStyle}"
|
||||
AutomationProperties.HeadingLevel="Level2"
|
||||
TextTrimming="Clip"/>
|
||||
|
||||
<TextBlock Margin="0,0,0,4"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
IsTextSelectionEnabled="True">
|
||||
<Run x:Name="SettingsVersion"/>
|
||||
<LineBreak/>
|
||||
<Run x:Name="SettingsCopyright"/>
|
||||
</TextBlock>
|
||||
|
||||
<HyperlinkButton Margin="0,-2"
|
||||
HorizontalAlignment="Left"
|
||||
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=529064"
|
||||
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=529064">
|
||||
<TextBlock x:Uid="SettingsEULA" TextWrapping="Wrap"/>
|
||||
</HyperlinkButton>
|
||||
|
||||
<HyperlinkButton Margin="0,-2"
|
||||
HorizontalAlignment="Left"
|
||||
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=822631"
|
||||
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=822631">
|
||||
<TextBlock x:Uid="SettingsServicesAgreement" TextWrapping="Wrap"/>
|
||||
</HyperlinkButton>
|
||||
|
||||
<HyperlinkButton Margin="0,-2"
|
||||
HorizontalAlignment="Left"
|
||||
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=521839"
|
||||
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=521839">
|
||||
<TextBlock x:Uid="SettingsPrivacyStatment" TextWrapping="Wrap"/>
|
||||
</HyperlinkButton>
|
||||
|
||||
<Button x:Name="SettingsFeedbackButton"
|
||||
x:Uid="SettingsFeedbackButton"
|
||||
Margin="0,24"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Style="{StaticResource ButtonRevealStyle}"
|
||||
Click="SettingsFeedbackButtonClick"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel x:Name="AboutStack"
|
||||
Grid.Row="3"
|
||||
AutomationProperties.LabeledBy="{Binding ElementName=SettingsAboutLabel}"
|
||||
Orientation="Vertical">
|
||||
|
||||
<TextBlock x:Name="SettingsAboutLabel"
|
||||
x:Uid="SettingsAboutLabel"
|
||||
Style="{StaticResource SubtitleTextBlockStyle}"
|
||||
AutomationProperties.HeadingLevel="Level2"
|
||||
TextTrimming="Clip"/>
|
||||
|
||||
<TextBlock Margin="0,0,0,4"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
IsTextSelectionEnabled="True">
|
||||
<Run x:Name="SettingsVersion"/>
|
||||
<LineBreak/>
|
||||
<Run x:Name="SettingsCopyright"/>
|
||||
</TextBlock>
|
||||
|
||||
<HyperlinkButton Margin="0,-2"
|
||||
HorizontalAlignment="Left"
|
||||
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=529064"
|
||||
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=529064">
|
||||
<TextBlock x:Uid="SettingsEULA" TextWrapping="Wrap"/>
|
||||
</HyperlinkButton>
|
||||
|
||||
<HyperlinkButton Margin="0,-2"
|
||||
HorizontalAlignment="Left"
|
||||
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=822631"
|
||||
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=822631">
|
||||
<TextBlock x:Uid="SettingsServicesAgreement" TextWrapping="Wrap"/>
|
||||
</HyperlinkButton>
|
||||
|
||||
<HyperlinkButton Margin="0,-2"
|
||||
HorizontalAlignment="Left"
|
||||
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=521839"
|
||||
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=521839">
|
||||
<TextBlock x:Uid="SettingsPrivacyStatment" TextWrapping="Wrap"/>
|
||||
</HyperlinkButton>
|
||||
|
||||
<Button x:Name="SettingsFeedbackButton"
|
||||
x:Uid="SettingsFeedbackButton"
|
||||
Margin="0,24"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Style="{StaticResource ButtonRevealStyle}"
|
||||
Click="SettingsFeedbackButtonClick"/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -19,12 +19,15 @@ using namespace Windows::UI::Xaml;
|
|||
using namespace Windows::UI::Xaml::Controls;
|
||||
using namespace Windows::UI::Xaml::Controls::Primitives;
|
||||
using namespace Windows::UI::Xaml::Data;
|
||||
using namespace winrt::Windows::Storage;
|
||||
|
||||
#ifndef BUILD_YEAR
|
||||
#define BUILD_YEAR 2020
|
||||
#endif
|
||||
|
||||
auto resourceLoader = AppResourceProvider::GetInstance();
|
||||
auto themevalue = Windows::Storage::ApplicationData::Current -> LocalSettings -> Values -> Lookup(L"themeSetting");
|
||||
String ^ colorSetting = safe_cast<String ^>(themevalue);
|
||||
|
||||
SettingsPage::SettingsPage()
|
||||
{
|
||||
|
@ -32,17 +35,14 @@ SettingsPage::SettingsPage()
|
|||
|
||||
InitializeComponent();
|
||||
|
||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
|
||||
|
||||
Language = locService->GetLanguage();
|
||||
|
||||
this->SetVersionString();
|
||||
this->SetCopyrightString();
|
||||
|
||||
auto value = Windows::Storage::ApplicationData::Current->LocalSettings->Values->Lookup(L"themeSetting");
|
||||
if (value != nullptr)
|
||||
|
||||
if (themevalue != nullptr)
|
||||
{
|
||||
String ^ colorSetting = safe_cast<String ^>(value);
|
||||
if (colorSetting == L"Dark")
|
||||
{
|
||||
SettingsDarkTheme->IsChecked = true;
|
||||
|
@ -56,6 +56,10 @@ SettingsPage::SettingsPage()
|
|||
SettingsSystemTheme->IsChecked = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsSystemTheme->IsChecked = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsPage::SetVersionString()
|
||||
|
@ -87,23 +91,45 @@ void SettingsPage::SettingsFeedbackButtonClick(_In_ Object ^ sender, _In_ Routed
|
|||
Launcher::LaunchUriAsync(ref new Uri("windows-feedback:?contextid=130&metadata=%7B%22Metadata%22:[%7B%22AppBuild%22:%22" + versionNumber + "%22%7D]%7D"));
|
||||
}
|
||||
|
||||
void SettingsPage::LightChecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Visible;
|
||||
SettingsRestartApp->Text = LocalizationStringUtil::GetLocalizedString(resourceLoader->GetResourceString("SettingsRestartNotice"));
|
||||
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"themeSetting", ApplicationTheme::Light.ToString());
|
||||
}
|
||||
|
||||
void SettingsPage::DarkChecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Visible;
|
||||
SettingsRestartApp->Text = LocalizationStringUtil::GetLocalizedString(resourceLoader->GetResourceString("SettingsRestartNotice"));
|
||||
if (colorSetting == "Dark")
|
||||
{
|
||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Visible;
|
||||
SettingsRestartApp->Text = resourceLoader->GetResourceString("SettingsRestartNotice");
|
||||
}
|
||||
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"themeSetting", ApplicationTheme::Dark.ToString());
|
||||
}
|
||||
|
||||
|
||||
void SettingsPage::LightChecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
if (colorSetting == "Light")
|
||||
{
|
||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Visible;
|
||||
SettingsRestartApp->Text = resourceLoader->GetResourceString("SettingsRestartNotice");
|
||||
}
|
||||
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"themeSetting", ApplicationTheme::Light.ToString());
|
||||
}
|
||||
|
||||
void SettingsPage::SystemChecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Visible;
|
||||
SettingsRestartApp->Text = LocalizationStringUtil::GetLocalizedString(resourceLoader->GetResourceString("SettingsRestartNotice"));
|
||||
if (colorSetting == "System")
|
||||
{
|
||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Visible;
|
||||
SettingsRestartApp->Text = resourceLoader->GetResourceString("SettingsRestartNotice");
|
||||
}
|
||||
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"themeSetting", L"System");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue