PageOtherHelpDetail.xaml.vb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  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 = HelpArgumentReplace(Content)
  19. If Content.Contains("xmlns") Then Content = Content.RegexReplace("xmlns[^""']*(""|')[^""']*(""|')", "").Replace("xmlns", "") '禁止声明命名空间
  20. 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"">" & Content & "</StackPanel>"
  21. Me.Entry = Entry
  22. PanCustom.Children.Clear()
  23. PanCustom.Children.Add(GetObjectFromXML(Content))
  24. Return True
  25. Catch ex As Exception
  26. Log("[System] 自定义信息内容:" & vbCrLf & Content)
  27. Log(ex, "加载帮助 XAML 文件失败", LogLevel.Msgbox)
  28. Return False
  29. End Try
  30. End Function
  31. End Class