Skip to content

Fixed animation sample links and icons #3827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Microsoft.Toolkit.Uwp.SampleApp/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
RequiresPointerMode="Auto">

<Application.Resources>
<ResourceDictionary>
<!-- Color Resources -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Styles/Themes.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/Generic.xaml" />
<Application.Resources>
<ResourceDictionary>
<!-- Color Resources -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Styles/Themes.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/Generic.xaml" />

<!-- WinUI -->
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
</ResourceDictionary.MergedDictionaries>
<!-- WinUI -->
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</ResourceDictionary.MergedDictionaries>

<!-- Converters -->
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
<!-- Converters -->
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />

<converters:EmptyStringToObjectConverter x:Key="EmptyStringToObject"
EmptyValue="Collapsed"
NotEmptyValue="Visible" />
<converters:EmptyStringToObjectConverter x:Key="EmptyStringToObject"
EmptyValue="Collapsed"
NotEmptyValue="Visible" />

<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
</ResourceDictionary>
</Application.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
</ResourceDictionary>
</Application.Resources>
</Application>
36 changes: 17 additions & 19 deletions Microsoft.Toolkit.Uwp.SampleApp/Controls/CodeRenderer.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.SampleApp.Controls"
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.Controls">
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.SampleApp.Controls"
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.Controls">

<Style TargetType="controls:CodeRenderer">
<Setter Property="Template">
Expand All @@ -14,25 +13,24 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid x:Name="Container"
Grid.RowSpan="2"
Opacity="0" />
<ScrollViewer
Grid.Row="0"
HorizontalScrollMode="Auto"
HorizontalScrollBarVisibility="Auto">
Grid.RowSpan="2"
Opacity="0" />
<ScrollViewer Grid.Row="0"
HorizontalScrollBarVisibility="Auto"
HorizontalScrollMode="Auto">
<RichTextBlock Name="codeView"
FontFamily="Consolas"
Padding="10" />
Padding="10"
FontFamily="Consolas" />
</ScrollViewer>
<StackPanel Grid.Row="1"
HorizontalAlignment="Center"
Orientation="Horizontal">
HorizontalAlignment="Center"
Orientation="Horizontal">
<Button x:Name="CopyButton"
Margin="5"
Content="Copy" />
Margin="5"
Content="Copy" />
<Button x:Name="PrintButton"
Margin="5"
Content="Print" />
Margin="5"
Content="Print" />
</StackPanel>
</Grid>
</ControlTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@
<Content Include="Icons\More.png" />
<Content Include="Icons\Notifications.png" />
<Content Include="Icons\Services.png" />
<Content Include="SamplePages\Animations\Effects\EffectAnimations.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="SamplePages\Graph\LoginButton.png" />
<Content Include="SamplePages\Graph\PeoplePicker.png" />
<Content Include="SamplePages\Graph\PersonView.png" />
<Content Include="SamplePages\Primitives\SwitchPresenter.png" />
<Content Include="SamplePages\TabbedCommandBar\TabbedCommandBar.png" />
<Content Include="SamplePages\Animations\Effects\FadeBehavior.png" />
Expand Down Expand Up @@ -490,12 +496,6 @@
<DependentUpon>AutoFocusBehaviorPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\CanvasPathGeometry\GeometryStreamReader.cs" />
<Compile Include="SamplePages\ColorPicker\ColorPickerButtonPage.xaml.cs">
<DependentUpon>ColorPickerButtonPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\ColorPicker\ColorPickerPage.xaml.cs">
<DependentUpon>ColorPickerPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\EnumValuesExtension\Animal.cs" />
<Compile Include="SamplePages\EnumValuesExtension\AnimalToColorConverter.xaml.cs" />
<Compile Include="SamplePages\EnumValuesExtension\EnumValuesExtensionPage.xaml.cs">
Expand Down Expand Up @@ -619,6 +619,9 @@
<Content Include="SamplePages\VisualEffectFactory\VisualEffectFactory.bind" />
<Content Include="SamplePages\Animations\Activities\InvokeActionsActivityCode.bind" />
<Content Include="SamplePages\Animations\Activities\StartAnimationActivityCode.bind" />
<Content Include="SamplePages\Graph\LoginButtonXaml.bind" />
<Content Include="SamplePages\Graph\PeoplePickerXaml.bind" />
<Content Include="SamplePages\Graph\PersonViewXaml.bind" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
Expand Down Expand Up @@ -900,9 +903,6 @@
<Compile Include="SamplePages\RadialGauge\RadialGaugePage.xaml.cs">
<DependentUpon>RadialGaugePage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\RangeSelector\RangeSelectorPage.xaml.cs">
<DependentUpon>RangeSelectorPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\WrapPanel\WrapPanelPage.xaml.cs">
<DependentUpon>WrapPanelPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -956,14 +956,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SamplePages\ColorPicker\ColorPickerButtonPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SamplePages\ColorPicker\ColorPickerPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SamplePages\EnumValuesExtension\EnumValuesExtensionPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -1349,10 +1341,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SamplePages\RangeSelector\RangeSelectorPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SamplePages\WrapLayout\WrapLayoutPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Toolkit.Uwp.SampleApp/Models/GitHubRelease.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class GitHubRelease
[JsonPropertyName("name")]
public string Name { get; set; }

