Skip to content

Commit

Permalink
v2.2.0 - Update
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou-kdan committed Dec 18, 2024
1 parent 1bdc059 commit 7dea478
Show file tree
Hide file tree
Showing 322 changed files with 10,309 additions and 3,767 deletions.
13 changes: 6 additions & 7 deletions ComPDFKit for Windows/Examples/Annotations/Annotations.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
<ApplicationIcon>ComPDFKit_Logo.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="ComPDFKit.NET, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll</HintPath>
<Reference Include="ComPDFKit.NET, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll</HintPath>
</Reference>
<Reference Include="ComPDFKit.Viewer, Version=2.1.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll</HintPath>
<Reference Include="ComPDFKit.Viewer, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll</HintPath>
Expand Down Expand Up @@ -93,7 +93,6 @@
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -124,11 +123,11 @@
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\ComPDFKit.NetFramework.2.1.3\build\ComPDFKit.NetFramework.targets" Condition="Exists('..\packages\ComPDFKit.NetFramework.2.1.3\build\ComPDFKit.NetFramework.targets')" />
<Import Project="..\packages\ComPDFKit.NetFramework.2.2.0\build\ComPDFKit.NetFramework.targets" Condition="Exists('..\packages\ComPDFKit.NetFramework.2.2.0\build\ComPDFKit.NetFramework.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<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>
</PropertyGroup>
<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'))" />
<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'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.3.0")]
[assembly: AssemblyFileVersion("2.1.3.0")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
2 changes: 1 addition & 1 deletion ComPDFKit for Windows/Examples/Annotations/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ComPDFKit.NetFramework" version="2.1.3" targetFramework="net461" />
<package id="ComPDFKit.NetFramework" version="2.2.0" targetFramework="net461" />
<package id="PresentationFramework.Aero2" version="1.0.1" targetFramework="net461" />
</packages>
296 changes: 218 additions & 78 deletions ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFToolManager.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows;
using ComPDFKit.Import;
Expand All @@ -20,12 +18,9 @@
using System.Windows.Media;
using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
using ComPDFKitViewer.Helper;
using Microsoft.SqlServer.Server;
using ComPDFKit.Tool.Help;
using System.Xml.Linq;
using ComPDFKit.Tool.SettingParam;
using ComPDFKit.Tool.UndoManger;
using System.Windows.Controls.Primitives;
using ComPDFKit.Measure;
using System.Dynamic;

Expand Down Expand Up @@ -53,13 +48,14 @@ public partial class CPDFViewerTool
BaseAnnot caheMoveAnnot;
BaseAnnot cacheHitTestAnnot;
bool isCacheRedaction = false;
int createAnnotTag = -1;
int selectedPageIndex = -1;
int selectedAnnotIndex = -1;
bool canSave = true;
bool isHitTestLink = false;
bool isHitTestRedact = false;

public event EventHandler<MeasureEventArgs> MeasureChanged;
internal int CreateAnnotTag { get; private set; } = -1;

public void InvokeMeasureChangeEvent(object sender, MeasureEventArgs e)
{
Expand Down Expand Up @@ -135,11 +131,15 @@ protected bool AnnotHitTest()
cacheHitTestAnnot = null;
return false;
}

cacheHitTestAnnot = baseAnnot;
return true;
}
cacheHitTestAnnot = baseAnnot;
return false;
else
{
cacheHitTestAnnot = null;
return false;
}
}

public void SelectedAnnotForIndex(int pageIndex, int annotIndex)
Expand All @@ -166,7 +166,7 @@ private void InsertAnnotView()
CreateAnnotTool createAnnotTool = new CreateAnnotTool(GetMeasureSetting(), GetDefaultDrawParam(), GetDefaultSettingParam());
int annotViewindex = PDFViewer.GetMaxViewIndex();
PDFViewer.InsertView(annotViewindex, createAnnotTool);
createAnnotTag = createAnnotTool.GetResTag();
CreateAnnotTag = createAnnotTool.GetResTag();
createAnnotTool.UpdateAnnotHandler += CreateAnnotTool_UpdateAnnotHandler;
createAnnotTool.CreateFreetextCanceled += CreateAnnotTool_CreateFreetextCanceled;
createAnnotTool.MeasureChanged += CreateAnnotTool_MeasureChanged;
Expand Down Expand Up @@ -206,7 +206,7 @@ public void SetAnnotIsProportionalScaling(bool isProportionalScaling)
{
return;
}
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
(baseLayer as CreateAnnotTool).SetIsProportionalScaling(isProportionalScaling);
}

