Skip to content

Commit 7dea478

Browse files
v2.2.0 - Update
1 parent 1bdc059 commit 7dea478

File tree

322 files changed

+10309
-3767
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

322 files changed

+10309
-3767
lines changed

ComPDFKit for Windows/Examples/Annotations/Annotations.csproj

+6-7
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
<ApplicationIcon>ComPDFKit_Logo.ico</ApplicationIcon>
4242
</PropertyGroup>
4343
<ItemGroup>
44-
<Reference Include="ComPDFKit.NET, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
45-
<HintPath>..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll</HintPath>
44+
<Reference Include="ComPDFKit.NET, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
45+
<HintPath>..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll</HintPath>
4646
</Reference>
47-
<Reference Include="ComPDFKit.Viewer, Version=2.1.3.0, Culture=neutral, processorArchitecture=MSIL">
48-
<HintPath>..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll</HintPath>
47+
<Reference Include="ComPDFKit.Viewer, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
48+
<HintPath>..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll</HintPath>
4949
</Reference>
5050
<Reference Include="PresentationFramework.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5151
<HintPath>..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll</HintPath>
@@ -93,7 +93,6 @@
9393
<EmbeddedResource Include="Properties\Resources.resx">
9494
<Generator>ResXFileCodeGenerator</Generator>
9595
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
96-
<SubType>Designer</SubType>
9796
</EmbeddedResource>
9897
</ItemGroup>
9998
<ItemGroup>
@@ -124,11 +123,11 @@
124123
</Content>
125124
</ItemGroup>
126125
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
127-
<Import Project="..\packages\ComPDFKit.NetFramework.2.1.3\build\ComPDFKit.NetFramework.targets" Condition="Exists('..\packages\ComPDFKit.NetFramework.2.1.3\build\ComPDFKit.NetFramework.targets')" />
126+
<Import Project="..\packages\ComPDFKit.NetFramework.2.2.0\build\ComPDFKit.NetFramework.targets" Condition="Exists('..\packages\ComPDFKit.NetFramework.2.2.0\build\ComPDFKit.NetFramework.targets')" />
128127
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
129128
<PropertyGroup>
130129
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
131130
</PropertyGroup>
132-
<Error Condition="!Exists('..\packages\ComPDFKit.NetFramework.2.1.3\build\ComPDFKit.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\ComPDFKit.NetFramework.2.1.3\build\ComPDFKit.NetFramework.targets'))" />
131+
<Error Condition="!Exists('..\packages\ComPDFKit.NetFramework.2.2.0\build\ComPDFKit.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\ComPDFKit.NetFramework.2.2.0\build\ComPDFKit.NetFramework.targets'))" />
133132
</Target>
134133
</Project>

ComPDFKit for Windows/Examples/Annotations/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("2.1.3.0")]
55-
[assembly: AssemblyFileVersion("2.1.3.0")]
54+
[assembly: AssemblyVersion("2.2.0.0")]
55+
[assembly: AssemblyFileVersion("2.2.0.0")]
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="ComPDFKit.NetFramework" version="2.1.3" targetFramework="net461" />
3+
<package id="ComPDFKit.NetFramework" version="2.2.0" targetFramework="net461" />
44
<package id="PresentationFramework.Aero2" version="1.0.1" targetFramework="net461" />
55
</packages>

ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFToolManager.cs

+218-78
Large diffs are not rendered by default.

ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Annot.cs

+55-31
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
using System;
1111
using System.Collections.Generic;
1212
using System.Linq;
13-
using System.Text;
14-
using System.Threading.Tasks;
1513
using System.Windows.Input;
1614
using System.Windows;
1715
using ComPDFKit.Import;
@@ -20,12 +18,9 @@
2018
using System.Windows.Media;
2119
using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
2220
using ComPDFKitViewer.Helper;
23-
using Microsoft.SqlServer.Server;
2421
using ComPDFKit.Tool.Help;
25-
using System.Xml.Linq;
2622
using ComPDFKit.Tool.SettingParam;
2723
using ComPDFKit.Tool.UndoManger;
28-
using System.Windows.Controls.Primitives;
2924
using ComPDFKit.Measure;
3025
using 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

ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.AnnotEdit.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public partial class CPDFViewerTool
1515
public event EventHandler<SelectedAnnotData> AnnotEditDataChanging;
1616
public event EventHandler<SelectedAnnotData> AnnotEditDataChanged;
1717
public event EventHandler<object> AnnotChanged;
18+
1819
private void InsertAnnotEditView()
1920
{
2021
int selectedRectViewIndex = PDFViewer.GetMaxViewIndex();
@@ -74,22 +75,23 @@ public void DrawEndEditAnnot()
7475
AnnotEdit annotEdit = CommonHelper.FindVisualChild<AnnotEdit>(baseLayer as CustomizeLayer);
7576
if (annotEdit != null)
7677
{
77-
annotEdit.Draw();
7878
annotEdit.OnMouseLeftButtonUp(point);
79+
annotEdit.Draw();
7980
}
8081
}
8182

82-
public void CleanEditAnnot()
83+
public void CleanEditAnnot(bool isDrawEditAnnot = false)
8384
{
8485
Point point = Mouse.GetPosition(this);
8586
BaseLayer baseLayer = PDFViewer.GetViewForTag(annotEditViewTag);
8687
AnnotEdit annotEdit = CommonHelper.FindVisualChild<AnnotEdit>(baseLayer as CustomizeLayer);
8788
if (annotEdit != null)
8889
{
8990
annotEdit.ClearDraw();
90-
IsDrawEditAnnot = false;
91+
IsDrawEditAnnot = isDrawEditAnnot;
9192
}
9293
}
94+
9395

9496
private void DrawEditAnnotLayer()
9597
{
@@ -108,7 +110,6 @@ private void DrawEditAnnotLayer()
108110
private bool DrawEditAnnotDownEvent()
109111
{
110112
BaseLayer baseLayer = PDFViewer.GetViewForTag(annotEditViewTag);
111-
112113
AnnotEdit selectedRect = CommonHelper.FindVisualChild<AnnotEdit>(baseLayer as CustomizeLayer);
113114
if (selectedRect != null)
114115
{

0 commit comments

Comments
 (0)