feat: 优化公告的渲染表现

This commit is contained in:
SherkeyXD
2023-10-06 19:02:14 +08:00
parent d61ed3a3c0
commit 45da058793
3 changed files with 24 additions and 37 deletions

View File

@@ -108,8 +108,10 @@
<Version>3.4.5</Version>
</PackageReference>
<PackageReference Include="MdXaml">
<Version>1.15.0</Version>
<Version>1.21.0</Version>
</PackageReference>
<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>

View File

@@ -20,8 +20,7 @@ using System.Windows.Documents;
using System.Windows.Input;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
using Markdig;
using Markdig.Wpf;
using MdXaml;
using Stylet;
namespace MaaWpfGui.ViewModels.UI
@@ -61,9 +60,6 @@ namespace MaaWpfGui.ViewModels.UI
}
}
public FlowDocument AnnouncementInfoDoc => Markdig.Wpf.Markdown.ToFlowDocument(AnnouncementInfo,
new MarkdownPipelineBuilder().UseSupportedExtensions().Build());
/// <summary>
/// 检查更新
/// </summary>

View File

@@ -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,23 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<FlowDocumentScrollViewer
x:Name="UpdateInfoMarkdownDocument"
Grid.Row="0"
Document="{Binding AnnouncementInfoDoc}"
Zoom="90">
<mdxam:MarkdownScrollViewer
ClickAction="SafetyOpenBrowser"
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"/>
</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 +46,4 @@
Content="{DynamicResource GachaShowDisclaimerNoMore}"
IsChecked="{Binding DoNotRemindThisAnnouncementAgain}" />
</Grid>
</hc:Window>
</hc:Window>