public string FullName => $"Version {Name.Replace("v", string.Empty)} notes";
public string FullName => $"Version {Name.Substring(1)} notes"; // Skip the initial 'v' we put at the front. If we replace all 'v's then we hit 'preview'.

[JsonPropertyName("draft")]
public bool IsDraft { get; set; }
Expand Down
42 changes: 26 additions & 16 deletions Microsoft.Toolkit.Uwp.SampleApp/Models/Sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using Microsoft.Toolkit.Uwp.UI.Controls;
using Microsoft.Toolkit.Uwp.UI.Media;
using Microsoft.UI.Xaml;
using Windows.ApplicationModel;
using Windows.Foundation.Metadata;
using Windows.Storage;
using Windows.Storage.Streams;
Expand Down Expand Up @@ -71,7 +72,6 @@ public static async void EnsureCacheLatest()
}

private string _cachedDocumentation = string.Empty;
private string _cachedPath = string.Empty;

internal static async Task<Sample> FindAsync(string category, string name)
{
Expand Down Expand Up @@ -118,7 +118,7 @@ public string CodeUrl
#if DEBUG
_codeUrl = value;
#else
var regex = new Regex("^https://github.com/Microsoft/WindowsCommunityToolkit/(tree|blob)/(?<branch>.+?)/(?<path>.*)");
var regex = new Regex("^https://github.com/windows-toolkit/WindowsCommunityToolkit/(tree|blob)/(?<branch>.+?)/(?<path>.*)");
var docMatch = regex.Match(value);

var branch = string.Empty;
Expand All @@ -135,7 +135,8 @@ public string CodeUrl
}
else
{
_codeUrl = $"https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/{path}";
var packageVersion = Package.Current.Id.Version.ToFormattedString(3);
_codeUrl = $"https://github.com/Microsoft/WindowsCommunityToolkit/tree/rel/{packageVersion}/{path}";
}
#endif
}
Expand All @@ -149,8 +150,21 @@ public string CodeUrl

public string XamlCode { get; private set; }

/// <summary>
/// Gets or sets the path set in the samples.json pointing to the doc for the sample.
/// </summary>
public string DocumentationUrl { get; set; }

/// <summary>
/// Gets or sets the absolute local doc path for cached file in app.
/// </summary>
public string LocalDocumentationFilePath { get; set; }

/// <summary>
/// Gets or sets the base path segment to the current document location.
/// </summary>
public string RemoteDocumentationPath { get; set; }

public string Icon { get; set; }

public string BadgeUpdateVersionRequired { get; set; }
Expand Down Expand Up @@ -191,32 +205,29 @@ public async Task<string> GetCSharpSourceAsync()
}
}

#pragma warning disable SA1009 // Doesn't like ValueTuples.
public async Task<(string contents, string path)> GetDocumentationAsync()
#pragma warning restore SA1009 // Doesn't like ValueTuples.
public async Task<string> GetDocumentationAsync()
{
if (!string.IsNullOrWhiteSpace(_cachedDocumentation))
{
return (_cachedDocumentation, _cachedPath);
return _cachedDocumentation;
}

var filepath = string.Empty;
var filename = string.Empty;
var localPath = string.Empty;
LocalDocumentationFilePath = string.Empty;

var docRegex = new Regex("^" + _docsOnlineRoot + "(?<branch>.+?)/docs/(?<file>.+)");
var docMatch = docRegex.Match(DocumentationUrl);
if (docMatch.Success)
{
filepath = docMatch.Groups["file"].Value;
filename = Path.GetFileName(filepath);
localPath = $"ms-appx:///docs/{Path.GetDirectoryName(filepath)}/";
filename = Path.GetFileName(RemoteDocumentationPath);
RemoteDocumentationPath = Path.GetDirectoryName(filepath);
LocalDocumentationFilePath = $"ms-appx:///docs/{RemoteDocumentationPath}/";
}

#if !DEBUG // use the docs repo in release mode
string modifiedDocumentationUrl = $"{_docsOnlineRoot}master/docs/{filepath}";

_cachedPath = modifiedDocumentationUrl.Replace(filename, string.Empty);
string modifiedDocumentationUrl = $"{_docsOnlineRoot}live/docs/{filepath}";

// Read from Cache if available.
try
Expand Down Expand Up @@ -264,15 +275,14 @@ public async Task<string> GetCSharpSourceAsync()
{
var result = await localDocsStream.ReadTextAsync(Encoding.UTF8);
_cachedDocumentation = ProcessDocs(result);
_cachedPath = localPath;
}
}
catch (Exception)
{
}
}

