|
@@ -1,10 +1,12 @@
|
|
|
using ComPDFKit.PDFAnnotation;
|
|
|
using ComPDFKitViewer;
|
|
|
using ComPDFKitViewer.AnnotEvent;
|
|
|
+using ComPDFKitViewer.PdfViewer;
|
|
|
using Microsoft.Win32;
|
|
|
using PDF_Office.CustomControl;
|
|
|
using PDF_Office.Helper;
|
|
|
using PDF_Office.Properties;
|
|
|
+using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
|
|
|
using PDFSettings;
|
|
|
using Prism.Mvvm;
|
|
|
using Prism.Regions;
|
|
@@ -21,6 +23,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
|
|
|
{
|
|
|
#region 初始化
|
|
|
+
|
|
|
private void BindingEvent()
|
|
|
{
|
|
|
propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
|
|
@@ -30,7 +33,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
|
|
|
private void InitDefaultValue()
|
|
|
{
|
|
|
-
|
|
|
InitAnnotHighlight();
|
|
|
InitAnnotUnderline();
|
|
|
InitAnnotSquiggly();
|
|
@@ -56,7 +58,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private void InitAnnotUnderline()
|
|
|
{
|
|
|
DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotUnderline);
|
|
@@ -114,8 +115,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
-
|
|
|
+ #endregion 初始化
|
|
|
|
|
|
#region 注释工具
|
|
|
|
|
@@ -128,7 +128,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
|
TextHighlightAnnotArgs highlightArgs = null;
|
|
|
|
|
|
- if(selectedhighlightArgs == null)
|
|
|
+ if (selectedhighlightArgs == null)
|
|
|
{
|
|
|
highlightArgs = new TextHighlightAnnotArgs();
|
|
|
highlightArgs.Color = Color.FromRgb(0xFF, 0xBB, 0x00);
|
|
@@ -154,6 +154,47 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
return highlightArgs;
|
|
|
}
|
|
|
|
|
|
+ private AnnotHandlerEventArgs GetLink(LinkAnnotArgs selectedfreetextArgs = null, AnnotAttribEvent annotAttribEvent = null)
|
|
|
+ {
|
|
|
+ Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
|
+ LinkAnnotArgs linkArgs = new LinkAnnotArgs();
|
|
|
+ DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotLink);
|
|
|
+ if (annotProperty != null)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ if (selectedfreetextArgs != null)
|
|
|
+ {
|
|
|
+ linkArgs.URI = selectedfreetextArgs.URI;
|
|
|
+ linkArgs.LinkType = selectedfreetextArgs.LinkType;
|
|
|
+ linkArgs.DestIndex = selectedfreetextArgs.DestIndex;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ linkArgs.URI = string.Empty;
|
|
|
+ linkArgs.LinkType = LINK_TYPE.GOTO;
|
|
|
+ linkArgs.DestIndex = -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //if (viewCtrl.PdfViewer.Document != null)
|
|
|
+ //{
|
|
|
+ // linkProperty.SetTotalPage(viewCtrl.PdfViewer.Document.PageCount);
|
|
|
+ //}
|
|
|
+ //linkProperty.SetLinkPageNum(linkArgs.DestIndex);
|
|
|
+ //linkProperty.SetLinkUrl(linkArgs.URI);
|
|
|
+ //linkProperty.SetLinkEmail(string.Empty);
|
|
|
+ //linkProperty.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(linkArgs, annotAttribsList);
|
|
|
+ //linkProperty.AnnotArgs = linkArgs;
|
|
|
+ //propertyPanel = linkProperty;
|
|
|
+ //annotArgs = linkArgs;
|
|
|
+ //viewCtrl.ShowPropertyPanel();
|
|
|
+ annotAttribsList[AnnotAttrib.LinkType] = linkArgs.LinkType;
|
|
|
+ annotAttribsList[AnnotAttrib.LinkUri] = linkArgs.URI;
|
|
|
+ annotAttribsList[AnnotAttrib.LinkDestIndx] = linkArgs.DestIndex;
|
|
|
+ AddToPropertyPanel("LinkAnnotProperty", "Link", linkArgs, annotAttribsList, annotAttribEvent);
|
|
|
+ return linkArgs;
|
|
|
+ }
|
|
|
+
|
|
|
private AnnotHandlerEventArgs GetUnderLine(TextUnderlineAnnotArgs selectedunderlineArgs = null)
|
|
|
{
|
|
|
Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
@@ -180,8 +221,8 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
annotAttribsList[AnnotAttrib.Color] = underlineArgs.Color;
|
|
|
annotAttribsList[AnnotAttrib.Transparency] = underlineArgs.Transparency;
|
|
|
annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
|
|
|
-
|
|
|
- AddToPropertyPanel("TextAnnotProperty", "UnderLine", underlineArgs, annotAttribsList);
|
|
|
+
|
|
|
+ AddToPropertyPanel("TextAnnotProperty", "UnderLine", underlineArgs, annotAttribsList);
|
|
|
return underlineArgs;
|
|
|
}
|
|
|
|
|
@@ -212,7 +253,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
annotAttribsList[AnnotAttrib.Transparency] = squigglyArgs.Transparency;
|
|
|
annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
|
|
|
|
|
|
- AddToPropertyPanel("TextAnnotProperty", "Squiggly", squigglyArgs, annotAttribsList);
|
|
|
+ AddToPropertyPanel("TextAnnotProperty", "Squiggly", squigglyArgs, annotAttribsList);
|
|
|
return squigglyArgs;
|
|
|
}
|
|
|
|
|
@@ -221,7 +262,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
|
TextStrikeoutAnnotArgs strikeoutArgs = null;
|
|
|
|
|
|
- if(selectedstrikeoutArgs == null)
|
|
|
+ if (selectedstrikeoutArgs == null)
|
|
|
{
|
|
|
strikeoutArgs = new TextStrikeoutAnnotArgs();
|
|
|
strikeoutArgs.Color = Color.FromRgb(0xFF, 0x3B, 0x30);
|
|
@@ -238,7 +279,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
|
strikeoutArgs = selectedstrikeoutArgs;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
annotAttribsList[AnnotAttrib.Color] = strikeoutArgs.Color;
|
|
|
annotAttribsList[AnnotAttrib.Transparency] = strikeoutArgs.Transparency;
|
|
|
annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
|
|
@@ -252,7 +293,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
|
FreehandAnnotArgs freehandArgs = null;
|
|
|
|
|
|
- if(selectedfreehandArgs == null)
|
|
|
+ if (selectedfreehandArgs == null)
|
|
|
{
|
|
|
freehandArgs = new FreehandAnnotArgs();
|
|
|
freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
|
|
@@ -266,13 +307,12 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
freehandArgs.LineWidth = annotProperty.Thickness;
|
|
|
freehandArgs.Content = annotProperty.NoteText;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
freehandArgs = selectedfreehandArgs;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
|
|
|
annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
|
|
|
annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
|
|
@@ -325,7 +365,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
textAlignment = TextAlignment.Center;
|
|
|
else
|
|
|
textAlignment = TextAlignment.Right;
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -333,7 +372,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
textAlignment = freetextArgs.Align;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
annotAttribsList[AnnotAttrib.Color] = freetextArgs.LineColor;
|
|
|
annotAttribsList[AnnotAttrib.FillColor] = freetextArgs.BgColor;
|
|
|
annotAttribsList[AnnotAttrib.Thickness] = freetextArgs.LineWidth;
|
|
@@ -378,7 +416,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
|
SquareAnnotArgs squareArgs = null;
|
|
|
|
|
|
- if(selectedsquareArgs == null)
|
|
|
+ if (selectedsquareArgs == null)
|
|
|
{
|
|
|
squareArgs = new SquareAnnotArgs();
|
|
|
|
|
@@ -416,7 +454,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
|
squareArgs = selectedsquareArgs;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
annotAttribsList[AnnotAttrib.Color] = squareArgs.LineColor;
|
|
|
annotAttribsList[AnnotAttrib.FillColor] = squareArgs.BgColor;
|
|
|
annotAttribsList[AnnotAttrib.LineStyle] = squareArgs.LineDash;
|
|
@@ -433,7 +471,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
|
CircleAnnotArgs circleAnnotArgs = null;
|
|
|
|
|
|
- if(selectedcircleAnnotArgs == null)
|
|
|
+ if (selectedcircleAnnotArgs == null)
|
|
|
{
|
|
|
circleAnnotArgs = new CircleAnnotArgs();
|
|
|
circleAnnotArgs.LineColor = Colors.Red;
|
|
@@ -469,7 +507,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
|
circleAnnotArgs = selectedcircleAnnotArgs;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
annotAttribsList[AnnotAttrib.Color] = circleAnnotArgs.LineColor;
|
|
|
annotAttribsList[AnnotAttrib.FillColor] = circleAnnotArgs.BgColor;
|
|
|
annotAttribsList[AnnotAttrib.LineStyle] = circleAnnotArgs.LineDash;
|
|
@@ -481,14 +519,13 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
return circleAnnotArgs;
|
|
|
}
|
|
|
|
|
|
- private AnnotHandlerEventArgs GetArrowLine(string TagStr,LineAnnotArgs selectedLineAnnotArgs = null)
|
|
|
+ private AnnotHandlerEventArgs GetArrowLine(string TagStr, LineAnnotArgs selectedLineAnnotArgs = null)
|
|
|
{
|
|
|
Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
|
LineAnnotArgs lineArgs = new LineAnnotArgs();
|
|
|
|
|
|
- if(selectedLineAnnotArgs == null)
|
|
|
+ if (selectedLineAnnotArgs == null)
|
|
|
{
|
|
|
-
|
|
|
lineArgs.LineColor = Colors.Red;
|
|
|
lineArgs.HeadLineType = C_LINE_TYPE.LINETYPE_NONE;
|
|
|
if (TagStr == "Line")
|
|
@@ -576,8 +613,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
if (openFileDialog.ShowDialog() == true)
|
|
|
{
|
|
|
stampArgs.ImagePath = openFileDialog.FileName;
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
AddToPropertyPanel("ImageAnnotProperty", null, stampArgs, annotAttribsList);
|
|
@@ -591,7 +626,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
/// <param name="toolTag">导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线</param>
|
|
|
/// <param name="annot">注释</param>
|
|
|
/// <param name="annotAttribsList">更改注释属性的键值对,更改值后会自动记录undoRedo容器里</param>
|
|
|
- private void AddToPropertyPanel(string viewContent, string toolTag = null, AnnotHandlerEventArgs annot = null, Dictionary<AnnotAttrib, object> annotAttribsList = null)
|
|
|
+ private void AddToPropertyPanel(string viewContent, string toolTag = null, AnnotHandlerEventArgs annot = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(toolTag) == false)
|
|
|
{
|
|
@@ -605,16 +640,25 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
propertyPanel.annot = annot;
|
|
|
|
|
|
if (annotAttribsList != null)
|
|
|
- propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
|
|
|
+ {
|
|
|
+ if (annot is LinkAnnotArgs && annotAttribEvent != null)
|
|
|
+ {
|
|
|
+ propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
|
|
|
+ if (annotAttribEvent.IsAnnotCreateReset)
|
|
|
+ {
|
|
|
+ propertyPanel.AnnotEvent.IsAnnotCreateReset = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if (string.IsNullOrEmpty(viewContent) == false)
|
|
|
viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- #endregion
|
|
|
-
|
|
|
-
|
|
|
+ #endregion 注释工具
|
|
|
}
|
|
|
-}
|
|
|
+}
|