mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
Clean up
This commit is contained in:
parent
75a08a01fd
commit
957859e393
5 changed files with 146 additions and 134 deletions
|
@ -70,21 +70,26 @@ App::App()
|
||||||
this->HighContrastAdjustment = ApplicationHighContrastAdjustment::None;
|
this->HighContrastAdjustment = ApplicationHighContrastAdjustment::None;
|
||||||
|
|
||||||
this->Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
|
this->Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
|
||||||
|
|
||||||
|
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"restartApp", nullptr);
|
||||||
|
|
||||||
auto value = Windows::Storage::ApplicationData::Current->LocalSettings->Values->Lookup(L"themeSetting");
|
auto value = Windows::Storage::ApplicationData::Current->LocalSettings->Values->Lookup(L"themeSetting");
|
||||||
auto DefaultTheme = ref new Windows::UI::ViewManagement::UISettings();
|
auto DefaultTheme = ref new Windows::UI::ViewManagement::UISettings();
|
||||||
auto uiTheme = DefaultTheme->GetColorValue(Windows::UI::ViewManagement::UIColorType::Background).ToString();
|
auto uiTheme = DefaultTheme->GetColorValue(Windows::UI::ViewManagement::UIColorType::Background).ToString();
|
||||||
|
|
||||||
if (value != nullptr)
|
if (value != nullptr)
|
||||||
{
|
{
|
||||||
String ^ colorSetting = safe_cast<String ^>(value);
|
String ^ colorSetting = safe_cast<String ^>(value);
|
||||||
|
|
||||||
// Apply theme choice.
|
// Apply theme choice.
|
||||||
if (colorSetting == L"Dark")
|
if (colorSetting == L"Light")
|
||||||
{
|
|
||||||
App::Current->RequestedTheme = ApplicationTheme::Dark;
|
|
||||||
}
|
|
||||||
else if (colorSetting == L"Light")
|
|
||||||
{
|
{
|
||||||
App::Current->RequestedTheme = ApplicationTheme::Light;
|
App::Current->RequestedTheme = ApplicationTheme::Light;
|
||||||
}
|
}
|
||||||
|
else if (colorSetting == L"Dark")
|
||||||
|
{
|
||||||
|
App::Current->RequestedTheme = ApplicationTheme::Dark;
|
||||||
|
}
|
||||||
else if (colorSetting == L"System")
|
else if (colorSetting == L"System")
|
||||||
{
|
{
|
||||||
if (uiTheme == "#FF000000")
|
if (uiTheme == "#FF000000")
|
||||||
|
@ -98,6 +103,7 @@ App::App()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
this->DebugSettings->IsBindingTracingEnabled = true;
|
this->DebugSettings->IsBindingTracingEnabled = true;
|
||||||
this->DebugSettings->BindingFailed += ref new BindingFailedEventHandler([](_In_ Object ^ /*sender*/, _In_ BindingFailedEventArgs ^ e) {
|
this->DebugSettings->BindingFailed += ref new BindingFailedEventHandler([](_In_ Object ^ /*sender*/, _In_ BindingFailedEventArgs ^ e) {
|
||||||
|
|
|
@ -4736,6 +4736,6 @@
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsContribute" xml:space="preserve">
|
<data name="SettingsContribute" xml:space="preserve">
|
||||||
<value>To learn how you can contribute to Windows Calculator, visit the project on%HL%GitHub%HL%.</value>
|
<value>To learn how you can contribute to Windows Calculator, visit the project on%HL%GitHub%HL%.</value>
|
||||||
<comment>{Locked="%HL%GitHub%HL%"}</comment>
|
<comment>{Locked="%HL%GitHub%HL%"}. GitHub link, displayed on the settings page.</comment>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -1,7 +1,6 @@
|
||||||
<Page x:Class="CalculatorApp.SettingsPage"
|
<Page x:Class="CalculatorApp.SettingsPage"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:Windows10version1809="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 7)"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="using:CalculatorApp"
|
xmlns:local="using:CalculatorApp"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
@ -37,14 +36,8 @@
|
||||||
|
|
||||||
<Button x:Name="BackButton"
|
<Button x:Name="BackButton"
|
||||||
x:Uid="BackButton"
|
x:Uid="BackButton"
|
||||||
HorizontalAlignment="Stretch"
|
Style="{StaticResource NavigationBackButtonNormalStyle}"
|
||||||
VerticalAlignment="Stretch"
|
Click="BackButtonClick"/>
|
||||||
Background="{ThemeResource AppChromeAcrylicHostBackdropMediumLowBrush}"
|
|
||||||
FontFamily="Segoe MDL2 Assets"
|
|
||||||
FontSize="15"
|
|
||||||
Windows10version1809:CornerRadius="0"
|
|
||||||
Click="BackButtonClick"
|
|
||||||
Content=""/>
|
|
||||||
|
|
||||||
<TextBlock x:Uid="SettingsHeader"
|
<TextBlock x:Uid="SettingsHeader"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
|
@ -67,23 +60,23 @@
|
||||||
|
|
||||||
<RadioButton x:Name="SettingsLightTheme"
|
<RadioButton x:Name="SettingsLightTheme"
|
||||||
x:Uid="SettingsLightTheme"
|
x:Uid="SettingsLightTheme"
|
||||||
Grid.Row="3"
|
Checked="ThemeChecked"
|
||||||
Checked="LightChecked"/>
|
Tag="Light"/>
|
||||||
|
|
||||||
<RadioButton x:Name="SettingsDarkTheme"
|
<RadioButton x:Name="SettingsDarkTheme"
|
||||||
x:Uid="SettingsDarkTheme"
|
x:Uid="SettingsDarkTheme"
|
||||||
Grid.Row="2"
|
Checked="ThemeChecked"
|
||||||
Checked="DarkChecked"/>
|
Tag="Dark"/>
|
||||||
|
|
||||||
<RadioButton x:Name="SettingsSystemTheme"
|
<RadioButton x:Name="SettingsSystemTheme"
|
||||||
x:Uid="SettingsSystemTheme"
|
x:Uid="SettingsSystemTheme"
|
||||||
Grid.Row="4"
|
Checked="ThemeChecked"
|
||||||
Checked="SystemChecked"/>
|
Tag="System"/>
|
||||||
|
|
||||||
|
|
||||||
<TextBlock x:Name="SettingsRestartApp"
|
<TextBlock x:Name="SettingsRestartApp"
|
||||||
Style="{StaticResource CaptionTextBlockStyle}"
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
Foreground="{StaticResource SystemColorGrayTextColor}"/>
|
Foreground="{StaticResource SystemBaseMediumColor}"/>
|
||||||
|
|
||||||
<HyperlinkButton x:Name="ColorSettingsButton"
|
<HyperlinkButton x:Name="ColorSettingsButton"
|
||||||
Margin="0,-2"
|
Margin="0,-2"
|
||||||
|
@ -141,13 +134,12 @@
|
||||||
Style="{StaticResource ButtonRevealStyle}"
|
Style="{StaticResource ButtonRevealStyle}"
|
||||||
Click="SettingsFeedbackButtonClick"/>
|
Click="SettingsFeedbackButtonClick"/>
|
||||||
|
|
||||||
<RichTextBlock x:Name="SettingsContribute"
|
<TextBlock x:Name="SettingsContribute"
|
||||||
Margin="0,12,12,6"
|
Margin="0,12,12,6"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
|
Style="{ThemeResource BodyTextBlockStyle}"
|
||||||
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
|
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
|
||||||
Style="{ThemeResource BodyRichTextBlockStyle}"
|
|
||||||
TextWrapping="Wrap">
|
TextWrapping="Wrap">
|
||||||
<Paragraph>
|
|
||||||
<Run x:Name="ContributeRunBeforeLink"/>
|
<Run x:Name="ContributeRunBeforeLink"/>
|
||||||
<Hyperlink NavigateUri="https://go.microsoft.com/fwlink/?linkid=2099939"
|
<Hyperlink NavigateUri="https://go.microsoft.com/fwlink/?linkid=2099939"
|
||||||
TextDecorations="None"
|
TextDecorations="None"
|
||||||
|
@ -155,8 +147,7 @@
|
||||||
<Run x:Name="ContributeRunLink"/>
|
<Run x:Name="ContributeRunLink"/>
|
||||||
</Hyperlink>
|
</Hyperlink>
|
||||||
<Run x:Name="ContributeRunAfterLink"/>
|
<Run x:Name="ContributeRunAfterLink"/>
|
||||||
</Paragraph>
|
</TextBlock>
|
||||||
</RichTextBlock>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
@ -25,48 +25,65 @@ using namespace winrt::Windows::Storage;
|
||||||
#define BUILD_YEAR 2021
|
#define BUILD_YEAR 2021
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto resourceLoader = AppResourceProvider::GetInstance();
|
|
||||||
auto themevalue = Windows::Storage::ApplicationData::Current -> LocalSettings -> Values -> Lookup(L"themeSetting");
|
|
||||||
String ^ colorSetting = safe_cast<String ^>(themevalue);
|
|
||||||
|
|
||||||
SettingsPage::SettingsPage()
|
SettingsPage::SettingsPage()
|
||||||
{
|
{
|
||||||
auto locService = LocalizationService::GetInstance();
|
auto resourceLoader = AppResourceProvider::GetInstance();
|
||||||
|
auto themevalue = Windows::Storage::ApplicationData::Current->LocalSettings->Values->Lookup(L"themeSetting");
|
||||||
|
auto restartValue = Windows::Storage::ApplicationData::Current->LocalSettings->Values->Lookup(L"restartApp");
|
||||||
|
String ^ colorSetting = safe_cast<String ^>(themevalue);
|
||||||
|
String ^ restartApp = safe_cast<String ^>(restartValue);
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Language = locService->GetLanguage();
|
|
||||||
|
|
||||||
this->SetVersionString();
|
this->SetVersionString();
|
||||||
this->SetCopyrightString();
|
this->SetCopyrightString();
|
||||||
|
this->InitializeContributeTextBlock();
|
||||||
|
SettingsLightTheme->Focus(::FocusState::Keyboard);
|
||||||
|
|
||||||
if (themevalue != nullptr)
|
if (themevalue != nullptr)
|
||||||
{
|
{
|
||||||
if (colorSetting == L"Dark")
|
if (colorSetting == L"Light")
|
||||||
{
|
|
||||||
SettingsDarkTheme->IsChecked = true;
|
|
||||||
}
|
|
||||||
else if (colorSetting == L"Light")
|
|
||||||
{
|
{
|
||||||
SettingsLightTheme->IsChecked = true;
|
SettingsLightTheme->IsChecked = true;
|
||||||
|
m_currentTheme = "Light";
|
||||||
|
}
|
||||||
|
else if (colorSetting == L"Dark")
|
||||||
|
{
|
||||||
|
SettingsDarkTheme->IsChecked = true;
|
||||||
|
m_currentTheme = "Dark";
|
||||||
}
|
}
|
||||||
else if (colorSetting == L"System")
|
else if (colorSetting == L"System")
|
||||||
{
|
{
|
||||||
SettingsSystemTheme->IsChecked = true;
|
SettingsSystemTheme->IsChecked = true;
|
||||||
|
m_currentTheme = "System";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SettingsSystemTheme->IsChecked = true;
|
SettingsSystemTheme->IsChecked = true;
|
||||||
|
m_currentTheme = "System";
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeContributeTextBlock();
|
if (restartValue != nullptr)
|
||||||
|
{
|
||||||
|
if (restartApp == L"True")
|
||||||
|
{
|
||||||
|
SettingsRestartApp->Visibility = ::Visibility::Visible;
|
||||||
|
}
|
||||||
|
else if (restartApp == L"False")
|
||||||
|
{
|
||||||
|
SettingsRestartApp->Visibility = ::Visibility::Collapsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SettingsRestartApp->Visibility = ::Visibility::Collapsed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e)
|
void SettingsPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e)
|
||||||
{
|
{
|
||||||
MainPage ^ mainPage = (MainPage ^) e->Parameter;
|
MainPage ^ mainPage = dynamic_cast<MainPage ^> (e->Parameter);
|
||||||
if (mainPage != nullptr)
|
if (mainPage != nullptr)
|
||||||
{
|
{
|
||||||
MainPageProperty = mainPage;
|
MainPageProperty = mainPage;
|
||||||
|
@ -75,6 +92,7 @@ void SettingsPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventA
|
||||||
|
|
||||||
void SettingsPage::InitializeContributeTextBlock()
|
void SettingsPage::InitializeContributeTextBlock()
|
||||||
{
|
{
|
||||||
|
auto resourceLoader = AppResourceProvider::GetInstance();
|
||||||
std::wstring contributeHyperlinkText = resourceLoader->GetResourceString(L"SettingsContribute")->Data();
|
std::wstring contributeHyperlinkText = resourceLoader->GetResourceString(L"SettingsContribute")->Data();
|
||||||
|
|
||||||
// The resource string has '%HL%' wrapped around 'GitHub'
|
// The resource string has '%HL%' wrapped around 'GitHub'
|
||||||
|
@ -102,6 +120,14 @@ void SettingsPage::InitializeContributeTextBlock()
|
||||||
|
|
||||||
void SettingsPage::BackButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
void SettingsPage::BackButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
|
if (SettingsRestartApp->Visibility == ::Visibility::Visible)
|
||||||
|
{
|
||||||
|
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"restartApp", L"True");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"restartApp", L"False");
|
||||||
|
}
|
||||||
MainPageProperty->CollapseSettings();
|
MainPageProperty->CollapseSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +141,8 @@ void SettingsPage::SetVersionString()
|
||||||
|
|
||||||
void SettingsPage::SetCopyrightString()
|
void SettingsPage::SetCopyrightString()
|
||||||
{
|
{
|
||||||
|
auto resourceLoader = AppResourceProvider::GetInstance();
|
||||||
|
|
||||||
auto copyrightText = LocalizationStringUtil::GetLocalizedString(resourceLoader->GetResourceString("SettingsCopyright"), StringReference(to_wstring(BUILD_YEAR).c_str()));
|
auto copyrightText = LocalizationStringUtil::GetLocalizedString(resourceLoader->GetResourceString("SettingsCopyright"), StringReference(to_wstring(BUILD_YEAR).c_str()));
|
||||||
|
|
||||||
SettingsCopyright->Text = copyrightText;
|
SettingsCopyright->Text = copyrightText;
|
||||||
|
@ -134,44 +162,32 @@ 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"));
|
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)
|
void SettingsPage::ThemeChecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
if (colorSetting == "Light")
|
auto resourceLoader = AppResourceProvider::GetInstance();
|
||||||
|
RadioButton ^ radioButton = safe_cast<RadioButton ^>(sender);
|
||||||
|
String ^ tag = radioButton->Tag->ToString();
|
||||||
|
|
||||||
|
if (m_currentTheme == tag)
|
||||||
{
|
{
|
||||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
|
SettingsRestartApp->Visibility = ::Visibility::Collapsed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SettingsRestartApp->Visibility = Windows::UI::Xaml::Visibility::Visible;
|
SettingsRestartApp->Visibility = ::Visibility::Visible;
|
||||||
SettingsRestartApp->Text = resourceLoader->GetResourceString("SettingsRestartNotice");
|
SettingsRestartApp->Text = resourceLoader->GetResourceString("SettingsRestartNotice");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag == "Light")
|
||||||
|
{
|
||||||
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"themeSetting", ApplicationTheme::Light.ToString());
|
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"themeSetting", ApplicationTheme::Light.ToString());
|
||||||
}
|
}
|
||||||
|
else if (tag == "Dark")
|
||||||
void SettingsPage::DarkChecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
|
||||||
{
|
{
|
||||||
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());
|
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"themeSetting", ApplicationTheme::Dark.ToString());
|
||||||
}
|
}
|
||||||
|
else if (tag == "System")
|
||||||
void SettingsPage::SystemChecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
|
||||||
{
|
{
|
||||||
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");
|
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"themeSetting", L"System");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -19,14 +19,13 @@ namespace CalculatorApp
|
||||||
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e) override;
|
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Platform::String ^ m_currentTheme;
|
||||||
void InitializeContributeTextBlock();
|
void InitializeContributeTextBlock();
|
||||||
void BackButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void BackButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void ColorSettingsButtonClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void ColorSettingsButtonClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void SettingsFeedbackButtonClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void SettingsFeedbackButtonClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void SetVersionString();
|
void SetVersionString();
|
||||||
void SetCopyrightString();
|
void SetCopyrightString();
|
||||||
void LightChecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void ThemeChecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void DarkChecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
|
||||||
void SystemChecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue