mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 17:57:01 +08:00
feat: 使用MdXaml来提升Markdown渲染表现 (#6723)
This commit is contained in:
@@ -107,15 +107,12 @@
|
||||
<PackageReference Include="HandyControls">
|
||||
<Version>3.4.5</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MdXaml">
|
||||
<Version>1.15.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MdXaml" Version="1.21.0" />
|
||||
<PackageReference Include="MdXaml.Html" Version="1.21.0" />
|
||||
<PackageReference Include="MdXaml.Plugins" Version="1.21.0" />
|
||||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
|
||||
<Version>7.1.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Markdig.Wpf">
|
||||
<Version>0.5.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>13.0.1</Version>
|
||||
</PackageReference>
|
||||
|
||||
@@ -17,8 +17,6 @@ using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using MaaWpfGui.Constants;
|
||||
using MaaWpfGui.Helper;
|
||||
using Markdig;
|
||||
using Markdig.Wpf;
|
||||
using Stylet;
|
||||
|
||||
namespace MaaWpfGui.ViewModels.UI
|
||||
@@ -58,9 +56,6 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
}
|
||||
}
|
||||
|
||||
public FlowDocument AnnouncementInfoDoc => Markdig.Wpf.Markdown.ToFlowDocument(AnnouncementInfo,
|
||||
new MarkdownPipelineBuilder().UseSupportedExtensions().Build());
|
||||
|
||||
/// <summary>
|
||||
/// 检查更新
|
||||
/// </summary>
|
||||
|
||||
@@ -29,8 +29,6 @@ using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.Main;
|
||||
using MaaWpfGui.Models;
|
||||
using MaaWpfGui.States;
|
||||
using Markdig;
|
||||
using Markdig.Wpf;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Semver;
|
||||
@@ -116,8 +114,6 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
}
|
||||
}
|
||||
|
||||
public FlowDocument UpdateInfoDoc => Markdig.Wpf.Markdown.ToFlowDocument(UpdateInfo,
|
||||
new MarkdownPipelineBuilder().UseSupportedExtensions().Build());
|
||||
|
||||
private string _updateUrl;
|
||||
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:markdig="clr-namespace:Markdig.Wpf;assembly=Markdig.Wpf"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:mdxam="clr-namespace:MdXaml;assembly=MdXaml"
|
||||
xmlns:mdplug="clr-namespace:MdXaml.Plugins;assembly=MdXaml.Plugins"
|
||||
xmlns:mdhtml="clr-namespace:MdXaml.Html;assembly=MdXaml.Html"
|
||||
xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI"
|
||||
Title="{DynamicResource Announcement}"
|
||||
Width="600"
|
||||
@@ -19,35 +20,25 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<FlowDocumentScrollViewer
|
||||
x:Name="UpdateInfoMarkdownDocument"
|
||||
<mdxam:MarkdownScrollViewer
|
||||
ClickAction="SafetyOpenBrowser"
|
||||
Grid.Row="0"
|
||||
Document="{Binding AnnouncementInfoDoc}"
|
||||
Zoom="90">
|
||||
Markdown="{Binding AnnouncementInfo}"
|
||||
Margin="10,0,10,0"
|
||||
Zoom="120">
|
||||
<mdxam:MarkdownScrollViewer.MarkdownStyle>
|
||||
<Style TargetType="FlowDocument" BasedOn="{x:Static mdxam:MarkdownStyle.Sasabune}">
|
||||
<Setter Property="FontFamily" Value="Microsoft YaHei"/>
|
||||
<Setter Property="PagePadding" Value="10"/>
|
||||
</Style>
|
||||
</mdxam:MarkdownScrollViewer.MarkdownStyle>
|
||||
<mdxam:MarkdownScrollViewer.Plugins>
|
||||
<mdplug:MdXamlPlugins>
|
||||
<mdhtml:HtmlPluginSetup/>
|
||||
</mdplug:MdXamlPlugins>
|
||||
</mdxam:MarkdownScrollViewer.Plugins>
|
||||
</mdxam:MarkdownScrollViewer>
|
||||
|
||||
<FlowDocumentScrollViewer.Template>
|
||||
<ControlTemplate TargetType="FlowDocumentScrollViewer">
|
||||
<Border
|
||||
Margin="{TemplateBinding Padding}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Focusable="False">
|
||||
|
||||
<hc:ScrollViewer
|
||||
x:Name="PART_ContentHost"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
CanContentScroll="True"
|
||||
IsInertiaEnabled="True" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</FlowDocumentScrollViewer.Template>
|
||||
|
||||
<FlowDocumentScrollViewer.CommandBindings>
|
||||
<CommandBinding Command="{x:Static markdig:Commands.Hyperlink}" Executed="{s:Action OpenHyperlink}" />
|
||||
</FlowDocumentScrollViewer.CommandBindings>
|
||||
</FlowDocumentScrollViewer>
|
||||
<CheckBox
|
||||
Grid.Row="1"
|
||||
Height="30"
|
||||
@@ -57,4 +48,4 @@
|
||||
Content="{DynamicResource GachaShowDisclaimerNoMore}"
|
||||
IsChecked="{Binding DoNotRemindThisAnnouncementAgain}" />
|
||||
</Grid>
|
||||
</hc:Window>
|
||||
</hc:Window>
|
||||
@@ -5,10 +5,8 @@
|
||||
xmlns:controls="clr-namespace:MaaWpfGui.Styles.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:markdig="clr-namespace:Markdig.Wpf;assembly=Markdig.Wpf"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:styles="clr-namespace:MaaWpfGui.Styles"
|
||||
xmlns:mdxam="clr-namespace:MdXaml;assembly=MdXaml"
|
||||
xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI"
|
||||
xmlns:viewModels="clr-namespace:MaaWpfGui.ViewModels"
|
||||
xmlns:vm="clr-namespace:MaaWpfGui"
|
||||
@@ -29,14 +27,14 @@
|
||||
HorizontalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<controls:TextBlock
|
||||
Margin="0,10,0,5"
|
||||
Margin="0,10,0,10"
|
||||
VerticalAlignment="Bottom"
|
||||
FontSize="20"
|
||||
Style="{StaticResource TextBlockDefaultBold}"
|
||||
Text="{DynamicResource VersionUpdatedTo}"
|
||||
TextWrapping="Wrap" />
|
||||
<controls:TextBlock
|
||||
Margin="0,10,0,5"
|
||||
Margin="0,10,0,10"
|
||||
VerticalAlignment="Bottom"
|
||||
FontSize="20"
|
||||
Style="{StaticResource TextBlockDefaultBold}"
|
||||
@@ -44,36 +42,19 @@
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
|
||||
<FlowDocumentScrollViewer
|
||||
x:Name="UpdateInfoMarkdownDocument"
|
||||
<mdxam:MarkdownScrollViewer
|
||||
ClickAction="SafetyOpenBrowser"
|
||||
Grid.Row="1"
|
||||
Margin="16,0"
|
||||
Document="{Binding UpdateInfoDoc}"
|
||||
IsSelectionEnabled="False"
|
||||
Zoom="90">
|
||||
Markdown="{Binding UpdateInfo}"
|
||||
Margin="10,10,10,0"
|
||||
Zoom="120">
|
||||
<mdxam:MarkdownScrollViewer.MarkdownStyle>
|
||||
<Style TargetType="FlowDocument" BasedOn="{x:Static mdxam:MarkdownStyle.Sasabune}">
|
||||
<Setter Property="FontFamily" Value="Microsoft YaHei" />
|
||||
<Setter Property="PagePadding" Value="10"/>
|
||||
</Style>
|
||||
</mdxam:MarkdownScrollViewer.MarkdownStyle>
|
||||
</mdxam:MarkdownScrollViewer>
|
||||
|
||||
<FlowDocumentScrollViewer.Template>
|
||||
<ControlTemplate TargetType="FlowDocumentScrollViewer">
|
||||
<Border
|
||||
Margin="{TemplateBinding Padding}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Focusable="False">
|
||||
|
||||
<hc:ScrollViewer
|
||||
x:Name="PART_ContentHost"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
CanContentScroll="True"
|
||||
IsInertiaEnabled="True" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</FlowDocumentScrollViewer.Template>
|
||||
|
||||
<FlowDocumentScrollViewer.CommandBindings>
|
||||
<CommandBinding Command="{x:Static markdig:Commands.Hyperlink}" Executed="{s:Action OpenHyperlink}" />
|
||||
</FlowDocumentScrollViewer.CommandBindings>
|
||||
</FlowDocumentScrollViewer>
|
||||
</Grid>
|
||||
</hc:Window>
|
||||
</hc:Window>
|
||||
Reference in New Issue
Block a user