Fix images loading, minor .csproj tweaks
This commit is contained in:
Родитель
c0dbe67f35
Коммит
0431589615
|
@ -64,15 +64,17 @@ public class SamplePageViewModel : ObservableObject
|
|||
// Skip if the loading has already started
|
||||
if (LoadDocsCommand.ExecutionTask is not null) return;
|
||||
|
||||
string path = Path.Combine("Assets", "docs", $"{name}.md");
|
||||
string directory = Path.GetDirectoryName(name);
|
||||
string filename = Path.GetFileName(name);
|
||||
string path = Path.Combine("Assets", "docs", directory, $"{filename}.md");
|
||||
using Stream stream = await FilesServices.OpenForReadAsync(path);
|
||||
using StreamReader reader = new(stream);
|
||||
string text = await reader.ReadToEndAsync();
|
||||
|
||||
// Drop image links
|
||||
string trimmedText = Regex.Replace(text, @"[ \r\n]+?!\[[^]]+\]\([^)]+\)[ \r\n]+?", string.Empty);
|
||||
// Fixup image links
|
||||
string fixedText = Regex.Replace(text, @"!\[[^\]]+\]\(([^ \)]+)(?:[^\)]+)?\)", m => $"![]({m.Groups[1].Value})");
|
||||
|
||||
Texts = MarkdownHelper.GetParagraphs(trimmedText);
|
||||
Texts = MarkdownHelper.GetParagraphs(fixedText);
|
||||
|
||||
OnPropertyChanged(nameof(GetParagraph));
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ using Microsoft.Toolkit.Uwp.UI.Controls;
|
|||
using Windows.System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
|
||||
#nullable enable
|
||||
|
||||
|
@ -40,6 +41,7 @@ public sealed class DocumentationBlock : ContentControl
|
|||
markdownTextBlock = (MarkdownTextBlock)GetTemplateChild("PART_MarkdownTextBlock")!;
|
||||
|
||||
markdownTextBlock.LinkClicked += MarkdownTextBlock_LinkClicked;
|
||||
markdownTextBlock.ImageResolving += MarkdownTextBlock_ImageResolving;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -57,6 +59,20 @@ public sealed class DocumentationBlock : ContentControl
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles an image being resolved and loads images from the local assets.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source <see cref="MarkdownTextBlock"/> control.</param>
|
||||
/// <param name="e">The input arguments.</param>
|
||||
private void MarkdownTextBlock_ImageResolving(object sender, ImageResolvingEventArgs e)
|
||||
{
|
||||
if (e.Url?.Contains("source-generator-visualization.png") == true)
|
||||
{
|
||||
e.Image = new BitmapImage(new Uri("ms-appx:///Assets/docs/images/source-generator-visualization.png"));
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="string"/> representing the text to display.
|
||||
/// </summary>
|
||||
|
|
|
@ -534,19 +534,23 @@
|
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\..\msdocs-communitytoolkit\docs\mvvm\generators\Overview.md">
|
||||
<Link>Assets\docs\Overview.md</Link>
|
||||
<Link>Assets\docs\generators\Overview.md</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\..\msdocs-communitytoolkit\docs\mvvm\generators\ObservableProperty.md">
|
||||
<Link>Assets\docs\ObservablePropertyAttribute.md</Link>
|
||||
<Link>Assets\docs\generators\ObservableProperty.md</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\..\msdocs-communitytoolkit\docs\mvvm\generators\RelayCommand.md">
|
||||
<Link>Assets\docs\RelayCommandAttribute.md</Link>
|
||||
<Link>Assets\docs\generators\RelayCommand.md</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\..\msdocs-communitytoolkit\docs\mvvm\generators\INotifyPropertyChanged.md">
|
||||
<Link>Assets\docs\INotifyPropertyChangedAttribute.md</Link>
|
||||
<Link>Assets\docs\generators\INotifyPropertyChanged.md</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\..\msdocs-communitytoolkit\docs\images\source-generator-visualization.png">
|
||||
<Link>Assets\docs\images\source-generator-visualization.png</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
<muxc:NavigationViewItem.MenuItems>
|
||||
<muxc:NavigationViewItem
|
||||
x:Name="CommandsItem"
|
||||
Content="Introduction"
|
||||
Content="Relay commands"
|
||||
Icon="Library"
|
||||
ToolTipService.ToolTip="Get started with the available command types included in the MVVM Toolkit." />
|
||||
<muxc:NavigationViewItem
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
mc:Ignorable="d">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Loaded">
|
||||
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="INotifyPropertyChangedAttribute" />
|
||||
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="generators/INotifyPropertyChanged" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
mc:Ignorable="d">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Loaded">
|
||||
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="ObservablePropertyAttribute" />
|
||||
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="generators/ObservableProperty" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
mc:Ignorable="d">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Loaded">
|
||||
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="RelayCommandAttribute" />
|
||||
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="generators/RelayCommand" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
mc:Ignorable="d">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Loaded">
|
||||
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="Overview" />
|
||||
<core:InvokeCommandAction Command="{x:Bind ViewModel.LoadDocsCommand}" CommandParameter="generators/Overview" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче