|
@@ -26,6 +26,7 @@ using System.Diagnostics;
|
|
|
using PDF_Office.Model.AnnotPanel;
|
|
|
using System.Windows.Input;
|
|
|
using PDF_Office.ViewModels.Tools.AnnotManager;
|
|
|
+using ComPDFKit.Import;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
@@ -100,7 +101,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
|
|
|
#region 与触发事件调用相关的函数
|
|
|
|
|
|
-
|
|
|
//鼠标左键双击注释
|
|
|
private void PDFViewer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
@@ -869,7 +869,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private void PDFViewer_AnnotHoverHandler(object sender, AnnotHoverData e)
|
|
|
{
|
|
|
if (e != null && e.DrawContext != null)
|
|
@@ -883,43 +882,58 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
hoverPen.DashStyle = DashStyles.Dash;
|
|
|
e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
|
|
|
|
|
|
-
|
|
|
//便签,显示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;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ PopAnnotToolTip(e.Annot.GetRect(), hoverRect, e.Annot.GetContent());
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
CloseAnnotToolTip();
|
|
|
}
|
|
|
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private Rect oldRect = new Rect(0, 0, 0, 0);
|
|
|
+ private void PopAnnotToolTip(CRect placementRect, Rect hoverRect, string content)
|
|
|
+ {
|
|
|
+ //便签,显示ToolTip内容
|
|
|
+ if (PDFViewer.ToolTip == null)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ TipChild.PlacementRectangle = new Rect(placementRect.left, placementRect.top, placementRect.right, placementRect.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;
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
private void CloseAnnotToolTip()
|
|
|
{
|
|
|
if (PDFViewer.ToolTip != null && PDFViewer.ToolTip is ToolTip)
|
|
@@ -933,28 +947,10 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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事件
|
|
|
|
|
|
- private void AnnotProperty_DefaultStored(object sender, object e)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
//同一属性面板,不同的注释类型
|
|
|
private void AnnotPropertyPanel_AnnotTypeChanged(object sender, Dictionary<AnnotArgsType, object> e)
|
|
|
{
|