Add GitHub contribution string

This commit is contained in:
Eric Tian 2021-02-07 17:41:02 -08:00
commit 75a08a01fd
4 changed files with 96 additions and 43 deletions

View file

@ -4734,4 +4734,8 @@
<value>Settings</value> <value>Settings</value>
<comment>Text for the "Settings" header</comment> <comment>Text for the "Settings" header</comment>
</data> </data>
</root> <data name="SettingsContribute" xml:space="preserve">
<value>To learn how you can contribute to Windows Calculator, visit the project on %HL%GitHub%HL%.</value>
<comment>{Locked="%HL%GitHub%HL%"}</comment>
</data>
</root>

View file

@ -6,7 +6,7 @@
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"
Background="{ThemeResource AppChromeAcrylicHostBackdropMediumLowBrush}" Background="{ThemeResource AppChromeAcrylicHostBackdropMediumLowBrush}"
d:Height="455" d:Height="465"
d:Width="445" d:Width="445"
mc:Ignorable="d"> mc:Ignorable="d">
@ -18,23 +18,24 @@
</Style> </Style>
</Page.Resources> </Page.Resources>
<Grid x:Name="PageGrid" AutomationProperties.LandmarkType="Main"> <ScrollViewer>
<Grid.RowDefinitions> <Grid x:Name="PageGrid" AutomationProperties.LandmarkType="Main">
<RowDefinition Height="1*" <Grid.RowDefinitions>
<RowDefinition Height="1*"
MinHeight="{StaticResource HamburgerHeight}" MinHeight="{StaticResource HamburgerHeight}"
MaxHeight="52"/> MaxHeight="52"/>
<RowDefinition Height="1*"/> <RowDefinition Height="1*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Height="{StaticResource HamburgerHeight}" <Grid Height="{StaticResource HamburgerHeight}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top"> VerticalAlignment="Top">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource HamburgerHeightGridLength}"/> <ColumnDefinition Width="{StaticResource HamburgerHeightGridLength}"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button x:Name="BackButton" <Button x:Name="BackButton"
x:Uid="BackButton" x:Uid="BackButton"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
@ -45,101 +46,119 @@
Click="BackButtonClick" Click="BackButtonClick"
Content="&#xE72B;"/> Content="&#xE72B;"/>
<TextBlock x:Uid="SettingsHeader" <TextBlock x:Uid="SettingsHeader"
Grid.Column="1" Grid.Column="1"
Margin="8,-3,0,0" Margin="8,-3,0,0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource CategoryNameTextBlockStyle}"/> Style="{StaticResource CategoryNameTextBlockStyle}"/>
</Grid> </Grid>
<StackPanel Grid.Row="1" Margin="12,0,12,0"> <StackPanel Grid.Row="1" Margin="12,0,12,0">
<StackPanel x:Name="SettingsStack" <StackPanel x:Name="SettingsStack"
AutomationProperties.LabeledBy="{Binding ElementName=SettingsAppTheme}" AutomationProperties.LabeledBy="{Binding ElementName=SettingsAppTheme}"
Orientation="Vertical"> Orientation="Vertical">
<TextBlock x:Name="SettingsAppTheme" <TextBlock x:Name="SettingsAppTheme"
x:Uid="SettingsAppTheme" x:Uid="SettingsAppTheme"
Style="{StaticResource SubtitleTextBlockStyle}" Style="{StaticResource SubtitleTextBlockStyle}"
AutomationProperties.HeadingLevel="Level1" AutomationProperties.HeadingLevel="Level1"
TextTrimming="Clip"/> TextTrimming="Clip"/>
<RadioButton x:Name="SettingsLightTheme" <RadioButton x:Name="SettingsLightTheme"
x:Uid="SettingsLightTheme" x:Uid="SettingsLightTheme"
Grid.Row="3" Grid.Row="3"
Checked="LightChecked"/> Checked="LightChecked"/>
<RadioButton x:Name="SettingsDarkTheme" <RadioButton x:Name="SettingsDarkTheme"
x:Uid="SettingsDarkTheme" x:Uid="SettingsDarkTheme"
Grid.Row="2" Grid.Row="2"
Checked="DarkChecked"/> Checked="DarkChecked"/>
<RadioButton x:Name="SettingsSystemTheme" <RadioButton x:Name="SettingsSystemTheme"
x:Uid="SettingsSystemTheme" x:Uid="SettingsSystemTheme"
Grid.Row="4" Grid.Row="4"
Checked="SystemChecked"/> Checked="SystemChecked"/>
<TextBlock x:Name="SettingsRestartApp" <TextBlock x:Name="SettingsRestartApp"
Style="{StaticResource CaptionTextBlockStyle}" Style="{StaticResource CaptionTextBlockStyle}"
Foreground="{StaticResource SystemColorGrayTextColor}"/> Foreground="{StaticResource SystemColorGrayTextColor}"/>
<HyperlinkButton x:Name="ColorSettingsButton" <HyperlinkButton x:Name="ColorSettingsButton"
Margin="0,-2" Margin="0,-2"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Click="ColorSettingsButtonClicked"> Click="ColorSettingsButtonClicked">
<TextBlock x:Uid="ColorSettingsButton" TextWrapping="Wrap"/> <TextBlock x:Uid="ColorSettingsButton" TextWrapping="Wrap"/>
</HyperlinkButton> </HyperlinkButton>
</StackPanel> </StackPanel>
<StackPanel x:Name="AboutStack" <StackPanel x:Name="AboutStack"
Margin="0,32,0,0" Margin="0,32,0,0"
AutomationProperties.LabeledBy="{Binding ElementName=SettingsAboutLabel}" AutomationProperties.LabeledBy="{Binding ElementName=SettingsAboutLabel}"
Orientation="Vertical"> Orientation="Vertical">
<TextBlock x:Name="SettingsAboutLabel" <TextBlock x:Name="SettingsAboutLabel"
x:Uid="SettingsAboutLabel" x:Uid="SettingsAboutLabel"
Style="{StaticResource SubtitleTextBlockStyle}" Style="{StaticResource SubtitleTextBlockStyle}"
AutomationProperties.HeadingLevel="Level2" AutomationProperties.HeadingLevel="Level2"
TextTrimming="Clip"/> TextTrimming="Clip"/>
<TextBlock Margin="0,0,0,4" <TextBlock Margin="0,0,0,4"
Style="{StaticResource BodyTextBlockStyle}" Style="{StaticResource BodyTextBlockStyle}"
IsTextSelectionEnabled="True"> IsTextSelectionEnabled="True">
<Run x:Name="SettingsVersion"/> <Run x:Name="SettingsVersion"/>
<LineBreak/> <LineBreak/>
<Run x:Name="SettingsCopyright"/> <Run x:Name="SettingsCopyright"/>
</TextBlock> </TextBlock>
<HyperlinkButton Margin="0,-2" <HyperlinkButton Margin="0,-2"
HorizontalAlignment="Left" HorizontalAlignment="Left"
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=529064" NavigateUri="https://go.microsoft.com/fwlink/?LinkID=529064"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=529064"> ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=529064">
<TextBlock x:Uid="SettingsEULA" TextWrapping="Wrap"/> <TextBlock x:Uid="SettingsEULA" TextWrapping="Wrap"/>
</HyperlinkButton> </HyperlinkButton>
<HyperlinkButton Margin="0,-2" <HyperlinkButton Margin="0,-2"
HorizontalAlignment="Left" HorizontalAlignment="Left"
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=822631" NavigateUri="https://go.microsoft.com/fwlink/?LinkID=822631"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=822631"> ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=822631">
<TextBlock x:Uid="SettingsServicesAgreement" TextWrapping="Wrap"/> <TextBlock x:Uid="SettingsServicesAgreement" TextWrapping="Wrap"/>
</HyperlinkButton> </HyperlinkButton>
<HyperlinkButton Margin="0,-2" <HyperlinkButton Margin="0,-2"
HorizontalAlignment="Left" HorizontalAlignment="Left"
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=521839" NavigateUri="https://go.microsoft.com/fwlink/?LinkID=521839"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=521839"> ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=521839">
<TextBlock x:Uid="SettingsPrivacyStatment" TextWrapping="Wrap"/> <TextBlock x:Uid="SettingsPrivacyStatment" TextWrapping="Wrap"/>
</HyperlinkButton> </HyperlinkButton>
<Button x:Name="SettingsFeedbackButton" <Button x:Name="SettingsFeedbackButton"
x:Uid="SettingsFeedbackButton" x:Uid="SettingsFeedbackButton"
Margin="0,24" Margin="0,12,0,0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
Style="{StaticResource ButtonRevealStyle}" Style="{StaticResource ButtonRevealStyle}"
Click="SettingsFeedbackButtonClick"/> Click="SettingsFeedbackButtonClick"/>
<RichTextBlock x:Name="SettingsContribute"
Margin="0,12,12,6"
HorizontalAlignment="Left"
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
Style="{ThemeResource BodyRichTextBlockStyle}"
TextWrapping="Wrap">
<Paragraph>
<Run x:Name="ContributeRunBeforeLink"/>
<Hyperlink NavigateUri="https://go.microsoft.com/fwlink/?linkid=2099939"
TextDecorations="None"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?linkid=2099939">
<Run x:Name="ContributeRunLink"/>
</Hyperlink>
<Run x:Name="ContributeRunAfterLink"/>
</Paragraph>
</RichTextBlock>
</StackPanel>
</StackPanel> </StackPanel>
</StackPanel> </Grid>
</Grid> </ScrollViewer>
</Page> </Page>

