|
@@ -23,6 +23,8 @@ using System.Windows.Controls;
|
|
|
using System.Windows.Controls.Primitives;
|
|
|
using System.Windows.Media;
|
|
|
using System.Diagnostics;
|
|
|
+using PDF_Office.Model.AnnotPanel;
|
|
|
+using System.Windows.Input;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
@@ -126,7 +128,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
PDFViewer.SnapshotCommandHandler -= PDFViewer_SnapshotCommandHandler;
|
|
|
PDFViewer.PDFActionHandler -= PDFViewer_PDFActionHandler;
|
|
|
PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -149,6 +150,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//是否为高亮注释
|
|
|
private bool isHightAnnot(AnnotHandlerEventArgs annot)
|
|
|
{
|
|
@@ -165,7 +167,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void GetSelectedAnnots(AnnotAttribEvent e)
|
|
|
{
|
|
|
var annot = e.AnnotItemsList[0];
|
|
@@ -229,8 +231,8 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
|
|
|
case AnnotArgsType.AnnotLink:
|
|
|
//viewContentViewModel.IsCreateLink = false;
|
|
|
+ //e.IsAnnotCreateReset= true;
|
|
|
GetLink(e.AnnotItemsList, e);
|
|
|
-
|
|
|
break;
|
|
|
|
|
|
case AnnotArgsType.AnnotSticky:
|
|
@@ -245,7 +247,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
+ #endregion 与触发事件调用相关的函数
|
|
|
|
|
|
#region PDFViewer事件
|
|
|
|
|
@@ -287,7 +289,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
if (ToolExpandDict.ContainsValue(e.AnnotItemsList[0].EventType))
|
|
|
{
|
|
|
var strLineAnnotTag = "";
|
|
|
- if(e.AnnotItemsList[0] is LineAnnotArgs)
|
|
|
+ if (e.AnnotItemsList[0] is LineAnnotArgs)
|
|
|
{
|
|
|
var lineAnnot = e.AnnotItemsList[0] as LineAnnotArgs;
|
|
|
if (lineAnnot.HeadLineType == C_LINE_TYPE.LINETYPE_NONE && lineAnnot.TailLineType == C_LINE_TYPE.LINETYPE_NONE)
|
|
@@ -305,27 +307,26 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
if (item.Value == e.AnnotItemsList[0].EventType)
|
|
|
{
|
|
|
annot = null;//新建注释时,回到默认值
|
|
|
- if(string.IsNullOrEmpty(strLineAnnotTag))
|
|
|
+ if (string.IsNullOrEmpty(strLineAnnotTag))
|
|
|
{
|
|
|
FindAnnotTypeKey(item.Key, ref annot);
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(strLineAnnotTag == item.Key)
|
|
|
+ if (strLineAnnotTag == item.Key)
|
|
|
{
|
|
|
FindAnnotTypeKey(item.Key, ref annot);
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//else
|
|
|
PDFViewer.SetToolParam(annot);
|
|
|
+
|
|
|
#region TO DO
|
|
|
|
|
|
//设计重新调整,阅读页空白处,右键菜单,添加链接需要显示,其他和pro mac一样的效果,不显示属性栏
|
|
@@ -394,20 +395,23 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
|
if (BtnLinkIsChecked == false)
|
|
|
{
|
|
|
- if (PDFViewer.MouseMode != MouseModes.AnnotCreate && PDFViewer.MouseMode != MouseModes.PanTool)
|
|
|
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
|
|
|
+ if (PDFViewer.MouseMode != MouseModes.AnnotCreate)
|
|
|
+ {
|
|
|
+ if (PDFViewer.MouseMode == MouseModes.PanTool && propertyPanel.IsAddLink == false && propertyPanel.IsLocationLink == false)
|
|
|
+ {
|
|
|
+ viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//在注释工具的状态下,右键菜单
|
|
|
private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
|
|
|
{
|
|
|
if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
|
|
|
return;
|
|
|
-
|
|
|
+
|
|
|
switch (e.CommandType)
|
|
|
{
|
|
|
case CommandType.Context:
|
|
@@ -423,12 +427,22 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
if (e.AnnotEventArgsList.Count == 1)
|
|
|
{
|
|
|
var selectedAnnot = e.AnnotEventArgsList[0];
|
|
|
+ PopMenuCheckedLineDash(selectedAnnot);
|
|
|
switch (selectedAnnot.EventType)
|
|
|
{
|
|
|
case AnnotArgsType.AnnotHighlight:
|
|
|
case AnnotArgsType.AnnotUnderline:
|
|
|
case AnnotArgsType.AnnotStrikeout:
|
|
|
case AnnotArgsType.AnnotSquiggly:
|
|
|
+ if (selectedAnnot.EventType == AnnotArgsType.AnnotHighlight)
|
|
|
+ {
|
|
|
+ colorContent.ItemSource = AnnotColorList.GetHighlightColorList();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ colorContent.ItemSource = AnnotColorList.GetBorderColorList();
|
|
|
+ }
|
|
|
+
|
|
|
e.PopupMenu = HightAnnotPopMenu.OpenMenu(selectedAnnot, sender);
|
|
|
break;
|
|
|
|
|
@@ -463,6 +477,8 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
e.PopupMenu = StampAnnotPopMenu.OpenMenu(selectedAnnot, sender);
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -510,6 +526,39 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //右键菜单,选中虚实线按钮状态
|
|
|
+ private void PopMenuCheckedLineDash(AnnotHandlerEventArgs annot)
|
|
|
+ {
|
|
|
+ if(annot != null)
|
|
|
+ {
|
|
|
+ bool isSolidLineDash = true;
|
|
|
+ if (annot.EventType == AnnotArgsType.AnnotFreehand)
|
|
|
+ {
|
|
|
+ var freeHand = annot as FreehandAnnotArgs;
|
|
|
+ isSolidLineDash = AnnotPropertyPanel.IsSolidStyle(freeHand.LineDash);
|
|
|
+ FreeHandAnnotPopMenu.SetIsChecked(isSolidLineDash ? "FreeHandSolid" : "FreeHandDash", true);
|
|
|
+ }
|
|
|
+ else if(annot.EventType == AnnotArgsType.AnnotSquare)
|
|
|
+ {
|
|
|
+ var square = annot as SquareAnnotArgs;
|
|
|
+ isSolidLineDash = AnnotPropertyPanel.IsSolidStyle(square.LineDash);
|
|
|
+ ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
|
|
|
+ }
|
|
|
+ else if (annot.EventType == AnnotArgsType.AnnotCircle)
|
|
|
+ {
|
|
|
+ var circle = annot as CircleAnnotArgs;
|
|
|
+ isSolidLineDash = AnnotPropertyPanel.IsSolidStyle(circle.LineDash);
|
|
|
+ ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
|
|
|
+ }
|
|
|
+ else if (annot.EventType == AnnotArgsType.AnnotLine)
|
|
|
+ {
|
|
|
+ var line = annot as LineAnnotArgs;
|
|
|
+ isSolidLineDash = AnnotPropertyPanel.IsSolidStyle(line.LineDash);
|
|
|
+ ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 内容选择工具
|
|
|
/// </summary>
|
|
@@ -660,7 +709,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
PDFViewer.SelectAnnotation(annot.PageIndex, annot.AnnotIndex);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
break;
|
|
|
|
|
|
case ActionType.Del:
|
|
@@ -720,11 +768,71 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
hoverPen.DashStyle = DashStyles.Dash;
|
|
|
e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
|
|
|
|
|
|
-
|
|
|
+ //Todo:目前ComPDFKit.Viewer没有e.Annot参数
|
|
|
+ //便签,显示ToolTip内容
|
|
|
+ //if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
|
|
|
+ //{
|
|
|
+ // if (PDFViewer.ToolTip == null)
|
|
|
+ // {
|
|
|
+ // var content = e.Annot.GetContent();
|
|
|
+ // if (string.IsNullOrEmpty(content) == false)
|
|
|
+ // {
|
|
|
+ // ToolTip TipChild = new ToolTip();
|
|
|
+ // TipChild.Style = App.Current.Resources["FlowToolTip"] as Style;
|
|
|
+ // TipChild.MaxWidth = 246;
|
|
|
+ // TipChild.Content = content;
|
|
|
+ // TipChild.Visibility = Visibility.Visible;
|
|
|
+ // TipChild.IsOpen = true;
|
|
|
+ // TipChild.Placement = PlacementMode.Right;
|
|
|
+ // var rec = e.Annot.GetRect();
|
|
|
+ // TipChild.PlacementRectangle = new Rect(rec.left, rec.top, rec.right, rec.bottom);
|
|
|
+ // TipChild.PlacementTarget = PDFViewer.Parent as ContentControl;
|
|
|
+ // TipChild.Placement = PlacementMode.MousePoint;
|
|
|
+ // PDFViewer.ToolTip = TipChild;
|
|
|
+ // oldRect = hoverRect;
|
|
|
+ // PDFViewer.MouseMove -= PDFViewer_MouseMove;
|
|
|
+ // PDFViewer.MouseMove += PDFViewer_MouseMove;
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+ //}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ CloseAnnotToolTip();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ Rect oldRect = new Rect(0, 0, 0, 0);
|
|
|
+ private void CloseAnnotToolTip()
|
|
|
+ {
|
|
|
+ if (PDFViewer.ToolTip != null && PDFViewer.ToolTip is ToolTip)
|
|
|
+ {
|
|
|
+ ToolTip oldTips = (ToolTip)PDFViewer.ToolTip;
|
|
|
+ oldTips.IsOpen = false;
|
|
|
+ oldTips.Visibility = Visibility.Collapsed;
|
|
|
+ PDFViewer.ToolTip = null;
|
|
|
+ PDFViewer.MouseMove -= PDFViewer_MouseMove;
|
|
|
+ oldRect = new Rect(0, 0, 0, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void PDFViewer_MouseMove(object sender, MouseEventArgs e)
|
|
|
+ {
|
|
|
+ if (sender != null && PDFViewer.ToolTip != null && PDFViewer.Parent != null)
|
|
|
+ {
|
|
|
+ var newPoint = e.GetPosition(PDFViewer.Parent as ContentControl);
|
|
|
+ var isOutw = newPoint.X > (oldRect.X + oldRect.Width + 4);
|
|
|
+ var isOuth = newPoint.Y > (oldRect.Y + oldRect.Height + 4);
|
|
|
+ if (newPoint.X < oldRect.X || newPoint.Y < oldRect.Y || isOutw || isOuth)
|
|
|
+ {
|
|
|
+ CloseAnnotToolTip();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
#endregion PDFViewer事件
|
|
|
|
|
|
#region BindingEvent事件
|
|
@@ -819,8 +927,8 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
break;
|
|
|
|
|
|
case AnnotArgsType.AnnotFreehand:
|
|
|
-
|
|
|
- if(e[argsType] is FreehandAnnotArgs)
|
|
|
+
|
|
|
+ if (e[argsType] is FreehandAnnotArgs)
|
|
|
{
|
|
|
var annot = e[argsType] as FreehandAnnotArgs;
|
|
|
if (annot != null)
|
|
@@ -835,8 +943,8 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
propertyPanel.AnnotEvents = AnnotEvents;
|
|
|
propertyPanel.annot = annot;
|
|
|
//手绘注释工具按钮的属性
|
|
|
- // FreehandPath.Opacity = annot.Transparency;
|
|
|
- // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
|
|
|
+ // FreehandPath.Opacity = annot.Transparency;
|
|
|
+ // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
|
|
|
}
|
|
|
PDFViewer.SetToolParam(annot);
|
|
|
}
|