更换Markdown转换器,将Pandoc更换为MarkdownDeep。
This commit is contained in:
parent
0769d970a3
commit
4647e085e8
|
@ -363,3 +363,5 @@ MigrationBackup/
|
|||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
/Output/MECF.Framework
|
||||
/SIC.Framework.und
|
||||
/MECF.Framework.Common/MECF.Framework.Common.und
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -32,6 +32,6 @@ public class ReferencedAssemblyInfo
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Name={Name}, Version={Version}, PublicKeyToken={BitConverter.ToString(PublicKeyToken)}";
|
||||
return string.Join(" - ", Name ?? "", Version?.ToString() ?? "", PublicKeyToken == null || PublicKeyToken.Length == 0 ? "null" : BitConverter.ToString(PublicKeyToken));
|
||||
}
|
||||
}
|
|
@ -5,8 +5,9 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:bhv="clr-namespace:MECF.Framework.UI.Core.Behaviors;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:conv="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:cal="clr-namespace:Caliburn.Micro"
|
||||
mc:Ignorable="d"
|
||||
Height="500" Width="600">
|
||||
Height="700" Width="600">
|
||||
<UserControl.Resources>
|
||||
<conv:MarkdownToHtmlConverter x:Key="MarkdownToHtmlConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
@ -14,7 +15,7 @@
|
|||
<StackPanel DockPanel.Dock="Top" Margin="0 0 0 20">
|
||||
|
||||
<TextBlock Text="SiC CVD System" Foreground="Black" FontSize="30" FontFamily="Segoe UI Semibold" FontWeight="Bold"/>
|
||||
<TextBlock Text="Vesion 1.x.x.x" Foreground="Black" FontSize="12" FontFamily="Segoe UI"/>
|
||||
<TextBlock Text="{Binding SicUIVersion}" Foreground="Black" FontSize="12" FontFamily="Segoe UI"/>
|
||||
<TextBlock Text="© 2023 Sicentury Semiconductor Technology (Suzhou) Co., Ltd" Foreground="Black" FontSize="12" FontFamily="Segoe UI"/>
|
||||
<TextBlock Text="All rights reserved." Foreground="Black" FontSize="12" FontFamily="Segoe UI"/>
|
||||
</StackPanel>
|
||||
|
@ -22,14 +23,16 @@
|
|||
<TabControl>
|
||||
<TabItem Header="Dependencies">
|
||||
<DockPanel>
|
||||
<Button DockPanel.Dock="Bottom" Content="Copy Info" Height="30"/>
|
||||
<ListBox Margin="0 0 0 5" ItemsSource="{Binding DependenciesInfo}"/>
|
||||
<Button DockPanel.Dock="Bottom" Content="Copy Info" Height="30" cal:Message.Attach="CopyAssembliesInfo()"/>
|
||||
<ListBox
|
||||
Style="{x:Null}"
|
||||
Margin="0 0 0 5" ItemsSource="{Binding DependenciesInfo}"/>
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Release Note">
|
||||
<DockPanel>
|
||||
<WebBrowser bhv:BrowserBehavior.Html="{Binding MdReleaseNote, Converter={StaticResource MarkdownToHtmlConverter}}"/>
|
||||
<WebBrowser bhv:BrowserBehavior.Html="{Binding MdReleaseNote}"/>
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
|
|
@ -1,6 +1,19 @@
|
|||
using MECF.Framework.Common.CommonData;
|
||||
using OpenSEMI.ClientBase;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.UI.Core.Converters;
|
||||
using System.Text;
|
||||
using System;
|
||||
using Aitex.Core.RT.Log;
|
||||
using System.Reflection;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Documents;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Dialogs
|
||||
{
|
||||
|
@ -8,23 +21,35 @@ namespace MECF.Framework.UI.Client.CenterViews.Dialogs
|
|||
{
|
||||
#region Variables
|
||||
|
||||
private const string KEY_ASSE = "System.AssembliesInfo";
|
||||
private const string KEY_RN = "System.ReleaseNote";
|
||||
|
||||
private readonly CancellationTokenSource _cts;
|
||||
private readonly MarkdownToHtmlConverter _mdToHtmlConverter;
|
||||
|
||||
private List<ReferencedAssemblyInfo> _dependencyAssembliesInfo;
|
||||
private string _mdReleaseNote;
|
||||
private Task _taskLoadData;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public SystemInfoViewModel(List<ReferencedAssemblyInfo> assembliesInfo, string mdReleaseNote)
|
||||
public SystemInfoViewModel()
|
||||
{
|
||||
DependenciesInfo = assembliesInfo;
|
||||
MdReleaseNote = mdReleaseNote;
|
||||
_cts = new CancellationTokenSource();
|
||||
_mdToHtmlConverter = new MarkdownToHtmlConverter();
|
||||
|
||||
PollDataAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public string SicUIVersion => $"SicUI Version {Assembly.GetEntryAssembly().GetName().Version}";
|
||||
|
||||
|
||||
public List<ReferencedAssemblyInfo> DependenciesInfo
|
||||
{
|
||||
get => _dependencyAssembliesInfo;
|
||||
|
@ -46,5 +71,78 @@ namespace MECF.Framework.UI.Client.CenterViews.Dialogs
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
_cts?.Cancel();
|
||||
_taskLoadData?.Dispose();
|
||||
}
|
||||
|
||||
private void PollData()
|
||||
{
|
||||
var dict = QueryDataClient.Instance.Service.PollData(new[] { KEY_ASSE, KEY_RN });
|
||||
var list = dict[KEY_ASSE] as List<ReferencedAssemblyInfo>;
|
||||
var releaseNote = _mdToHtmlConverter.Convert(dict[KEY_RN], null, null, CultureInfo.CurrentCulture)?.ToString();
|
||||
DependenciesInfo = list;
|
||||
MdReleaseNote = releaseNote;
|
||||
}
|
||||
|
||||
private void PollDataAsync()
|
||||
{
|
||||
// Load信息用于提醒用户正在加载
|
||||
DependenciesInfo = new List<ReferencedAssemblyInfo>(new[]
|
||||
{
|
||||
new ReferencedAssemblyInfo()
|
||||
{
|
||||
Name = "Loading..."
|
||||
}
|
||||
});
|
||||
|
||||
// 异步拉取数据,以便窗口及时弹出
|
||||
List<ReferencedAssemblyInfo> list = null;
|
||||
var releaseNote = "";
|
||||
_taskLoadData = Task.Run(() =>
|
||||
{
|
||||
var dict = QueryDataClient.Instance.Service.PollData(new[] { KEY_ASSE, KEY_RN });
|
||||
list = dict[KEY_ASSE] as List<ReferencedAssemblyInfo>;
|
||||
releaseNote = _mdToHtmlConverter.Convert(dict[KEY_RN], null, null, CultureInfo.CurrentCulture)?.ToString();
|
||||
}, _cts.Token).ContinueWith(t =>
|
||||
{
|
||||
if (t.IsCompleted)
|
||||
{
|
||||
Application.Current?.Dispatcher.Invoke(() =>
|
||||
{
|
||||
DependenciesInfo = list;
|
||||
MdReleaseNote = releaseNote;
|
||||
Debug.WriteLine($"{MdReleaseNote.Substring(0, 100)} =- {releaseNote.Substring(0, 100)}");
|
||||
});
|
||||
}
|
||||
}, _cts.Token);
|
||||
}
|
||||
|
||||
public void CopyAssembliesInfo()
|
||||
{
|
||||
if(DependenciesInfo.Count > 0)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach(var dependency in DependenciesInfo)
|
||||
{
|
||||
sb.AppendLine(dependency.ToString());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(sb.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Error($"Unable to copy assemblis info to clipboard, {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,14 +62,7 @@ namespace OpenSEMI.Ctrlib.Window
|
|||
|
||||
private void ShowSystemMenu(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
const string KEY_ASSE = "System.AssembliesInfo";
|
||||
const string KEY_RN = "System.ReleaseNote";
|
||||
|
||||
var dict = QueryDataClient.Instance.Service.PollData(new[] { KEY_ASSE, KEY_RN });
|
||||
var list = dict[KEY_ASSE] as List<ReferencedAssemblyInfo>;
|
||||
var releaseNote = dict[KEY_RN].ToString();
|
||||
|
||||
var vm = new SystemInfoViewModel(list, releaseNote);
|
||||
var vm = new SystemInfoViewModel();
|
||||
var wm = new WindowManager();
|
||||
|
||||
dynamic settings = new ExpandoObject();
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
// *
|
||||
// * *****************************************************************************/
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
|
@ -36,7 +38,9 @@ namespace MECF.Framework.UI.Core.Behaviors
|
|||
static void OnHtmlChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var browser = dependencyObject as WebBrowser;
|
||||
browser?.NavigateToString(e.NewValue.ToString());
|
||||
var html = e.NewValue.ToString();
|
||||
Debug.WriteLine(html);
|
||||
browser?.NavigateToString(html);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
using MarkdownRender;
|
||||
|
||||
namespace MECF.Framework.UI.Core.Converters
|
||||
{
|
||||
|
@ -23,10 +23,27 @@ namespace MECF.Framework.UI.Core.Converters
|
|||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string markdown)
|
||||
if (value is string mdText)
|
||||
{
|
||||
var html = Markdown.ConvertToHtml(markdown);
|
||||
return html;
|
||||
var conv = new MarkdownDeep.Markdown();
|
||||
var html = conv.Transform(mdText);
|
||||
var sb = new StringBuilder();
|
||||
sb.Append(
|
||||
"<!DOCTYPE html><html lang=\"en\">" +
|
||||
"<head> " +
|
||||
" <meta charset=\"UTF-8\" />" +
|
||||
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /> " +
|
||||
" <title>Sic ϵͳ¸üÐÂÀúÊ·¼Ç¼</title> " +
|
||||
" <style> " +
|
||||
" .mainContainer { font-family: Tahoma, Verdana, sans-serif; margin: 10px;} " +
|
||||
" </style>" +
|
||||
" </head><body oncontextmenu=\"return false;\"> " +
|
||||
" <div class=mainContainer> ");
|
||||
sb.Append(html);
|
||||
sb.Append("<div>" +
|
||||
"</body>" +
|
||||
"</html>");
|
||||
return sb.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -43,15 +43,13 @@
|
|||
<Reference Include="Autofac">
|
||||
<HintPath>..\Dependencies\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HtmlAgilityPack">
|
||||
<HintPath>..\Dependencies\HtmlAgilityPack.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\ThirdParty\dlls\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MarkdownRender">
|
||||
<HintPath>..\Dependencies\MarkdownRender.dll</HintPath>
|
||||
<Reference Include="MarkdownDeep, Version=1.5.7366.28328, Culture=neutral, PublicKeyToken=a3790ba34fe8597c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Dependencies\MarkdownDeep.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
@ -1294,10 +1292,5 @@
|
|||
<Name>MECF.Framework.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="pandoc.exe">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
Binary file not shown.
Loading…
Reference in New Issue