Expand All @@ -216,7 +216,7 @@ public double GetMoveLength()
{
return 0;
}
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetMoveLength();
}

Expand All @@ -228,7 +228,7 @@ public CPDFAnnotation StartDrawAnnot(C_ANNOTATION_TYPE annotType)
}

Point point = Mouse.GetPosition(this);
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
PDFViewer.GetPointPageInfo(point, out int index, out Rect paintRect, out Rect pageBound);
if (index < 0)
{
Expand All @@ -240,7 +240,7 @@ public CPDFAnnotation StartDrawAnnot(C_ANNOTATION_TYPE annotType)
{
DefaultSettingParam defaultSettingParam = GetDefaultSettingParam();
StampParam stampParam = defaultSettingParam.StampParamDef;
stampParam.Rotation = cPDFPage.Rotation;
stampParam.PageRotation = cPDFPage.Rotation;
defaultSettingParam.SetAnnotParam(stampParam);
}
Point cropPoint = new Point();
Expand Down Expand Up @@ -271,7 +271,7 @@ public void MultipleClick()
return;
}
Point point = Mouse.GetPosition(this);
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
PDFViewer.GetPointPageInfo(point, out int index, out Rect paintRect, out Rect pageBound);
if (index < 0)
{
Expand Down Expand Up @@ -309,7 +309,7 @@ public void MoveDrawAnnot()
return;
}
Point point = Mouse.GetPosition(this);
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
(baseLayer as CreateAnnotTool).MoveDraw(point, PDFViewer.GetZoom());
}

Expand All @@ -320,8 +320,8 @@ public void CreateTextBox()
return;
}
Point point = Mouse.GetPosition(this);
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
(baseLayer as CreateAnnotTool).CreateTextBox();
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
(baseLayer as CreateAnnotTool).CreateTextBox();
}

public Rect EndDrawAnnot()
Expand All @@ -330,7 +330,7 @@ public Rect EndDrawAnnot()
{
return new Rect();
}
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).EndDraw();
}

Expand Down Expand Up @@ -415,7 +415,7 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION
List<CRect> coreRectList = new List<CRect>();
foreach (Rect copyRect in pageSelectRectList)
{
coreRectList.Add(new CRect((float)copyRect.Left, (float)copyRect.Top, (float)copyRect.Right, (float)copyRect.Bottom));
coreRectList.Add(new CRect((float)copyRect.Left, (float)copyRect.Bottom, (float)copyRect.Right, (float)copyRect.Top));
}
CreateDefaultAnnot(annotCore, annotType, null);
string markupContent = textSelectInfo.PageSelectText[pageIndex];
Expand Down Expand Up @@ -510,6 +510,17 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION
historyGroup.Histories.Add(redactHistory);
}
break;
case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
{
LinkAnnotHistory linkHistory = new LinkAnnotHistory();
AnnotParam annotParam = ParamConverter.AnnotConverter(cPDFDocument, annotCore);
linkHistory.Action = HistoryAction.Add;
linkHistory.CurrentParam = (LinkParam)annotParam;
linkHistory.PDFDoc = cPDFDocument;
linkHistory.Action = HistoryAction.Add;
historyGroup.Histories.Add(linkHistory);
}
break;
default:
break;
}
Expand All @@ -528,25 +539,25 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION

public Point GetStartPoint()
{
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetStartPoint();
}

public Point GetEndPoint()
{
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetEndPoint();
}

public List<Point> GetInkDrawPoints()
{
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetInkDrawPoints();
}

public List<Point> GetMeasureDrawPoints()
{
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetMeasureDrawPoints();
}

Expand All @@ -557,7 +568,7 @@ public Rect GetDrawAnnotMaxRect()
return new Rect();
}
Point point = Mouse.GetPosition(this);
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
return (baseLayer as CreateAnnotTool).GetMaxRect();
}

Expand All @@ -568,7 +579,7 @@ public void ClearDrawAnnot()
return;
}
Point point = Mouse.GetPosition(this);
BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag);
BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
(baseLayer as CreateAnnotTool).ClearDraw();
}

Expand All @@ -589,7 +600,7 @@ protected void UpdateTextPop()
{
return;
}
AnnotData annotData = currentAnnot.GetAnnotData();
AnnotData annotData = currentAnnot.GetAnnotData();

