PageOtherHelpDetail.xaml.vb 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. Public Class PageOtherHelpDetail
  2. Implements IRefreshable
  3. Public Entry As HelpEntry
  4. Public Sub Refresh() Implements IRefreshable.Refresh
  5. Init(New HelpEntry(Entry.RawPath))
  6. End Sub
  7. Private Sub PageOtherHelpDetail_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
  8. PanBack.ScrollToTop()
  9. End Sub
  10. ''' <summary>
  11. ''' 根据特定帮助项初始化页面 UI,返回是否成功加载。
  12. ''' </summary>
  13. Public Function Init(Entry As HelpEntry) As Boolean
  14. Dim Content = If(Entry.XamlContent, "")
  15. If Content = "" Then Throw New Exception("帮助 xaml 文件为空")
  16. Try
  17. '修改时应同时修改 PageLaunchRight.LoadContent
  18. Content = ArgumentReplace(Content, AddressOf StringUtils.XmlEscape)
  19. Do While Content.Contains("xmlns")
  20. Content = Content.RegexReplace("xmlns[^""']*(""|')[^""']*(""|')", "").Replace("xmlns", "") '禁止声明命名空间
  21. Loop
  22. Content = "<StackPanel xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:sys=""clr-namespace:System;assembly=mscorlib"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:local=""clr-namespace:PCL;assembly=Plain Craft Launcher 2"" xmlns:core=""clr-namespace:MeloongCore;assembly=MeloongCore"" xmlns:corewpf=""clr-namespace:MeloongCore.Wpf;assembly=MeloongCore.Wpf"">" & Content & "</StackPanel>"
  23. Me.Entry = Entry
  24. PanCustom.Children.Clear()
  25. PanCustom.Children.Add(GetObjectFromXML(Content))
  26. Return True
  27. Catch ex As Exception
  28. Logger.Info($"自定义信息内容:{vbCrLf}{Content}")
  29. Logger.Error(ex, "加载帮助 XAML 文件失败", LogBehavior.Alert)
  30. Return False
  31. End Try
  32. End Function
  33. End Class