using ComPDFKit.PDFDocument; using compdfkit_tools.PDFControl; using compdfkit_tools.PDFView.PDFOutline.PDFOutlineData; using ComPDFKitViewer.PdfViewer; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace compdfkit_tools.PDFControlUI { public partial class CPDFOutlineNode { /// /// 大纲父节点 /// public CPDFOutlineNode ParentNode = null; /// /// 当前大纲 /// public CPDFOutline PDFOutline = null; /// /// 当前node名 /// public string CurrentNodeName = string.Empty; /// /// 子大纲集合 /// public ObservableCollection ChildrenNodeList { get; set; } /// /// 当前展开状态 /// public bool IsExpanded = false; /// /// 当前节点页面 /// public int PageIndex = 0; /// /// 当前节点所在页面中的水平位置 /// public double PositionX; /// /// 当前节点所在页面中的垂直位置 /// public double PositionY; } /// /// CPDFOutlineUI.xaml 的交互逻辑 /// public partial class CPDFOutlineUI : UserControl, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public ObservableCollection OutlineList { get; set; } = new ObservableCollection(); public CPDFOutlineUI() { InitializeComponent(); } private void BuildOutlineTree(List outlineList, ItemCollection nodes) { foreach (var outline in outlineList) { TreeViewItem new_node = new TreeViewItem(); new_node.Header = outline.Title; ToolTipService.SetToolTip(new_node, new_node.Header); nodes.Add(new_node); new_node.Tag = outline; List childList = outline.ChildList; if (childList != null && childList.Count > 0) { BuildOutlineTree(childList, new_node.Items); } } } public void SetOutlineTree(List outlineList) { this.OutlineList.Clear(); if (!OutlineTree.HasItems) { //OutlineTree.FontSize = 14; if (outlineList != null && outlineList.Count > 0) { OutlineTree.BeginInit(); BuildOutlineTree(outlineList, OutlineTree.Items); OutlineTree.EndInit(); } } if(outlineList==null || outlineList.Count==0) { NoResultText.Visibility = Visibility.Visible; } else { NoResultText.Visibility= Visibility.Collapsed; } } } }