1010using System ;
1111using System . Collections . Generic ;
1212using System . Linq ;
13- using System . Text ;
14- using System . Threading . Tasks ;
1513using System . Windows . Input ;
1614using System . Windows ;
1715using ComPDFKit . Import ;
2018using System . Windows . Media ;
2119using static ComPDFKit . PDFAnnotation . CTextAttribute . CFontNameHelper ;
2220using ComPDFKitViewer . Helper ;
23- using Microsoft . SqlServer . Server ;
2421using ComPDFKit . Tool . Help ;
25- using System . Xml . Linq ;
2622using ComPDFKit . Tool . SettingParam ;
2723using ComPDFKit . Tool . UndoManger ;
28- using System . Windows . Controls . Primitives ;
2924using ComPDFKit . Measure ;
3025using System . Dynamic ;
3126
@@ -53,13 +48,14 @@ public partial class CPDFViewerTool
5348 BaseAnnot caheMoveAnnot ;
5449 BaseAnnot cacheHitTestAnnot ;
5550 bool isCacheRedaction = false ;
56- int createAnnotTag = - 1 ;
5751 int selectedPageIndex = - 1 ;
5852 int selectedAnnotIndex = - 1 ;
5953 bool canSave = true ;
6054 bool isHitTestLink = false ;
6155 bool isHitTestRedact = false ;
56+
6257 public event EventHandler < MeasureEventArgs > MeasureChanged ;
58+ internal int CreateAnnotTag { get ; private set ; } = - 1 ;
6359
6460 public void InvokeMeasureChangeEvent ( object sender , MeasureEventArgs e )
6561 {
@@ -135,11 +131,15 @@ protected bool AnnotHitTest()
135131 cacheHitTestAnnot = null ;
136132 return false ;
137133 }
134+
138135 cacheHitTestAnnot = baseAnnot ;
139136 return true ;
140137 }
141- cacheHitTestAnnot = baseAnnot ;
142- return false ;
138+ else
139+ {
140+ cacheHitTestAnnot = null ;
141+ return false ;
142+ }
143143 }
144144
145145 public void SelectedAnnotForIndex ( int pageIndex , int annotIndex )
@@ -166,7 +166,7 @@ private void InsertAnnotView()
166166 CreateAnnotTool createAnnotTool = new CreateAnnotTool ( GetMeasureSetting ( ) , GetDefaultDrawParam ( ) , GetDefaultSettingParam ( ) ) ;
167167 int annotViewindex = PDFViewer . GetMaxViewIndex ( ) ;
168168 PDFViewer . InsertView ( annotViewindex , createAnnotTool ) ;
169- createAnnotTag = createAnnotTool . GetResTag ( ) ;
169+ CreateAnnotTag = createAnnotTool . GetResTag ( ) ;
170170 createAnnotTool . UpdateAnnotHandler += CreateAnnotTool_UpdateAnnotHandler ;
171171 createAnnotTool . CreateFreetextCanceled += CreateAnnotTool_CreateFreetextCanceled ;
172172 createAnnotTool . MeasureChanged += CreateAnnotTool_MeasureChanged ;
@@ -206,7 +206,7 @@ public void SetAnnotIsProportionalScaling(bool isProportionalScaling)
206206 {
207207 return ;
208208 }
209- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
209+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
210210 ( baseLayer as CreateAnnotTool ) . SetIsProportionalScaling ( isProportionalScaling ) ;
211211 }
212212
@@ -216,7 +216,7 @@ public double GetMoveLength()
216216 {
217217 return 0 ;
218218 }
219- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
219+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
220220 return ( baseLayer as CreateAnnotTool ) . GetMoveLength ( ) ;
221221 }
222222
@@ -228,7 +228,7 @@ public CPDFAnnotation StartDrawAnnot(C_ANNOTATION_TYPE annotType)
228228 }
229229
230230 Point point = Mouse . GetPosition ( this ) ;
231- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
231+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
232232 PDFViewer . GetPointPageInfo ( point , out int index , out Rect paintRect , out Rect pageBound ) ;
233233 if ( index < 0 )
234234 {
@@ -240,7 +240,7 @@ public CPDFAnnotation StartDrawAnnot(C_ANNOTATION_TYPE annotType)
240240 {
241241 DefaultSettingParam defaultSettingParam = GetDefaultSettingParam ( ) ;
242242 StampParam stampParam = defaultSettingParam . StampParamDef ;
243- stampParam . Rotation = cPDFPage . Rotation ;
243+ stampParam . PageRotation = cPDFPage . Rotation ;
244244 defaultSettingParam . SetAnnotParam ( stampParam ) ;
245245 }
246246 Point cropPoint = new Point ( ) ;
@@ -271,7 +271,7 @@ public void MultipleClick()
271271 return ;
272272 }
273273 Point point = Mouse . GetPosition ( this ) ;
274- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
274+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
275275 PDFViewer . GetPointPageInfo ( point , out int index , out Rect paintRect , out Rect pageBound ) ;
276276 if ( index < 0 )
277277 {
@@ -309,7 +309,7 @@ public void MoveDrawAnnot()
309309 return ;
310310 }
311311 Point point = Mouse . GetPosition ( this ) ;
312- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
312+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
313313 ( baseLayer as CreateAnnotTool ) . MoveDraw ( point , PDFViewer . GetZoom ( ) ) ;
314314 }
315315
@@ -320,8 +320,8 @@ public void CreateTextBox()
320320 return ;
321321 }
322322 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 ( ) ;
325325 }
326326
327327 public Rect EndDrawAnnot ( )
@@ -330,7 +330,7 @@ public Rect EndDrawAnnot()
330330 {
331331 return new Rect ( ) ;
332332 }
333- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
333+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
334334 return ( baseLayer as CreateAnnotTool ) . EndDraw ( ) ;
335335 }
336336
@@ -415,7 +415,7 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION
415415 List < CRect > coreRectList = new List < CRect > ( ) ;
416416 foreach ( Rect copyRect in pageSelectRectList )
417417 {
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 ) ) ;
419419 }
420420 CreateDefaultAnnot ( annotCore , annotType , null ) ;
421421 string markupContent = textSelectInfo . PageSelectText [ pageIndex ] ;
@@ -510,6 +510,17 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION
510510 historyGroup . Histories . Add ( redactHistory ) ;
511511 }
512512 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 ;
513524 default :
514525 break ;
515526 }
@@ -528,25 +539,25 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION
528539
529540 public Point GetStartPoint ( )
530541 {
531- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
542+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
532543 return ( baseLayer as CreateAnnotTool ) . GetStartPoint ( ) ;
533544 }
534545
535546 public Point GetEndPoint ( )
536547 {
537- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
548+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
538549 return ( baseLayer as CreateAnnotTool ) . GetEndPoint ( ) ;
539550 }
540551
541552 public List < Point > GetInkDrawPoints ( )
542553 {
543- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
554+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
544555 return ( baseLayer as CreateAnnotTool ) . GetInkDrawPoints ( ) ;
545556 }
546557
547558 public List < Point > GetMeasureDrawPoints ( )
548559 {
549- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
560+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
550561 return ( baseLayer as CreateAnnotTool ) . GetMeasureDrawPoints ( ) ;
551562 }
552563
@@ -557,7 +568,7 @@ public Rect GetDrawAnnotMaxRect()
557568 return new Rect ( ) ;
558569 }
559570 Point point = Mouse . GetPosition ( this ) ;
560- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
571+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
561572 return ( baseLayer as CreateAnnotTool ) . GetMaxRect ( ) ;
562573 }
563574
@@ -568,7 +579,7 @@ public void ClearDrawAnnot()
568579 return ;
569580 }
570581 Point point = Mouse . GetPosition ( this ) ;
571- BaseLayer baseLayer = PDFViewer . GetViewForTag ( createAnnotTag ) ;
582+ BaseLayer baseLayer = PDFViewer . GetViewForTag ( CreateAnnotTag ) ;
572583 ( baseLayer as CreateAnnotTool ) . ClearDraw ( ) ;
573584 }
574585
@@ -589,7 +600,7 @@ protected void UpdateTextPop()
589600 {
590601 return ;
591602 }
592- AnnotData annotData = currentAnnot . GetAnnotData ( ) ;
603+ AnnotData annotData = currentAnnot . GetAnnotData ( ) ;
593604
594605 if ( annotData . PaintRect == Rect . Empty )
595606 {
@@ -629,7 +640,7 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)
629640 double Height = DpiHelper . PDFNumToStandardNum ( drawRect . height ( ) ) ;
630641 textui = new TextBox ( ) ;
631642 textui . Name = "PdfViewerTextBox" ;
632- textBorder = new Border ( ) ;
643+ textBorder = new DashedBorder ( ) ;
633644 textBorder . Child = textui ;
634645 textBorder . MinWidth = Width * PDFViewer . GetZoom ( ) ;
635646 textBorder . MinHeight = Height * PDFViewer . GetZoom ( ) ;
@@ -667,9 +678,22 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)
667678
668679 textBorder . Padding = new Thickness ( 0 ) ;
669680 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 ) ;
671684 textui . BorderThickness = new Thickness ( 0 ) ;
672685 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+ }
673697
674698 string fontName = string . Empty ;
675699 string fontFamily = string . Empty ;
@@ -783,10 +807,10 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)
783807 viewer . UpdateAnnotFrame ( ) ;
784808 }
785809 RemovePopTextUI ( ) ;
786- }
810+ }
787811 } ;
788812
789- BaseLayer createAnnotTool = PDFViewer ? . GetView ( createAnnotTag ) as CreateAnnotTool ;
813+ BaseLayer createAnnotTool = PDFViewer ? . GetView ( CreateAnnotTag ) as CreateAnnotTool ;
790814 if ( createAnnotTool != null )
791815 {
792816 createAnnotTool . Children . Add ( textBorder ) ;
@@ -907,7 +931,7 @@ public void RemovePopTextUI()
907931 {
908932 return ;
909933 }
910- BaseLayer removeLayer = PDFViewer ? . GetView ( createAnnotTag ) as CreateAnnotTool ;
934+ BaseLayer removeLayer = PDFViewer ? . GetView ( CreateAnnotTag ) as CreateAnnotTool ;
911935 removeLayer . Children . Remove ( textBorder ) ;
912936 }
913937
0 commit comments