|
@@ -6,6 +6,7 @@ using ComPDFKitViewer;
|
|
|
using ComPDFKitViewer.AnnotEvent;
|
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
using DryIoc;
|
|
|
+using ImTools;
|
|
|
using Microsoft.Office.Interop.Excel;
|
|
|
using Microsoft.Office.Interop.PowerPoint;
|
|
|
using Microsoft.Office.Interop.Word;
|
|
@@ -33,6 +34,7 @@ using System.Windows;
|
|
|
using System.Windows.Annotations.Storage;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Data;
|
|
|
+using System.Windows.Documents;
|
|
|
using System.Windows.Forms;
|
|
|
using System.Windows.Markup;
|
|
|
using System.Windows.Media;
|
|
@@ -760,6 +762,57 @@ namespace PDF_Office.ViewModels.BOTA
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public async void UpdateAddedAnnot(int pageIndex, int annotIndex)
|
|
|
+ {
|
|
|
+ var annots = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
|
|
|
+ foreach (var item in annots)
|
|
|
+ {
|
|
|
+ if (item.AnnotIndex == annotIndex && item.EventType != AnnotArgsType.AnnotRedaction)
|
|
|
+ {
|
|
|
+ AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(item);
|
|
|
+ if (args.AnnotHandlerEventArgs != null)
|
|
|
+ {
|
|
|
+ AnnotationListItems.Add(args);
|
|
|
+ await Task.Delay(1);//不加延时 每页的第一个注释不会展开
|
|
|
+ ExpandGroupHeader(args, listBox);
|
|
|
+ listBox.SelectedItem = item;
|
|
|
+ await Task.Delay(1);//不加延时 会有不滚动的现象
|
|
|
+ listBox.ScrollIntoView(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (IsEmptyPanelVisibility == Visibility.Visible && AnnotationListItems.Count > 0)
|
|
|
+ {
|
|
|
+ IsEmptyPanelVisibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 展开item所在分组
|
|
|
+ /// </summary>
|
|
|
+ private void ExpandGroupHeader(AnnotationHandlerEventArgs item, ListBox listBox)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var groups = listBox.Items.Groups;
|
|
|
+ for (int i = 0; i < groups.Count; i++)
|
|
|
+ {
|
|
|
+ var l = groups[i] as CollectionViewGroup;
|
|
|
+ if (l.Items.Contains(item))
|
|
|
+ {
|
|
|
+ var scroller = GetScrollHost(listBox);
|
|
|
+ var stackpanel = CommonHelper.FindVisualChild<StackPanel>(scroller);
|
|
|
+ int count = VisualTreeHelper.GetChildrenCount(stackpanel);
|
|
|
+ var groupItem = VisualTreeHelper.GetChild(stackpanel, i) as GroupItem;
|
|
|
+ var g = CommonHelper.FindVisualChild<Expander>(groupItem);
|
|
|
+ if (g != null)
|
|
|
+ g.IsExpanded = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 页面加载时
|
|
|
/// </summary>
|
|
@@ -887,26 +940,11 @@ namespace PDF_Office.ViewModels.BOTA
|
|
|
//原型图上,目前对波浪线的类型,在注释列表不显示
|
|
|
if (item.EventType != AnnotArgsType.AnnotRedaction && item.EventType != AnnotArgsType.AnnotSquiggly)
|
|
|
{
|
|
|
- AnnotationHandlerEventArgs args = new AnnotationHandlerEventArgs();
|
|
|
- if (item.EventType == AnnotArgsType.AnnotFreehand)
|
|
|
+ AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(item);
|
|
|
+ if (args.AnnotHandlerEventArgs != null)
|
|
|
{
|
|
|
- WriteableBitmap bitmap = GetAnnotImage(PdfViewer.Document, item.PageIndex, item.AnnotIndex);
|
|
|
- args.WriteableBitmap = bitmap;
|
|
|
+ list.Add(args);
|
|
|
}
|
|
|
- args.AnnotHandlerEventArgs = item;
|
|
|
- args.PageIndex = item.PageIndex;
|
|
|
- args.AnnotIndex = item.AnnotIndex;
|
|
|
- args.EventType = item.EventType;
|
|
|
- args.CreateTime = item.CreateTime;
|
|
|
- args.UpdateTime = item.UpdateTime;
|
|
|
- args.Content = item.Content;
|
|
|
- args.MarkupContent = item.MarkupContent;
|
|
|
- args.Author = item.Author;
|
|
|
- args.Locked = item.Locked;
|
|
|
- args.ReadOnly = item.ReadOnly;
|
|
|
- args.FormField = item.FormField;
|
|
|
- args.Document = PdfViewer.Document;
|
|
|
- list.Add(args);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -914,6 +952,30 @@ namespace PDF_Office.ViewModels.BOTA
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ private AnnotationHandlerEventArgs GetAddAnnotEventArgs(AnnotHandlerEventArgs item)
|
|
|
+ {
|
|
|
+ AnnotationHandlerEventArgs args = new AnnotationHandlerEventArgs();
|
|
|
+ if (item.EventType == AnnotArgsType.AnnotFreehand)
|
|
|
+ {
|
|
|
+ WriteableBitmap bitmap = GetAnnotImage(PdfViewer.Document, item.PageIndex, item.AnnotIndex);
|
|
|
+ args.WriteableBitmap = bitmap;
|
|
|
+ }
|
|
|
+ args.AnnotHandlerEventArgs = item;
|
|
|
+ args.PageIndex = item.PageIndex;
|
|
|
+ args.AnnotIndex = item.AnnotIndex;
|
|
|
+ args.EventType = item.EventType;
|
|
|
+ args.CreateTime = item.CreateTime;
|
|
|
+ args.UpdateTime = item.UpdateTime;
|
|
|
+ args.Content = item.Content;
|
|
|
+ args.MarkupContent = item.MarkupContent;
|
|
|
+ args.Author = item.Author;
|
|
|
+ args.Locked = item.Locked;
|
|
|
+ args.ReadOnly = item.ReadOnly;
|
|
|
+ args.FormField = item.FormField;
|
|
|
+ args.Document = PdfViewer.Document;
|
|
|
+ return args;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取手绘图案
|
|
|
/// </summary>
|
|
@@ -962,8 +1024,7 @@ namespace PDF_Office.ViewModels.BOTA
|
|
|
/// <param name="e"></param>
|
|
|
private void AnnotationListItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
|
|
{
|
|
|
- ObservableCollection<AnnotationHandlerEventArgs> obsSender = sender as ObservableCollection<AnnotationHandlerEventArgs>;
|
|
|
- if (obsSender != null)
|
|
|
+ if (sender is ObservableCollection<AnnotationHandlerEventArgs> obsSender)
|
|
|
{
|
|
|
currentAnnotationArgs.Clear();
|
|
|
currentAnnotationArgs.AddRange(obsSender);
|