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>
<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> </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,6 +18,7 @@
</Style> </Style>
</Page.Resources> </Page.Resources>
<ScrollViewer>
<Grid x:Name="PageGrid" AutomationProperties.LandmarkType="Main"> <Grid x:Name="PageGrid" AutomationProperties.LandmarkType="Main">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="1*" <RowDefinition Height="1*"
@ -134,12 +135,30 @@
<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);