10
10
using System ;
11
11
using System . Collections . Generic ;
12
12
using System . Linq ;
13
- using System . Text ;
14
- using System . Threading . Tasks ;
15
13
using System . Windows . Input ;
16
14
using System . Windows ;
17
15
using ComPDFKit . Import ;
20
18
using System . Windows . Media ;
21
19
using static ComPDFKit . PDFAnnotation . CTextAttribute . CFontNameHelper ;
22
20
using ComPDFKitViewer . Helper ;
23
- using Microsoft . SqlServer . Server ;
24
21
using ComPDFKit . Tool . Help ;
25
- using System . Xml . Linq ;
26
22
using ComPDFKit . Tool . SettingParam ;
27
23
using ComPDFKit . Tool . UndoManger ;
28
- using System . Windows . Controls . Primitives ;
29
24
using ComPDFKit . Measure ;
30
25
using System . Dynamic ;
31
26
@@ -53,13 +48,14 @@ public partial class CPDFViewerTool
53
48
BaseAnnot caheMoveAnnot ;
54
49
BaseAnnot cacheHitTestAnnot ;
55
50
bool isCacheRedaction = false ;
56
- int createAnnotTag = - 1 ;
57
51
int selectedPageIndex = - 1 ;
58
52
int selectedAnnotIndex = - 1 ;
59
53
bool canSave = true ;
60
54
bool isHitTestLink = false ;
61
55
bool isHitTestRedact = false ;
56
+
62
57
public event EventHandler < MeasureEventArgs > MeasureChanged ;
58
+ internal int CreateAnnotTag { get ; private set ; } = - 1 ;
63
59
64
60
public void InvokeMeasureChangeEvent ( object sender , MeasureEventArgs e )
65
61
{
@@ -135,11 +131,15 @@ protected bool AnnotHitTest()
135
131
cacheHitTestAnnot = null ;
136
132
return false ;
137
133
}
134
+
138
135
cacheHitTestAnnot = baseAnnot ;
139
136
return true ;
140
137
}
141
- cacheHitTestAnnot = baseAnnot ;
142
- return false ;
138
+ else
139
+ {
140
+ cacheHitTestAnnot = null ;
141
+ return false ;
142
+ }
143
143
}
144
144
145
145
public void SelectedAnnotForIndex ( int pageIndex , int annotIndex )
@@ -166,7 +166,7 @@ private void InsertAnnotView()
166
166
CreateAnnotTool createAnnotTool = new CreateAnnotTool ( GetMeasureSetting ( ) , GetDefaultDrawParam ( ) , GetDefaultSettingParam ( ) ) ;
167
167
int annotViewindex = PDFViewer . GetMaxViewIndex ( ) ;
168
168
PDFViewer . InsertView ( annotViewindex , createAnnotTool ) ;
169
- createAnnotTag = createAnnotTool . GetResTag ( ) ;
169
+ CreateAnnotTag = createAnnotTool . GetResTag ( ) ;
170
170
createAnnotTool . UpdateAnnotHandler += CreateAnnotTool_UpdateAnnotHandler ;
171
171
createAnnotTool . CreateFreetextCanceled += CreateAnnotTool_CreateFreetextCanceled ;
172
172
createAnnotTool . MeasureChanged += CreateAnnotTool_MeasureChanged ;
@@ -206,7 +206,7 @@ public void SetAnnotIsProportionalScaling(bool isProportionalScaling)
206
206
{
207
207
return ;
208
208
}
209
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
209
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
210
210
( baseLayer as CreateAnnotTool ) . SetIsProportionalScaling ( isProportionalScaling ) ;
211
211
}
212
212
@@ -216,7 +216,7 @@ public double GetMoveLength()
216
216
{
217
217
return 0 ;
218
218
}
219
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
219
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
220
220
return ( baseLayer as CreateAnnotTool ) . GetMoveLength ( ) ;
221
221
}
222
222
@@ -228,7 +228,7 @@ public CPDFAnnotation StartDrawAnnot(C_ANNOTATION_TYPE annotType)
228
228
}
229
229
230
230
Point point = Mouse . GetPosition ( this ) ;
231
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
231
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
232
232
PDFViewer . GetPointPageInfo ( point , out int index , out Rect paintRect , out Rect pageBound ) ;
233
233
if ( index < 0 )
234
234
{
@@ -240,7 +240,7 @@ public CPDFAnnotation StartDrawAnnot(C_ANNOTATION_TYPE annotType)
240
240
{
241
241
DefaultSettingParam defaultSettingParam = GetDefaultSettingParam ( ) ;
242
242
StampParam stampParam = defaultSettingParam . StampParamDef ;
243
- stampParam . Rotation = cPDFPage . Rotation ;
243
+ stampParam . PageRotation = cPDFPage . Rotation ;
244
244
defaultSettingParam . SetAnnotParam ( stampParam ) ;
245
245
}
246
246
Point cropPoint = new Point ( ) ;
@@ -271,7 +271,7 @@ public void MultipleClick()
271
271
return ;
272
272
}
273
273
Point point = Mouse . GetPosition ( this ) ;
274
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
274
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
275
275
PDFViewer . GetPointPageInfo ( point , out int index , out Rect paintRect , out Rect pageBound ) ;
276
276
if ( index < 0 )
277
277
{
@@ -309,7 +309,7 @@ public void MoveDrawAnnot()
309
309
return ;
310
310
}
311
311
Point point = Mouse . GetPosition ( this ) ;
312
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
312
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
313
313
( baseLayer as CreateAnnotTool ) . MoveDraw ( point , PDFViewer . GetZoom ( ) ) ;
314
314
}
315
315
@@ -320,8 +320,8 @@ public void CreateTextBox()
320
320
return ;
321
321
}
322
322
Point point = Mouse . GetPosition ( this ) ;
323
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
324
- ( baseLayer as CreateAnnotTool ) . CreateTextBox ( ) ;
323
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
324
+ ( baseLayer as CreateAnnotTool ) . CreateTextBox ( ) ;
325
325
}
326
326
327
327
public Rect EndDrawAnnot ( )
@@ -330,7 +330,7 @@ public Rect EndDrawAnnot()
330
330
{
331
331
return new Rect ( ) ;
332
332
}
333
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
333
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
334
334
return ( baseLayer as CreateAnnotTool ) . EndDraw ( ) ;
335
335
}
336
336
@@ -415,7 +415,7 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION
415
415
List < CRect > coreRectList = new List < CRect > ( ) ;
416
416
foreach ( Rect copyRect in pageSelectRectList )
417
417
{
418
- coreRectList . Add ( new CRect ( ( float ) copyRect . Left , ( float ) copyRect . Top , ( float ) copyRect . Right , ( float ) copyRect . Bottom ) ) ;
418
+ coreRectList . Add ( new CRect ( ( float ) copyRect . Left , ( float ) copyRect . Bottom , ( float ) copyRect . Right , ( float ) copyRect . Top ) ) ;
419
419
}
420
420
CreateDefaultAnnot ( annotCore , annotType , null ) ;
421
421
string markupContent = textSelectInfo . PageSelectText [ pageIndex ] ;
@@ -510,6 +510,17 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION
510
510
historyGroup . Histories . Add ( redactHistory ) ;
511
511
}
512
512
break ;
513
+ case C_ANNOTATION_TYPE . C_ANNOTATION_LINK :
514
+ {
515
+ LinkAnnotHistory linkHistory = new LinkAnnotHistory ( ) ;
516
+ AnnotParam annotParam = ParamConverter . AnnotConverter ( cPDFDocument , annotCore ) ;
517
+ linkHistory . Action = HistoryAction . Add ;
518
+ linkHistory . CurrentParam = ( LinkParam ) annotParam ;
519
+ linkHistory . PDFDoc = cPDFDocument ;
520
+ linkHistory . Action = HistoryAction . Add ;
521
+ historyGroup . Histories . Add ( linkHistory ) ;
522
+ }
523
+ break ;
513
524
default :
514
525
break ;
515
526
}
@@ -528,25 +539,25 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION
528
539
529
540
public Point GetStartPoint ( )
530
541
{
531
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
542
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
532
543
return ( baseLayer as CreateAnnotTool ) . GetStartPoint ( ) ;
533
544
}
534
545
535
546
public Point GetEndPoint ( )
536
547
{
537
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
548
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
538
549
return ( baseLayer as CreateAnnotTool ) . GetEndPoint ( ) ;
539
550
}
540
551
541
552
public List < Point > GetInkDrawPoints ( )
542
553
{
543
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
554
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
544
555
return ( baseLayer as CreateAnnotTool ) . GetInkDrawPoints ( ) ;
545
556
}
546
557
547
558
public List < Point > GetMeasureDrawPoints ( )
548
559
{
549
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
560
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
550
561
return ( baseLayer as CreateAnnotTool ) . GetMeasureDrawPoints ( ) ;
551
562
}
552
563
@@ -557,7 +568,7 @@ public Rect GetDrawAnnotMaxRect()
557
568
return new Rect ( ) ;
558
569
}
559
570
Point point = Mouse . GetPosition ( this ) ;
560
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
571
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
561
572
return ( baseLayer as CreateAnnotTool ) . GetMaxRect ( ) ;
562
573
}
563
574
@@ -568,7 +579,7 @@ public void ClearDrawAnnot()
568
579
return ;
569
580
}
570
581
Point point = Mouse . GetPosition ( this ) ;
571
- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
582
+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
572
583
( baseLayer as CreateAnnotTool ) . ClearDraw ( ) ;
573
584
}
574
585
@@ -589,7 +600,7 @@ protected void UpdateTextPop()
589
600
{
590
601
return ;
591
602
}
592
- AnnotData annotData = currentAnnot . GetAnnotData ( ) ;
603
+ AnnotData annotData = currentAnnot . GetAnnotData ( ) ;
593
604
594
605
if ( annotData . PaintRect == Rect . Empty )
595
606
{
@@ -629,7 +640,7 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)
629
640
double Height = DpiHelper . PDFNumToStandardNum ( drawRect . height ( ) ) ;
630
641
textui = new TextBox ( ) ;
631
642
textui . Name = "PdfViewerTextBox" ;
632
- textBorder = new Border ( ) ;
643
+ textBorder = new DashedBorder ( ) ;
633
644
textBorder . Child = textui ;
634
645
textBorder . MinWidth = Width * PDFViewer . GetZoom ( ) ;
635
646
textBorder . MinHeight = Height * PDFViewer . GetZoom ( ) ;
@@ -667,9 +678,22 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)
667
678
668
679
textBorder . Padding = new Thickness ( 0 ) ;
669
680
textBorder . BorderBrush = new SolidColorBrush ( borderColor ) ;
670
- textBorder . BorderThickness = new Thickness ( DpiHelper . PDFNumToStandardNum ( textWidget . GetBorderWidth ( ) * annotData . CurrentZoom ) ) ;
681
+ double rawWidth = textWidget . GetBorderWidth ( ) ;
682
+ double drawWidth = DpiHelper . PDFNumToStandardNum ( rawWidth * annotData . CurrentZoom ) ;
683
+ textBorder . BorderThickness = new Thickness ( drawWidth ) ;
671
684
textui . BorderThickness = new Thickness ( 0 ) ;
672
685
textui . Text = textWidget . Content ;
686
+ if ( textWidget . BorderStyle != C_BORDER_STYLE . BS_SOLID && textWidget . Dash != null && textWidget . Dash . Length > 0 )
687
+ {
688
+ //补充保存虚线样式
689
+ DashedBorder dashBorder = textBorder as DashedBorder ;
690
+ DoubleCollection dashCollection = new DoubleCollection ( ) ;
691
+ foreach ( float num in textWidget . Dash )
692
+ {
693
+ dashCollection . Add ( num ) ;
694
+ }
695
+ dashBorder ? . DrawDashBorder ( true , drawWidth , rawWidth , dashCollection ) ;
696
+ }
673
697
674
698
string fontName = string . Empty ;
675
699
string fontFamily = string . Empty ;
@@ -783,10 +807,10 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)
783
807
viewer . UpdateAnnotFrame ( ) ;
784
808
}
785
809
RemovePopTextUI ( ) ;
786
- }
810
+ }
787
811
} ;
788
812
789
- BaseLayer createAnnotTool = PDFViewer ? . GetView ( createAnnotTag ) as CreateAnnotTool ;
813
+ BaseLayer createAnnotTool = PDFViewer ? . GetView ( CreateAnnotTag ) as CreateAnnotTool ;
790
814
if ( createAnnotTool != null )
791
815
{
792
816
createAnnotTool . Children . Add ( textBorder ) ;
@@ -907,7 +931,7 @@ public void RemovePopTextUI()
907
931
{
908
932
return ;
909
933
}
910
- BaseLayer removeLayer = PDFViewer ? . GetView ( createAnnotTag ) as CreateAnnotTool ;
934
+ BaseLayer removeLayer = PDFViewer ? . GetView ( CreateAnnotTag ) as CreateAnnotTool ;
911
935
removeLayer . Children . Remove ( textBorder ) ;
912
936
}
913
937
0 commit comments