View file

@ -60,6 +60,8 @@ SettingsPage::SettingsPage()
{ {
SettingsSystemTheme->IsChecked = true; SettingsSystemTheme->IsChecked = true;
} }
InitializeContributeTextBlock();
} }
void SettingsPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e) void SettingsPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e)
@ -71,6 +73,33 @@ void SettingsPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventA
} }
} }
void SettingsPage::InitializeContributeTextBlock()
{
std::wstring contributeHyperlinkText = resourceLoader->GetResourceString(L"SettingsContribute")->Data();
// The resource string has '%HL%' wrapped around 'GitHub'
// Break the string and assign pieces appropriately.
static const std::wstring delimiter{ L"%HL%" };
static const size_t delimiterLength{ delimiter.length() };
// Find the delimiters.
size_t firstSplitPosition = contributeHyperlinkText .find(delimiter, 0);
assert(firstSplitPosition != std::wstring::npos);
size_t secondSplitPosition = contributeHyperlinkText .find(delimiter, firstSplitPosition + 1);
assert(secondSplitPosition != std::wstring::npos);
size_t hyperlinkTextLength = secondSplitPosition - (firstSplitPosition + delimiterLength);
// Assign pieces.
auto contributeTextBeforeHyperlink = ref new String(contributeHyperlinkText.substr(0, firstSplitPosition).c_str());
auto contributeTextLink = ref new String(contributeHyperlinkText.substr(firstSplitPosition + delimiterLength, hyperlinkTextLength).c_str());
auto contributeTextAfterHyperlink = ref new String(contributeHyperlinkText.substr(secondSplitPosition + delimiterLength).c_str());
ContributeRunBeforeLink->Text = contributeTextBeforeHyperlink;
ContributeRunLink->Text = contributeTextLink;
ContributeRunAfterLink->Text = contributeTextAfterHyperlink;
}
void SettingsPage::BackButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) void SettingsPage::BackButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
{ {
MainPageProperty->CollapseSettings(); MainPageProperty->CollapseSettings();

View file

@ -19,6 +19,7 @@ namespace CalculatorApp
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e) override; virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e) override;
private: private:
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);