if (annotData.PaintRect == Rect.Empty)
{
Expand Down Expand Up @@ -629,7 +640,7 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)
double Height = DpiHelper.PDFNumToStandardNum(drawRect.height());
textui = new TextBox();
textui.Name = "PdfViewerTextBox";
textBorder = new Border();
textBorder = new DashedBorder();
textBorder.Child = textui;
textBorder.MinWidth = Width * PDFViewer.GetZoom();
textBorder.MinHeight = Height * PDFViewer.GetZoom();
Expand Down Expand Up @@ -667,9 +678,22 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)

textBorder.Padding = new Thickness(0);
textBorder.BorderBrush = new SolidColorBrush(borderColor);
textBorder.BorderThickness = new Thickness(DpiHelper.PDFNumToStandardNum(textWidget.GetBorderWidth() * annotData.CurrentZoom));
double rawWidth = textWidget.GetBorderWidth();
double drawWidth = DpiHelper.PDFNumToStandardNum(rawWidth * annotData.CurrentZoom);
textBorder.BorderThickness = new Thickness(drawWidth);
textui.BorderThickness = new Thickness(0);
textui.Text = textWidget.Content;
if (textWidget.BorderStyle != C_BORDER_STYLE.BS_SOLID && textWidget.Dash != null && textWidget.Dash.Length > 0)
{
//补充保存虚线样式
DashedBorder dashBorder = textBorder as DashedBorder;
DoubleCollection dashCollection = new DoubleCollection();
foreach (float num in textWidget.Dash)
{
dashCollection.Add(num);
}
dashBorder?.DrawDashBorder(true, drawWidth, rawWidth, dashCollection);
}

string fontName = string.Empty;
string fontFamily = string.Empty;
Expand Down Expand Up @@ -783,10 +807,10 @@ protected void BuildPopTextUI(BaseAnnot textAnnot)
viewer.UpdateAnnotFrame();
}
RemovePopTextUI();
}
}
};

BaseLayer createAnnotTool = PDFViewer?.GetView(createAnnotTag) as CreateAnnotTool;
BaseLayer createAnnotTool = PDFViewer?.GetView(CreateAnnotTag) as CreateAnnotTool;
if (createAnnotTool != null)
{
createAnnotTool.Children.Add(textBorder);
Expand Down Expand Up @@ -907,7 +931,7 @@ public void RemovePopTextUI()
{
return;
}
BaseLayer removeLayer = PDFViewer?.GetView(createAnnotTag) as CreateAnnotTool;
BaseLayer removeLayer = PDFViewer?.GetView(CreateAnnotTag) as CreateAnnotTool;
removeLayer.Children.Remove(textBorder);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public partial class CPDFViewerTool
public event EventHandler<SelectedAnnotData> AnnotEditDataChanging;
public event EventHandler<SelectedAnnotData> AnnotEditDataChanged;
public event EventHandler<object> AnnotChanged;

private void InsertAnnotEditView()
{
int selectedRectViewIndex = PDFViewer.GetMaxViewIndex();
Expand Down Expand Up @@ -74,22 +75,23 @@ public void DrawEndEditAnnot()
AnnotEdit annotEdit = CommonHelper.FindVisualChild<AnnotEdit>(baseLayer as CustomizeLayer);
if (annotEdit != null)
{
annotEdit.Draw();
annotEdit.OnMouseLeftButtonUp(point);
annotEdit.Draw();
}
}

public void CleanEditAnnot()
public void CleanEditAnnot(bool isDrawEditAnnot = false)
{
Point point = Mouse.GetPosition(this);
BaseLayer baseLayer = PDFViewer.GetViewForTag(annotEditViewTag);
AnnotEdit annotEdit = CommonHelper.FindVisualChild<AnnotEdit>(baseLayer as CustomizeLayer);
if (annotEdit != null)
{
annotEdit.ClearDraw();
IsDrawEditAnnot = false;
IsDrawEditAnnot = isDrawEditAnnot;
}
}


private void DrawEditAnnotLayer()
{
Expand All @@ -108,7 +110,6 @@ private void DrawEditAnnotLayer()
private bool DrawEditAnnotDownEvent()
{
BaseLayer baseLayer = PDFViewer.GetViewForTag(annotEditViewTag);

AnnotEdit selectedRect = CommonHelper.FindVisualChild<AnnotEdit>(baseLayer as CustomizeLayer);
if (selectedRect != null)
{
Expand Down
Loading

0 comments on commit 7dea478

Please sign in to comment.