return (_cachedDocumentation, _cachedPath);
return _cachedDocumentation;
}

/// <summary>
Expand Down Expand Up @@ -660,7 +670,7 @@ private static async Task<string> GetDocsSHA()
{
try
{
var branchEndpoint = "https://api.github.com/repos/microsoftdocs/uwpcommunitytoolkitdocs/git/refs/heads/live";
var branchEndpoint = "https://api.github.com/repos/microsoftdocs/windowscommunitytoolkitdocs/git/refs/heads/live";

var request = new HttpRequestMessage(HttpMethod.Get, branchEndpoint);
request.Headers.Add("User-Agent", "Windows Community Toolkit Sample App");
Expand Down
4 changes: 2 additions & 2 deletions Microsoft.Toolkit.Uwp.SampleApp/Pages/About.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
xmlns:animations="using:Microsoft.Toolkit.Uwp.UI.Animations"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.Pages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sampleapp="using:Microsoft.Toolkit.Uwp.SampleApp"
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
Loaded="Page_Loaded"
mc:Ignorable="d">

Expand Down Expand Up @@ -150,7 +150,7 @@
<TextBlock Margin="0,20,0,0"
FontSize="14"
Foreground="{ThemeResource Brush-Link-Normal}"
Text="The Windows Community Toolkit is a collection of helper functions, custom controls, and app services. It simplifies and demonstrates common developer patterns when building experiences for Windows 10."
Text="The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks for building UWP and .NET apps for Windows 10."
TextWrapping="Wrap" />
</StackPanel>

Expand Down
18 changes: 10 additions & 8 deletions Microsoft.Toolkit.Uwp.SampleApp/Pages/SampleController.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)

if (CurrentSample.HasDocumentation)
{
#pragma warning disable SA1008 // Opening parenthesis must be spaced correctly
var (contents, path) = await CurrentSample.GetDocumentationAsync();
#pragma warning restore SA1008 // Opening parenthesis must be spaced correctly
documentationPath = path;
var contents = await CurrentSample.GetDocumentationAsync();
if (!string.IsNullOrWhiteSpace(contents))
{
DocumentationTextBlock.Text = contents;
Expand Down Expand Up @@ -431,9 +428,15 @@ private async void DocumentationTextBlock_OnLinkClicked(object sender, LinkClick
{
TrackingManager.TrackEvent("Link", e.Link);
var link = e.Link;
if (e.Link.EndsWith(".md"))
if (link.EndsWith(".md"))
{
link = string.Format("https://docs.microsoft.com/en-us/windows/communitytoolkit/{0}/{1}", CurrentSample.CategoryName.ToLower(), link.Replace(".md", string.Empty));
// Link to one of our other documents, so we'll construct the proper link here
link = string.Format("https://docs.microsoft.com/windows/communitytoolkit/{0}/{1}", CurrentSample.RemoteDocumentationPath, link.Replace(".md", string.Empty));
}
else if (link.StartsWith("/"))
{
// We don't root our links to other docs.microsoft.com pages anymore, so we'll add it here.
link = string.Format("https://docs.microsoft.com{0}", link);
}

if (Uri.TryCreate(link, UriKind.Absolute, out Uri result))
Expand All @@ -450,7 +453,7 @@ private async void DocumentationTextBlock_ImageResolving(object sender, ImageRes
// Determine if the link is not absolute, meaning it is relative.
if (!Uri.TryCreate(e.Url, UriKind.Absolute, out Uri url))
{
url = new Uri(documentationPath + e.Url);
url = new Uri(CurrentSample.LocalDocumentationFilePath + e.Url);
}

if (url.Scheme == "ms-appx")
Expand Down Expand Up @@ -698,7 +701,6 @@ public bool UseBackground

private PaneState _paneState;
private bool _onlyDocumentation;
private string documentationPath;

private ThemeListener _themeListener;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading