|
@@ -7,12 +7,14 @@ using ComPDFKitViewer.AnnotEvent;
|
|
using ComPDFKitViewer.PdfViewer;
|
|
using ComPDFKitViewer.PdfViewer;
|
|
using DryIoc;
|
|
using DryIoc;
|
|
using Microsoft.Office.Interop.Excel;
|
|
using Microsoft.Office.Interop.Excel;
|
|
|
|
+using Microsoft.Office.Interop.PowerPoint;
|
|
using Microsoft.Office.Interop.Word;
|
|
using Microsoft.Office.Interop.Word;
|
|
using PDF_Office.CustomControl;
|
|
using PDF_Office.CustomControl;
|
|
using PDF_Office.DataConvert;
|
|
using PDF_Office.DataConvert;
|
|
using PDF_Office.Helper;
|
|
using PDF_Office.Helper;
|
|
using PDF_Office.Model;
|
|
using PDF_Office.Model;
|
|
using PDF_Office.Model.BOTA;
|
|
using PDF_Office.Model.BOTA;
|
|
|
|
+using PDF_Office.Views.BOTA;
|
|
using PDF_Office.Views.PropertyPanel.AnnotPanel;
|
|
using PDF_Office.Views.PropertyPanel.AnnotPanel;
|
|
using Prism.Commands;
|
|
using Prism.Commands;
|
|
using Prism.Mvvm;
|
|
using Prism.Mvvm;
|
|
@@ -23,10 +25,12 @@ using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.Configuration;
|
|
|
|
+using System.Drawing;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows;
|
|
|
|
+using System.Windows.Annotations.Storage;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Data;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms;
|
|
@@ -35,8 +39,10 @@ using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using System.Windows.Shapes;
|
|
using static Dropbox.Api.Files.SearchMatchType;
|
|
using static Dropbox.Api.Files.SearchMatchType;
|
|
|
|
+using static Dropbox.Api.TeamLog.SpaceCapsType;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolBar;
|
|
using Border = System.Windows.Controls.Border;
|
|
using Border = System.Windows.Controls.Border;
|
|
using ListBox = System.Windows.Controls.ListBox;
|
|
using ListBox = System.Windows.Controls.ListBox;
|
|
using Task = System.Threading.Tasks.Task;
|
|
using Task = System.Threading.Tasks.Task;
|
|
@@ -65,6 +71,15 @@ namespace PDF_Office.ViewModels.BOTA
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private ObservableCollection<AnnotationHandlerEventArgs> currentAnnotationArgs = new ObservableCollection<AnnotationHandlerEventArgs>();
|
|
|
|
+ private AnnotationSortOrder annotationSortOrder = AnnotationSortOrder.PageIndexAscending;
|
|
|
|
+
|
|
|
|
+ public AnnotationSortOrder AnnotationSortOrder
|
|
|
|
+ {
|
|
|
|
+ get { return annotationSortOrder; }
|
|
|
|
+ set { annotationSortOrder = value; }
|
|
|
|
+ }
|
|
|
|
+
|
|
private ObservableCollection<AnnotationHandlerEventArgs> annotationListItems;
|
|
private ObservableCollection<AnnotationHandlerEventArgs> annotationListItems;
|
|
|
|
|
|
public ObservableCollection<AnnotationHandlerEventArgs> AnnotationListItems
|
|
public ObservableCollection<AnnotationHandlerEventArgs> AnnotationListItems
|
|
@@ -76,15 +91,24 @@ namespace PDF_Office.ViewModels.BOTA
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private List<string> colors = new List<string>();
|
|
|
|
+ private List<string> authors = new List<string>();
|
|
|
|
+ private List<AnnotArgsType> annotArgsTypes = new List<AnnotArgsType>();
|
|
public DelegateCommand<object> LoadedCommand { get; set; }
|
|
public DelegateCommand<object> LoadedCommand { get; set; }
|
|
public DelegateCommand<object> ListBoxItemPreviewMouseLeftButtonDown { get; set; }
|
|
public DelegateCommand<object> ListBoxItemPreviewMouseLeftButtonDown { get; set; }
|
|
public DelegateCommand<object> AddNotesCommand { get; set; }
|
|
public DelegateCommand<object> AddNotesCommand { get; set; }
|
|
public DelegateCommand<object> ScreenCommand { get; set; }
|
|
public DelegateCommand<object> ScreenCommand { get; set; }
|
|
public DelegateCommand<object> ExportCommentsCommand { get; set; }
|
|
public DelegateCommand<object> ExportCommentsCommand { get; set; }
|
|
|
|
+ public DelegateCommand<object> ImportCommentsCommand { get; set; }
|
|
public DelegateCommand<object> DeleteCommand { get; set; }
|
|
public DelegateCommand<object> DeleteCommand { get; set; }
|
|
|
|
|
|
public DelegateCommand DeleteAllCommand { get; set; }
|
|
public DelegateCommand DeleteAllCommand { get; set; }
|
|
|
|
|
|
|
|
+ public DelegateCommand PageSortCommand { get; set; }
|
|
|
|
+
|
|
|
|
+ public DelegateCommand TimeAscendingCommand { get; set; }
|
|
|
|
+ public DelegateCommand TimeDescendingCommand { get; set; }
|
|
|
|
+
|
|
public AnnotationContentViewModel(IRegionManager regionManager, IDialogService dialogService)
|
|
public AnnotationContentViewModel(IRegionManager regionManager, IDialogService dialogService)
|
|
{
|
|
{
|
|
region = regionManager;
|
|
region = regionManager;
|
|
@@ -94,8 +118,92 @@ namespace PDF_Office.ViewModels.BOTA
|
|
AddNotesCommand = new DelegateCommand<object>(AddNotesEvent);
|
|
AddNotesCommand = new DelegateCommand<object>(AddNotesEvent);
|
|
ScreenCommand = new DelegateCommand<object>(ScreenEvent);
|
|
ScreenCommand = new DelegateCommand<object>(ScreenEvent);
|
|
ExportCommentsCommand = new DelegateCommand<object>(ExportCommentsEvent);
|
|
ExportCommentsCommand = new DelegateCommand<object>(ExportCommentsEvent);
|
|
|
|
+ ImportCommentsCommand = new DelegateCommand<object>(ImportCommentsEvent);
|
|
DeleteCommand = new DelegateCommand<object>(DelegateEvent);
|
|
DeleteCommand = new DelegateCommand<object>(DelegateEvent);
|
|
DeleteAllCommand = new DelegateCommand(DeleteAllEvent);
|
|
DeleteAllCommand = new DelegateCommand(DeleteAllEvent);
|
|
|
|
+ PageSortCommand = new DelegateCommand(PageSortEvent);
|
|
|
|
+ TimeAscendingCommand = new DelegateCommand(TimeAscendingEvent);
|
|
|
|
+ TimeDescendingCommand = new DelegateCommand(TimeDescendingEvent);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 导入注释
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="obj"></param>
|
|
|
|
+ private async void ImportCommentsEvent(object obj)
|
|
|
|
+ {
|
|
|
|
+ Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
|
|
|
|
+ dlg.Filter = "PDF|*.xfdf";
|
|
|
|
+ dlg.DefaultExt = ".xfdf";
|
|
|
|
+ if (dlg.ShowDialog() == true)
|
|
|
|
+ {
|
|
|
|
+ string fileName = dlg.FileName;
|
|
|
|
+ await Task.Delay(5);
|
|
|
|
+ var result = PdfViewer.ImportAnnotationFromXFDFPath(fileName);
|
|
|
|
+ if (result == false)
|
|
|
|
+ {
|
|
|
|
+ //MessageBoxEx.Show("导入失败", "", Winform.MessageBoxButtons.OK, Winform.MessageBoxIcon.Error);
|
|
|
|
+ AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
|
+ alertsMessage.Show("提示", "导入失败!", "OK");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ PdfViewer.ReloadVisibleAnnots();
|
|
|
|
+ //提取出来的注释文件 时间为空 则显示未系统当前时间
|
|
|
|
+ currentAnnotationArgs = GetDocumentAnnotionList();
|
|
|
|
+
|
|
|
|
+ AnnotationListItems.Clear();
|
|
|
|
+ AnnotationListItems.AddRange(currentAnnotationArgs);
|
|
|
|
+ await Task.Delay(5);
|
|
|
|
+ RefreshAnnotationListItems(null);
|
|
|
|
+
|
|
|
|
+ PdfViewer.UndoManager.CanSave = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 时间倒序
|
|
|
|
+ /// </summary>
|
|
|
|
+ private void TimeDescendingEvent()
|
|
|
|
+ {
|
|
|
|
+ ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
|
|
|
|
+ CreateTimeToDate createTimeToDate = new CreateTimeToDate();
|
|
|
|
+ v.GroupDescriptions.Clear();
|
|
|
|
+ v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.CreateTime), createTimeToDate));
|
|
|
|
+ v.SortDescriptions.Clear();
|
|
|
|
+ v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.CreateTime), ListSortDirection.Descending));
|
|
|
|
+ v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Descending));
|
|
|
|
+ AnnotationSortOrder = AnnotationSortOrder.TimeDescending;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 时间正序
|
|
|
|
+ /// </summary>
|
|
|
|
+ private void TimeAscendingEvent()
|
|
|
|
+ {
|
|
|
|
+ ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
|
|
|
|
+ CreateTimeToDate createTimeToDate = new CreateTimeToDate();
|
|
|
|
+ v.GroupDescriptions.Clear();
|
|
|
|
+ v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.CreateTime), createTimeToDate));
|
|
|
|
+
|
|
|
|
+ v.SortDescriptions.Clear();
|
|
|
|
+ v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.CreateTime), ListSortDirection.Ascending));
|
|
|
|
+ v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
|
|
|
|
+ AnnotationSortOrder = AnnotationSortOrder.TimeAscending;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 页面排序
|
|
|
|
+ /// </summary>
|
|
|
|
+ private void PageSortEvent()
|
|
|
|
+ {
|
|
|
|
+ ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
|
|
|
|
+ v.GroupDescriptions.Clear();
|
|
|
|
+ v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.PageIndex)));
|
|
|
|
+
|
|
|
|
+ v.SortDescriptions.Clear();
|
|
|
|
+ v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
|
|
|
|
+ v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
|
|
|
|
+ AnnotationSortOrder = AnnotationSortOrder.PageIndexAscending;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -105,9 +213,9 @@ namespace PDF_Office.ViewModels.BOTA
|
|
{
|
|
{
|
|
//调用集中删除的接口 方便一次性undo
|
|
//调用集中删除的接口 方便一次性undo
|
|
Dictionary<int, List<int>> deleteLists = new Dictionary<int, List<int>>();
|
|
Dictionary<int, List<int>> deleteLists = new Dictionary<int, List<int>>();
|
|
- for (int i = 0; i < annotationListItems.Count; i++)
|
|
|
|
|
|
+ for (int i = 0; i < AnnotationListItems.Count; i++)
|
|
{
|
|
{
|
|
- AnnotationHandlerEventArgs item = annotationListItems[i] as AnnotationHandlerEventArgs;
|
|
|
|
|
|
+ AnnotationHandlerEventArgs item = AnnotationListItems[i] as AnnotationHandlerEventArgs;
|
|
if (!deleteLists.ContainsKey(item.PageIndex))
|
|
if (!deleteLists.ContainsKey(item.PageIndex))
|
|
{
|
|
{
|
|
deleteLists.Add(item.PageIndex, new List<int>() { item.AnnotIndex });
|
|
deleteLists.Add(item.PageIndex, new List<int>() { item.AnnotIndex });
|
|
@@ -119,7 +227,8 @@ namespace PDF_Office.ViewModels.BOTA
|
|
}
|
|
}
|
|
}
|
|
}
|
|
PdfViewer.RemovePageAnnot(deleteLists);
|
|
PdfViewer.RemovePageAnnot(deleteLists);
|
|
- annotationListItems.Clear();
|
|
|
|
|
|
+ AnnotationListItems.Clear();
|
|
|
|
+ currentAnnotationArgs.Clear();
|
|
PdfViewer.UndoManager.CanSave = true;
|
|
PdfViewer.UndoManager.CanSave = true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -137,6 +246,7 @@ namespace PDF_Office.ViewModels.BOTA
|
|
if (result)
|
|
if (result)
|
|
{
|
|
{
|
|
AnnotationListItems.Remove(annotation);
|
|
AnnotationListItems.Remove(annotation);
|
|
|
|
+ currentAnnotationArgs.Remove(annotation);
|
|
//记录是删除了哪些页面的注释,然后更新对应页面的注释即可
|
|
//记录是删除了哪些页面的注释,然后更新对应页面的注释即可
|
|
UpdateAnnotListAfterDelete(annotation.PageIndex, annotation.AnnotIndex);
|
|
UpdateAnnotListAfterDelete(annotation.PageIndex, annotation.AnnotIndex);
|
|
PdfViewer.UndoManager.CanSave = true;
|
|
PdfViewer.UndoManager.CanSave = true;
|
|
@@ -145,6 +255,11 @@ namespace PDF_Office.ViewModels.BOTA
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 删除之后,更新
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="pageIndex"></param>
|
|
|
|
+ /// <param name="annoteIndex"></param>
|
|
private void UpdateAnnotListAfterDelete(int pageIndex, int annoteIndex)
|
|
private void UpdateAnnotListAfterDelete(int pageIndex, int annoteIndex)
|
|
{
|
|
{
|
|
var items = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
|
|
var items = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
|
|
@@ -156,12 +271,12 @@ namespace PDF_Office.ViewModels.BOTA
|
|
{
|
|
{
|
|
//相当于将后面的索引-1
|
|
//相当于将后面的索引-1
|
|
if (AnnotationListItems[k].PageIndex == pageIndex &&
|
|
if (AnnotationListItems[k].PageIndex == pageIndex &&
|
|
- AnnotationListItems[k].AnnotIndex == (items[j].AnnotIndex + 1) &&
|
|
|
|
- string.Equals(AnnotationListItems[k].MarkupContent, items[j].MarkupContent) &&
|
|
|
|
- string.Equals(AnnotationListItems[k].Content, items[j].Content) &&
|
|
|
|
- string.Equals(AnnotationListItems[k].CreateTime, items[j].CreateTime) &&
|
|
|
|
- string.Equals(AnnotationListItems[k].Author, items[j].Author)
|
|
|
|
- )
|
|
|
|
|
|
+ AnnotationListItems[k].AnnotIndex == (items[j].AnnotIndex + 1) &&
|
|
|
|
+ string.Equals(AnnotationListItems[k].MarkupContent, items[j].MarkupContent) &&
|
|
|
|
+ string.Equals(AnnotationListItems[k].Content, items[j].Content) &&
|
|
|
|
+ string.Equals(AnnotationListItems[k].CreateTime, items[j].CreateTime) &&
|
|
|
|
+ string.Equals(AnnotationListItems[k].Author, items[j].Author)
|
|
|
|
+ )
|
|
{
|
|
{
|
|
AnnotationListItems[k].AnnotHandlerEventArgs = items[j];
|
|
AnnotationListItems[k].AnnotHandlerEventArgs = items[j];
|
|
AnnotationListItems[k].PageIndex = items[j].PageIndex;
|
|
AnnotationListItems[k].PageIndex = items[j].PageIndex;
|
|
@@ -182,6 +297,10 @@ namespace PDF_Office.ViewModels.BOTA
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 导出注释
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="obj"></param>
|
|
private void ExportCommentsEvent(object obj)
|
|
private void ExportCommentsEvent(object obj)
|
|
{
|
|
{
|
|
if (ViewContentViewModel.CanSave)
|
|
if (ViewContentViewModel.CanSave)
|
|
@@ -198,24 +317,392 @@ namespace PDF_Office.ViewModels.BOTA
|
|
var result = PdfViewer.ExportAnnotationToXFDFPath(fileName);
|
|
var result = PdfViewer.ExportAnnotationToXFDFPath(fileName);
|
|
if (result)
|
|
if (result)
|
|
{
|
|
{
|
|
- MessageBoxEx.Show("导出成功", "", Winform.MessageBoxButtons.OK);
|
|
|
|
|
|
+ //MessageBoxEx.Show("导出成功", "", Winform.MessageBoxButtons.OK);
|
|
|
|
+ AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
|
+ alertsMessage.Show("提示", "导出成功!", "OK");
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- MessageBoxEx.Show("导出失败", "", Winform.MessageBoxButtons.OK, Winform.MessageBoxIcon.Error);
|
|
|
|
|
|
+ AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
|
+ alertsMessage.Show("提示", "导出失败!", "OK");
|
|
|
|
+ //MessageBoxEx.Show("导出失败", "", Winform.MessageBoxButtons.OK, Winform.MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 筛选注释
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="obj"></param>
|
|
private void ScreenEvent(object obj)
|
|
private void ScreenEvent(object obj)
|
|
{
|
|
{
|
|
- DialogParameters value = new DialogParameters();
|
|
|
|
- value.Add(ParameterNames.AnnotationList, AnnotationListItems);
|
|
|
|
- dialogs.ShowDialog(DialogNames.ScreenAnnotationDialog, value, e =>
|
|
|
|
|
|
+ if (obj is System.Windows.Controls.Button button)
|
|
{
|
|
{
|
|
- });
|
|
|
|
|
|
+ DialogParameters value = new DialogParameters();
|
|
|
|
+ value.Add(ParameterNames.AnnotationList, currentAnnotationArgs);
|
|
|
|
+ value.Add(ParameterNames.AnnotArgsTypes, annotArgsTypes);
|
|
|
|
+ value.Add(ParameterNames.AnnotationColors, colors);
|
|
|
|
+ value.Add(ParameterNames.AnnotationAuthor, authors);
|
|
|
|
+ dialogs.ShowDialog(DialogNames.ScreenAnnotationDialog, value, e =>
|
|
|
|
+ {
|
|
|
|
+ if (e.Result == ButtonResult.OK && e.Parameters != null)
|
|
|
|
+ {
|
|
|
|
+ bool cleanState = false;
|
|
|
|
+ if (e.Parameters.ContainsKey(ParameterNames.AnnotationCleanState))
|
|
|
|
+ {
|
|
|
|
+ cleanState = e.Parameters.GetValue<bool>(ParameterNames.AnnotationCleanState);
|
|
|
|
+ if (cleanState)
|
|
|
|
+ {
|
|
|
|
+ colors.Clear();
|
|
|
|
+ authors.Clear();
|
|
|
|
+ annotArgsTypes.Clear();
|
|
|
|
+ AnnotationListItems.Clear();
|
|
|
|
+ AnnotationListItems.AddRange(currentAnnotationArgs);
|
|
|
|
+ RefreshAnnotationListItems(button);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (e.Parameters.ContainsKey(ParameterNames.AnnotArgsTypes))
|
|
|
|
+ {
|
|
|
|
+ annotArgsTypes = e.Parameters.GetValue<List<AnnotArgsType>>(ParameterNames.AnnotArgsTypes);
|
|
|
|
+ }
|
|
|
|
+ if (e.Parameters.ContainsKey(ParameterNames.AnnotationColors))
|
|
|
|
+ {
|
|
|
|
+ colors = e.Parameters.GetValue<List<string>>(ParameterNames.AnnotationColors);
|
|
|
|
+ }
|
|
|
|
+ if (e.Parameters.ContainsKey(ParameterNames.AnnotationAuthor))
|
|
|
|
+ {
|
|
|
|
+ authors = e.Parameters.GetValue<List<string>>(ParameterNames.AnnotationAuthor);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ObservableCollection<AnnotationHandlerEventArgs> screenAnnotationArgs = SelectAnnotationListItems(annotArgsTypes, colors, authors);
|
|
|
|
+ AnnotationListItems.Clear();
|
|
|
|
+ AnnotationListItems.AddRange(screenAnnotationArgs);
|
|
|
|
+
|
|
|
|
+ RefreshAnnotationListItems(button);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if (e.Result == ButtonResult.Cancel && e.Parameters != null)
|
|
|
|
+ {
|
|
|
|
+ colors.Clear();
|
|
|
|
+ authors.Clear();
|
|
|
|
+ annotArgsTypes.Clear();
|
|
|
|
+ AnnotationListItems.Clear();
|
|
|
|
+ AnnotationListItems.AddRange(currentAnnotationArgs);
|
|
|
|
+
|
|
|
|
+ RefreshAnnotationListItems(button);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 刷新列表数据
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="button"></param>
|
|
|
|
+ private async void RefreshAnnotationListItems(System.Windows.Controls.Button button)
|
|
|
|
+ {
|
|
|
|
+ switch (AnnotationSortOrder)
|
|
|
|
+ {
|
|
|
|
+ case AnnotationSortOrder.TimeAscending:
|
|
|
|
+ TimeAscendingEvent();
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotationSortOrder.TimeDescending:
|
|
|
|
+ TimeDescendingEvent();
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotationSortOrder.PageIndexAscending:
|
|
|
|
+ PageSortEvent();
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (AnnotationListItems.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ IsEmptyPanelVisibility = Visibility.Collapsed;
|
|
|
|
+ await Task.Delay(10);
|
|
|
|
+ //展开数据
|
|
|
|
+ ExpandGroupHeader(AnnotationListItems, listBox);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (button != null)
|
|
|
|
+ {
|
|
|
|
+ button.IsEnabled = true;
|
|
|
|
+ }
|
|
|
|
+ IsEmptyPanelVisibility = Visibility.Visible;
|
|
|
|
+ //AnnotationListItems.AddRange(currentAnnotationArgs);
|
|
|
|
+ //RefreshAnnotationListItems();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 根据条件筛选列表数据
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="annotArgsTypes"></param>
|
|
|
|
+ /// <param name="colors"></param>
|
|
|
|
+ /// <param name="authors"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ private ObservableCollection<AnnotationHandlerEventArgs> SelectAnnotationListItems(List<AnnotArgsType> annotArgsTypes, List<string> colors, List<string> authors)
|
|
|
|
+ {
|
|
|
|
+ ObservableCollection<AnnotationHandlerEventArgs> annotationArgs = new ObservableCollection<AnnotationHandlerEventArgs>();
|
|
|
|
+
|
|
|
|
+ #region 类型 颜色 作者
|
|
|
|
+
|
|
|
|
+ if (annotArgsTypes.Count > 0 && colors.Count > 0 && authors.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var item in currentAnnotationArgs)
|
|
|
|
+ {
|
|
|
|
+ foreach (var type in annotArgsTypes)
|
|
|
|
+ {
|
|
|
|
+ foreach (var color in colors)
|
|
|
|
+ {
|
|
|
|
+ foreach (var author in authors)
|
|
|
|
+ {
|
|
|
|
+ if (item.EventType == type && item.Author == author)
|
|
|
|
+ {
|
|
|
|
+ SelectAnnotationColors(item, color, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion 类型 颜色 作者
|
|
|
|
+
|
|
|
|
+ #region 颜色 作者
|
|
|
|
+
|
|
|
|
+ else if (colors.Count > 0 && authors.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var item in currentAnnotationArgs)
|
|
|
|
+ {
|
|
|
|
+ foreach (var color in colors)
|
|
|
|
+ {
|
|
|
|
+ foreach (var author in authors)
|
|
|
|
+ {
|
|
|
|
+ if (item.Author == author)
|
|
|
|
+ {
|
|
|
|
+ SelectAnnotationColors(item, color, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion 颜色 作者
|
|
|
|
+
|
|
|
|
+ #region 类型 作者
|
|
|
|
+
|
|
|
|
+ else if (annotArgsTypes.Count > 0 && authors.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var item in currentAnnotationArgs)
|
|
|
|
+ {
|
|
|
|
+ foreach (var type in annotArgsTypes)
|
|
|
|
+ {
|
|
|
|
+ foreach (var author in authors)
|
|
|
|
+ {
|
|
|
|
+ if (item.EventType == type && item.Author == author)
|
|
|
|
+ {
|
|
|
|
+ annotationArgs.Add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion 类型 作者
|
|
|
|
+
|
|
|
|
+ #region 类型 颜色
|
|
|
|
+
|
|
|
|
+ else if (annotArgsTypes.Count > 0 && colors.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var item in currentAnnotationArgs)
|
|
|
|
+ {
|
|
|
|
+ foreach (var type in annotArgsTypes)
|
|
|
|
+ {
|
|
|
|
+ foreach (var color in colors)
|
|
|
|
+ {
|
|
|
|
+ if (item.EventType == type)
|
|
|
|
+ {
|
|
|
|
+ SelectAnnotationColors(item, color, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion 类型 颜色
|
|
|
|
+
|
|
|
|
+ #region 类型
|
|
|
|
+
|
|
|
|
+ else if (annotArgsTypes.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var item in currentAnnotationArgs)
|
|
|
|
+ {
|
|
|
|
+ foreach (var type in annotArgsTypes)
|
|
|
|
+ {
|
|
|
|
+ if (item.EventType == type)
|
|
|
|
+ {
|
|
|
|
+ annotationArgs.Add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion 类型
|
|
|
|
+
|
|
|
|
+ #region 颜色
|
|
|
|
+
|
|
|
|
+ else if (colors.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var item in currentAnnotationArgs)
|
|
|
|
+ {
|
|
|
|
+ foreach (var color in colors)
|
|
|
|
+ {
|
|
|
|
+ SelectAnnotationColors(item, color, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion 颜色
|
|
|
|
+
|
|
|
|
+ #region 作者
|
|
|
|
+
|
|
|
|
+ else if (authors.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var item in currentAnnotationArgs)
|
|
|
|
+ {
|
|
|
|
+ foreach (var author in authors)
|
|
|
|
+ {
|
|
|
|
+ if (item.Author == author)
|
|
|
|
+ {
|
|
|
|
+ annotationArgs.Add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion 作者
|
|
|
|
+
|
|
|
|
+ return annotationArgs;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 根据颜色筛选注释
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="item"></param>
|
|
|
|
+ /// <param name="color"></param>
|
|
|
|
+ /// <param name="annotationArgs"></param>
|
|
|
|
+ private void SelectAnnotationColors(AnnotationHandlerEventArgs item, string color, ObservableCollection<AnnotationHandlerEventArgs> annotationArgs)
|
|
|
|
+ {
|
|
|
|
+ AnnotHandlerEventArgs data = item.AnnotHandlerEventArgs;
|
|
|
|
+
|
|
|
|
+ switch (item.EventType)
|
|
|
|
+ {
|
|
|
|
+ case AnnotArgsType.AnnotFreeText://文本
|
|
|
|
+ if (data is FreeTextAnnotArgs textAnnotArgs)
|
|
|
|
+ {
|
|
|
|
+ AddScreenAnnotationArgs(textAnnotArgs.FontColor, color, item, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotArgsType.AnnotHighlight://高亮
|
|
|
|
+ if (data is TextHighlightAnnotArgs highlightAnnotArgs)
|
|
|
|
+ {
|
|
|
|
+ AddScreenAnnotationArgs(highlightAnnotArgs.Color, color, item, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotArgsType.AnnotFreehand://手绘
|
|
|
|
+ if (data is FreehandAnnotArgs freehandAnnotArgs)
|
|
|
|
+ {
|
|
|
|
+ AddScreenAnnotationArgs(freehandAnnotArgs.InkColor, color, item, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotArgsType.AnnotSquiggly://波浪线
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotArgsType.AnnotStamp://图章
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotArgsType.AnnotStrikeout://删除线
|
|
|
|
+ if (data is TextStrikeoutAnnotArgs textStrikeoutAnnotArgs)
|
|
|
|
+ {
|
|
|
|
+ AddScreenAnnotationArgs(textStrikeoutAnnotArgs.Color, color, item, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotArgsType.AnnotSticky://便签
|
|
|
|
+ if (data is StickyAnnotArgs stickyAnnotArgs)
|
|
|
|
+ {
|
|
|
|
+ AddScreenAnnotationArgs(stickyAnnotArgs.Color, color, item, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotArgsType.AnnotUnderline://下划线
|
|
|
|
+ if (data is TextUnderlineAnnotArgs textUnderlineAnnotArgs)
|
|
|
|
+ {
|
|
|
|
+ AddScreenAnnotationArgs(textUnderlineAnnotArgs.Color, color, item, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotArgsType.AnnotLine:
|
|
|
|
+ //if ((item.AnnotHandlerEventArgs as LineAnnotArgs).HeadLineType >= (C_LINE_TYPE)1 || (item.AnnotHandlerEventArgs as LineAnnotArgs).TailLineType >= (C_LINE_TYPE)1)
|
|
|
|
+ //{
|
|
|
|
+ // //箭头
|
|
|
|
+ //}
|
|
|
|
+ //else
|
|
|
|
+ //{
|
|
|
|
+ // //线
|
|
|
|
+ //}
|
|
|
|
+ if (data is LineAnnotArgs lineAnnotArgs)
|
|
|
|
+ {
|
|
|
|
+ AddScreenAnnotationArgs(lineAnnotArgs.LineColor, color, item, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotArgsType.AnnotSquare://矩形
|
|
|
|
+ if (data is SquareAnnotArgs squareAnnotArgs)
|
|
|
|
+ {
|
|
|
|
+ AddScreenAnnotationArgs(squareAnnotArgs.LineColor, color, item, annotationArgs);
|
|
|
|
+ AddScreenAnnotationArgs(squareAnnotArgs.BgColor, color, item, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case AnnotArgsType.AnnotCircle://圆
|
|
|
|
+ if (data is CircleAnnotArgs circleAnnotArgs)
|
|
|
|
+ {
|
|
|
|
+ AddScreenAnnotationArgs(circleAnnotArgs.LineColor, color, item, annotationArgs);
|
|
|
|
+ AddScreenAnnotationArgs(circleAnnotArgs.BgColor, color, item, annotationArgs);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 对比颜色
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="color1"></param>
|
|
|
|
+ /// <param name="color"></param>
|
|
|
|
+ /// <param name="item"></param>
|
|
|
|
+ /// <param name="annotationArgs"></param>
|
|
|
|
+ private void AddScreenAnnotationArgs(System.Windows.Media.Color color1, string color, AnnotationHandlerEventArgs item, ObservableCollection<AnnotationHandlerEventArgs> annotationArgs)
|
|
|
|
+ {
|
|
|
|
+ if (color1.ToString() == color)
|
|
|
|
+ {
|
|
|
|
+ annotationArgs.Add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 添加附注的注释
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="obj"></param>
|
|
private void AddNotesEvent(object obj)
|
|
private void AddNotesEvent(object obj)
|
|
{
|
|
{
|
|
if (obj is AnnotationHandlerEventArgs data)
|
|
if (obj is AnnotationHandlerEventArgs data)
|
|
@@ -307,16 +794,20 @@ namespace PDF_Office.ViewModels.BOTA
|
|
ViewContentViewModel = viewContentViewModel;
|
|
ViewContentViewModel = viewContentViewModel;
|
|
PdfViewer = pdfview;
|
|
PdfViewer = pdfview;
|
|
AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>();
|
|
AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>();
|
|
- AnnotationListItems = GetDocumentAnnotionList();
|
|
|
|
AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
|
|
AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
|
|
|
|
+ AnnotationListItems = GetDocumentAnnotionList();
|
|
|
|
+ currentAnnotationArgs.AddRange(AnnotationListItems);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 默认按照PageIndex,分组 排序
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="listBox"></param>
|
|
private async void SetGroupHeader(ListBox listBox)
|
|
private async void SetGroupHeader(ListBox listBox)
|
|
{
|
|
{
|
|
//按照PageIndex,分组 排序
|
|
//按照PageIndex,分组 排序
|
|
ICollectionView iCollectionView = CollectionViewSource.GetDefaultView(AnnotationListItems);
|
|
ICollectionView iCollectionView = CollectionViewSource.GetDefaultView(AnnotationListItems);
|
|
- CreateTimeToDate createTimeToDate = new CreateTimeToDate();
|
|
|
|
iCollectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotationHandlerEventArgs.PageIndex)));
|
|
iCollectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotationHandlerEventArgs.PageIndex)));
|
|
iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
|
|
iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
|
|
iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
|
|
iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
|
|
@@ -381,6 +872,10 @@ namespace PDF_Office.ViewModels.BOTA
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 获取listbox绑定数据
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
private ObservableCollection<AnnotationHandlerEventArgs> GetDocumentAnnotionList()
|
|
private ObservableCollection<AnnotationHandlerEventArgs> GetDocumentAnnotionList()
|
|
{
|
|
{
|
|
ObservableCollection<AnnotationHandlerEventArgs> list = new ObservableCollection<AnnotationHandlerEventArgs>();
|
|
ObservableCollection<AnnotationHandlerEventArgs> list = new ObservableCollection<AnnotationHandlerEventArgs>();
|
|
@@ -460,11 +955,18 @@ namespace PDF_Office.ViewModels.BOTA
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// listbox的itemsource发生变化时
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="sender"></param>
|
|
|
|
+ /// <param name="e"></param>
|
|
private void AnnotationListItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
|
private void AnnotationListItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
|
{
|
|
{
|
|
ObservableCollection<AnnotationHandlerEventArgs> obsSender = sender as ObservableCollection<AnnotationHandlerEventArgs>;
|
|
ObservableCollection<AnnotationHandlerEventArgs> obsSender = sender as ObservableCollection<AnnotationHandlerEventArgs>;
|
|
if (obsSender != null)
|
|
if (obsSender != null)
|
|
{
|
|
{
|
|
|
|
+ currentAnnotationArgs.Clear();
|
|
|
|
+ currentAnnotationArgs.AddRange(obsSender);
|
|
if (obsSender.Count < 1)
|
|
if (obsSender.Count < 1)
|
|
{
|
|
{
|
|
IsEmptyPanelVisibility = Visibility.Visible;
|
|
IsEmptyPanelVisibility = Visibility.Visible;
|