diff --git a/ComPDFKit for Windows/Examples/Annotations/Annotations.csproj b/ComPDFKit for Windows/Examples/Annotations/Annotations.csproj index 2f2b190..2245277 100644 --- a/ComPDFKit for Windows/Examples/Annotations/Annotations.csproj +++ b/ComPDFKit for Windows/Examples/Annotations/Annotations.csproj @@ -41,11 +41,11 @@ ComPDFKit_Logo.ico - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll ..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll @@ -93,7 +93,6 @@ ResXFileCodeGenerator Resources.Designer.cs - Designer @@ -124,11 +123,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Annotations/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Annotations/Properties/AssemblyInfo.cs index 114956e..4fdc626 100644 --- a/ComPDFKit for Windows/Examples/Annotations/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Annotations/Properties/AssemblyInfo.cs @@ -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")] \ No newline at end of file +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Annotations/packages.config b/ComPDFKit for Windows/Examples/Annotations/packages.config index 5f51c51..ee67883 100644 --- a/ComPDFKit for Windows/Examples/Annotations/packages.config +++ b/ComPDFKit for Windows/Examples/Annotations/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFToolManager.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFToolManager.cs index 180bb9b..9eb3f46 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFToolManager.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFToolManager.cs @@ -20,6 +20,9 @@ using ComPDFKit.Measure; using System.Dynamic; using System.Globalization; +using ComPDFKitViewer.Layer; +using ComPDFKitViewer; +using ComPDFKitViewer.Annot; namespace ComPDFKit.Tool { @@ -82,6 +85,7 @@ public class CPDFToolManager /// private Cursor addImageEditCursor = Cursors.Arrow; + public bool SaveEmptyStickyAnnot { get; set; } = true; public void SetActiveCropping(bool isActiveCropping) { this.isActiveCropping = isActiveCropping; @@ -264,12 +268,12 @@ public bool SetCreateContentEditType(CPDFEditType editType) createContentEditType = editType; return true; } + public CPDFEditType GetCreateContentEditType() { return createContentEditType; } - public void ClearSelect() { /// Clear some UI effects of other modules @@ -340,13 +344,11 @@ public void SetToolType(ToolType toolType) break; } - if (oldToolType == ToolType.ContentEdit) + if (oldToolType == ToolType.ContentEdit || currentToolType == ToolType.ContentEdit) { viewerTool.GetCPDFViewer().GetDocument()?.ReleasePages(); //Undo delete logic viewerTool.GetCPDFViewer().UndoManager.ClearHistory(); - // viewerTool.GetCPDFViewer().UndoManager.RemoveRedoHistoryForType(typeof(PDFEditHistory)); - //viewerTool.GetCPDFViewer().UndoManager.RemoveUndoHistoryForType(typeof(PDFEditHistory)); viewerTool.GetCPDFViewer().UpdateVirtualNodes(); viewerTool.GetCPDFViewer().UpdateRenderFrame(); } @@ -468,9 +470,19 @@ private void ViewerTool_SelectedDataChanged(object sender, DrawTool.SelectedAnno e.Square.Width / e.annotData.CurrentZoom, e.Square.Height / e.annotData.CurrentZoom ); + Rect rect = DpiHelper.StandardRectToPDFRect(rect1); CRect cRect = new CRect((float)rect.Left, (float)rect.Bottom, (float)rect.Right, (float)rect.Top); - e.annotData.Annot.SetRect(cRect); + if (e.annotData.AnnotType == C_ANNOTATION_TYPE.C_ANNOTATION_STAMP) + { + CPDFStampAnnotation stampAnnot = e.annotData.Annot as CPDFStampAnnotation; + stampAnnot.SetSourceRect(cRect); + stampAnnot.AnnotationRotator.SetRotation(-e.rotationAngle); + } + else + { + e.annotData.Annot.SetRect(cRect); + } } switch (e.annotData.AnnotType) @@ -488,6 +500,10 @@ private void ViewerTool_SelectedDataChanged(object sender, DrawTool.SelectedAnno if (e.annotData.AnnotType != C_ANNOTATION_TYPE.C_ANNOTATION_SOUND) { e.annotData.Annot.UpdateAp(); + if (e.annotData.Annot is CPDFTextAnnotation) + { + CommonHelper.UpdateStickyAP(e.annotData.Annot as CPDFTextAnnotation); + } } break; } @@ -530,7 +546,6 @@ private void SaveToMulitChanged(MultiSelectedData e) CPDFDocument cPDFDocument = viewerTool.GetCPDFViewer().GetDocument(); CPDFPage cPDFPage = cPDFDocument.PageAtIndex(e.PageIndex); CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage(); - //cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage); List cPDFEditAreas = cPDFEditPage.GetEditAreaList(false); float zoom = (float)viewerTool.PDFViewer.GetZoom(); for (int i = 0; i < e.MultiObjectIndex.Count; i++) @@ -640,7 +655,6 @@ private void ViewerTool_AnnotEditDataChanged(object sender, SelectedAnnotData e) List cPoints = new List(); for (int i = 0; i < e.Points.Count; i++) { - Point cPoint = new Point((float)((e.Points[i].X - e.annotData.PaintOffset.X) / e.annotData.CurrentZoom), (float)((e.Points[i].Y - e.annotData.PaintOffset.Y) / e.annotData.CurrentZoom)); cPoints.Add(cPoint); @@ -683,27 +697,28 @@ private void ViewerTool_AnnotEditDataChanged(object sender, SelectedAnnotData e) { lineMeasure.SetLeadLength(-(float)saveLength); } + if (lineCenterPoint.Y > crossCenterPoint.Y) { lineMeasure.SetLeadLength((float)saveLength); } + if (lineCenterPoint.Y == crossCenterPoint.Y) { if (lineCenterPoint.X > crossCenterPoint.X) { lineMeasure.SetLeadLength(-(float)saveLength); } + if (lineCenterPoint.X < crossCenterPoint.X) { lineMeasure.SetLeadLength((float)saveLength); } } - lineMeasure.UpdateAnnotMeasure(); + annotLine.UpdateAp(); - if (annotLine.IsMeasured()) - { - PostMeasureInfo(this, annotLine); - } + lineMeasure.UpdateAnnotMeasure(); + PostMeasureInfo(this, annotLine); } else { @@ -734,25 +749,24 @@ private void ViewerTool_AnnotEditDataChanged(object sender, SelectedAnnotData e) (float)((e.Points[i].Y - e.annotData.PaintOffset.Y) / e.annotData.CurrentZoom)); cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(cPoint))); } - CPDFPolygonAnnotation annotLine = (e.annotData.Annot as CPDFPolygonAnnotation); - - annotLine.SetPoints(cPoints); + CPDFPolygonAnnotation polygonAnnot = (e.annotData.Annot as CPDFPolygonAnnotation); + polygonAnnot.SetPoints(cPoints); double left = cPoints.AsEnumerable().Select(x => x.x).Min(); double right = cPoints.AsEnumerable().Select(x => x.x).Max(); double top = cPoints.AsEnumerable().Select(x => x.y).Min(); double bottom = cPoints.AsEnumerable().Select(x => x.y).Max(); - - annotLine.SetRect(new CRect( + polygonAnnot.SetRect(new CRect( (float)left, (float)bottom, (float)right, (float)top)); - annotLine.GetAreaMeasure().UpdateAnnotMeasure(); - annotLine.UpdateAp(); - if (annotLine.IsMeasured()) + + polygonAnnot.UpdateAp(); + if (polygonAnnot.IsMeasured()) { - PostMeasureInfo(this, annotLine); + polygonAnnot.GetAreaMeasure().UpdateAnnotMeasure(); + PostMeasureInfo(this, polygonAnnot); } } break; @@ -765,26 +779,24 @@ private void ViewerTool_AnnotEditDataChanged(object sender, SelectedAnnotData e) (float)((e.Points[i].Y - e.annotData.PaintOffset.Y) / e.annotData.CurrentZoom)); cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(cPoint))); } - CPDFPolylineAnnotation annotLine = (e.annotData.Annot as CPDFPolylineAnnotation); - - annotLine.SetPoints(cPoints); + CPDFPolylineAnnotation polylineAnnot = (e.annotData.Annot as CPDFPolylineAnnotation); + polylineAnnot.SetPoints(cPoints); double left = cPoints.AsEnumerable().Select(x => x.x).Min(); double right = cPoints.AsEnumerable().Select(x => x.x).Max(); double top = cPoints.AsEnumerable().Select(x => x.y).Min(); double bottom = cPoints.AsEnumerable().Select(x => x.y).Max(); - - annotLine.SetRect(new CRect( + polylineAnnot.SetRect(new CRect( (float)left, (float)bottom, (float)right, (float)top)); - annotLine.GetPerimeterMeasure().UpdateAnnotMeasure(); - annotLine.UpdateAp(); - if (annotLine.IsMeasured()) + polylineAnnot.UpdateAp(); + if (polylineAnnot.IsMeasured()) { - PostMeasureInfo(this, annotLine); + polylineAnnot.GetPerimeterMeasure().UpdateAnnotMeasure(); + PostMeasureInfo(this, polylineAnnot); } } break; @@ -817,14 +829,7 @@ private void ViewerTool_AnnotEditDataChanged(object sender, SelectedAnnotData e) annotHistory.CurrentParam = currentParam; annotHistory.Action = HistoryAction.Update; viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory); - if (e.annotData.Annot.IsMeasured()) - { - viewerTool.GetCPDFViewer().UpdateRenderFrame(); - } - else - { - viewerTool.GetCPDFViewer().UpdateAnnotFrame(); - } + viewerTool.GetCPDFViewer().UpdateAnnotFrame(); } private void ViewerTool_MouseLeftButtonUpHandler(object sender, MouseEventObject e) @@ -868,11 +873,11 @@ private void ViewerTool_MouseLeftButtonUpHandler(object sender, MouseEventObject if (e.hitTestType == MouseHitTestType.SelectRect) { List list = new List() - { - C_ANNOTATION_TYPE.C_ANNOTATION_LINE, - C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE, - C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON, - }; + { + C_ANNOTATION_TYPE.C_ANNOTATION_LINE, + C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE, + C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON, + }; if (list.Contains(e.annotType)) { viewerTool.DrawEndEditAnnot(); @@ -984,7 +989,7 @@ private void ViewerTool_MouseLeftButtonUpHandler(object sender, MouseEventObject { if (viewerTool.CanAddTextEdit) { - e.IsCreate = viewerTool.DrawEndTest(); + e.IsCreate = viewerTool.DrawEndTest(); } } else @@ -1093,8 +1098,7 @@ private void SaveCurrentAnnot() } } - #region MouseLeftButtonUpCreateAnnot - + #region MouseLeftButtonUpCreateAnnot private void CreateAnnotTypeMouseLeftUp(ref MouseEventObject e) { //Mersured @@ -1115,7 +1119,7 @@ private void CreateAnnotTypeMouseLeftUp(ref MouseEventObject e) } break; case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON: - if ((cPDFAnnotation as CPDFPolygonAnnotation).IsMeasured()) + // if ((cPDFAnnotation as CPDFPolygonAnnotation).IsMeasured()) { DefaultSettingParam defSetting = viewerTool.GetDefaultSettingParam(); if (defSetting.IsCreateSquarePolygonMeasure) @@ -1143,11 +1147,20 @@ private void CreateAnnotTypeMouseLeftUp(ref MouseEventObject e) private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventObject e) { + if (annotation == null) { return; } + if (!annotation.IsValid()) + { + annotation.RemoveAnnot(); + annotation = null; + + return; + } + Point StartPoint = viewerTool.GetStartPoint(); Point EndPoint = viewerTool.GetEndPoint(); List points = viewerTool.GetInkDrawPoints(); @@ -1156,6 +1169,8 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO annotation.SetModifyDate(PDFHelp.GetCurrentPdfTime()); Rect rect = viewerTool.EndDrawAnnot(); + + if (annotation != null) { switch (annotation.Type) @@ -1226,14 +1241,14 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO break; case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON: { + List cPoints = new List(); + foreach (Point item in measurepoints) + { + cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item))); + } + (annotation as CPDFPolygonAnnotation).SetPoints(cPoints); if ((annotation as CPDFPolygonAnnotation).IsMeasured()) { - List cPoints = new List(); - foreach (Point item in measurepoints) - { - cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item))); - } - (annotation as CPDFPolygonAnnotation).SetPoints(cPoints); (annotation as CPDFPolygonAnnotation).GetAreaMeasure().UpdateAnnotMeasure(); PostMeasureInfo(this, annotation); } @@ -1271,6 +1286,7 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO { switch (createAnnotType) { + case C_ANNOTATION_TYPE.C_ANNOTATION_LINK: case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT: case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE: case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY: @@ -1316,6 +1332,12 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO { viewerTool.GetCPDFViewer().UpdateAnnotFrame(); } + else if (createAnnotType == C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT && textSelectInfo.PageSelectPointList.Count == 0) + { + bool isA = annotation.RemoveAnnot(); + annotation = null; + return; + } } break; case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP: @@ -1353,19 +1375,32 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO (mousePoint.Y - pageBound.Y + (cropPoint.Y * viewerTool.GetCPDFViewer().GetZoom())) / viewerTool.GetCPDFViewer().GetZoom(), stampRect.Width, stampRect.Height) ); + + if (annotation.Page.Rotation % 2 != 0) + { + PDFRect = RotateRect90(PDFRect); + } + CRect cStampRect = new CRect((float)PDFRect.Left, (float)PDFRect.Bottom, (float)PDFRect.Right, (float)PDFRect.Top); - annotation.SetRect(cStampRect); + annotation.SetSourceRect(cStampRect); + (annotation as CPDFStampAnnotation).AnnotationRotator.SetRotation(annotation.Page.Rotation * 90); annotation.UpdateAp(); e.IsCreate = true; e.annotType = C_ANNOTATION_TYPE.C_ANNOTATION_STAMP; e.Data = GetAnnotExpandObject(annotation); - StampAnnotHistory freeTextAnnotHistory = new StampAnnotHistory(); - AnnotParam annotParam = ParamConverter.AnnotConverter(viewerTool.GetCPDFViewer().GetDocument(), annotation); + StampAnnotHistory stampAnnotHistory = new StampAnnotHistory(); + StampParam annotParam = ParamConverter.AnnotConverter(viewerTool.GetCPDFViewer().GetDocument(), annotation) as StampParam; + if (annotParam.StampType == C_STAMP_TYPE.IMAGE_STAMP) + { + annotParam.CopyImageAnnot = CPDFAnnotation.CopyAnnot(annotation); + } + annotParam.AnnotIndex = annotation.Page.GetAnnotCount() - 1; - freeTextAnnotHistory.CurrentParam = (StampParam)annotParam; - freeTextAnnotHistory.PDFDoc = viewerTool.GetCPDFViewer().GetDocument(); - viewerTool.GetCPDFViewer().UndoManager.AddHistory(freeTextAnnotHistory); + stampAnnotHistory.CurrentParam = annotParam; + stampAnnotHistory.PDFDoc = viewerTool.GetCPDFViewer().GetDocument(); + viewerTool.GetCPDFViewer().UndoManager.AddHistory(stampAnnotHistory); } + viewerTool.GetCPDFViewer().UpdateAnnotFrame(); } break; @@ -1419,7 +1454,7 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO annotation = null; return; } - //CRect cRect = new CRect((float)rect.Left + annotation.GetBorderWidth(), (float)rect.Bottom - annotation.GetBorderWidth(), (float)rect.Right - annotation.GetBorderWidth(), (float)rect.Top + annotation.GetBorderWidth()); + CRect cRect = new CRect( (float)rect.Left, (float)rect.Bottom, @@ -1427,13 +1462,23 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO (float)rect.Top); annotation.SetRect(cRect); - annotation.UpdateAp(); + SaveSharpAnnotBoundText(annotation); + + if (annotation.Type != C_ANNOTATION_TYPE.C_ANNOTATION_TEXT) + { + annotation.UpdateAp(); + } + else + { + CommonHelper.UpdateStickyAP(annotation as CPDFTextAnnotation); + } AnnotHistory annotHistory = ParamConverter.CreateHistory(annotation); if (annotHistory == null) { return; } + AnnotParam currentParam; switch (annotation.Type) { @@ -1447,10 +1492,25 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO annotHistory.CurrentParam = currentParam; annotHistory.Action = HistoryAction.Add; annotHistory.PDFDoc = viewerTool.PDFViewer.GetDocument(); - viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory); viewerTool.ClearDrawAnnot(); viewerTool.GetCPDFViewer().UpdateAnnotFrame(); + viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory); + + if (annotation.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT && SaveEmptyStickyAnnot == false) + { + BaseLayer baseLayer1 = viewerTool.GetCPDFViewer().GetViewForTag(viewerTool.GetCPDFViewer().GetAnnotViewTag()); + int checkPageIndex = currentParam.PageIndex; + int checkAnnotIndex = currentParam.AnnotIndex; + BaseAnnot selectAnnot = (baseLayer1 as AnnotLayer).GetSelectedAnnot(ref checkPageIndex, ref checkAnnotIndex); + if (selectAnnot != null) + { + StickyNoteAnnot stickyAnnot = selectAnnot as StickyNoteAnnot; + StickyNoteAnnot.StickyPopupClosed -= StickyAnnot_StickyPopupClosed; + StickyNoteAnnot.StickyPopupClosed += StickyAnnot_StickyPopupClosed; + stickyAnnot.PopStickyNote(); + } + } { e.annotType = annotation.Type; @@ -1461,9 +1521,71 @@ private void SaveCreateAnnotation(ref CPDFAnnotation annotation, ref MouseEventO expandData.AnnotParam = currentParam; e.Data = expandData; } + + } + } + + private void SaveSharpAnnotBoundText(CPDFAnnotation boundAnnot) + { + if (boundAnnot == null || boundAnnot.Page == null || boundAnnot.Page.IsValid() == false) + { + return; + } + + if (boundAnnot.Type != C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE && boundAnnot.Type != C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE) + { + return; + } + + CPDFTextPage textPage = boundAnnot.Page.GetTextPage(); + if (textPage == null || textPage.IsValid() == false) + { + return; + } + + string boundText = textPage.GetBoundedText(boundAnnot.GetRect()); + if (string.IsNullOrEmpty(boundText) == false) + { + boundAnnot.SetContent(boundText); } } + private void StickyAnnot_StickyPopupClosed(object sender, EventArgs e) + { + StickyNoteAnnot.StickyPopupClosed -= StickyAnnot_StickyPopupClosed; + StickyNoteAnnot stickyAnnot = sender as StickyNoteAnnot; + if (stickyAnnot == null) + { + return; + } + AnnotData annotData = stickyAnnot.GetAnnotData(); + AnnotParam currentParam = ParamConverter.AnnotConverter(viewerTool.GetCPDFViewer().GetDocument(), annotData.Annot); + AnnotHistory annotHistory = ParamConverter.CreateHistory(annotData.Annot); + string content = annotData.Annot.GetContent(); + if (string.IsNullOrEmpty(content)) + { + if (annotData.Annot.RemoveAnnot()) + { + viewerTool.ClearDrawAnnot(); + viewerTool.GetCPDFViewer().UpdateAnnotFrame(); + viewerTool.SelectedAnnotForIndex(-1, -1); + annotHistory.CurrentParam = currentParam; + annotHistory.Action = HistoryAction.Remove; + annotHistory.PDFDoc = viewerTool.PDFViewer.GetDocument(); + viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory); + } + + return; + } + AnnotParam previousParam = ParamConverter.AnnotConverter(viewerTool.GetCPDFViewer().GetDocument(), annotData.Annot); + previousParam.Content = string.Empty; + annotHistory.PreviousParam = previousParam; + annotHistory.CurrentParam = currentParam; + annotHistory.Action = HistoryAction.Update; + annotHistory.PDFDoc = viewerTool.PDFViewer.GetDocument(); + viewerTool.GetCPDFViewer().UndoManager.AddHistory(annotHistory); + } + internal void PostMeasureInfo(object sender, CPDFAnnotation rawAnnot) { if (rawAnnot == null) @@ -1921,10 +2043,13 @@ private void ViewerTool_MouseMoveHandler(object sender, MouseEventObject e) { cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect()); } + } else { + cursor = viewerTool.DrawMoveTest(viewerTool.GetLastSelectedRect()); + if (multiSelectedRect == null || multiSelectedRect.Children.Count == 0) { //Selection of mobile drawing logic @@ -1933,7 +2058,6 @@ private void ViewerTool_MouseMoveHandler(object sender, MouseEventObject e) viewerTool.DrawMoveFrameSelect(); } } - } if (cursor == Cursors.Arrow && createContentEditType == CPDFEditType.EditText) @@ -1942,12 +2066,12 @@ private void ViewerTool_MouseMoveHandler(object sender, MouseEventObject e) } viewerTool.Cursor = cursor; viewerTool.PDFViewer.Cursor = cursor; + } else { Cursor cursor = Cursors.Arrow; MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(viewerTool.PDFViewer.GetViewForTag(viewerTool.MultiSelectedRectViewTag)); - if (viewerTool.GetLastSelectedRect() != null) { if (editSelected) @@ -2019,6 +2143,7 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje viewerTool.EndDrawAnnot(); } break; + case C_ANNOTATION_TYPE.C_ANNOTATION_LINK: case C_ANNOTATION_TYPE.C_ANNOTATION_REDACT: if (viewerTool.IsText()) { @@ -2045,13 +2170,9 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje { bool cansave = true; CPDFPolygonAnnotation PolyAnnotation = (cPDFAnnotation as CPDFPolygonAnnotation); - PolyAnnotation?.IsMeasured(); if (PolyAnnotation != null) { - if (PolyAnnotation.IsMeasured()) - { - cansave = false; - } + cansave = false; } viewerTool.SetIsCanSave(cansave); } @@ -2086,17 +2207,19 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje { if (!viewerTool.IsCanSave()) { - viewerTool.SetIsCanSave(true); + BaseLayer baseLayer = viewerTool.PDFViewer.GetViewForTag(viewerTool.CreateAnnotTag); + bool canSave = (baseLayer as CreateAnnotTool).IsCanSave(); + viewerTool.SetIsCanSave(canSave); } } break; } - } else if (currentToolType == ToolType.WidgetEdit) { cPDFAnnotation = viewerTool.StartDrawWidget(createWidgetType); viewerTool.CreateDefaultWidget(cPDFAnnotation, createWidgetType, null); + viewerTool?.InvokeWidgetCreated(cPDFAnnotation); } else if (currentToolType == ToolType.Pan || currentToolType == ToolType.Viewer) { @@ -2151,11 +2274,14 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje } else { - viewerTool.CleanEditAnnot(); - viewerTool.DrawStartSelectedRect(); - if (currentToolType == ToolType.WidgetEdit) + if (currentToolType != ToolType.Viewer) { - viewerTool.MoveDrawWidget(true); + viewerTool.CleanEditAnnot(); + viewerTool.DrawStartSelectedRect(); + if (currentToolType == ToolType.WidgetEdit) + { + viewerTool.MoveDrawWidget(true); + } } } } @@ -2224,7 +2350,7 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje EditAreaObject editAreaObject = viewerTool.GetEditAreaObjectForRect(viewerTool.GetLastSelectedRect()); if (pointControlType != PointControlType.None && - (editAreaObject.cPDFEditArea.Type == CPDFEditType.EditImage || pointControlType != PointControlType.Body)) + (editAreaObject.cPDFEditArea.Type != CPDFEditType.EditText || pointControlType != PointControlType.Body)) { switch (pointControlType) { @@ -2240,7 +2366,7 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje case PointControlType.RightTop: viewerTool.PDFViewer.Cursor = viewerTool.Cursor = Cursors.SizeNESW; break; - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: case PointControlType.MiddleTop: viewerTool.PDFViewer.Cursor = viewerTool.Cursor = Cursors.SizeNS; break; @@ -2265,7 +2391,6 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(viewerTool.PDFViewer.GetViewForTag(viewerTool.MultiSelectedRectViewTag)); if (multiSelectedRect != null && multiSelectedRect.Children.Count > 0) { - viewerTool.PDFViewer.UpdateRenderFrame(); return; } Point point = Mouse.GetPosition(viewerTool); @@ -2297,6 +2422,7 @@ private void ViewerTool_MouseLeftButtonDownHandler(object sender, MouseEventObje default: break; } + MouseLeftButtonDownHandler?.Invoke(this, e); } @@ -2309,5 +2435,19 @@ private void ViewerTool_MouseRightButtonDownHandler(object sender, MouseEventObj MouseRightButtonDownHandler?.Invoke(sender, e); } + + private Rect RotateRect90(Rect rect) + { + double centerX = rect.Left + rect.Width / 2; + double centerY = rect.Top + rect.Height / 2; + + double newWidth = rect.Height; + double newHeight = rect.Width; + + double newLeft = centerX - newWidth / 2.0; + double newTop = centerY - newHeight / 2.0; + + return new Rect(newLeft, newTop, newWidth, newHeight); + } } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Annot.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Annot.cs index b26d869..a8ae21b 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Annot.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Annot.cs @@ -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; @@ -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; @@ -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 MeasureChanged; + internal int CreateAnnotTag { get; private set; } = -1; public void InvokeMeasureChangeEvent(object sender, MeasureEventArgs e) { @@ -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) @@ -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; @@ -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); } @@ -216,7 +216,7 @@ public double GetMoveLength() { return 0; } - BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag); + BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag); return (baseLayer as CreateAnnotTool).GetMoveLength(); } @@ -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) { @@ -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(); @@ -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) { @@ -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()); } @@ -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() @@ -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(); } @@ -415,7 +415,7 @@ public bool CreateAnnotForSelectText(TextSelectInfo textSelectInfo, C_ANNOTATION List coreRectList = new List(); 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]; @@ -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; } @@ -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 GetInkDrawPoints() { - BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag); + BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag); return (baseLayer as CreateAnnotTool).GetInkDrawPoints(); } public List GetMeasureDrawPoints() { - BaseLayer baseLayer = PDFViewer.GetViewForTag(createAnnotTag); + BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag); return (baseLayer as CreateAnnotTool).GetMeasureDrawPoints(); } @@ -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(); } @@ -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(); } @@ -589,7 +600,7 @@ protected void UpdateTextPop() { return; } - AnnotData annotData = currentAnnot.GetAnnotData(); + AnnotData annotData = currentAnnot.GetAnnotData(); if (annotData.PaintRect == Rect.Empty) { @@ -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(); @@ -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; @@ -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); @@ -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); } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.AnnotEdit.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.AnnotEdit.cs index 8a76dec..50afcb0 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.AnnotEdit.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.AnnotEdit.cs @@ -15,6 +15,7 @@ public partial class CPDFViewerTool public event EventHandler AnnotEditDataChanging; public event EventHandler AnnotEditDataChanged; public event EventHandler AnnotChanged; + private void InsertAnnotEditView() { int selectedRectViewIndex = PDFViewer.GetMaxViewIndex(); @@ -74,12 +75,12 @@ public void DrawEndEditAnnot() AnnotEdit annotEdit = CommonHelper.FindVisualChild(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); @@ -87,9 +88,10 @@ public void CleanEditAnnot() if (annotEdit != null) { annotEdit.ClearDraw(); - IsDrawEditAnnot = false; + IsDrawEditAnnot = isDrawEditAnnot; } } + private void DrawEditAnnotLayer() { @@ -108,7 +110,6 @@ private void DrawEditAnnotLayer() private bool DrawEditAnnotDownEvent() { BaseLayer baseLayer = PDFViewer.GetViewForTag(annotEditViewTag); - AnnotEdit selectedRect = CommonHelper.FindVisualChild(baseLayer as CustomizeLayer); if (selectedRect != null) { diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Command.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Command.cs index 3b89439..079aebf 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Command.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.Command.cs @@ -38,7 +38,6 @@ public class CommandData public AnnotParam CurrentParam { get; set; } = null; } - /// /// System provided related command time notification /// @@ -63,6 +62,8 @@ internal class PDFEditCommandData internal Point rightPressPoint = new Point(-1, -1); internal static List lastPDFEditArgsList { get; private set; } = new List(); internal static List lastAnnotList { get; private set; } = new List(); + private bool IsCanDoCommand = true; + internal void BindCommand() { CommandBinding copyBind = new CommandBinding(ApplicationCommands.Copy); @@ -141,7 +142,6 @@ public void ReBindCommand(List commandBindings) } } - private bool IsCanDoCommand = true; public void CanDoCommand() { IsCanDoCommand = true; @@ -239,7 +239,6 @@ public void SetPastePoint(Point point) } #region ContentEdit - private void CheckPDFEditCommandStatus(RoutedUICommand uiCommand, CanExecuteRoutedEventArgs e) { switch (uiCommand.Name) @@ -276,6 +275,12 @@ private void CheckPDFEditCommandStatus(RoutedUICommand uiCommand, CanExecuteRout e.CanExecute = true; break; } + + if (checkItem.EditType == CPDFEditType.EditPath && checkItem.EditAreaCopied) + { + e.CanExecute = true; + break; + } } try { @@ -456,6 +461,7 @@ private void CopyPDFEditData(out CPDFEditType editType) commandData.PDFRect = DataConversionForWPF.CRectConversionForRect(currentEditAreaObject.cPDFEditArea.GetFrame()); lastPDFEditArgsList.Add(commandData); } + if (currentEditAreaObject.cPDFEditArea.Type == CPDFEditType.EditImage) { editType = CPDFEditType.EditImage; @@ -471,6 +477,22 @@ private void CopyPDFEditData(out CPDFEditType editType) lastPDFEditArgsList.Add(commandData); } } + + if (currentEditAreaObject.cPDFEditArea.Type == CPDFEditType.EditPath) + { + editType = CPDFEditType.EditPath; + CPDFEditPage editPage = currentEditAreaObject.cPDFEditPage; + commandData.PDFRect = DataConversionForWPF.CRectConversionForRect(currentEditAreaObject.cPDFEditArea.GetFrame()); + commandData.EditAreaCopied = editPage.CopyEditArea(currentEditAreaObject.cPDFEditArea); + commandData.EditType = CPDFEditType.EditPath; + if (commandData.EditAreaCopied) + { + List copyList = editPage.GetCopyEditAreaList(); + commandData.CopyArea = copyList[copyList.Count - 1]; + commandData.EditPage = editPage; + lastPDFEditArgsList.Add(commandData); + } + } } else { @@ -517,6 +539,7 @@ private void CopyPDFEditData(out CPDFEditType editType) commandData.PDFRect = DataConversionForWPF.CRectConversionForRect(editAreaObject.cPDFEditArea.GetFrame()); lastPDFEditArgsList.Add(commandData); } + if (editAreaObject.cPDFEditArea.Type == CPDFEditType.EditImage) { editType = CPDFEditType.EditImage; @@ -532,6 +555,22 @@ private void CopyPDFEditData(out CPDFEditType editType) lastPDFEditArgsList.Add(commandData); } } + + if (editAreaObject.cPDFEditArea.Type == CPDFEditType.EditPath) + { + editType = CPDFEditType.EditPath; + CPDFEditPage editPage = editAreaObject.cPDFEditPage; + commandData.PDFRect = DataConversionForWPF.CRectConversionForRect(editAreaObject.cPDFEditArea.GetFrame()); + commandData.EditAreaCopied = editPage.CopyEditArea(editAreaObject.cPDFEditArea); + commandData.EditType = CPDFEditType.EditPath; + if (commandData.EditAreaCopied) + { + List copyList = editPage.GetCopyEditAreaList(); + commandData.CopyArea = copyList[copyList.Count - 1]; + commandData.EditPage = editPage; + lastPDFEditArgsList.Add(commandData); + } + } } } } @@ -574,6 +613,12 @@ private void DelPDFEditData(out CPDFEditType editType) RemoveImageBlock(); } + if (currentEditAreaObject.cPDFEditArea.Type == CPDFEditType.EditPath) + { + editType = CPDFEditType.EditPath; + RemovePathBlock(); + } + if (PDFViewer != null && PDFViewer.UndoManager != null) { PDFViewer.UndoManager.AddHistory(groupHistory); @@ -617,6 +662,12 @@ private void DelPDFEditData(out CPDFEditType editType) editType = CPDFEditType.EditImage; RemoveImageBlock(editareaobject); } + + if (editareaobject.cPDFEditArea.Type == CPDFEditType.EditPath) + { + editType = CPDFEditType.EditPath; + RemovePathBlock(editareaobject); + } } if (PDFViewer != null && PDFViewer.UndoManager != null) @@ -829,6 +880,7 @@ private void PastePDFEditData(out CPDFEditType editType, bool pasteMatchStyle = } } } + if (commandData.EditType == CPDFEditType.EditImage) { editType = CPDFEditType.EditImage; @@ -836,7 +888,6 @@ private void PastePDFEditData(out CPDFEditType editType, bool pasteMatchStyle = if (commandData.EditAreaCopied) { commandData.CopyArea?.PasteEditArea(editPage, new CPoint((float)offsetRect.Left, (float)offsetRect.Top)); - editHistory.EditPage = editPage; editHistory.PageIndex = pageIndex; CPDFViewer pdfViewer = GetCPDFViewer(); @@ -885,6 +936,25 @@ private void PastePDFEditData(out CPDFEditType editType, bool pasteMatchStyle = } } + if (commandData.EditType == CPDFEditType.EditPath) + { + editType = CPDFEditType.EditPath; + PDFEditHistory editHistory = new PDFEditHistory(); + if (commandData.EditAreaCopied) + { + commandData.CopyArea?.PasteEditArea(editPage, new CPoint((float)offsetRect.Left, (float)offsetRect.Top)); + editHistory.EditPage = editPage; + editHistory.PageIndex = pageIndex; + CPDFViewer pdfViewer = GetCPDFViewer(); + if (pdfViewer != null && pdfViewer.UndoManager != null) + { + pdfViewer.UndoManager.AddHistory(editHistory); + } + + SelectedEditAreaForIndex(pageIndex, editPage.GetEditAreaList().Count - 1, false); + } + } + editPage.EndEdit(); } } @@ -895,12 +965,15 @@ private void SelectAllPDFEditData(out CPDFEditType editType) if (currentEditAreaObject != null && currentEditAreaObject.cPDFEditPage != null) { CPDFEditTextArea textArea = currentEditAreaObject.cPDFEditArea as CPDFEditTextArea; - textArea.SelectAllChars(); + if (textArea == null) + return; + textArea.SelectAllChars(); editType = CPDFEditType.EditText; PDFViewer.UpdateRenderFrame(); } } + private Rect AddPasteOffset(Rect clientRect, int offsetX, int offsetY, Size pageSize) { clientRect.X += offsetX; @@ -928,7 +1001,6 @@ private Rect AddPasteOffset(Rect clientRect, int offsetX, int offsetY, Size page #endregion #region Annot - private bool CheckCacheHitTestAnnot(string cmdName = "") { if (cacheHitTestAnnot == null) @@ -1076,6 +1148,39 @@ private void ExecuteViewerCommand(RoutedUICommand uiCommand) } } + private void ClearLastAnnotList() + { + foreach(var item in lastAnnotList) + { + if (item is StampParam stampParam) + { + if (stampParam.StampType == C_STAMP_TYPE.IMAGE_STAMP) + { + if(stampParam.CopyImageAnnot != null) + { + CPDFAnnotation.ReleaseCopyAnnot(stampParam.CopyImageAnnot); + stampParam.CopyImageAnnot = null; + } + } + } + } + + lastAnnotList.Clear(); + } + + private void AddLastAnnotList(AnnotParam annotParam) + { + if (annotParam is StampParam stampParam) + { + if (stampParam.StampType == C_STAMP_TYPE.IMAGE_STAMP) + { + stampParam.CopyImageAnnot = CPDFAnnotation.CopyAnnot(cacheHitTestAnnot.GetAnnotData().Annot); + } + } + + lastAnnotList.Add(annotParam); + } + private void ExecuteAnnotCommand(RoutedUICommand uiCommand) { switch (uiCommand.Name) @@ -1083,15 +1188,16 @@ private void ExecuteAnnotCommand(RoutedUICommand uiCommand) case "Copy": if (cacheHitTestAnnot != null) { - lastAnnotList.Clear(); + ClearLastAnnotList(); AnnotParam annotParam = ParamConverter.AnnotConverter(GetCPDFViewer().GetDocument(), cacheHitTestAnnot.GetAnnotData().Annot); - lastAnnotList.Add(annotParam); + AddLastAnnotList(annotParam); } + if (cacheMoveWidget != null) { - lastAnnotList.Clear(); + ClearLastAnnotList(); AnnotParam annotParam = ParamConverter.WidgetConverter(GetCPDFViewer().GetDocument(), cacheMoveWidget.GetAnnotData().Annot); - lastAnnotList.Add(annotParam); + AddLastAnnotList(annotParam); } else { @@ -1125,7 +1231,7 @@ private void ExecuteAnnotCommand(RoutedUICommand uiCommand) case "Cut": if (cacheHitTestAnnot != null) { - lastAnnotList.Clear(); + ClearLastAnnotList(); AnnotParam annotParam; if (cacheHitTestAnnot.CurrentType == C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET) { @@ -1135,13 +1241,14 @@ private void ExecuteAnnotCommand(RoutedUICommand uiCommand) { annotParam = ParamConverter.AnnotConverter(GetCPDFViewer().GetDocument(), cacheHitTestAnnot.GetAnnotData().Annot); } - lastAnnotList.Add(annotParam); + + AddLastAnnotList(annotParam); } if (cacheMoveWidget != null) { - lastAnnotList.Clear(); + ClearLastAnnotList(); AnnotParam annotParam = ParamConverter.WidgetConverter(GetCPDFViewer().GetDocument(), cacheMoveWidget.GetAnnotData().Annot); - lastAnnotList.Add(annotParam); + AddLastAnnotList(annotParam); } DeleteAnnotData(); PDFViewer.UpdateAnnotFrame(); @@ -1158,6 +1265,7 @@ private void ExecuteAnnotCommand(RoutedUICommand uiCommand) break; } } + private void PasteAnnotData(bool pasteMatchStyle = false) { AnnotHistory annotHistory = null; @@ -1211,7 +1319,7 @@ private void PasteAnnotData(bool pasteMatchStyle = false) CPDFAnnotation cPDFAnnotation = cPDFPage.CreateAnnot(item.CurrentType); CreateDefaultAnnot(cPDFAnnotation, item.CurrentType, item); cPDFAnnotation.SetRect(setRect); - cPDFAnnotation.UpdateAp(); + CommonHelper.UpdateStickyAP(cPDFAnnotation as CPDFTextAnnotation); AnnotParam annotParam = ParamConverter.AnnotConverter(cPDFDocument, cPDFAnnotation); (annotHistory as StickyNoteAnnotHistory).CurrentParam = (StickyNoteParam)annotParam; } @@ -1446,8 +1554,67 @@ private void PasteAnnotData(bool pasteMatchStyle = false) (annotHistory as CircleAnnotHistory).CurrentParam = (CircleParam)annotParam; } break; + case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON: + { + CPDFDocument cPDFDocument = PDFViewer.GetDocument(); + Rect rect; + annotHistory = new PolygonMeasureAnnotHistory(); + annotHistory.PDFDoc = cPDFDocument; + int index = -1; + if (point.Equals(new Point(-1, -1))) + { + index = item.PageIndex; + rect = new Rect( + (item.ClientRect.left + 25), + (item.ClientRect.top + 25), + item.ClientRect.width(), + item.ClientRect.height() + ); + } + else + { + PDFViewer.GetPointPageInfo(point, out index, out Rect paintRect, out var pageBound); + CRect cRect = item.ClientRect; + Point zoomPoint = new Point((point.X - pageBound.X) / currentZoom, (point.Y - pageBound.Y) / currentZoom); + Point pdfPoint = DpiHelper.StandardPointToPDFPoint(zoomPoint); + rect = new Rect( + (pdfPoint.X - cRect.width() / 2), + (pdfPoint.Y - cRect.height() / 2), + cRect.width(), + cRect.height() + ); + } + + CRect setRect = DataConversionForWPF.RectConversionForCRect(rect); + PolygonMeasureParam newPolygonParam = new PolygonMeasureParam(); + item.CopyTo(newPolygonParam); + if(newPolygonParam.SavePoints != null && newPolygonParam.SavePoints.Count>0) + { + float offsetX = setRect.left - item.ClientRect.left; + float offsetY = setRect.top - item.ClientRect.top; + List arrangeList = new List(); + foreach (CPoint addPoint in newPolygonParam.SavePoints) + { + arrangeList.Add(new CPoint(addPoint.x + offsetX, addPoint.y + offsetY)); + } + + newPolygonParam.SavePoints = arrangeList; + newPolygonParam.ClientRect = setRect; + } + + CPDFPage cPDFPage = cPDFDocument.PageAtIndex(index); + if (cPDFPage == null) + return; + + CPDFAnnotation cPDFAnnotation = cPDFPage.CreateAnnot(newPolygonParam.CurrentType); + CreateDefaultAnnot(cPDFAnnotation, newPolygonParam.CurrentType, newPolygonParam); + cPDFAnnotation.UpdateAp(); + AnnotParam annotParam = ParamConverter.AnnotConverter(cPDFDocument, cPDFAnnotation); + (annotHistory as PolygonMeasureAnnotHistory).CurrentParam = (PolygonMeasureParam)annotParam; + } break; + case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE: break; case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP: @@ -1470,7 +1637,7 @@ private void PasteAnnotData(bool pasteMatchStyle = false) else { PDFViewer.GetPointPageInfo(point, out index, out Rect paintRect, out var pageBound); - CRect cRect = item.ClientRect; + CRect cRect = (item as StampParam).SourceRect; Point zoomPoint = new Point((point.X - pageBound.X) / currentZoom, (point.Y - pageBound.Y) / currentZoom); Point pdfPoint = DpiHelper.StandardPointToPDFPoint(zoomPoint); rect = new Rect( @@ -1486,12 +1653,29 @@ private void PasteAnnotData(bool pasteMatchStyle = false) if (cPDFPage == null) return; - CPDFAnnotation cPDFAnnotation = cPDFPage.CreateAnnot(item.CurrentType); - CreateDefaultAnnot(cPDFAnnotation, item.CurrentType, item); - cPDFAnnotation.SetRect(setRect); - cPDFAnnotation.UpdateAp(); - AnnotParam annotParam = ParamConverter.AnnotConverter(cPDFDocument, cPDFAnnotation); - (annotHistory as StampAnnotHistory).CurrentParam = (StampParam)annotParam; + StampParam stampParam = item as StampParam; + CPDFStampAnnotation stampAnnot; + if (stampParam.StampType == C_STAMP_TYPE.IMAGE_STAMP) + { + stampAnnot = CPDFAnnotation.AddCopyAnnotToPage(cPDFDocument, cPDFPage, stampParam.CopyImageAnnot) as CPDFStampAnnotation; + } + else + { + stampAnnot = cPDFPage.CreateAnnot(item.CurrentType) as CPDFStampAnnotation; + CreateDefaultAnnot(stampAnnot, item.CurrentType, item); + } + + stampAnnot.SetSourceRect(setRect); + stampAnnot.AnnotationRotator.SetRotation(stampParam.Rotation); + stampAnnot.UpdateAp(); + + StampParam annotParam = ParamConverter.AnnotConverter(cPDFDocument, stampAnnot) as StampParam; + if (annotParam.StampType == C_STAMP_TYPE.IMAGE_STAMP) + { + annotParam.CopyImageAnnot = CPDFAnnotation.CopyAnnot(stampAnnot); + } + + (annotHistory as StampAnnotHistory).CurrentParam = annotParam; } break; case C_ANNOTATION_TYPE.C_ANNOTATION_CARET: @@ -1606,8 +1790,8 @@ private void DeleteAnnotData() { return; } - AnnotParam annotParam = null; + AnnotParam annotParam = null; if (cacheHitTestAnnot is BaseWidget) { annotParam = ParamConverter.WidgetConverter(PDFViewer.GetDocument(), cacheHitTestAnnot.GetAnnotData().Annot); @@ -1616,6 +1800,7 @@ private void DeleteAnnotData() { annotParam = ParamConverter.AnnotConverter(PDFViewer.GetDocument(), cacheHitTestAnnot.GetAnnotData().Annot); } + if (annotParam != null) { notifyData = new ExpandoObject(); @@ -1629,6 +1814,14 @@ private void DeleteAnnotData() notifyData.WidgetType = (annotParam as WidgetParm).WidgetType; } + if (annotParam is StampParam stampParam) + { + if (stampParam.StampType == C_STAMP_TYPE.IMAGE_STAMP) + { + stampParam.CopyImageAnnot = CPDFAnnotation.CopyAnnot(cacheHitTestAnnot.GetAnnotData().Annot); + } + } + annotHistory.CurrentParam = annotParam; annotHistory.PDFDoc = PDFViewer.GetDocument(); annotHistory.Action = HistoryAction.Remove; diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.CreateWidget.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.CreateWidget.cs index b6b57e7..546d9dd 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.CreateWidget.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.CreateWidget.cs @@ -8,11 +8,6 @@ using ComPDFKitViewer.Helper; using ComPDFKitViewer.Layer; using ComPDFKitViewer.Widget; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Input; @@ -27,6 +22,7 @@ public BaseWidget GetCacheHitTestWidget() { return cacheMoveWidget; } + private void InsertWidgetView() { CreateWidgetTool createAnnotTool = new CreateWidgetTool(); diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.CustomizeTool.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.CustomizeTool.cs index d72873f..cfcc09c 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.CustomizeTool.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.CustomizeTool.cs @@ -70,9 +70,11 @@ public void DrawStartCustomizeTool(CustomizeToolType ToolType) CPDFDocument cPDFDocument = PDFViewer.GetDocument(); CPDFPage cPDFPage = cPDFDocument.PageAtIndex(index); BaseLayer layer = PDFViewer.GetViewForTag(PDFViewer.GetAnnotViewTag()); + (baseLayer as CreateCustomizeTool).ErasePageIndex = -1; if (ToolType == CustomizeToolType.kErase) { (baseLayer as CreateCustomizeTool).SetAnnotLayer(layer as AnnotLayer); + (baseLayer as CreateCustomizeTool).ErasePageIndex = index; } (baseLayer as CreateCustomizeTool).StartDraw(point, cPDFPage, paintRect, pageBound, ToolType); } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.DataMethod.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.DataMethod.cs index add6a0a..5b1462b 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.DataMethod.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.DataMethod.cs @@ -4,9 +4,6 @@ using ComPDFKit.PDFDocument; using ComPDFKit.Tool.SettingParam; using ComPDFKitViewer; -using System; -using System.Collections.Generic; -using System.Linq; using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper; using static ComPDFKit.PDFAnnotation.CTextAttribute; using ComPDFKit.Tool.Help; @@ -24,9 +21,11 @@ public CPDFViewer GetCPDFViewer() } #region DefaultAnnot - public void CreateDefaultAnnot(CPDFAnnotation cPDFAnnotation, C_ANNOTATION_TYPE annotType, AnnotParam annotParam) { + if (cPDFAnnotation == null || !cPDFAnnotation.IsValid()) + return; + switch (annotType) { case C_ANNOTATION_TYPE.C_ANNOTATION_NONE: @@ -65,7 +64,6 @@ public void CreateDefaultAnnot(CPDFAnnotation cPDFAnnotation, C_ANNOTATION_TYPE { DefaultLineAnnot(cPDFAnnotation, annotParam); } - } break; case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE: @@ -183,6 +181,10 @@ private void DefaultTextAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam annotPar } TextAnnotation.SetColor(StickyNoteParamDef.StickyNoteColor); + if (string.IsNullOrEmpty(StickyNoteParamDef.IconName) == false) + { + TextAnnotation.SetIconName(StickyNoteParamDef.IconName); + } DefaultAnnot(cPDFAnnotation, StickyNoteParamDef); } @@ -254,7 +256,6 @@ private void DefaultFreeTextAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam anno { freeTextAnnotation.SetLineColor(FreeTextParam.LineColor); } - freeTextAnnotation.SetBorderWidth(1); freeTextAnnotation.SetTransparency(FreeTextParam.Transparency); freeTextAnnotation.SetLineWidth((float)FreeTextParam.LineWidth); @@ -262,6 +263,12 @@ private void DefaultFreeTextAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam anno { freeTextAnnotation.SetBgColor(FreeTextParam.BgColor); } + + if (FreeTextParam.Dash != null && FreeTextParam.Dash.Length > 0) + { + freeTextAnnotation.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, FreeTextParam.Dash); + } + CTextAttribute textAttr = new CTextAttribute(); textAttr.FontColor = FreeTextParam.FontColor; textAttr.FontSize = (float)FreeTextParam.FontSize; @@ -525,8 +532,8 @@ private void DefaultStrikeoutAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam ann private void DefaultStampAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam annotParam) { - CPDFStampAnnotation strikeoutAnnotation = (cPDFAnnotation as CPDFStampAnnotation); - if (strikeoutAnnotation == null) + CPDFStampAnnotation stampAnnot = (cPDFAnnotation as CPDFStampAnnotation); + if (stampAnnot == null) { return; } @@ -535,7 +542,6 @@ private void DefaultStampAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam annotPa if (annotParam == null) { DefaultSettingParam defaultSettingParam = GetDefaultSettingParam(); - stampParam = defaultSettingParam.StampParamDef; } else @@ -552,7 +558,8 @@ private void DefaultStampAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam annotPa { stampText = string.Empty; } - strikeoutAnnotation.SetStandardStamp(stampText, stampParam.Rotation); + + stampAnnot.SetStandardStamp(stampText, stampParam.PageRotation); } break; case C_STAMP_TYPE.IMAGE_STAMP: @@ -561,15 +568,14 @@ private void DefaultStampAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam annotPa int imageWidth = 0; int imageHeight = 0; PDFHelp.ImageStreamToByte(stampParam.ImageStream, ref imageData, ref imageWidth, ref imageHeight); - if (imageData != null && imageWidth > 0 && imageHeight > 0) { - strikeoutAnnotation.SetRect(new CRect(0, imageHeight, imageWidth, 0)); - strikeoutAnnotation.SetImageStamp( + stampAnnot.SetRect(new CRect(0, imageHeight, imageWidth, 0)); + stampAnnot.SetImageStamp( imageData, imageWidth, imageHeight, - stampParam.Rotation); + stampParam.PageRotation); } } break; @@ -585,12 +591,12 @@ private void DefaultStampAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam annotPa { stampText = string.Empty; } - strikeoutAnnotation.SetTextStamp( + stampAnnot.SetTextStamp( stampText, dateText, stampParam.TextStampShape, stampParam.TextStampColor, - stampParam.Rotation); + stampParam.PageRotation); } break; default: @@ -625,7 +631,16 @@ private void DefaultInkAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam annotPara } InkAnnotation.SetThickness((float)inkParam.Thickness); - (cPDFAnnotation as CPDFInkAnnotation).SetInkPath(inkParam.InkPath); + CPDFInkAnnotation inkAnnot = cPDFAnnotation as CPDFInkAnnotation; + inkAnnot.SetInkPath(inkParam.InkPath); + if (inkParam.Dash != null && inkParam.Dash.Length > 0) + { + inkAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, inkParam.Dash); + } + else + { + inkAnnot.SetBorderStyle(C_BORDER_STYLE.BS_SOLID, new float[0]); + } DefaultAnnot(cPDFAnnotation, inkParam); } @@ -709,7 +724,6 @@ private void DefaultRedactAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam annotP textAttr.FontSize = (float)redactParam.FontSize; textAttr.FontName = redactParam.FontName; redactAnnotation.SetTextAttribute(textAttr); - DefaultAnnot(cPDFAnnotation, redactParam); } @@ -779,68 +793,81 @@ private void DefaultLineMeasureAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam a private void DefaultPolygonMeasureAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam annotParam) { CPDFPolygonAnnotation PolyAnnotation = (cPDFAnnotation as CPDFPolygonAnnotation); + bool IsOpenMeasure = true; if (PolyAnnotation == null) { return; } - if (!PolyAnnotation.IsMeasured() && annotParam != null) - { - return; - } - PolygonMeasureParam MeasureParam; + + PolygonMeasureParam polyonMeasureParam; if (annotParam == null) { DefaultSettingParam defaultSettingParam = GetDefaultSettingParam(); - - MeasureParam = defaultSettingParam.PolygonMeasureParamDef; + polyonMeasureParam = defaultSettingParam.PolygonMeasureParamDef; + IsOpenMeasure = defaultSettingParam.IsOpenMeasure; } else { - MeasureParam = annotParam as PolygonMeasureParam; + polyonMeasureParam = annotParam as PolygonMeasureParam; + IsOpenMeasure = defaultSettingParam.IsOpenMeasure; } - if (MeasureParam.LineColor != null) + if (polyonMeasureParam.LineColor != null) { - PolyAnnotation.SetLineColor(MeasureParam.LineColor); + PolyAnnotation.SetLineColor(polyonMeasureParam.LineColor); } - PolyAnnotation.SetLineWidth((float)MeasureParam.LineWidth); - if (MeasureParam.LineDash != null) + PolyAnnotation.SetLineWidth((float)polyonMeasureParam.LineWidth); + if (polyonMeasureParam.LineDash != null) { - if (MeasureParam.LineDash.Length == 0) + if (polyonMeasureParam.LineDash.Length == 0) { PolyAnnotation.SetBorderStyle(C_BORDER_STYLE.BS_SOLID, new float[0]); } else { - PolyAnnotation.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, MeasureParam.LineDash); + PolyAnnotation.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, polyonMeasureParam.LineDash); } } - if (MeasureParam.HasFillColor && MeasureParam.FillColor != null && MeasureParam.FillColor.Length == 3) + if (polyonMeasureParam.HasFillColor && polyonMeasureParam.FillColor != null && polyonMeasureParam.FillColor.Length == 3) { - PolyAnnotation.SetBgColor(MeasureParam.FillColor); + PolyAnnotation.SetBgColor(polyonMeasureParam.FillColor); } - CTextAttribute textAttribute = new CTextAttribute(); - textAttribute.FontColor = MeasureParam.FontColor; - textAttribute.FontSize = (float)MeasureParam.FontSize; - textAttribute.FontName = CFontNameHelper.ObtainFontName(CFontNameHelper.GetFontType(MeasureParam.FontName), - MeasureParam.IsBold, - MeasureParam.IsItalic); - PolyAnnotation.SetTextAttribute(textAttribute); - if (MeasureParam.measureInfo != null) + if(polyonMeasureParam.BorderEffector != null) { - CPDFAreaMeasure polygonMeasure = PolyAnnotation.GetAreaMeasure(); - if (polygonMeasure != null) + PolyAnnotation.SetAnnotBorderEffector(polyonMeasureParam.BorderEffector); + } + + if (polyonMeasureParam.SavePoints != null && polyonMeasureParam.SavePoints.Count>0) + { + PolyAnnotation.SetPoints(polyonMeasureParam.SavePoints); + } + + if (IsOpenMeasure) + { + CTextAttribute textAttribute = new CTextAttribute(); + textAttribute.FontColor = polyonMeasureParam.FontColor; + textAttribute.FontSize = (float)polyonMeasureParam.FontSize; + textAttribute.FontName = CFontNameHelper.ObtainFontName(CFontNameHelper.GetFontType(polyonMeasureParam.FontName), + polyonMeasureParam.IsBold, + polyonMeasureParam.IsItalic); + PolyAnnotation.SetTextAttribute(textAttribute); + if (polyonMeasureParam.measureInfo != null) { - polygonMeasure.SetMeasureInfo(MeasureParam.measureInfo); - polygonMeasure.SetMeasureScale(MeasureParam.measureInfo.RulerBase, MeasureParam.measureInfo.RulerBaseUnit, - MeasureParam.measureInfo.RulerTranslate, MeasureParam.measureInfo.RulerTranslateUnit); - polygonMeasure.UpdateAnnotMeasure(); + CPDFAreaMeasure polygonMeasure = PolyAnnotation.GetAreaMeasure(); + if (polygonMeasure != null) + { + polygonMeasure.SetMeasureInfo(polyonMeasureParam.measureInfo); + polygonMeasure.SetMeasureScale(polyonMeasureParam.measureInfo.RulerBase, polyonMeasureParam.measureInfo.RulerBaseUnit, + polyonMeasureParam.measureInfo.RulerTranslate, polyonMeasureParam.measureInfo.RulerTranslateUnit); + polygonMeasure.UpdateAnnotMeasure(); + } } } - DefaultAnnot(cPDFAnnotation, MeasureParam); + + DefaultAnnot(cPDFAnnotation, polyonMeasureParam); } private void DefaultPolyLineMeasureAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam annotParam) @@ -999,11 +1026,7 @@ private void DefaultPushButton(CPDFAnnotation cPDFAnnotation, AnnotParam annotPa CTextAttribute textAttr = new CTextAttribute(); textAttr.FontColor = pushButtonParam.FontColor; textAttr.FontSize = (float)pushButtonParam.FontSize; - FontType checkFontType = CFontNameHelper.GetFontType(pushButtonParam.FontName); - textAttr.FontName = CFontNameHelper.ObtainFontName( - checkFontType == FontType.Unknown ? FontType.Helvetica : checkFontType, - pushButtonParam.IsBold, - pushButtonParam.IsItalic); + textAttr.FontName = pushButtonParam.FontName; widget.SetTextAttribute(textAttr); if (!string.IsNullOrEmpty(pushButtonParam.FieldName)) @@ -1156,11 +1179,7 @@ private void DefaultTextField(CPDFAnnotation cPDFAnnotation, AnnotParam annotPar CTextAttribute textAttr = new CTextAttribute(); textAttr.FontColor = textBoxParam.FontColor; textAttr.FontSize = (float)textBoxParam.FontSize; - FontType checkFontType = CFontNameHelper.GetFontType(textBoxParam.FontName); - textAttr.FontName = CFontNameHelper.ObtainFontName( - checkFontType == FontType.Unknown ? FontType.Helvetica : checkFontType, - textBoxParam.IsBold, - textBoxParam.IsItalic); + textAttr.FontName = textBoxParam.FontName; widget.SetTextAttribute(textAttr); if (!string.IsNullOrEmpty(textBoxParam.FieldName)) @@ -1205,11 +1224,7 @@ private void DefaultComBoBox(CPDFAnnotation cPDFAnnotation, AnnotParam annotPara CTextAttribute textAttr = new CTextAttribute(); textAttr.FontColor = comboBoxParam.FontColor; textAttr.FontSize = (float)comboBoxParam.FontSize; - FontType checkFontType = CFontNameHelper.GetFontType(comboBoxParam.FontName); - textAttr.FontName = CFontNameHelper.ObtainFontName( - checkFontType == FontType.Unknown ? FontType.Helvetica : checkFontType, - comboBoxParam.IsBold, - comboBoxParam.IsItalic); + textAttr.FontName = comboBoxParam.FontName; widget.SetTextAttribute(textAttr); if (!string.IsNullOrEmpty(comboBoxParam.FieldName)) @@ -1260,11 +1275,7 @@ private void DefaultListBox(CPDFAnnotation cPDFAnnotation, AnnotParam annotParam CTextAttribute textAttr = new CTextAttribute(); textAttr.FontColor = listBoxParam.FontColor; textAttr.FontSize = (float)listBoxParam.FontSize; - FontType checkFontType = CFontNameHelper.GetFontType(listBoxParam.FontName); - textAttr.FontName = CFontNameHelper.ObtainFontName( - checkFontType == FontType.Unknown ? FontType.Helvetica : checkFontType, - listBoxParam.IsBold, - listBoxParam.IsItalic); + textAttr.FontName = listBoxParam.FontName; widget.SetTextAttribute(textAttr); if (!string.IsNullOrEmpty(listBoxParam.FieldName)) @@ -1316,11 +1327,7 @@ private void DefaultSignatureFields(CPDFAnnotation cPDFAnnotation, AnnotParam an textAttr.FontSize = (float)signatureParam.FontSize; bool isBold = IsBold(textAttr.FontName); bool isItalic = IsItalic(textAttr.FontName); - FontType checkFontType = CFontNameHelper.GetFontType(signatureParam.FontName); - textAttr.FontName = CFontNameHelper.ObtainFontName( - checkFontType == FontType.Unknown ? FontType.Helvetica : checkFontType, - isBold, - isItalic); + textAttr.FontName = signatureParam.FontName; widget.SetTextAttribute(textAttr); if (!string.IsNullOrEmpty(signatureParam.FieldName)) diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.FindReplace.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.FindReplace.cs index 783bf16..f763684 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.FindReplace.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.FindReplace.cs @@ -102,7 +102,7 @@ internal void FindText([CallerMemberName] string caller = "") // Start searching from the currently displayed page CPDFPage pdfPage = GetCPDFViewer().GetDocument().PageAtIndex(nextPageIndex); findSelectionEditPage = pdfPage.GetEditPage(); - findSelectionEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage); + findSelectionEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath); // If the passed value is null, it will cause the program to freeze if (string.IsNullOrEmpty(findText)) @@ -328,7 +328,7 @@ public int ReplaceAllText(string replaceText) { CPDFPage page = PDFViewer.GetDocument().PageAtIndex(pageIndex); CPDFEditPage editPage = page.GetEditPage(); - editPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage); + editPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath); editPage.FindText(findText, options); List editTextFindSelectionList = editPage.GetTextFindSelectionList(); diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.MultiSelectedRect.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.MultiSelectedRect.cs index aa5eea1..1b960ff 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.MultiSelectedRect.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.MultiSelectedRect.cs @@ -1,4 +1,5 @@ -using ComPDFKit.Tool.DrawTool; +using ComPDFKit.PDFPage.Edit; +using ComPDFKit.Tool.DrawTool; using ComPDFKit.Tool.Help; using ComPDFKit.Viewer.Layer; using System; @@ -207,13 +208,16 @@ public void SelectedMultiRect(Rect selectedRects, Rect MaxRect, SelectedType typ selectedRect.SetRect(selectedRects, currentZoom); selectedRect.SetMaxRect(MaxRect); EditAreaObject editAreaObject = GetEditAreaObjectForRect(lastSelectedRect); - if (startSelectedIndex != editAreaIndex || startSelectedPageIndex != pageIndex) + if (editAreaObject.cPDFEditArea is CPDFEditPathArea == false) { - startSelectedIndex = editAreaIndex; - startSelectedPageIndex = pageIndex; - startSelectedEditAreaObject = editAreaObject; - startSelectedRect = selectedRect; - editAreaList.Add(startSelectedRect, editAreaObject); + if (startSelectedIndex != editAreaIndex || startSelectedPageIndex != pageIndex) + { + startSelectedIndex = editAreaIndex; + startSelectedPageIndex = pageIndex; + startSelectedEditAreaObject = editAreaObject; + startSelectedRect = selectedRect; + editAreaList.Add(startSelectedRect, editAreaObject); + } } } } @@ -235,6 +239,13 @@ public void CleanSelectedMultiRect() MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(PDFViewer.GetViewForTag(MultiSelectedRectViewTag)); if (multiSelectedRect != null) { + if(editAreaList.Count != 0) + { + cachePathList.Clear(); + cachePathList = new List(); + GetDrawPathList(Mouse.GetPosition(this)); + } + multiSelectedRect.Children.Clear(); multiSelectedRect.CleanMulitSelectedRect(); editAreaMultiIndex.Clear(); @@ -246,7 +257,6 @@ public void CleanSelectedMultiRect() public void DrawStartSelectedMultiRect() { MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(PDFViewer.GetViewForTag(MultiSelectedRectViewTag)); - if (multiSelectedRect != null) { Point point = Mouse.GetPosition(this); @@ -258,7 +268,6 @@ public void DrawStartSelectedMultiRect() public void DrawMoveSelectedMultiRect() { MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(PDFViewer.GetViewForTag(MultiSelectedRectViewTag)); - if (multiSelectedRect != null&& multiSelectedRect.Children.Count>0) { Point point = Mouse.GetPosition(this); @@ -269,7 +278,6 @@ public void DrawMoveSelectedMultiRect() public void DrawEndSelectedMultiRect() { MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(PDFViewer.GetViewForTag(MultiSelectedRectViewTag)); - if (multiSelectedRect != null) { Point point = Mouse.GetPosition(this); @@ -285,9 +293,6 @@ public void ReDrawSelectedMultiRect() { multiSelectedRect.ClearDraw(); multiSelectedRect.CleanMulitSelectedRect(); - - Point point = Mouse.GetPosition(this); - switch (multiSelectedRect.GetSelectedType()) { case SelectedType.Annot: diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.PDFCompareEffect.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.PDFCompareEffect.cs new file mode 100644 index 0000000..add9b7f --- /dev/null +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.PDFCompareEffect.cs @@ -0,0 +1,131 @@ +using ComPDFKit.Tool.Help; +using ComPDFKit.Viewer.Layer; +using ComPDFKitViewer; +using ComPDFKitViewer.Helper; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media; + +namespace ComPDFKit.Tool +{ + public partial class CPDFViewerTool + { + private int PDFCompareViewID { get; set; } = -1; + private int PDFComparePageIndex { get; set; } = -1; + private List PDFCompareRectList { get; set; } + private SolidColorBrush PDFCompareBrush { get; set; } + private Pen PDFComparePen { get; set; } + private CustomizeLayer GetPDFCompareDrawView() + { + if(PDFViewer==null) + { + return null; + } + if (PDFCompareViewID != -1) + { + return PDFViewer.GetViewForTag(PDFCompareViewID) as CustomizeLayer; + } + int maxId = PDFViewer.GetMaxViewIndex(); + CustomizeLayer customizeLayer = new CustomizeLayer(); + PDFViewer.InsertView(maxId, customizeLayer); + PDFCompareViewID = customizeLayer.GetResTag(); + PDFViewer.DrawChanged -= DrawChangedNotify; + PDFViewer.DrawChanged += DrawChangedNotify; + return customizeLayer; + } + + private void DrawPDFCompare() + { + if (PDFCompareViewID==-1) + { + return; + } + CustomizeLayer drawLayer = GetPDFCompareDrawView(); + if (drawLayer == null) + { + return; + } + + if (PDFViewer.CurrentRenderFrame == null) + { + return; + } + + RenderFrame frame = PDFViewer.CurrentRenderFrame; + List drawDataList = frame.GetRenderDatas(); + if (drawDataList == null || drawDataList.Count == 0) + { + return; + } + + RenderData drawData = null; + foreach (RenderData data in drawDataList) + { + if (data.PageIndex == PDFComparePageIndex) + { + drawData = data; + break; + } + } + + DrawingContext drawDC= drawLayer.RenderOpen(); + + if (drawData != null && PDFCompareRectList != null) + { + foreach(Rect drawRect in PDFCompareRectList) + { + Rect standRect = DpiHelper.PDFRectToStandardRect(drawRect); + + Rect paintRect = new Rect( + standRect.Left * frame.ZoomFactor, + standRect.Top * frame.ZoomFactor, + standRect.Width * frame.ZoomFactor, + standRect.Height * frame.ZoomFactor); + + Rect offsetRect = new Rect( + paintRect.Left + drawData.PageBound.Left, + paintRect.Top + drawData.PageBound.Top, + paintRect.Width, + paintRect.Height); + + drawDC.DrawRectangle(PDFCompareBrush,PDFComparePen,offsetRect); + } + } + + drawDC.Close(); + } + + private void DrawChangedNotify(object sender, EventArgs e) + { + DrawPDFCompare(); + } + + public void SetPDFCompareView(SolidColorBrush FillBrush,Pen BorderPen,int PageIndex,List PDFRectList) + { + PDFCompareRectList=PDFRectList; + PDFComparePageIndex = PageIndex; + PDFCompareBrush = FillBrush; + PDFComparePen = BorderPen; + if(PDFCompareViewID==-1) + { + GetPDFCompareDrawView(); + } + DrawPDFCompare(); + } + + public void ClearPDFCompareView() + { + CustomizeLayer drawLayer = GetPDFCompareDrawView(); + if (drawLayer != null && PDFViewer != null) + { + PDFViewer.RemoveView(drawLayer); + PDFCompareViewID = -1; + } + } + } +} diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.PageSelected.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.PageSelected.cs index 1596a6e..3080405 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.PageSelected.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.PageSelected.cs @@ -4,15 +4,9 @@ using ComPDFKit.Tool.DrawTool; using ComPDFKit.Tool.Help; using ComPDFKit.Viewer.Layer; -using ComPDFKitViewer; using ComPDFKitViewer.Helper; using ComPDFKitViewer.Layer; using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -213,7 +207,7 @@ public void CreatePageSelectdRect() if (pageSelectedRect != null) { 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) { diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.SelectText.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.SelectText.cs index f509185..70a82a5 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.SelectText.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.SelectText.cs @@ -1,17 +1,10 @@ using ComPDFKit.Tool.DrawTool; using ComPDFKitViewer.Layer; -using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Input; using System.Windows; using ComPDFKitViewer.Helper; -using ComPDFKitViewer; using ComPDFKit.Tool.Help; -using System.Windows.Media; -using System.Xml.Linq; namespace ComPDFKit.Tool { diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.SelectedRect.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.SelectedRect.cs index 3d8c216..e2506fd 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.SelectedRect.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.SelectedRect.cs @@ -150,7 +150,7 @@ private void SelectedAnnot() SelectedRect selectedRect = CommonHelper.FindVisualChild(baseLayer as CustomizeLayer); if (selectedRect != null) { - selectedRect.SetAnnotData(cacheHitTestAnnot.GetAnnotData()); + selectedRect.SetAnnotData(cacheHitTestAnnot.GetAnnotData(), PDFViewer); } } @@ -166,7 +166,7 @@ private void SelectedAnnot(AnnotData annotData) } else { - selectedRect.SetAnnotData(annotData); + selectedRect.SetAnnotData(annotData, PDFViewer); } } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.TextEdit.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.TextEdit.cs index 4c3ea43..7695119 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.TextEdit.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.TextEdit.cs @@ -13,7 +13,6 @@ using ComPDFKitViewer.Layer; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Text; using System.Threading; @@ -112,7 +111,7 @@ public partial class CPDFViewerTool private int selectedEditAreaIndex = -1; private bool selectAllCharsForLine = false; private CPoint rawHitPos; - private CPDFEditType contentEditType = CPDFEditType.EditText | CPDFEditType.EditImage; + private CPDFEditType contentEditType = CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath; /// /// Save Current Crop Box @@ -151,6 +150,10 @@ public partial class CPDFViewerTool private List text = new List(); + private List path = new List(); + + private List cachePathList = new List(); + protected List ignoreTextPoints { get; set; } = new List(); protected List ignoreImagePoints { get; set; } = new List(); @@ -236,6 +239,18 @@ public void SelectedEditAreaForIndex(int pageIndex, int editAreaIndex, bool draw this.drawCaret = drawCaret; } + public void ClearLastSelectChars() + { + if (lastSelectedRect != null) + { + editArea.TryGetValue(lastSelectedRect, out EditAreaObject editAreaObject); + if (editAreaObject.cPDFEditArea is CPDFEditTextArea) + { + (editAreaObject.cPDFEditArea as CPDFEditTextArea).ClearSelectChars(); + } + } + } + /// /// Get the current set edit index /// @@ -384,36 +399,42 @@ public void SetEditTextRect(RenderFrame currentRenderFrame) hitTestRects.Clear(); image.Clear(); text.Clear(); - BaseLayer customizeLayer = PDFViewer.GetViewForTag(textEditTag); + path.Clear(); + BaseLayer customizeLayer = PDFViewer.GetViewForTag(textEditTag); customizeLayer.Children.Clear(); operateChildrenIndex = -1; CaretVisual caretVisual = new CaretVisual(GetDefaultDrawParam()); customizeLayer.Children.Add(caretVisual); - currentZoom = currentRenderFrame.ZoomFactor; - + MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(PDFViewer.GetViewForTag(MultiSelectedRectViewTag)); foreach (RenderData item in currentRenderFrame.GetRenderDatas()) { if (item.CPDFEditPageObj == null) - { continue; - } - foreach (CPDFEditArea editArea in item.CPDFEditPageObj.GetEditAreaList()) + + foreach (CPDFEditArea editArea in item.CPDFEditPageObj.GetEditAreaList().AsEnumerable().Reverse()) { + if (editArea is CPDFEditPathArea) + { + if (!cachePathList.Contains(editArea)) + continue; + } + SelectedRect selectedRect = new SelectedRect(GetDefaultDrawParam(), SelectedType.PDFEdit); selectedRect.SetEditPen(editPen, editHoverPen); selectedRect.SetDrawMoveType(DrawMoveType.kReferenceLine); customizeLayer.Children.Add(selectedRect); - Rect TextBlock = DataConversionForWPF.CRectConversionForRect(editArea.GetFrame()); + Rect editAreaRect = new Rect(); if (editArea.Type == CPDFEditType.EditImage) { if ((contentEditType & CPDFEditType.EditImage) != CPDFEditType.EditImage) { continue; } - TextBlock = DataConversionForWPF.CRectConversionForRect((editArea as CPDFEditImageArea).GetClipRect()); + + editAreaRect = DataConversionForWPF.CRectConversionForRect((editArea as CPDFEditImageArea).GetClipRect()); } else if (editArea.Type == CPDFEditType.EditText) { @@ -421,24 +442,51 @@ public void SetEditTextRect(RenderFrame currentRenderFrame) { continue; } + + editAreaRect = DataConversionForWPF.CRectConversionForRect(editArea.GetFrame()); + } + else if (editArea.Type == CPDFEditType.EditPath) + { + if ((contentEditType & CPDFEditType.EditPath) != CPDFEditType.EditPath) + { + continue; + } + + editAreaRect = DataConversionForWPF.CRectConversionForRect((editArea as CPDFEditPathArea).GetClipRect()); } - Rect rect = TextBlock; - rect.X = (rect.X) * currentRenderFrame.ZoomFactor; - rect.Y = (rect.Y) * currentRenderFrame.ZoomFactor; - rect.Width *= currentRenderFrame.ZoomFactor; - rect.Height *= currentRenderFrame.ZoomFactor; - rect = DpiHelper.PDFRectToStandardRect(rect); + editAreaRect.X = (editAreaRect.X) * currentZoom; + editAreaRect.Y = (editAreaRect.Y) * currentZoom; + editAreaRect.Width *= currentZoom; + editAreaRect.Height *= currentZoom; + editAreaRect = DpiHelper.PDFRectToStandardRect(editAreaRect); + editAreaRect.X += item.PageBound.X; + editAreaRect.Y += item.PageBound.Y; - rect.X += item.PageBound.X; - rect.Y += item.PageBound.Y; + if (editArea is CPDFEditPathArea) + { + selectedRect.RectMinHeight = 1; + selectedRect.RectMinWidth = 1; + } - //PDF对象设置界面矩形 selectedRect.SetRectPadding(5); - selectedRect.SetRect(rect, currentZoom); + selectedRect.SetRect(editAreaRect, currentZoom); selectedRect.SetMaxRect(item.PageBound); selectedRect.SetIgnorePointsAll(); - selectedRect.Draw(); + if ((editArea is CPDFEditPathArea)) + { + if (multiSelectedRect.selectedRects.Count==0) + { + selectedRect.Draw(); + } + + selectedRect.IsPath = true; + } + else + { + selectedRect.Draw(); + } + EditAreaObject editAreaObject = new EditAreaObject(); editAreaObject.ControlType = PointControlType.None; editAreaObject.cPDFEditArea = editArea; @@ -459,13 +507,18 @@ public void SetEditTextRect(RenderFrame currentRenderFrame) case CPDFEditType.EditImage: image.Add(selectedRect); break; + case CPDFEditType.EditPath: + path.Add(selectedRect); + break; default: break; } } } + hitTestRects.AddRange(text); hitTestRects.AddRange(image); + hitTestRects.AddRange(path); } public void DrawStartTextEdit(SelectedRect selectedRect, EditAreaObject editAreaObject) @@ -759,6 +812,41 @@ public MultiSelectedRect GetMultiSelectedRect() return multiSelectedRect; } + private void GetDrawPathList(Point point) + { + if ((contentEditType & CPDFEditType.EditPath) != CPDFEditType.EditPath) + return; + + PDFViewer.GetePointToPage(point, out RenderData renderData, out Point pagePoint); + pagePoint = new Point(pagePoint.X / currentZoom, pagePoint.Y / currentZoom); + if (renderData == null || renderData.CPDFEditPageObj == null) + return; + + foreach (CPDFEditArea editArea in renderData.CPDFEditPageObj.GetEditAreaList()) + { + if (editArea is CPDFEditPathArea) + { + CPDFEditPathArea pathArea = editArea as CPDFEditPathArea; + Rect rect = DataConversionForWPF.CRectConversionForRect(pathArea.GetClipRect()); + rect = DpiHelper.PDFRectToStandardRect(rect); + if(rect.Width <=1) + rect.Width += 1; + + if (rect.Height <= 1) + rect.Height += 1; + + if (rect.Contains(pagePoint)) + { + if (cachePathList.Contains(pathArea) == false) + { + cachePathList.Add(pathArea); + return; + } + } + } + } + } + /// /// Select /// @@ -787,17 +875,17 @@ public void DrawTextEditDownEvent(bool drawCaret = true) } //Prioritize the selected status - List checkList = new List(); - if (hitTestRects != null && hitTestRects.Count > 0) - { - List checkedList = hitTestRects.AsEnumerable().Where(x => x.GetIsSelected() == true).ToList(); - List unCheckList = hitTestRects.AsEnumerable().Where(x => x.GetIsSelected() == false).ToList(); + //List checkList = new List(); + //if (hitTestRects != null && hitTestRects.Count > 0) + //{ + // List checkedList = hitTestRects.AsEnumerable().Where(x => x.GetIsSelected() == true).ToList(); + // List unCheckList = hitTestRects.AsEnumerable().Where(x => x.GetIsSelected() == false).ToList(); - checkList.AddRange(checkedList); - checkList.AddRange(unCheckList); - } + // checkList.AddRange(checkedList); + // checkList.AddRange(unCheckList); + //} - foreach (SelectedRect rect in checkList) + foreach (SelectedRect rect in hitTestRects) { rect.SetIsHover(false); rect.SetIsSelected(false); @@ -808,9 +896,9 @@ public void DrawTextEditDownEvent(bool drawCaret = true) } else { - pointControlType = rect.GetHitControlIndex(point); } + editArea.TryGetValue(rect, out EditAreaObject editObject); if (pointControlType != PointControlType.None) { @@ -954,7 +1042,6 @@ public void DrawTextEditDownEvent(bool drawCaret = true) lastSelectedRect.Draw(); } - if (editAreaObject.cPDFEditArea is CPDFEditTextArea) { string chars = (editAreaObject.cPDFEditArea as CPDFEditTextArea).GetAllChars(); @@ -966,16 +1053,23 @@ public void DrawTextEditDownEvent(bool drawCaret = true) lastSelectedRect.ClearDraw(); } } + lastSelectedRect.DataChanged -= LastSelectedRect_DataChanged; if (lastSelectedRect.GetCurrentDrawPointType() != DrawPointType.Crop) { lastSelectedRect = null; } } + + if(editAreaList.Count == 0) + { + cachePathList.Clear(); + cachePathList = new List(); + GetDrawPathList(point); + } + caretVisual?.StopTimer(); caretVisual?.CleanDraw(); - - return; } /// @@ -1009,6 +1103,7 @@ public bool DelMultiSelectRect() } } } + return false; } @@ -1060,7 +1155,6 @@ private void LastSelectedRect_DataChanged(object sender, SelectedAnnotData e) keyValuePairs.Add(currentEditAreaObject.PageIndex, OldRect); DrawUpdateText(keyValuePairs, currentEditAreaObject.PageBound); - UpdateSelectRect(editAreaObject.cPDFEditArea); // Move the moved selected box to the top layer of the selected logic @@ -1074,10 +1168,19 @@ private void LastSelectedRect_DataChanged(object sender, SelectedAnnotData e) image.Remove(selectedRect); image.Insert(0, selectedRect); break; + case CPDFEditType.EditPath: + path.Remove(selectedRect); + path.Insert(0, selectedRect); + break; + + default: + break; } + hitTestRects.Clear(); hitTestRects.AddRange(text); hitTestRects.AddRange(image); + hitTestRects.AddRange(path); } } @@ -1279,6 +1382,7 @@ public void RemoveTextBlock(EditAreaObject areaObject = null) { continue; } + if (editAreaObject.cPDFEditArea is CPDFEditTextArea) { CPDFEditPage editPage = editAreaObject.cPDFEditPage; @@ -1289,7 +1393,6 @@ public void RemoveTextBlock(EditAreaObject areaObject = null) Rect.ClearDraw(); } } - SelectedEditAreaForIndex(-1, -1); } else { @@ -1298,15 +1401,13 @@ public void RemoveTextBlock(EditAreaObject areaObject = null) if (areaObject.cPDFEditArea is CPDFEditTextArea) { CPDFEditPage editPage = areaObject.cPDFEditPage; - CPDFEditTextArea textArea = areaObject.cPDFEditArea as CPDFEditTextArea; - int index = areaObject.EditAreaIndex; - editPage.RemoveEditArea(index); + editPage.RemoveEditArea(areaObject.EditAreaIndex); editPage.EndEdit(); - } } - SelectedEditAreaForIndex(-1, -1); } + + SelectedEditAreaForIndex(-1, -1); } /// @@ -1324,17 +1425,17 @@ public void RemoveImageBlock(EditAreaObject areaObject = null) { continue; } + if (editAreaObject.cPDFEditArea is CPDFEditImageArea) { CPDFEditPage editPage = editAreaObject.cPDFEditPage; - CPDFEditImageArea textArea = editAreaObject.cPDFEditArea as CPDFEditImageArea; - int index = editAreaObject.cPDFEditPage.GetEditAreaList().IndexOf(textArea); + CPDFEditImageArea imageArea = editAreaObject.cPDFEditArea as CPDFEditImageArea; + int index = editAreaObject.cPDFEditPage.GetEditAreaList().IndexOf(imageArea); editPage.RemoveEditArea(index); editPage.EndEdit(); Rect.ClearDraw(); } } - SelectedEditAreaForIndex(-1, -1); } else { @@ -1343,14 +1444,51 @@ public void RemoveImageBlock(EditAreaObject areaObject = null) if (areaObject.cPDFEditArea is CPDFEditImageArea) { CPDFEditPage editPage = areaObject.cPDFEditPage; - CPDFEditImageArea textArea = areaObject.cPDFEditArea as CPDFEditImageArea; - int index = areaObject.EditAreaIndex; + editPage.RemoveEditArea(areaObject.EditAreaIndex); + editPage.EndEdit(); + } + } + } + + SelectedEditAreaForIndex(-1, -1); + } + + public void RemovePathBlock(EditAreaObject areaObject = null) + { + if (currentEditAreaObject != null && currentEditAreaObject.cPDFEditPage != null) + { + foreach (var Rect in hitTestRects) + { + editArea.TryGetValue(Rect, out EditAreaObject editAreaObject); + if (editAreaObject != currentEditAreaObject) + { + continue; + } + if (editAreaObject.cPDFEditArea is CPDFEditPathArea) + { + CPDFEditPage editPage = editAreaObject.cPDFEditPage; + CPDFEditPathArea pathArea = editAreaObject.cPDFEditArea as CPDFEditPathArea; + int index = editAreaObject.cPDFEditPage.GetEditAreaList().IndexOf(pathArea); editPage.RemoveEditArea(index); editPage.EndEdit(); + Rect.ClearDraw(); + } + } + } + else + { + if (areaObject != null && areaObject.cPDFEditPage != null) + { + if (areaObject.cPDFEditArea is CPDFEditPathArea) + { + CPDFEditPage editPage = areaObject.cPDFEditPage; + editPage.RemoveEditArea(areaObject.EditAreaIndex); + editPage.EndEdit(); } } - SelectedEditAreaForIndex(-1, -1); } + + SelectedEditAreaForIndex(-1, -1); } public void CleanEditView() @@ -1422,6 +1560,9 @@ private void DelaySetText(string content) editHistory.EditPage = currentEditAreaObject.cPDFEditPage; editHistory.PageIndex = currentEditAreaObject.PageIndex; CPDFEditTextArea textArea = currentEditAreaObject.cPDFEditArea as CPDFEditTextArea; + if (textArea == null) + return; + Rect OldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame()); GroupHistory groupHistory = new GroupHistory(); if (content == "\b") @@ -1580,20 +1721,35 @@ public Cursor DrawMoveTest(SelectedRect selectedRect1) } //Prioritize the selected status - List checkList = new List(); - if (hitTestRects != null && hitTestRects.Count > 0) - { - List checkedList = hitTestRects.AsEnumerable().Where(x => x.GetIsSelected() == true).ToList(); - List unCheckList = hitTestRects.AsEnumerable().Where(x => x.GetIsSelected() == false).ToList(); - - checkList.AddRange(checkedList); - checkList.AddRange(unCheckList); + //List checkList = new List(); + //if (hitTestRects != null && hitTestRects.Count > 0) + //{ + // List checkedList = hitTestRects.AsEnumerable().Where(x => x.GetIsSelected() == true).ToList(); + // List unCheckList = hitTestRects.AsEnumerable().Where(x => x.GetIsSelected() == false).ToList(); + + // checkList.AddRange(checkedList); + // checkList.AddRange(unCheckList); + //} + + //Multiple selection of mouse styles + MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(PDFViewer.GetViewForTag(MultiSelectedRectViewTag)); + if (multiSelectedRect != null && multiSelectedRect.selectedRects.Count > 0) + { + PointControlType pointMultiControlType = multiSelectedRect.GetHitControlIndex(point); + if (pointMultiControlType != PointControlType.None) + { + cursor = GetCursors(pointMultiControlType, true); + return cursor; + } } - foreach (SelectedRect rect in checkList) + foreach (SelectedRect rect in hitTestRects) { - PointControlType pointControlType = rect.GetHitControlIndex(point, false); - MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(PDFViewer.GetViewForTag(MultiSelectedRectViewTag)); + if (multiSelectedRect != null && multiSelectedRect.selectedRects.Contains(rect)) + { + continue; + } + if (GetIsCropMode()) { PointControlType pointCropControlType = rect.GetHitCropControlIndex(point, false); @@ -1605,16 +1761,11 @@ public Cursor DrawMoveTest(SelectedRect selectedRect1) } else { - //Multiple selection of mouse styles - if (multiSelectedRect != null && multiSelectedRect.Children.Count > 0) - { - PointControlType pointMultiControlType = multiSelectedRect.GetHitControlIndex(Mouse.GetPosition(this)); - cursor = GetCursors(pointMultiControlType, true); - } + PointControlType pointControlType = rect.GetHitControlIndex(point, false); if (pointControlType != PointControlType.None) { EditAreaObject editAreaObject = GetEditAreaObjectForRect(rect); - if (editAreaObject.cPDFEditArea.Type == CPDFEditType.EditImage) + if (editAreaObject.cPDFEditArea.Type == CPDFEditType.EditImage || editAreaObject.cPDFEditArea.Type == CPDFEditType.EditPath) { //image hover if (selectedRect1 == null) @@ -1678,7 +1829,7 @@ public Cursor DrawMoveTest(SelectedRect selectedRect1) return cursor; } - private Cursor GetCursors(PointControlType controlType, bool isImage) + private Cursor GetCursors(PointControlType controlType, bool notText) { switch (controlType) { @@ -1694,12 +1845,12 @@ private Cursor GetCursors(PointControlType controlType, bool isImage) case PointControlType.RightTop: return Cursors.SizeNESW; - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: case PointControlType.MiddleTop: return Cursors.SizeNS; case PointControlType.Body: - if (isImage) + if (notText) { return Cursors.SizeAll; } @@ -1874,17 +2025,32 @@ private void UpdateSelectRect(CPDFEditArea editArea) selectedRect = item.Key; } } + if (selectedRect != null) { Rect maxrect = selectedRect.GetMaxRect(); - Rect rect = DataConversionForWPF.CRectConversionForRect(editArea.GetFrame()); - if (editArea.Type == CPDFEditType.EditImage) + Rect rect = new Rect(); + if (editArea.Type == CPDFEditType.EditText) + { + if ((contentEditType & CPDFEditType.EditText) == CPDFEditType.EditText) + { + rect = DataConversionForWPF.CRectConversionForRect(editArea.GetFrame()); + } + } + else if (editArea.Type == CPDFEditType.EditImage) { if ((contentEditType & CPDFEditType.EditImage) == CPDFEditType.EditImage) { rect = DataConversionForWPF.CRectConversionForRect((editArea as CPDFEditImageArea).GetClipRect()); } } + else if (editArea.Type == CPDFEditType.EditPath) + { + if ((contentEditType & CPDFEditType.EditPath) == CPDFEditType.EditPath) + { + rect = DataConversionForWPF.CRectConversionForRect((editArea as CPDFEditPathArea).GetClipRect()); + } + } rect.X = (rect.X) * currentZoom; rect.Y = (rect.Y) * currentZoom; @@ -2003,7 +2169,6 @@ private void CleanDraw() caretVisual.StopCaret(); } - /// /// Jump cursor to a specific position in a text area. /// @@ -2174,61 +2339,90 @@ public Rect DrawEndFrameSelect() /// public void FrameSelectAddRect(Rect rectFrameSelect) { - if (rectFrameSelect.Width == 0 || rectFrameSelect.Height == 0) - { + if (rectFrameSelect.Width == 0 || rectFrameSelect.Height == 0 || PDFViewer.CurrentRenderFrame == null) return; - } - if (PDFViewer.CurrentRenderFrame == null) - { - return; - } + RenderFrame currentRenderFrame = PDFViewer.CurrentRenderFrame; BaseLayer customizeLayer = PDFViewer.GetViewForTag(textEditTag); - customizeLayer.Children.Clear(); CaretVisual caretVisual = new CaretVisual(GetDefaultDrawParam()); customizeLayer.Children.Add(caretVisual); - currentZoom = currentRenderFrame.ZoomFactor; MultiSelectedRect multiSelectedRect = CommonHelper.FindVisualChild(PDFViewer.GetViewForTag(MultiSelectedRectViewTag)); foreach (RenderData item in currentRenderFrame.GetRenderDatas()) { - if (item.PageIndex == FrameSelectPageIndex) + if (item.PageIndex == FrameSelectPageIndex && item.CPDFEditPageObj != null) { - if (item.CPDFEditPageObj == null) - { - continue; - } foreach (CPDFEditArea editArea in item.CPDFEditPageObj.GetEditAreaList()) { - Rect TextBlock = DataConversionForWPF.CRectConversionForRect(editArea.GetFrame()); + Rect editAreaRect = new Rect(); if (editArea.Type == CPDFEditType.EditImage) { if ((contentEditType & CPDFEditType.EditImage) != CPDFEditType.EditImage) - { continue; - } - TextBlock = DataConversionForWPF.CRectConversionForRect((editArea as CPDFEditImageArea).GetClipRect()); + + editAreaRect = DataConversionForWPF.CRectConversionForRect((editArea as CPDFEditImageArea).GetClipRect()); } else if (editArea.Type == CPDFEditType.EditText) { if ((contentEditType & CPDFEditType.EditText) != CPDFEditType.EditText) - { continue; - } + + editAreaRect = DataConversionForWPF.CRectConversionForRect(editArea.GetFrame()); } - Rect rect = TextBlock; - if (rectFrameSelect.IntersectsWith(rect)) + else if (editArea.Type == CPDFEditType.EditPath) { - SelectedRect selectedRects = GetSelectedRectForEditAreaObject(editArea); + if ((contentEditType & CPDFEditType.EditPath) != CPDFEditType.EditPath) + continue; + + editAreaRect = DataConversionForWPF.CRectConversionForRect((editArea as CPDFEditPathArea).GetClipRect()); + } + + if (rectFrameSelect.IntersectsWith(editAreaRect)) + { + SelectedRect editAreaSelectedRect = GetSelectedRectForEditAreaObject(editArea); + if (editAreaSelectedRect == null && editArea is CPDFEditPathArea) + { + cachePathList.Add(editArea as CPDFEditPathArea); + + editAreaRect.X = (editAreaRect.X) * currentZoom; + editAreaRect.Y = (editAreaRect.Y) * currentZoom; + editAreaRect.Width *= currentZoom; + editAreaRect.Height *= currentZoom; + editAreaRect = DpiHelper.PDFRectToStandardRect(editAreaRect); + editAreaRect.X += item.PageBound.X; + editAreaRect.Y += item.PageBound.Y; + + editAreaSelectedRect = new SelectedRect(GetDefaultDrawParam(), SelectedType.PDFEdit); + editAreaSelectedRect.SetEditPen(editPen, editHoverPen); + editAreaSelectedRect.SetDrawMoveType(DrawMoveType.kReferenceLine); + customizeLayer.Children.Add(editAreaSelectedRect); + + editAreaSelectedRect.SetRectPadding(5); + editAreaSelectedRect.SetRect(editAreaRect, currentZoom); + editAreaSelectedRect.SetMaxRect(item.PageBound); + editAreaSelectedRect.SetIgnorePointsAll(); + + EditAreaObject editAreaObjects = new EditAreaObject(); + editAreaObjects.ControlType = PointControlType.None; + editAreaObjects.cPDFEditArea = editArea; + editAreaObjects.cPDFEditPage = item.CPDFEditPageObj; + editAreaObjects.PageIndex = item.PageIndex; + editAreaObjects.EditAreaIndex = item.CPDFEditPageObj.GetEditAreaList().IndexOf(editArea); + editAreaObjects.PageBound = item.PageBound; + editAreaObjects.PaintRect = item.PaintRect; + + this.editArea.Add(editAreaSelectedRect, editAreaObjects); + } + SelectedRect selectedRect = new SelectedRect(GetDefaultDrawParam(), SelectedType.PDFEdit); selectedRect.SetEditPen(editPen, editHoverPen); multiSelectedRect.SetSelectedType(SelectedType.PDFEdit); selectedRect.SetDrawMoveType(DrawMoveType.kReferenceLine); - selectedRect.SetRect(selectedRects.GetRect(), currentZoom); - selectedRect.SetMaxRect(selectedRects.GetMaxRect()); - EditAreaObject editAreaObject = null; + selectedRect.SetRect(editAreaSelectedRect.GetRect(), currentZoom); + selectedRect.SetMaxRect(editAreaSelectedRect.GetMaxRect()); + EditAreaObject editAreaObject = null; foreach (var eitem in this.editArea) { if (eitem.Value.cPDFEditArea == editArea) @@ -2237,36 +2431,38 @@ public void FrameSelectAddRect(Rect rectFrameSelect) break; } } + int pageIndex = editAreaObject.PageIndex; if (multiPage != pageIndex && editAreaList.Count > 0) { foreach (int itemIndex in editAreaMultiIndex) { - SelectedRect OldRect = GetEditAreaForIndex(multiPage, itemIndex); - if (OldRect != null) - { - OldRect.Draw(); - } + SelectedRect oldRect = GetEditAreaForIndex(multiPage, itemIndex); + oldRect?.Draw(); } + editAreaMultiIndex.Clear(); multiSelectedRect.ClearDraw(); multiSelectedRect.CleanMulitSelectedRect(); - multiPage = pageIndex; } - multiPage = editAreaObject.PageIndex; + + multiPage = pageIndex; editAreaMultiIndex.Add(editAreaObject.EditAreaIndex); editAreaList.Add(selectedRect, editAreaObject); multiSelectedRect.Children.Add(selectedRect); multiSelectedRect.SetMulitSelectedRect(selectedRect, editAreaObject.PageIndex, editAreaObject.EditAreaIndex); - multiSelectedRect.SetRect(selectedRects.GetRect()); - multiSelectedRect.SetMaxRect(selectedRects.GetMaxRect()); - multiSelectedRect.Draw(); + multiSelectedRect.SetRect(editAreaSelectedRect.GetRect()); + multiSelectedRect.SetMaxRect(editAreaSelectedRect.GetMaxRect()); + //multiSelectedRect.Draw(); } } } } - PDFViewer.UpdateRenderFrame(); + + //PDFViewer.UpdateRenderFrame(); + SetEditTextRect(PDFViewer.CurrentRenderFrame); + ReDrawSelectedMultiRect(); } #endregion @@ -2362,7 +2558,7 @@ private void SetPDFEditAlignLeft() CPDFDocument cPDFDocument = GetCPDFViewer().GetDocument(); CPDFPage cPDFPage = cPDFDocument.PageAtIndex(multiPage); CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage(); - cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage); + cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath); foreach (SelectedRect checkItem in MultiSelectEditList.GetMulitSelectList()) { SelectedRect item = checkItem; @@ -2422,7 +2618,7 @@ private void SetPDFEditAlignVerticalCenter() CPDFDocument cPDFDocument = GetCPDFViewer().GetDocument(); CPDFPage cPDFPage = cPDFDocument.PageAtIndex(multiPage); CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage(); - cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage); + cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath); foreach (SelectedRect checkItem in MultiSelectEditList.GetMulitSelectList()) { SelectedRect item = checkItem; @@ -2495,7 +2691,7 @@ private void SetPDFEditAlignRight() CPDFDocument cPDFDocument = GetCPDFViewer().GetDocument(); CPDFPage cPDFPage = cPDFDocument.PageAtIndex(multiPage); CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage(); - cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage); + cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath); foreach (SelectedRect checkItem in MultiSelectEditList.GetMulitSelectList()) { SelectedRect item = checkItem; @@ -2570,7 +2766,7 @@ private void SetPDFEditAlignTop() CPDFDocument cPDFDocument = GetCPDFViewer().GetDocument(); CPDFPage cPDFPage = cPDFDocument.PageAtIndex(multiPage); CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage(); - cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage); + cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath); foreach (SelectedRect checkItem in MultiSelectEditList.GetMulitSelectList()) { SelectedRect item = checkItem; @@ -2630,7 +2826,7 @@ private void SetPDFEditAlignHorizonCenter() CPDFDocument cPDFDocument = GetCPDFViewer().GetDocument(); CPDFPage cPDFPage = cPDFDocument.PageAtIndex(multiPage); CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage(); - cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage); + cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath); foreach (SelectedRect checkItem in MultiSelectEditList.GetMulitSelectList()) { SelectedRect item = checkItem; @@ -2687,7 +2883,7 @@ private void SetPDFEditAlignBottom() CPDFDocument cPDFDocument = GetCPDFViewer().GetDocument(); CPDFPage cPDFPage = cPDFDocument.PageAtIndex(multiPage); CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage(); - cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage); + cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath); foreach (SelectedRect checkItem in MultiSelectEditList.GetMulitSelectList()) { SelectedRect item = checkItem; @@ -2746,7 +2942,7 @@ private void SetPDFEditDistributeHorizontal() CPDFDocument cPDFDocument = GetCPDFViewer().GetDocument(); CPDFPage cPDFPage = cPDFDocument.PageAtIndex(multiPage); CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage(); - cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage); + cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath); foreach (SelectedRect item in MultiSelectEditList.GetMulitSelectList()) { Rect rect = item.GetRect(); @@ -2809,7 +3005,7 @@ private void SetPDFEditDistributeVertical() CPDFDocument cPDFDocument = GetCPDFViewer().GetDocument(); CPDFPage cPDFPage = cPDFDocument.PageAtIndex(multiPage); CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage(); - cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage); + cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath); foreach (SelectedRect item in MultiSelectEditList.GetMulitSelectList()) { Rect rect = item.GetRect(); diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.WidgetTool.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.WidgetTool.cs index e7922da..06dd7e3 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.WidgetTool.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.WidgetTool.cs @@ -39,6 +39,7 @@ public partial class CPDFViewerTool public static DependencyProperty PopupAttachDataProperty = DependencyProperty.Register("PopupAttachData", typeof(BaseAnnot), typeof(CPDFViewerTool)); public event EventHandler WidgetActionHandler; + public event EventHandler WidgetCreatedHandler; private CustomizeLayer formPopLayer=null; // Inner default pop-up control @@ -871,5 +872,13 @@ internal void PDFActionHandler(CPDFAction action,CPDFDocument currentDoc,CPDFVie } } } + + internal void InvokeWidgetCreated(CPDFAnnotation annot) + { + if(annot!=null && annot.IsValid()) + { + WidgetCreatedHandler?.Invoke(this, annot); + } + } } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.xaml b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.xaml index 6b57067..d7d89b2 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.xaml +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.xaml @@ -12,7 +12,7 @@ > + MouseUp="ScrollViewer_MouseUp" MouseDown="ScrollViewer_MouseDown" ScrollChanged="ScrollViewer_ScrollChanged"> diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.xaml.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.xaml.cs index 2b3ad27..63dcedc 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.xaml.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/CPDFViewerTool.xaml.cs @@ -1,5 +1,4 @@ -using ComPDFKit.Import; -using ComPDFKit.PDFAnnotation; +using ComPDFKit.PDFAnnotation; using ComPDFKit.PDFDocument; using ComPDFKit.PDFDocument.Action; using ComPDFKit.PDFPage; @@ -28,6 +27,7 @@ public struct MouseEventObject public MouseEventArgs mouseButtonEventArgs; public MouseHitTestType hitTestType; public C_ANNOTATION_TYPE annotType; + /// /// Identifies whether the object is created /// @@ -46,6 +46,7 @@ public enum MouseHitTestType Widget, TextEdit, ImageEdit, + PathEdit, ImageSelect, MultiTextEdit, SelectedPageRect, @@ -65,6 +66,7 @@ public enum ToolType public partial class CPDFViewerTool : UserControl { + public Cursor RotationCursor; public bool IsDocumentModified { get => isDocumentModified; @@ -110,6 +112,7 @@ protected override Visual GetVisualChild(int index) public event EventHandler MouseLeftButtonUpHandler; public event EventHandler MouseMoveHandler; public event EventHandler MouseRightButtonDownHandler; + public event EventHandler ScrollChangedHandler; public event EventHandler DrawChanged; public event EventHandler DocumentModifiedChanged; @@ -125,8 +128,6 @@ protected override Visual GetVisualChild(int index) private bool isMultiSelected; private bool isDocumentModified = false; - - public bool CanAddTextEdit = true; protected bool isContinueCreateTextEdit = false; @@ -142,12 +143,10 @@ public bool GetIsMultiSelected() /// public void SetContinueCreateTextEdit(bool isContinueCreateTextEdit) { - this.isContinueCreateTextEdit = isContinueCreateTextEdit; CanAddTextEdit = true; } - - + /// /// Does it support multiple selection /// @@ -322,7 +321,6 @@ protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { if (isContinueCreateTextEdit) { - if (lastSelectedRect != null) { CanAddTextEdit = false; @@ -333,7 +331,7 @@ protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) } } - if (PDFViewer == null || PDFViewer.CurrentRenderFrame == null) + if (PDFViewer == null || PDFViewer.CurrentRenderFrame == null || PDFViewer.IsRendering) { return; } @@ -342,6 +340,7 @@ protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { RemovePopTextUI(); } + Focus(); Mouse.Capture(this, CaptureMode.SubTree); MouseEventObject mouseEventObject = new MouseEventObject @@ -456,6 +455,11 @@ protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) } else if ((currentModel == ToolType.Pan || currentModel == ToolType.Viewer)) { + if (AnnotHitTest() && cacheHitTestAnnot.CurrentType == C_ANNOTATION_TYPE.C_ANNOTATION_LINK) + { + LinkAnnotAction(cacheHitTestAnnot); + } + if (DrawDownSelectImage(true)) { mouseEventObject.hitTestType = MouseHitTestType.ImageSelect; @@ -473,7 +477,7 @@ protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { cacheHitTestAnnot = PDFViewer?.AnnotHitTest() as BaseWidget; SelectedAnnot(); - mouseEventObject.hitTestType = MouseHitTestType.Annot; + mouseEventObject.hitTestType = MouseHitTestType.Annot; mouseEventObject.annotType = cacheMoveWidget.GetAnnotData().AnnotType; } @@ -575,7 +579,7 @@ protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) { - if (PDFViewer == null || PDFViewer.CurrentRenderFrame == null) + if (PDFViewer == null || PDFViewer.CurrentRenderFrame == null || PDFViewer.IsRendering) { return; } @@ -607,9 +611,9 @@ protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) ReleaseMouseCapture(); } - protected override void OnMouseMove(MouseEventArgs e) - { - if (PDFViewer == null || PDFViewer.CurrentRenderFrame == null) + protected override async void OnMouseMove(MouseEventArgs e) + { + if (PDFViewer == null || PDFViewer.CurrentRenderFrame == null || PDFViewer.IsRendering) { return; } @@ -718,6 +722,7 @@ protected override void OnMouseMove(MouseEventArgs e) } MouseMoveHandler?.Invoke(this, mouseEventObject); + PDFViewer.SetCustomMousePoint(Mouse.GetPosition(this).Y, Mouse.GetPosition(this).X); if (oldCursor != newCursor) { @@ -727,6 +732,14 @@ protected override void OnMouseMove(MouseEventArgs e) protected override void OnMouseRightButtonDown(MouseButtonEventArgs e) { + BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag); + bool isCreating = (baseLayer as CreateAnnotTool).IsCreating(); + if (PDFViewer.IsRendering || isCreating) + { + ContextMenu = null; + return; + } + MouseEventObject mouseEventObject = new MouseEventObject { mouseButtonEventArgs = e, @@ -768,13 +781,11 @@ protected override void OnMouseRightButtonDown(MouseButtonEventArgs e) } Point = e.GetPosition(this); - // Annotation selection effect if ((currentModel == ToolType.Pan || currentModel == ToolType.CreateAnnot)) { if (AnnotHitTest()) { - if (!isCacheRedaction) { if (cacheHitTestAnnot?.CurrentType == C_ANNOTATION_TYPE.C_ANNOTATION_LINK && currentModel != ToolType.CreateAnnot) @@ -815,6 +826,7 @@ protected override void OnMouseRightButtonDown(MouseButtonEventArgs e) else { CleanSelectedRect(); + CleanEditAnnot(); } } @@ -861,10 +873,13 @@ protected override void OnMouseRightButtonDown(MouseButtonEventArgs e) case CPDFEditType.EditImage: mouseEventObject.hitTestType = MouseHitTestType.ImageEdit; break; + case CPDFEditType.EditPath: + mouseEventObject.hitTestType = MouseHitTestType.PathEdit; + break; default: break; } - } + } } } else @@ -1021,6 +1036,7 @@ public void SizeChangeds() else { SelectedAnnot(null); + CleanEditAnnot(true); } } else if (selectedPageIndex != -1 && selectedAnnotIndex != -1) @@ -1078,5 +1094,25 @@ private void ScrollViewer_MouseDown(object sender, MouseButtonEventArgs e) { } + + private void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e) + { + ScrollChangedHandler?.Invoke(this, e); + } + + public void SetPageImageScale(float imageScale) + { + if (imageScale <= 0) + { + imageScale = 1; + } + + CPDFViewer.PageImageScale = imageScale; + } + + public float GetPageImageScale() + { + return CPDFViewer.PageImageScale; + } } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/ComPDFKit.Tool.csproj b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/ComPDFKit.Tool.csproj index 580c5dc..443260e 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/ComPDFKit.Tool.csproj +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/ComPDFKit.Tool.csproj @@ -83,11 +83,11 @@ 7.3 - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -113,6 +113,7 @@ + @@ -127,6 +128,7 @@ + @@ -168,6 +170,7 @@ + @@ -179,6 +182,7 @@ + @@ -209,24 +213,19 @@ - - {56e518ad-c126-4b48-9a09-0a64c87020e4} - ComPDFKit.NET - - - {783263cf-0da3-4095-9df8-2c4a6b3ff908} - ComPDFKit.Viewer - + + PreserveNewest + - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/AnnotEdit.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/AnnotEdit.cs index 7dd6b6e..1260d8f 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/AnnotEdit.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/AnnotEdit.cs @@ -4,18 +4,13 @@ using ComPDFKit.Tool.SettingParam; using ComPDFKit.Viewer.Helper; using ComPDFKitViewer; -using ComPDFKitViewer.Annot; using ComPDFKitViewer.Helper; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; -using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Media; -using System.Windows.Media.TextFormatting; -using static ComPDFKit.Tool.Help.ImportWin32; namespace ComPDFKit.Tool.DrawTool { @@ -49,7 +44,11 @@ internal class AnnotEdit : DrawingVisual /// protected bool isMouseDown { get; set; } - protected DrawingContext drawDC { get; set; } + protected DrawingContext drawDC + { + get; + set; + } /// /// Current annotation's control points collection (96 DPI coordinate points, minus page offset) @@ -188,17 +187,17 @@ public bool SetAnnotObject(AnnotData Data) case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE: break; case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON: - for (int i = 0; i < (annotData.Annot as CPDFPolygonAnnotation).Points.Count; i++) - { - Point point = DpiHelper.PDFPointToStandardPoint(new Point((annotData.Annot as CPDFPolygonAnnotation).Points[i].x, (annotData.Annot as CPDFPolygonAnnotation).Points[i].y)); - point = new Point( - point.X * annotData.CurrentZoom + annotData.PaintOffset.X - annotData.CropLeft * annotData.CurrentZoom, - point.Y * annotData.CurrentZoom + annotData.PaintOffset.Y - annotData.CropTop * annotData.CurrentZoom - ); - activePoints.Add(point); - } - if ((annotData.Annot as CPDFPolygonAnnotation).IsMeasured()) { + for (int i = 0; i < (annotData.Annot as CPDFPolygonAnnotation).Points.Count; i++) + { + Point point = DpiHelper.PDFPointToStandardPoint(new Point((annotData.Annot as CPDFPolygonAnnotation).Points[i].x, (annotData.Annot as CPDFPolygonAnnotation).Points[i].y)); + point = new Point( + point.X * annotData.CurrentZoom + annotData.PaintOffset.X - annotData.CropLeft * annotData.CurrentZoom, + point.Y * annotData.CurrentZoom + annotData.PaintOffset.Y - annotData.CropTop * annotData.CurrentZoom + ); + activePoints.Add(point); + } + CRect rawRect = annotData.Annot.GetRect(); Rect rect = DataConversionForWPF.CRectConversionForRect(rawRect); rect = DpiHelper.PDFRectToStandardRect(rect); @@ -210,18 +209,19 @@ public bool SetAnnotObject(AnnotData Data) ); } break; + case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE: - for (int i = 0; i < (annotData.Annot as CPDFPolylineAnnotation).Points.Count; i++) - { - Point point = DpiHelper.PDFPointToStandardPoint(new Point((annotData.Annot as CPDFPolylineAnnotation).Points[i].x, (annotData.Annot as CPDFPolylineAnnotation).Points[i].y)); - point = new Point( - point.X * annotData.CurrentZoom + annotData.PaintOffset.X - annotData.CropLeft * annotData.CurrentZoom, - point.Y * annotData.CurrentZoom + annotData.PaintOffset.Y - annotData.CropTop * annotData.CurrentZoom - ); - activePoints.Add(point); - } - if ((annotData.Annot as CPDFPolylineAnnotation).IsMeasured()) { + for (int i = 0; i < (annotData.Annot as CPDFPolylineAnnotation).Points.Count; i++) + { + Point point = DpiHelper.PDFPointToStandardPoint(new Point((annotData.Annot as CPDFPolylineAnnotation).Points[i].x, (annotData.Annot as CPDFPolylineAnnotation).Points[i].y)); + point = new Point( + point.X * annotData.CurrentZoom + annotData.PaintOffset.X - annotData.CropLeft * annotData.CurrentZoom, + point.Y * annotData.CurrentZoom + annotData.PaintOffset.Y - annotData.CropTop * annotData.CurrentZoom + ); + activePoints.Add(point); + } + CRect rawRect = annotData.Annot.GetRect(); Rect rect = DataConversionForWPF.CRectConversionForRect(rawRect); rect = DpiHelper.PDFRectToStandardRect(rect); @@ -233,6 +233,7 @@ public bool SetAnnotObject(AnnotData Data) ); } break; + case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT: break; case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE: @@ -318,7 +319,7 @@ private void CalcMeasurePoints(CPDFLineAnnotation Annot) lineVector.Normalize(); Vector leadEndVector = lineVector * (Math.Abs(LeadLength) + Math.Abs(LeadOffset) + Math.Abs(LeadExtension) * annotData.CurrentZoom); Vector leadStartVector = lineVector * (Math.Abs(LeadOffset)) * annotData.CurrentZoom; - Vector leadCrossVector = lineVector * (Math.Abs(LeadLength) * annotData.CurrentZoom + Math.Abs(LeadOffset)); + Vector leadCrossVector = lineVector * (Math.Abs(LeadLength) * annotData.CurrentZoom + Math.Abs(LeadOffset)); Matrix rotateMatrix = new Matrix(); double angle = LeadLength < 0 ? 90 : -90; rotateMatrix.Rotate(angle); @@ -362,20 +363,20 @@ public virtual void OnMouseMove(Point mousePoint, out bool Tag) { Tag = isMouseDown; mouseEndDrawPoint = mousePoint; - Point newOffset = new Point( mouseEndDrawPoint.X - mouseDownPoint.X, mouseEndDrawPoint.Y - mouseDownPoint.Y ); Point movePoint = CheckMoveOffSet(activePoints.ToList(), maxRect, newOffset); - if(movePoint.X==0) + + if (movePoint.X == 0) { - newOffset.X=moveOffset.X; + newOffset.X = moveOffset.X; } - if(movePoint.Y==0) + if (movePoint.Y == 0) { - newOffset.Y=moveOffset.Y; + newOffset.Y = moveOffset.Y; } moveOffset = newOffset; Draw(); @@ -385,26 +386,30 @@ public virtual void OnMouseMove(Point mousePoint, out bool Tag) public virtual void OnMouseLeftButtonUp(Point upPoint) { + if (annotData == null) + return; + isMouseDown = false; - Draw(); - if (annotData!=null&&annotData.AnnotType == C_ANNOTATION_TYPE.C_ANNOTATION_LINE) + if (annotData.AnnotType == C_ANNOTATION_TYPE.C_ANNOTATION_LINE) { if ((annotData.Annot as CPDFLineAnnotation).IsMeasured()) { activePoints.Clear(); - if (moveLeftLine == null) { moveLeftLine = leftLine.ToArray(); } + if (moveRightLine == null) { moveRightLine = rightLine.ToArray(); } + if (moveCrossLine == null) { moveCrossLine = crossLine.ToArray(); } + activePoints.Add(moveLeftLine[0]); activePoints.Add(moveLeftLine[1]); activePoints.Add(moveRightLine[0]); @@ -413,18 +418,21 @@ public virtual void OnMouseLeftButtonUp(Point upPoint) activePoints.Add(moveCrossLine[1]); } } + moveLeftLine = null; moveRightLine = null; moveCrossLine = null; - if (moveOffset!= new Point(0, 0)) + if (moveOffset != new Point(0, 0)) { InvokeDataChangEvent(true); } + moveOffset = new Point(0, 0); mouseDownPoint = new Point(); - mouseEndDrawPoint = new Point(); hitIndex = -1; + + SetAnnotObject(annotData); } /// @@ -511,7 +519,7 @@ public void Draw() }); } - private Point CheckPointBound(Point checkPoint,Rect bound) + private Point CheckPointBound(Point checkPoint, Rect bound) { if (checkPoint.X < bound.Left) { @@ -551,7 +559,7 @@ private Point CheckMoveOffSet(List checkPoints, Rect bound, Point moveOff Point movePoint = moveOffset; - if(left+moveOffset.Xbound.Right) + if (left + moveOffset.X < bound.Left || right + moveOffset.X > bound.Right) { movePoint.X = 0; } @@ -572,7 +580,7 @@ private void DrawLine(DrawingContext drawingContext) PolyLineSegment polySegment = new PolyLineSegment(); if (hitIndex != -1 && hitIndex < activePoints.Count) { - if (mouseEndDrawPoint!=new Point() && !activePoints.Contains(mouseEndDrawPoint)) + if (mouseEndDrawPoint != new Point() && !activePoints.Contains(mouseEndDrawPoint)) { activePoints[hitIndex] = CheckPointBound(mouseEndDrawPoint, maxRect); } @@ -584,7 +592,7 @@ private void DrawLine(DrawingContext drawingContext) StartPoint.X += moveOffset.X; StartPoint.Y += moveOffset.Y; } - + drawFigure.StartPoint = StartPoint; for (int i = 1; i < activePoints.Count; i++) { @@ -651,7 +659,7 @@ private void DrawLineMeasure(DrawingContext drawingContext) moveRightLine = rightLine.ToArray(); moveCrossLine = crossLine.ToArray(); switch (hitIndex) - { + { case 0://Left { moveLeftLine[0].X += moveOffset.X; @@ -825,12 +833,13 @@ private void DrawPolyLineMeasure(DrawingContext drawingContext) PolyLineSegment polySegment = new PolyLineSegment(); if (hitIndex != -1 && hitIndex < activePoints.Count) { - if (mouseEndDrawPoint != new Point()) + if (mouseEndDrawPoint != new Point() && !activePoints.Contains(mouseEndDrawPoint)) { - activePoints[hitIndex] = mouseEndDrawPoint; + activePoints[hitIndex] = CheckPointBound(mouseEndDrawPoint, maxRect); } } + Point StartPoint = activePoints[0]; if (hitIndex == -1) { @@ -889,11 +898,12 @@ private void DrawPolygonMeasure(DrawingContext drawingContext) PathFigure drawFigure = new PathFigure(); PolyLineSegment polySegment = new PolyLineSegment(); + if (hitIndex != -1 && hitIndex < activePoints.Count) { - if (mouseEndDrawPoint!=new Point()) + if (mouseEndDrawPoint != new Point() && !activePoints.Contains(mouseEndDrawPoint)) { - activePoints[hitIndex] = mouseEndDrawPoint; + activePoints[hitIndex] = CheckPointBound(mouseEndDrawPoint, maxRect); } } @@ -950,9 +960,10 @@ private void DrawPolygonMeasure(DrawingContext drawingContext) } } + int i = 0; public virtual void ClearDraw() { - drawDC = RenderOpen(); + drawDC = RenderOpen(); drawDC?.Close(); drawDC = null; } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/CreateAnnotTool.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/CreateAnnotTool.cs index 16b439c..f106191 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/CreateAnnotTool.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/CreateAnnotTool.cs @@ -9,27 +9,16 @@ using ComPDFKit.Viewer.Helper; using ComPDFKit.Viewer.Layer; using ComPDFKitViewer; -using ComPDFKitViewer.Annot; -using ComPDFKitViewer.BaseObject; using ComPDFKitViewer.Helper; using ComPDFKitViewer.Layer; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Annotations; using System.Windows.Controls; -using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Media.Media3D; using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper; -using static ComPDFKit.Tool.Help.ImportWin32; namespace ComPDFKit.Tool.DrawTool { @@ -245,6 +234,7 @@ public CPDFAnnotation StartDraw(Point downPoint, Point cropPoint, CPDFPage cPDFP { RemoveTextBox(); mouseStartPoint = downPoint; + mouseEndPoint = downPoint; isDrawAnnot = true; this.maxRect = maxRect; zoomFactor = zoom; @@ -299,7 +289,17 @@ public Rect EndDraw() DPIRect = drawRect = new Rect(mouseEndPoint.X, mouseEndPoint.Y, 32 * zoomFactor, 32 * zoomFactor); } } - Rect StandardRect = new Rect( + + if (cPDFAnnotation is CPDFPolylineAnnotation) + { + double left = drawPoints.AsEnumerable().Select(x => x.X).Min(); + double right = drawPoints.AsEnumerable().Select(x => x.X).Max(); + double top = drawPoints.AsEnumerable().Select(x => x.Y).Min(); + double bottom = drawPoints.AsEnumerable().Select(x => x.Y).Max(); + DPIRect = new Rect(left, top, right - left, bottom - top); + } + + Rect standardRect = new Rect( (DPIRect.Left - pageBound.X + (cropPoint.X * zoomFactor)) / zoomFactor, (DPIRect.Top - pageBound.Y + (cropPoint.Y * zoomFactor)) / zoomFactor, DPIRect.Width / zoomFactor, DPIRect.Height / zoomFactor); isDrawAnnot = false; @@ -312,7 +312,7 @@ public Rect EndDraw() cPDFAnnotation = null; inkDrawPoints.Clear(); drawPoints.Clear(); - return DpiHelper.StandardRectToPDFRect(StandardRect); + return DpiHelper.StandardRectToPDFRect(standardRect); } return new Rect(); } @@ -321,7 +321,6 @@ public override void Draw() { Dispatcher.Invoke(() => { - if (cPDFAnnotation == null) { return; @@ -680,6 +679,16 @@ private void DrawInk(DrawingContext drawingContext) lineSegment.IsSmoothJoin = true; pathFigure.Segments.Add(lineSegment); } + if (annotLine.Dash != null && annotLine.Dash.Length > 0) + { + DashStyle dash = new DashStyle(); + foreach (var offset in annotLine.Dash) + { + dash.Dashes.Add(offset); + } + DrawPen.DashStyle = dash; + DrawPen.DashCap = PenLineCap.Flat; + } Rect checkRect = pageBound; RectangleGeometry rectGeometry = new RectangleGeometry(); drawRect = rectGeometry.Rect = checkRect; @@ -1029,34 +1038,33 @@ private void DrawPolyLineMeasure(DrawingContext drawingContext) MeasureChanged?.Invoke(this, measureEvent); } - } private void DrawPolygonMeasure(DrawingContext drawingContext) { - CPDFPolygonAnnotation polyLine = (cPDFAnnotation as CPDFPolygonAnnotation); - byte[] bytes = polyLine.LineColor; + CPDFPolygonAnnotation polygonAnnot = (cPDFAnnotation as CPDFPolygonAnnotation); + byte[] bytes = polygonAnnot.LineColor; Color color = ParamConverter.ConverterByteForColor(bytes); - color.A = polyLine.GetTransparency(); - Pen DrawPen = new Pen(new SolidColorBrush(color), polyLine.GetBorderWidth()); - Pen EndDrawPen = new Pen(Brushes.Black, polyLine.GetBorderWidth()); + color.A = polygonAnnot.GetTransparency(); + Pen DrawPen = new Pen(new SolidColorBrush(color), polygonAnnot.GetBorderWidth()); + Pen EndDrawPen = new Pen(Brushes.Black, polygonAnnot.GetBorderWidth()); SolidColorBrush TextBrush = Brushes.Red; - if (polyLine.IsMeasured()) + if (polygonAnnot.IsMeasured()) { - CPDFAreaMeasure measureInfo = polyLine.GetAreaMeasure(); + CPDFAreaMeasure measureInfo = polygonAnnot.GetAreaMeasure(); if (measureInfo != null && measureInfo.TextAttribute != null && measureInfo.TextAttribute.FontColor != null && measureInfo.TextAttribute.FontColor.Length >= 3) { byte[] fontColor = measureInfo.TextAttribute.FontColor; TextBrush = new SolidColorBrush(Color.FromRgb(fontColor[0], fontColor[1], fontColor[2])); } - if (polyLine.Dash != null && polyLine.Dash.Length > 0) + if (polygonAnnot.Dash != null && polygonAnnot.Dash.Length > 0) { DashStyle dash = new DashStyle(); - foreach (var offset in polyLine.Dash) + foreach (var offset in polygonAnnot.Dash) { - dash.Dashes.Add(offset / polyLine.LineWidth); + dash.Dashes.Add(offset / polygonAnnot.LineWidth); } DrawPen.DashStyle = dash; DrawPen.DashCap = PenLineCap.Flat; @@ -1070,6 +1078,7 @@ private void DrawPolygonMeasure(DrawingContext drawingContext) mouseEndPoint = CalcAnglePoint(mouseEndPoint, drawPoints[drawPoints.Count - 1], pageBound); } } + Point checkPoint = mouseEndPoint; checkPoint.X = Math.Max(pageBound.Left, checkPoint.X); checkPoint.X = Math.Min(pageBound.Right, checkPoint.X); @@ -1087,214 +1096,256 @@ private void DrawPolygonMeasure(DrawingContext drawingContext) points.Add(rect.BottomRight); points.Add(rect.TopRight); } + if (points.Count > 0) { - PathGeometry drawPath = new PathGeometry(); - PathFigure drawFigure = new PathFigure(); - - drawFigure.StartPoint = points[0]; - PolyLineSegment polySegment = new PolyLineSegment(); - - for (int i = 1; i < points.Count; i++) + CPDFBorderEffector borderEffector = polygonAnnot.GetAnnotBorderEffector(); + if (borderEffector != null && borderEffector.BorderIntensity != C_BORDER_INTENSITY.C_INTENSITY_ZERO && borderEffector.BorderType != C_BORDER_TYPE.C_BORDER_TYPE_STRAIGHT) { - polySegment.Points.Add(points[i]); - } + //Draw the example line connected by the start point and the end point. + if (points.Count == 1) + { + Pen dashedPen = new Pen(Brushes.Gray, 1); + dashedPen.DashStyle = new DashStyle(new double[] { 2, 2 }, 0); + drawingContext?.DrawLine(dashedPen, points[0], checkPoint); + } - if (defaultSettingParam.IsCreateSquarePolygonMeasure) - { - polySegment.Points.Add(points[0]); + double left = drawPoints.AsEnumerable().Select(x => x.X).Min(); + double right = drawPoints.AsEnumerable().Select(x => x.X).Max(); + double top = drawPoints.AsEnumerable().Select(x => x.Y).Min(); + double bottom = drawPoints.AsEnumerable().Select(x => x.Y).Max(); + DPIRect = new Rect(left, top, right - left, bottom - top); + + polygonAnnot.SetAnnotBorderEffector(borderEffector); + drawPoints.Add(checkPoint); + List measurePoint = new List(); + measurePoint = GetMeasureDrawPoints(); + drawPoints.RemoveAt(drawPoints.Count - 1); + List cPoints = new List(); + foreach (Point item in measurePoint) + { + cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item))); + } + + polygonAnnot.SetPoints(cPoints); + polygonAnnot.UpdateAp(); + cPDFViewer.UpdateAnnotFrame(); } else { - //Add the current point during the movement. - polySegment.Points.Add(checkPoint); - } + PathGeometry drawPath = new PathGeometry(); + PathFigure drawFigure = new PathFigure(); - if (polySegment.Points.Count > 0) - { - drawFigure.Segments.Add(polySegment); - } - if (drawFigure.Segments.Count > 0) - { - drawPath.Figures.Add(drawFigure); - } + drawFigure.StartPoint = points[0]; + PolyLineSegment polySegment = new PolyLineSegment(); - //Draw the line segment. - drawingContext?.DrawGeometry(null, DrawPen, drawPath); + for (int i = 1; i < points.Count; i++) + { + polySegment.Points.Add(points[i]); + } - //Draw the example line connected by the start point and the end point. - if (points.Count > 1) - { if (defaultSettingParam.IsCreateSquarePolygonMeasure) { - drawingContext?.DrawLine(DrawPen, points[0], polySegment.Points.Last()); + polySegment.Points.Add(points[0]); } else { - drawingContext?.DrawLine(EndDrawPen, points[0], polySegment.Points.Last()); + //Add the current point during the movement. + polySegment.Points.Add(checkPoint); } - } - //Calculate the length. - double totalInch = 0; - if (points.Count > 1) - { - for (int i = 0; i < points.Count - 1; i++) + if (polySegment.Points.Count > 0) { - totalInch += measureSetting.GetMeasureLength(points[i], points[i + 1], zoomFactor); + drawFigure.Segments.Add(polySegment); } - } - double currentInch = measureSetting.GetMeasureLength(points[points.Count - 1], checkPoint, zoomFactor); - if (defaultSettingParam.IsCreateSquarePolygonMeasure) - { - currentInch = measureSetting.GetMeasureLength(points[points.Count - 1], points[0], zoomFactor); - } - totalInch += currentInch; - - Point closePoint = points[points.Count - 1]; - Vector movevector = checkPoint - closePoint; - FormattedText moveText = new FormattedText( - string.Format("{0} {1}", measureSetting.GetPrecisionData(currentInch), measureSetting.RulerTranslateUnit), - CultureInfo.GetCultureInfo("en-us"), - FlowDirection.LeftToRight, - new Typeface("YaHei"), - 16, - TextBrush); - - FormattedText totalText = new FormattedText( - string.Format("{0} {1}", measureSetting.GetPrecisionData(totalInch), measureSetting.RulerTranslateUnit), - CultureInfo.GetCultureInfo("en-us"), - FlowDirection.LeftToRight, - new Typeface("YaHei"), - 16, - TextBrush); - - //Judge the text display form. - if (movevector.Length > moveText.Width + textPadding || defaultSettingParam.IsCreateSquarePolygonMeasure) - { - if (checkPoint.X >= closePoint.X) + if (drawFigure.Segments.Count > 0) { - Point linePoint = new Point(closePoint.X + movevector.Length, closePoint.Y); - Point drawPoint = new Point( - linePoint.X - moveText.Width - textPadding, - linePoint.Y - moveText.Height); - - Vector anglevector = linePoint - closePoint; + drawPath.Figures.Add(drawFigure); + } - RotateTransform transform = new RotateTransform(); - transform.CenterX = closePoint.X; - transform.CenterY = closePoint.Y; - double angle = Vector.AngleBetween(movevector, anglevector); - transform.Angle = -angle; + //Draw the line segment. + drawingContext?.DrawGeometry(null, DrawPen, drawPath); - drawingContext?.PushTransform(transform); - if (!defaultSettingParam.IsCreateSquarePolygonMeasure) + //Draw the example line connected by the start point and the end point. + if (points.Count > 1) + { + if (defaultSettingParam.IsCreateSquarePolygonMeasure) { - drawingContext?.DrawText(moveText, drawPoint); + drawingContext?.DrawLine(DrawPen, points[0], polySegment.Points.Last()); } - if (totalInch > currentInch) + else { - drawingContext?.DrawText(totalText, new Point( - drawPoint.X + moveText.Width + textPadding * 2, - drawPoint.Y - )); + drawingContext?.DrawLine(EndDrawPen, points[0], polySegment.Points.Last()); } - drawingContext.Pop(); } - else - { - Point linePoint = new Point(closePoint.X - movevector.Length, closePoint.Y); - Point drawPoint = new Point( - linePoint.X + textPadding, - linePoint.Y - moveText.Height); - - Vector anglevector = linePoint - closePoint; - RotateTransform transform = new RotateTransform(); - transform.CenterX = closePoint.X; - transform.CenterY = closePoint.Y; - double angle = Vector.AngleBetween(movevector, anglevector); - transform.Angle = -angle; - - drawingContext?.PushTransform(transform); - if (!defaultSettingParam.IsCreateSquarePolygonMeasure) + //Calculate the length. + double totalInch = 0; + if (points.Count > 1) + { + for (int i = 0; i < points.Count - 1; i++) { - drawingContext?.DrawText(moveText, drawPoint); + totalInch += measureSetting.GetMeasureLength(points[i], points[i + 1], zoomFactor); } - if (totalInch > currentInch) + } + + double currentInch = measureSetting.GetMeasureLength(points[points.Count - 1], checkPoint, zoomFactor); + if (defaultSettingParam.IsCreateSquarePolygonMeasure) + { + currentInch = measureSetting.GetMeasureLength(points[points.Count - 1], points[0], zoomFactor); + } + + totalInch += currentInch; + Point closePoint = points[points.Count - 1]; + Vector movevector = checkPoint - closePoint; + if (polygonAnnot.IsMeasured()) + { + FormattedText moveText = new FormattedText( + string.Format("{0} {1}", measureSetting.GetPrecisionData(currentInch), measureSetting.RulerTranslateUnit), + CultureInfo.GetCultureInfo("en-us"), + FlowDirection.LeftToRight, + new Typeface("YaHei"), + 16, + TextBrush); + + FormattedText totalText = new FormattedText( + string.Format("{0} {1}", measureSetting.GetPrecisionData(totalInch), measureSetting.RulerTranslateUnit), + CultureInfo.GetCultureInfo("en-us"), + FlowDirection.LeftToRight, + new Typeface("YaHei"), + 16, + TextBrush); + + //Judge the text display form. + if (movevector.Length > moveText.Width + textPadding || defaultSettingParam.IsCreateSquarePolygonMeasure) { - drawingContext?.DrawText(totalText, - new Point( - drawPoint.X - totalText.Width - textPadding * 2, - drawPoint.Y - )); + if (checkPoint.X >= closePoint.X) + { + Point linePoint = new Point(closePoint.X + movevector.Length, closePoint.Y); + Point drawPoint = new Point( + linePoint.X - moveText.Width - textPadding, + linePoint.Y - moveText.Height); + + Vector anglevector = linePoint - closePoint; + + RotateTransform transform = new RotateTransform(); + transform.CenterX = closePoint.X; + transform.CenterY = closePoint.Y; + double angle = Vector.AngleBetween(movevector, anglevector); + transform.Angle = -angle; + + drawingContext?.PushTransform(transform); + if (!defaultSettingParam.IsCreateSquarePolygonMeasure) + { + drawingContext?.DrawText(moveText, drawPoint); + } + if (totalInch > currentInch) + { + drawingContext?.DrawText(totalText, new Point( + drawPoint.X + moveText.Width + textPadding * 2, + drawPoint.Y + )); + } + drawingContext.Pop(); + } + else + { + Point linePoint = new Point(closePoint.X - movevector.Length, closePoint.Y); + Point drawPoint = new Point( + linePoint.X + textPadding, + linePoint.Y - moveText.Height); + + Vector anglevector = linePoint - closePoint; + RotateTransform transform = new RotateTransform(); + transform.CenterX = closePoint.X; + transform.CenterY = closePoint.Y; + double angle = Vector.AngleBetween(movevector, anglevector); + transform.Angle = -angle; + + drawingContext?.PushTransform(transform); + if (!defaultSettingParam.IsCreateSquarePolygonMeasure) + { + drawingContext?.DrawText(moveText, drawPoint); + } + if (totalInch > currentInch) + { + drawingContext?.DrawText(totalText, + new Point( + drawPoint.X - totalText.Width - textPadding * 2, + drawPoint.Y + )); + } + drawingContext.Pop(); + } } - drawingContext.Pop(); } - } - double left = drawPoints.AsEnumerable().Select(x => x.X).Min(); - double right = drawPoints.AsEnumerable().Select(x => x.X).Max(); - double top = drawPoints.AsEnumerable().Select(x => x.Y).Min(); - double bottom = drawPoints.AsEnumerable().Select(x => x.Y).Max(); - DPIRect = new Rect(left, top, right - left, bottom - top); - if (defaultSettingParam.IsCreateSquarePolygonMeasure) - { - double deleft = points.AsEnumerable().Select(x => x.X).Min(); - double deright = points.AsEnumerable().Select(x => x.X).Max(); - double detop = points.AsEnumerable().Select(x => x.Y).Min(); - double debottom = points.AsEnumerable().Select(x => x.Y).Max(); - DPIRect = new Rect(deleft, detop, deright - deleft, debottom - detop); - } - - MeasureEventArgs measureEvent = new MeasureEventArgs(); - if (points.Count < 2) - { - measureEvent.Angle = 0; - } - else - { - Vector standVector = points[points.Count - 1] - points[points.Count - 2]; - Vector endvector = closePoint - checkPoint; - measureEvent.Angle = (int)Math.Abs(Vector.AngleBetween(endvector, standVector)); if (defaultSettingParam.IsCreateSquarePolygonMeasure) { - measureEvent.Angle = 90; + double deleft = points.AsEnumerable().Select(x => x.X).Min(); + double deright = points.AsEnumerable().Select(x => x.X).Max(); + double detop = points.AsEnumerable().Select(x => x.Y).Min(); + double debottom = points.AsEnumerable().Select(x => x.Y).Max(); + DPIRect = new Rect(deleft, detop, deright - deleft, debottom - detop); + } + else + { + double left = drawPoints.AsEnumerable().Select(x => x.X).Min(); + double right = drawPoints.AsEnumerable().Select(x => x.X).Max(); + double top = drawPoints.AsEnumerable().Select(x => x.Y).Min(); + double bottom = drawPoints.AsEnumerable().Select(x => x.Y).Max(); + DPIRect = new Rect(left, top, right - left, bottom - top); } - } - - List pon = new List(); - if (!defaultSettingParam.IsCreateSquarePolygonMeasure) - { - points.Add(checkPoint); - } - foreach (Point drawPoint in points) - { - Point savePoint = new Point( - (drawPoint.X - pageBound.Left) + cropPoint.X, - (drawPoint.Y - pageBound.Top) + cropPoint.Y); - pon.Add(DpiHelper.StandardPointToPDFPoint(new Point( - (float)drawPoint.X / zoomFactor, - (float)drawPoint.Y / zoomFactor - ))); - } - double area = measureSetting.ComputePolygonArea(pon.ToList()); - double ratio = measureSetting.GetMeasureAreaRatio(); - double rate = measureSetting.RulerTranslate / measureSetting.RulerBase; - double inch = area * ratio * ratio * rate * rate; + MeasureEventArgs measureEvent = new MeasureEventArgs(); + if (points.Count < 2) + { + measureEvent.Angle = 0; + } + else + { + Vector standVector = points[points.Count - 1] - points[points.Count - 2]; + Vector endvector = closePoint - checkPoint; + measureEvent.Angle = (int)Math.Abs(Vector.AngleBetween(endvector, standVector)); + if (defaultSettingParam.IsCreateSquarePolygonMeasure) + { + measureEvent.Angle = 90; + } + } - measureEvent.RulerTranslateUnit = measureSetting.RulerTranslateUnit; - measureEvent.RulerTranslate = measureSetting.RulerTranslate; - measureEvent.RulerBase = measureSetting.RulerBase; - measureEvent.RulerBaseUnit = measureSetting.RulerBaseUnit; - measureEvent.Precision = measureSetting.Precision; - measureEvent.Type = CPDFMeasureType.CPDF_AREA_MEASURE; - measureEvent.Distance = totalText.Text; - measureEvent.Area = string.Format("{0} sq {1}", measureSetting.GetPrecisionData(inch), measureSetting.RulerTranslateUnit); + List pon = new List(); + if (!defaultSettingParam.IsCreateSquarePolygonMeasure) + { + points.Add(checkPoint); + } + foreach (Point drawPoint in points) + { + Point savePoint = new Point( + (drawPoint.X - pageBound.Left) + cropPoint.X, + (drawPoint.Y - pageBound.Top) + cropPoint.Y); + pon.Add(DpiHelper.StandardPointToPDFPoint(new Point( + (float)drawPoint.X / zoomFactor, + (float)drawPoint.Y / zoomFactor + ))); + } - MeasureChanged?.Invoke(this, measureEvent); + double area = measureSetting.ComputePolygonArea(pon.ToList()); + double ratio = measureSetting.GetMeasureAreaRatio(); + double rate = measureSetting.RulerTranslate / measureSetting.RulerBase; + double inch = area * ratio * ratio * rate * rate; + + //measureEvent.RulerTranslateUnit = measureSetting.RulerTranslateUnit; + //measureEvent.RulerTranslate = measureSetting.RulerTranslate; + //measureEvent.RulerBase = measureSetting.RulerBase; + //measureEvent.RulerBaseUnit = measureSetting.RulerBaseUnit; + //measureEvent.Precision = measureSetting.Precision; + //measureEvent.Type = CPDFMeasureType.CPDF_AREA_MEASURE; + //measureEvent.Distance = totalText.Text; + // measureEvent.Area = string.Format("{0} sq {1}", measureSetting.GetPrecisionData(inch), measureSetting.RulerTranslateUnit); + + MeasureChanged?.Invoke(this, measureEvent); + } } } @@ -1434,7 +1485,10 @@ private void DrawLineMeasure(DrawingContext drawingContext) #endregion public void MultipleClick(Point downPoint) { - drawPoints.Add(downPoint); + if(!drawPoints.Contains(downPoint)) + { + drawPoints.Add(downPoint); + } } public Rect GetMaxRect() @@ -1452,7 +1506,7 @@ public void CreateTextBox() TextBox textui = new TextBox(); - Border textBorder = new Border(); + DashedBorder textBorder = new DashedBorder(); textBorder.Child = textui; textui.Width = 200; CTextAttribute textAttribute = annotFreeText.FreeTextDa; @@ -1487,7 +1541,20 @@ public void CreateTextBox() textBorder.Padding = new Thickness(0); textBorder.BorderBrush = new SolidColorBrush(borderColor); - textBorder.BorderThickness = new Thickness(DpiHelper.PDFNumToStandardNum(annotFreeText.GetBorderWidth() * zoomFactor)); + double rawWidth = annotFreeText.GetBorderWidth(); + double drawWidth = DpiHelper.PDFNumToStandardNum(rawWidth * zoomFactor); + textBorder.BorderThickness = new Thickness(drawWidth); + if (annotFreeText.BorderStyle != C_BORDER_STYLE.BS_SOLID && annotFreeText.Dash != null && annotFreeText.Dash.Length > 0) + { + //补充保存虚线样式 + DoubleCollection dashCollection = new DoubleCollection(); + foreach (float num in annotFreeText.Dash) + { + dashCollection.Add(num); + } + textBorder?.DrawDashBorder(true, drawWidth, rawWidth, dashCollection); + } + textui.BorderThickness = new Thickness(0); textui.Text = annotFreeText.Content; @@ -1532,7 +1599,7 @@ public void CreateTextBox() CPDFAnnotation currentAnnot = textui.GetValue(PopupTextAttachDataProperty) as CPDFAnnotation; AnnotParam annotParam = ParamConverter.AnnotConverter(cPDFViewer.GetDocument(), currentAnnot); if (currentAnnot != null && currentAnnot.IsValid()) - { + { CPDFFreeTextAnnotation updateFreeText = currentAnnot as CPDFFreeTextAnnotation; if (textui.Text != string.Empty || updateFreeText.GetBorderWidth() != 0) { @@ -1551,7 +1618,7 @@ public void CreateTextBox() )); updateFreeText.UpdateAp(); FreeTextAnnotHistory freeTextAnnotHistory = new FreeTextAnnotHistory(); - annotParam = ParamConverter.AnnotConverter(cPDFViewer.GetDocument(), currentAnnot); + annotParam = ParamConverter.AnnotConverter(cPDFViewer.GetDocument(), currentAnnot); annotParam.AnnotIndex = currentAnnot.Page.GetAnnotCount() - 1; freeTextAnnotHistory.CurrentParam = (FreeTextParam)annotParam; freeTextAnnotHistory.PDFDoc = cPDFViewer.GetDocument(); @@ -1713,10 +1780,23 @@ private void DrawText() lastTextui.Background = new SolidColorBrush(backgroundColor); lastTextBorder.Padding = new Thickness(0); lastTextBorder.BorderBrush = new SolidColorBrush(borderColor); - lastTextBorder.BorderThickness = new Thickness(DpiHelper.PDFNumToStandardNum(annotFreeText.GetBorderWidth() * zoomFactor)); + double rawWidth = annotFreeText.GetBorderWidth(); + double drawWidth = DpiHelper.PDFNumToStandardNum(rawWidth * zoomFactor); + lastTextBorder.BorderThickness = new Thickness(drawWidth); lastTextui.BorderThickness = new Thickness(0); lastTextui.Text = annotFreeText.Content; lastTextui.Opacity = annotFreeText.Transparency; + if (annotFreeText.BorderStyle != C_BORDER_STYLE.BS_SOLID && annotFreeText.Dash != null && annotFreeText.Dash.Length > 0) + { + //补充保存虚线样式 + DashedBorder dashBorder = (DashedBorder)lastTextBorder; + DoubleCollection dashCollection = new DoubleCollection(); + foreach (float num in annotFreeText.Dash) + { + dashCollection.Add(num); + } + dashBorder.DrawDashBorder(true, drawWidth, rawWidth, dashCollection); + } string fontName = string.Empty; string fontFamily = string.Empty; @@ -1873,5 +1953,24 @@ internal Point CalcAnglePoint(Point currentPoint, Point startPoint, Rect pageBou } return anglePoint; } + + public bool IsCanSave() + { + if (cPDFAnnotation == null) + return false; + + if (cPDFAnnotation is CPDFPolygonAnnotation) + { + if (drawPoints.Count <= 2) + return false; + } + + return true; + } + + public bool IsCreating() + { + return cPDFAnnotation != null; + } } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/CreateCustomizeTool.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/CreateCustomizeTool.cs index 94c972b..2552f07 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/CreateCustomizeTool.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/CreateCustomizeTool.cs @@ -67,6 +67,7 @@ internal class CreateCustomizeTool : CustomizeLayer /// Standard DPI rectangle (without removing half of the pen thickness) /// protected Rect DPIRect { get; set; } + internal int ErasePageIndex { get; set; } public SolidColorBrush FillBrush; public Pen DrawPen; public event EventHandler> DeleteChanged; @@ -273,8 +274,17 @@ private void DrawErase(DrawingContext drawingContext) CPDFDocument pdfDoc = PDFViewer?.GetDocument(); List paramList = new List(); List paramNewList = new List(); + + PDFViewer.GetPointPageInfo(mouseEndPoint, out int index, out Rect checkpaintRect, out Rect checkpageBound); + foreach (var item in annotControlList) { + AnnotData coreAnnotData = item.GetAnnotData(); + + if (coreAnnotData == null || coreAnnotData.PageIndex != ErasePageIndex) + { + continue; + } InkAnnot ink = item as InkAnnot; int Tag = ErasePoint(ink, eraseRect); if (Tag == 1) diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/DashBorder.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/DashBorder.cs new file mode 100644 index 0000000..55d7c1e --- /dev/null +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/DashBorder.cs @@ -0,0 +1,47 @@ +using ComPDFKitViewer.Annot; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Media; +using System.Windows.Shapes; + +namespace ComPDFKit.Tool.DrawTool +{ + internal class DashedBorder : Border + { + private bool DrawDash { get; set; } + private double DashThickness { get; set; } + private double DashWidth { get; set; } + private DoubleCollection DashArray { get; set; } + protected override void OnRender(DrawingContext dc) + { + if (DrawDash) + { + Pen dashPen = new Pen(BorderBrush, DashThickness); + dashPen.DashCap = PenLineCap.Flat; + DashStyle dash = new DashStyle(); + foreach (double offset in DashArray) + { + dash.Dashes.Add(offset / DashWidth); + } + dashPen.DashStyle = dash; + dc.DrawRectangle(null, dashPen, new Rect(0, 0, ActualWidth, ActualHeight)); + return; + } + base.OnRender(dc); + } + public void DrawDashBorder(bool isDash,double dashWidth,double rawWidth, DoubleCollection dashArray) + { + DrawDash = isDash; + DashArray = dashArray; + DashThickness=dashWidth; + DashWidth=rawWidth; + InvalidateVisual(); + } + } +} diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/FrameSelectTool.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/FrameSelectTool.cs index 1afaa67..d0ca6b8 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/FrameSelectTool.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/FrameSelectTool.cs @@ -1,35 +1,9 @@ -using ComPDFKit.Import; -using ComPDFKit.Measure; -using ComPDFKit.PDFAnnotation; -using ComPDFKit.PDFDocument; -using ComPDFKit.PDFPage; -using ComPDFKit.Tool.Help; -using ComPDFKit.Tool.SettingParam; -using ComPDFKit.Tool.UndoManger; -using ComPDFKit.Viewer.Helper; -using ComPDFKit.Viewer.Layer; -using ComPDFKitViewer; -using ComPDFKitViewer.Annot; -using ComPDFKitViewer.BaseObject; +using ComPDFKit.Viewer.Layer; using ComPDFKitViewer.Helper; -using ComPDFKitViewer.Layer; using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Annotations; using System.Windows.Controls; -using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Media.Media3D; -using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper; -using static ComPDFKit.Tool.Help.ImportWin32; namespace ComPDFKit.Tool.DrawTool { diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/MultiSelectedRect.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/MultiSelectedRect.cs index 5c26f46..3514d85 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/MultiSelectedRect.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/MultiSelectedRect.cs @@ -1,15 +1,9 @@ using ComPDFKit.Tool.SettingParam; -using ComPDFKitViewer; using System; using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media; -using static ComPDFKit.Tool.Help.ImportWin32; namespace ComPDFKit.Tool.DrawTool { @@ -20,7 +14,6 @@ public enum MulitiDrawMoveType Alone } - public class MultiSelectedRect : DrawingVisual { /// @@ -178,7 +171,7 @@ public void Arrange() /// /// Array passed from outside for multiple selection /// - protected List selectedRects = new List(); + internal List selectedRects = new List(); protected Dictionary> RelationDict=new Dictionary>(); protected bool isHover = false; @@ -357,7 +350,6 @@ public float GetChangeY() return (float)(drawRect.Height - drawDefaultRect.Height); } - public void Draw() { switch (currentDrawType) @@ -373,9 +365,9 @@ public void Draw() SolidColorBrush solidColorBrush = drawParam.SPDFEditMultiRectFillBrush; Pen pen = drawParam.SPDFEditMultiRectLinePen; GetBrushAndPen(ref solidColorBrush, ref pen); - if (selectedRects.Count >= 1) + foreach (SelectedRect item in selectedRects) { - foreach (SelectedRect item in selectedRects) + if (!item.IsPath) { Rect rect = item.GetRect(); rect.X -= rectPadding; @@ -421,7 +413,7 @@ public void Draw() if (selectedType == SelectedType.PDFEdit) { //Edit Settings Frame - DrawCirclePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, new SolidColorBrush(Color.FromRgb(71, 126, 222))); + DrawCirclePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, PointBrush); } else { @@ -435,7 +427,6 @@ public void Draw() drawDC?.Close(); drawDC = null; } - }); break; case MulitiDrawMoveType.Alone: @@ -671,7 +662,7 @@ protected void DrawMoveBounds(DrawingContext drawDc, PointControlType controltyp drawDc?.DrawLine(activePen, new Point(0, moveRect.Bottom), new Point(PDFViewerActualWidth, moveRect.Bottom)); drawDc?.DrawLine(activePen, new Point(moveRect.Left, 0), new Point(moveRect.Left, PDFViewerActualHeight)); break; - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: drawDc?.DrawLine(activePen, new Point(0, moveRect.Bottom), new Point(PDFViewerActualWidth, moveRect.Bottom)); break; case PointControlType.RightBottom: @@ -824,7 +815,7 @@ public void SetIgnorePointsAll() ignorePoints.Add(PointControlType.LeftTop); ignorePoints.Add(PointControlType.LeftMiddle); ignorePoints.Add(PointControlType.LeftBottom); - ignorePoints.Add(PointControlType.MiddlBottom); + ignorePoints.Add(PointControlType.MiddleBottom); ignorePoints.Add(PointControlType.RightBottom); ignorePoints.Add(PointControlType.RightMiddle); ignorePoints.Add(PointControlType.RightTop); @@ -840,7 +831,7 @@ public void DisableAll() ignorePoints.Add(PointControlType.LeftTop); ignorePoints.Add(PointControlType.LeftMiddle); ignorePoints.Add(PointControlType.LeftBottom); - ignorePoints.Add(PointControlType.MiddlBottom); + ignorePoints.Add(PointControlType.MiddleBottom); ignorePoints.Add(PointControlType.RightBottom); ignorePoints.Add(PointControlType.RightMiddle); ignorePoints.Add(PointControlType.RightTop); @@ -923,7 +914,7 @@ protected bool NormalScaling(Point mousePoint) TmpDown = TmpUp + rectMinHeight; } break; - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: TmpLeft = cacheRect.Left; TmpRight = cacheRect.Right; TmpUp = cacheRect.Top; @@ -1049,7 +1040,7 @@ protected Point ProportionalScalingOffsetPos(Point movePoint) case PointControlType.RightMiddle: offsetPos = new Point(movePoint.X, Math.Abs(movePoint.X) * ratioX * (movePoint.X < 0 ? -1 : 1)); break; - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: offsetPos = new Point(Math.Abs(movePoint.Y) * ratioY * (movePoint.Y < 0 ? 1 : -1), movePoint.Y); break; case PointControlType.MiddleTop: @@ -1306,7 +1297,7 @@ public PointControlType GetHitControlIndex(Point point) } } - if ((PointControlType)i == PointControlType.MiddlBottom) + if ((PointControlType)i == PointControlType.MiddleBottom) { if (Math.Abs(point.Y - checkPoint.Y) < hlen && checkVector.Length < drawRect.Width / 3) { diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/PageSelectedRect.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/PageSelectedRect.cs index 97e1afe..6814ee8 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/PageSelectedRect.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/PageSelectedRect.cs @@ -670,7 +670,7 @@ protected void DrawMoveBounds(DrawingContext drawDc, PointControlType controltyp drawDc?.DrawLine(activePen, new Point(0, moveRect.Bottom), new Point(PDFViewerActualWidth, moveRect.Bottom)); drawDc?.DrawLine(activePen, new Point(moveRect.Left, 0), new Point(moveRect.Left, PDFViewerActualHeight)); break; - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: drawDc?.DrawLine(activePen, new Point(0, moveRect.Bottom), new Point(PDFViewerActualWidth, moveRect.Bottom)); break; case PointControlType.RightBottom: @@ -801,7 +801,7 @@ protected bool NormalScaling(Point mousePoint) TmpDown = TmpUp + rectMinHeight; } break; - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: TmpLeft = cacheRect.Left; TmpRight = cacheRect.Right; TmpUp = cacheRect.Top; @@ -928,7 +928,7 @@ protected Point ProportionalScalingOffsetPos(Point movePoint) case PointControlType.RightMiddle: offsetPos = new Point(movePoint.X, Math.Abs(movePoint.X) * ratioX * (movePoint.X < 0 ? -1 : 1)); break; - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: offsetPos = new Point(Math.Abs(movePoint.Y) * ratioY * (movePoint.Y < 0 ? 1 : -1), movePoint.Y); break; case PointControlType.MiddleTop: diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/SelectedRect.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/SelectedRect.cs index 1abf392..8126573 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/SelectedRect.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/SelectedRect.cs @@ -1,24 +1,16 @@ -using ComPDFKit.PDFAnnotation; +using ComPDFKit.Import; +using ComPDFKit.PDFAnnotation; +using ComPDFKit.Tool.Help; using ComPDFKit.Tool.SettingParam; -using ComPDFKit.Viewer.Layer; +using ComPDFKit.Viewer.Helper; using ComPDFKitViewer; using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Media3D; -using System.Xml.Linq; -using static ComPDFKit.Tool.Help.ImportWin32; -using static System.Net.Mime.MediaTypeNames; namespace ComPDFKit.Tool.DrawTool { @@ -28,14 +20,14 @@ public enum PointControlType LeftTop, LeftMiddle, LeftBottom, - MiddlBottom, + MiddleBottom, RightBottom, RightMiddle, RightTop, - MiddleTop, - Rotate, + MiddleTop, Body, - Line + Line, + Rotate } public enum SelectedType @@ -45,18 +37,18 @@ public enum SelectedType PDFEdit } - public enum DrawPointType { Circle, - Square, - Crop + Square, + Crop, } public enum DrawMoveType { kDefault, kReferenceLine, + kRotatable } public class SelectedAnnotData @@ -73,10 +65,11 @@ public class SelectedAnnotData public AnnotData annotData { get; set; } + public int rotationAngle { get; set; } } public partial class SelectedRect : DrawingVisual - { + { /// /// Re-layout child elements /// @@ -126,6 +119,8 @@ public void Arrange() protected bool isSelected = false; + protected bool canRotate = false; + protected SelectedType selectedType = SelectedType.None; public SelectedType GetSelectedType() @@ -177,13 +172,25 @@ public virtual void OnMouseLeftButtonDown(Point downPoint) { hitControlType = GetHitCropControlIndex(downPoint); } - else + else { hitControlType = GetHitControlIndex(downPoint); } + if (hitControlType != PointControlType.None) { cacheRect = drawRect; + rotateRect = drawRect; + rotateControlPoints = controlPoints.ToList(); + + if (hitControlType != PointControlType.Rotate) + { + isInScaling = true; + } + else + { + isInRotate = true; + } } } } @@ -193,6 +200,8 @@ public virtual void OnMouseLeftButtonUp(Point upPoint) if (isMouseDown && hitControlType != PointControlType.None) { isMouseDown = false; + isInScaling = false; + isInRotate = false; cacheRect = SetDrawRect = drawRect; Draw(); if ((int)upPoint.X != (int)mouseDownPoint.X || (int)upPoint.Y != (int)mouseDownPoint.Y) @@ -223,7 +232,7 @@ public virtual void OnMouseMove(Point mousePoint, out bool Tag, double width, do } public Cursor GetCursor(Point downPoint, Cursor cursor) - { + { if (isMouseDown) { return cursor; @@ -233,23 +242,22 @@ public Cursor GetCursor(Point downPoint, Cursor cursor) { case PointControlType.LeftTop: case PointControlType.RightBottom: - return Cursors.SizeNWSE; - + return Cursors.SizeNWSE; case PointControlType.LeftMiddle: case PointControlType.RightMiddle: - return Cursors.SizeWE; - + return Cursors.SizeWE; case PointControlType.LeftBottom: case PointControlType.RightTop: return Cursors.SizeNESW; - - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: case PointControlType.MiddleTop: return Cursors.SizeNS; case PointControlType.Body: return Cursors.Arrow; case PointControlType.Line: return Cursors.SizeAll; + case PointControlType.Rotate: + return CommonHelper.RotationCursor; default: return Cursors.Arrow; } @@ -281,7 +289,7 @@ public void Draw() SolidColorBrush moveBrush = DrawParam.AnnotMoveBrush; Pen movepen = DrawParam.AnnotMovePen; - GetMoveBrushAndPen(ref moveBrush, ref movepen); + GetMoveBrushAndPen(ref moveBrush, ref movepen); if (selectedType == SelectedType.PDFEdit) { DrawMoveBounds(drawDC, hitControlType, movepen, moveBrush, drawRect, DrawParam.PDFEditMoveRectPen); @@ -299,8 +307,10 @@ public void Draw() SolidColorBrush solidColorBrush = DrawParam.AnnotRectFillBrush; Pen pen = DrawParam.AnnotRectLinePen; GetBrushAndPen(ref solidColorBrush, ref pen); + RotateTransform rotateTransform = new RotateTransform(rotateAngle, centerPoint.X, centerPoint.Y); + drawDC.PushTransform(rotateTransform); drawDC?.DrawRectangle(solidColorBrush, pen, currentRect); - + drawDC.Pop(); SolidColorBrush PointBrush = DrawParam.AnnotPointBorderBrush; Pen PointPen = DrawParam.AnnotPointPen; GetPointBrushAndPen(ref PointBrush, ref PointPen); @@ -310,16 +320,14 @@ public void Draw() case DrawPointType.Circle: if (selectedType == SelectedType.PDFEdit) { - DrawCirclePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, new SolidColorBrush(Color.FromRgb(71, 126, 222))); - - //DrawEditSelectionBox(drawDC, PointPen); + DrawCirclePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, PointBrush); } else { DrawCirclePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, PointBrush); } break; - case DrawPointType.Square: + case DrawPointType.Square: DrawSquarePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, PointBrush); break; case DrawPointType.Crop: @@ -330,7 +338,7 @@ public void Draw() drawDC = null; }); } - + private void GetMoveBrushAndPen(ref SolidColorBrush colorBrush, ref Pen pen) { switch (selectedType) @@ -340,7 +348,7 @@ private void GetMoveBrushAndPen(ref SolidColorBrush colorBrush, ref Pen pen) case SelectedType.Annot: colorBrush = DrawParam.AnnotMoveBrush; pen = DrawParam.AnnotMovePen; - break; + break; case SelectedType.PDFEdit: colorBrush = DrawParam.PDFEditMoveBrush; pen = DrawParam.PDFEditMovePen; @@ -368,7 +376,8 @@ private void GetPointBrushAndPen(ref SolidColorBrush colorBrush, ref Pen pen) } else if (currentDrawPointType == DrawPointType.Crop) { - colorBrush = DrawParam.SPDFEditCropBorderBrush;//new SolidColorBrush((DrawParam.SPDFEditPointPen.Brush as SolidColorBrush).Color); + colorBrush = DrawParam.SPDFEditCropBorderBrush; + //new SolidColorBrush((DrawParam.SPDFEditPointPen.Brush as SolidColorBrush).Color); pen = DrawParam.SPDFEditPointPen.Clone(); pen.DashStyle = DashStyles.Solid; } @@ -470,6 +479,7 @@ public void SetEditPen(Pen editPen = null, Pen editHoverPen = null) public virtual void ClearDraw() { SetDrawRect = drawRect = new Rect(); + rotateAngle = 0; drawDC = RenderOpen(); drawDC?.Close(); drawDC = null; @@ -490,7 +500,7 @@ public void SetRect(Rect newRect, double zoom) { return; } - newRect = new Rect((int)(newRect.X - rectPadding * zoom), (int)(newRect.Y - rectPadding * zoom), (int)(newRect.Width + 2 * rectPadding * zoom), (int)(newRect.Height + 2 * rectPadding * zoom)); + newRect = new Rect((newRect.X - rectPadding * zoom), (newRect.Y - rectPadding * zoom), (newRect.Width + 2 * rectPadding * zoom), (newRect.Height + 2 * rectPadding * zoom)); currentZoom = zoom; SetDrawRect = drawRect = newRect; drawCenterPoint = new Point(drawRect.Left + drawRect.Width / 2, drawRect.Top + drawRect.Height / 2); @@ -502,12 +512,22 @@ public void SetRect(Rect newRect, double zoom) /// /// The new rect to set /// - public Rect GetRect() + public Rect GetRect() { - Rect rect = new Rect(drawRect.X + rectPadding * currentZoom, drawRect.Y + rectPadding * currentZoom, Math.Max(rectMinWidth, drawRect.Width - 2 * rectPadding * currentZoom), Math.Max(RectMinHeight, drawRect.Height - 2 * rectPadding * currentZoom)); + Rect rect = new Rect(drawRect.X + rectPadding * currentZoom, drawRect.Y + rectPadding * currentZoom, Math.Max(RectMinWidth, drawRect.Width - 2 * rectPadding * currentZoom), Math.Max(RectMinHeight, drawRect.Height - 2 * rectPadding * currentZoom)); return rect; } + public int GetRotation() + { + return rotateAngle; + } + + public void SetRotation(int rotationAngle) + { + this.rotateAngle = rotationAngle; + } + public void SetRectPadding(double rectPadding) { this.rectPadding = rectPadding; @@ -569,15 +589,17 @@ public void SetMaxRect(Rect rect) { maxRect = rect; } + public Rect GetMaxRect() { return maxRect; } - public void SetAnnotData(AnnotData annotData) + public void SetAnnotData(AnnotData annotData, CPDFViewer viewer) { SetIgnorePoints(new List()); SetIsProportionalScaling(false); + SetRoationHandle(false); isProportionalScaling = false; switch (annotData.AnnotType) { @@ -598,6 +620,7 @@ public void SetAnnotData(AnnotData annotData) case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP: SetIsProportionalScaling(true); + SetRoationHandle(true); break; case C_ANNOTATION_TYPE.C_ANNOTATION_LINK: @@ -607,12 +630,43 @@ public void SetAnnotData(AnnotData annotData) default: break; } + SetMaxRect(annotData.PaintOffset); - SetRect(annotData.PaintRect, annotData.CurrentZoom); + if(annotData.AnnotType == C_ANNOTATION_TYPE.C_ANNOTATION_STAMP) + { + CRect sourceRect = new CRect(); + annotData.Annot.GetSourceRect(ref sourceRect); + if (!sourceRect.IsEmpty) + { + RenderData renderData = viewer.GetCurrentRenderPageForIndex(annotData.PageIndex); + Rect zoomRect = new Rect(sourceRect.left / 72 * 96 * annotData.CurrentZoom, sourceRect.top / 72 * 96 * annotData.CurrentZoom, sourceRect.width() / 72 * 96 * annotData.CurrentZoom, sourceRect.height() / 72 * 96 * annotData.CurrentZoom); + Rect rotateRect = zoomRect; + rotateRect.X += renderData.PageBound.X - renderData.CropLeft * annotData.CurrentZoom; + rotateRect.Y += renderData.PageBound.Y - renderData.CropTop * annotData.CurrentZoom; + SetRect(rotateRect, annotData.CurrentZoom); + rotateAngle = -(annotData.Annot as CPDFStampAnnotation).AnnotationRotator.GetRotation(); + pageRotation = annotData.Annot.Page.Rotation; + } + else + { + SetRect(annotData.PaintRect, annotData.CurrentZoom); + } + } + else + { + SetRect(annotData.PaintRect, annotData.CurrentZoom); + } + + //SetRotation(annotData.Rotation); selectedRectData = new SelectedAnnotData(); selectedRectData.annotData = annotData; } + private void SetRoationHandle(bool canRotate) + { + this.canRotate = canRotate; + } + public void SetIsProportionalScaling(bool isProportionalScaling) { this.isProportionalScaling = isProportionalScaling; @@ -620,11 +674,11 @@ public void SetIsProportionalScaling(bool isProportionalScaling) if (isProportionalScaling) { ignorePoints.Add(PointControlType.LeftMiddle); - ignorePoints.Add(PointControlType.MiddlBottom); + ignorePoints.Add(PointControlType.MiddleBottom); ignorePoints.Add(PointControlType.RightMiddle); ignorePoints.Add(PointControlType.MiddleTop); ignorePoints.Add(PointControlType.Rotate); - } + } } public void SetDrawType(DrawPointType drawType) @@ -688,7 +742,7 @@ public void SetIgnorePointsAll() ignorePoints.Add(PointControlType.LeftTop); ignorePoints.Add(PointControlType.LeftMiddle); ignorePoints.Add(PointControlType.LeftBottom); - ignorePoints.Add(PointControlType.MiddlBottom); + ignorePoints.Add(PointControlType.MiddleBottom); ignorePoints.Add(PointControlType.RightBottom); ignorePoints.Add(PointControlType.RightMiddle); ignorePoints.Add(PointControlType.RightTop); @@ -704,7 +758,7 @@ public void DisableAll() ignorePoints.Add(PointControlType.LeftTop); ignorePoints.Add(PointControlType.LeftMiddle); ignorePoints.Add(PointControlType.LeftBottom); - ignorePoints.Add(PointControlType.MiddlBottom); + ignorePoints.Add(PointControlType.MiddleBottom); ignorePoints.Add(PointControlType.RightBottom); ignorePoints.Add(PointControlType.RightMiddle); ignorePoints.Add(PointControlType.RightTop); @@ -786,7 +840,6 @@ public PointControlType GetHitControlIndex(Point point, bool isIgnore = true) if (hitResult != null && hitResult.VisualHit is DrawingVisual) { List ignoreList = GetIgnorePoints(); - List IgnorePointsList = new List(); foreach (PointControlType type in ignoreList) { @@ -799,10 +852,33 @@ public PointControlType GetHitControlIndex(Point point, bool isIgnore = true) { Point checkPoint = controlPoints[i]; + if (canRotate) + { + // Convert the rotation angle from degrees to radians + double angleRad = rotateAngle * Math.PI / 180.0; + + // Calculate the sine and cosine of the angle + double cosAngle = Math.Cos(angleRad); + double sinAngle = Math.Sin(angleRad); + + // Translate checkPoint to the origin (centerPoint becomes the origin) + double translatedX = checkPoint.X - centerPoint.X; + double translatedY = checkPoint.Y - centerPoint.Y; + + // Apply the rotation matrix + double rotatedX = translatedX * cosAngle - translatedY * sinAngle; + double rotatedY = translatedX * sinAngle + translatedY * cosAngle; + + // Translate the point back to its original position + checkPoint.X = rotatedX + centerPoint.X; + checkPoint.Y = rotatedY + centerPoint.Y; + } + if (isIgnore && IgnorePointsList.Contains(checkPoint)) { continue; } + switch (currentDrawPointType) { case DrawPointType.Circle: @@ -831,7 +907,6 @@ public PointControlType GetHitControlIndex(Point point, bool isIgnore = true) } if ((PointControlType)i == PointControlType.RightMiddle) { - if (Math.Abs(point.X - checkPoint.X) < wlen && checkVector.Length < drawRect.Height/3) { return (PointControlType)i; @@ -853,7 +928,7 @@ public PointControlType GetHitControlIndex(Point point, bool isIgnore = true) } } - if ((PointControlType)i == PointControlType.MiddlBottom) + if ((PointControlType)i == PointControlType.MiddleBottom) { if (Math.Abs(point.Y - checkPoint.Y) < hlen && checkVector.Length < drawRect.Width/3) { @@ -865,13 +940,25 @@ public PointControlType GetHitControlIndex(Point point, bool isIgnore = true) return (PointControlType)i; } break; - case DrawPointType.Square: + case DrawPointType.Square: Rect checkRect = new Rect(Math.Max(checkPoint.X - pointSize, 0), Math.Max(checkPoint.Y - pointSize, 0), pointSize * 2, pointSize * 2); if (checkRect.Contains(point)) { return (PointControlType)i; } + + if (canRotate) + { + Point hitRotationPoint = new Point(centerPoint.X + (rotationPoint.X - centerPoint.X) * Math.Cos(rotateAngle * Math.PI / 180) - (rotationPoint.Y - centerPoint.Y) * Math.Sin(rotateAngle * Math.PI / 180), + centerPoint.Y + (rotationPoint.X - centerPoint.X) * Math.Sin(rotateAngle * Math.PI / 180) + (rotationPoint.Y - centerPoint.Y) * Math.Cos(rotateAngle * Math.PI / 180)); + Vector checkVector1 = point - hitRotationPoint; + + if (checkVector1.Length < pointSize) + { + return PointControlType.Rotate; + } + } break; case DrawPointType.Crop: @@ -881,28 +968,58 @@ public PointControlType GetHitControlIndex(Point point, bool isIgnore = true) return (PointControlType)i; } break; + default: break; } } - if (drawRect.Contains(point)) + + if (canRotate) { - double rectWidth = (drawRect.Width - 2 * rectPadding > 0) ? drawRect.Width - 2 * rectPadding : 0; - double rectHeight = (drawRect.Height - 2 * rectPadding > 0) ? drawRect.Height - 2 * rectPadding : 0; - Rect rect = new Rect(Math.Max(drawRect.X + rectPadding, 0), Math.Max(drawRect.Y + rectPadding, 0), rectWidth, rectHeight); - if (rect.Contains(point)) + bool isIn = DataConversionForWPF.IsPointInRotatedRectangle(point, drawRect, rotateAngle); + if(isIn) { + double rectWidth = (drawRect.Width - 2 * rectPadding > 0) ? drawRect.Width - 2 * rectPadding : 0; + double rectHeight = (drawRect.Height - 2 * rectPadding > 0) ? drawRect.Height - 2 * rectPadding : 0; + Rect rect = new Rect(Math.Max(drawRect.X + rectPadding, 0), Math.Max(drawRect.Y + rectPadding, 0), rectWidth, rectHeight); + isIn = DataConversionForWPF.IsPointInRotatedRectangle(point, rect, rotateAngle); + if (isIn) + { + if (!ignoreList.Contains(PointControlType.Body)) + { + return PointControlType.Body; + } + } + if (!ignoreList.Contains(PointControlType.Body)) { - return PointControlType.Body; + return PointControlType.Line; } } - if (!ignoreList.Contains(PointControlType.Body)) + } + else + { + if (drawRect.Contains(point)) { - return PointControlType.Line; + double rectWidth = (drawRect.Width - 2 * rectPadding > 0) ? drawRect.Width - 2 * rectPadding : 0; + double rectHeight = (drawRect.Height - 2 * rectPadding > 0) ? drawRect.Height - 2 * rectPadding : 0; + Rect rect = new Rect(Math.Max(drawRect.X + rectPadding, 0), Math.Max(drawRect.Y + rectPadding, 0), rectWidth, rectHeight); + if (rect.Contains(point)) + { + if (!ignoreList.Contains(PointControlType.Body)) + { + return PointControlType.Body; + } + } + + if (!ignoreList.Contains(PointControlType.Body)) + { + return PointControlType.Line; + } } } } + return PointControlType.None; } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/SelectedRect.protected.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/SelectedRect.protected.cs index 4a960ea..75006b5 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/SelectedRect.protected.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/DrawTool/SelectedRect.protected.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Windows; using System.Windows.Media; @@ -8,7 +9,6 @@ namespace ComPDFKit.Tool.DrawTool public partial class SelectedRect { #region Properties - /// /// Current control point drawing style. /// @@ -18,7 +18,6 @@ protected DrawPointType currentDrawPointType set; } - /// /// Current drag drawing style. /// @@ -27,7 +26,11 @@ protected DrawPointType currentDrawPointType /// /// Current click hit control point. /// - protected PointControlType hitControlType { get; set; } + protected PointControlType hitControlType + { + get; + set; + } /// /// Mouse down position information. @@ -39,6 +42,10 @@ protected DrawPointType currentDrawPointType /// protected bool isMouseDown { get; set; } + protected bool isInRotate { get; set; } = false; + + protected bool isInScaling { get; set; } = false; + /// /// Whether proportional scaling is required. /// @@ -52,12 +59,12 @@ protected DrawPointType currentDrawPointType /// /// Rectangular minimum width. /// - protected int rectMinWidth { get; set; } = 10; + public int RectMinWidth { get; set; } = 10; /// /// Rectangular minimum height. /// - protected int RectMinHeight { get; set; } = 10; + public int RectMinHeight { get; set; } = 10; /// /// Current set of ignore points. @@ -67,12 +74,20 @@ protected DrawPointType currentDrawPointType /// /// Current set of drawing rectangles (original data). /// - protected Rect SetDrawRect { get; set; } = new Rect(0, 0, 0, 0); + protected Rect SetDrawRect + { + get; + set; + } = new Rect(0, 0, 0, 0); /// /// Current drawing rectangle (calculated during operation). /// - protected Rect drawRect { get; set; } = new Rect(0, 0, 0, 0); + protected Rect drawRect + { + get; + set; + } = new Rect(0, 0, 0, 0); /// /// Maximum range that can be drawn. @@ -94,6 +109,12 @@ protected DrawPointType currentDrawPointType /// protected List controlPoints { get; set; } = new List(); + protected Point centerPoint = new Point(); + + protected Point rotationPoint = new Point(); + + protected Point dragRotationPoint = new Point(); + /// /// Move offset during movement. /// @@ -119,6 +140,10 @@ protected DrawPointType currentDrawPointType protected double PDFViewerActualHeight { get; set; } = 0; + protected int rotateAngle { get; set; } = 0; + + protected int pageRotation { get; set; } = 0; + protected double rectPadding = 6; protected double currentZoom = 1; @@ -127,6 +152,12 @@ protected DrawPointType currentDrawPointType protected bool disable = false; + protected List rotateControlPoints = new List(); + + protected Rect rotateRect = new Rect(); + + public bool IsPath { get; set; } = false; + #endregion #region Functions @@ -140,17 +171,43 @@ protected DrawPointType currentDrawPointType protected void CalcControlPoint(Rect currentRect) { controlPoints.Clear(); - int centerX = (int)(currentRect.Left + currentRect.Right) / 2; - int centerY = (int)(currentRect.Top + currentRect.Bottom) / 2; + centerPoint.X = (int)(currentRect.Left + currentRect.Right) / 2; + centerPoint.Y = (int)(currentRect.Top + currentRect.Bottom) / 2; controlPoints.Add(new Point(currentRect.Left, currentRect.Top)); - controlPoints.Add(new Point(currentRect.Left, centerY)); + controlPoints.Add(new Point(currentRect.Left, centerPoint.Y)); controlPoints.Add(new Point(currentRect.Left, currentRect.Bottom)); - controlPoints.Add(new Point(centerX, currentRect.Bottom)); + controlPoints.Add(new Point(centerPoint.X, currentRect.Bottom)); controlPoints.Add(new Point(currentRect.Right, currentRect.Bottom)); - controlPoints.Add(new Point(currentRect.Right, centerY)); + controlPoints.Add(new Point(currentRect.Right, centerPoint.Y)); controlPoints.Add(new Point(currentRect.Right, currentRect.Top)); - controlPoints.Add(new Point(centerX, currentRect.Top)); + controlPoints.Add(new Point(centerPoint.X, currentRect.Top)); + + if (canRotate) + { + rotationPoint = new Point(centerPoint.X, currentRect.Top - 30); + switch (pageRotation) + { + case 0: + rotationPoint = new Point(centerPoint.X, currentRect.Top - 30); + break; + + case 1: + rotationPoint = new Point(currentRect.Right + 30, centerPoint.Y); + break; + + case 2: + rotationPoint = new Point(centerPoint.X, currentRect.Bottom + 30); + break; + + case 3: + rotationPoint = new Point(currentRect.Left - 30, centerPoint.Y); + break; + + default: + break; + } + } } protected List GetControlPoint(Rect currentRect) @@ -234,9 +291,23 @@ protected bool CalcHitPointMove(Point mousePoint) { return false; } + + if (hitControlType == PointControlType.Rotate) + { + SetRotateByMousePoint(mousePoint); + return false; + } + if (!isOutSideScaling) { - return NormalScaling(mousePoint); + if (selectedRectData.rotationAngle != 0) + { + return RotateScaling(mousePoint); + } + else + { + return NormalScaling(mousePoint); + } } else { @@ -249,11 +320,10 @@ public void SetOutSideScaling(bool IsOutSideScaling) isOutSideScaling = IsOutSideScaling; } - private Size GetProportionalScalingSize(double width, double height) { double minHeight = RectMinHeight + 2 * rectPadding * currentZoom; - double minWidth = rectMinWidth + 2 * rectPadding * currentZoom; + double minWidth = RectMinWidth + 2 * rectPadding * currentZoom; if (minWidth > width || minHeight > height) { if (cacheRect.Width >= cacheRect.Height) @@ -271,6 +341,13 @@ private Size GetProportionalScalingSize(double width, double height) return new Size(width, height); } + private void SetRotateByMousePoint(Point mousePoint) + { + dragRotationPoint = mousePoint; + Vector moveVector = (mousePoint - centerPoint); + rotateAngle = (int)(Math.Atan2(moveVector.X, -moveVector.Y) * 180 / Math.PI) - pageRotation * 90; + } + /// /// Draw the algorithm in the form of normal scaling (drag a point, only scale in one direction). /// @@ -282,7 +359,7 @@ protected bool NormalScaling(Point mousePoint) { double left = 0, right = 0, top = 0, bottom = 0; double minHeight = RectMinHeight + 2 * rectPadding * currentZoom; - double minWidth = rectMinWidth + 2 * rectPadding * currentZoom; + double minWidth = RectMinWidth + 2 * rectPadding * currentZoom; Point centerPoint = new Point((cacheRect.Right + cacheRect.Left) / 2, (cacheRect.Bottom + cacheRect.Top) / 2); Point moveVector = (Point)(mousePoint - centerPoint); @@ -391,7 +468,7 @@ protected bool NormalScaling(Point mousePoint) } break; - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: { left = cacheRect.Left; right = cacheRect.Right; @@ -434,7 +511,7 @@ protected bool NormalScaling(Point mousePoint) } } else - { + { if (left + minWidth > right) { right = left + minWidth; @@ -521,11 +598,11 @@ protected bool NormalScaling(Point mousePoint) case PointControlType.Body: case PointControlType.Line: { - Point OffsetPos = CalcMoveBound(cacheRect, ((Point)(mousePoint - mouseDownPoint)), maxRect); - left = cacheRect.Left + OffsetPos.X; - right = cacheRect.Right + OffsetPos.X; - top = cacheRect.Top + OffsetPos.Y; - bottom = cacheRect.Bottom + OffsetPos.Y; + Point offsetPos = CalcMoveBound(cacheRect, ((Point)(mousePoint - mouseDownPoint)), maxRect); + left = cacheRect.Left + offsetPos.X; + right = cacheRect.Right + offsetPos.X; + top = cacheRect.Top + offsetPos.Y; + bottom = cacheRect.Bottom + offsetPos.Y; } break; @@ -563,6 +640,182 @@ protected bool NormalScaling(Point mousePoint) return false; } + protected bool RotateScaling(Point mouseMovePoint) + { + Point rotatePoint = new Point(); + Point hitControlUIPos = new Point(); + if (hitControlType < PointControlType.Body) + { + hitControlUIPos = rotateControlPoints[(int)hitControlType]; + } + + hitControlUIPos = GetRotateUIPoint(hitControlUIPos); + Point centerPoint = new Point((rotateRect.Left + rotateRect.Right) / 2, (rotateRect.Top + rotateRect.Bottom) / 2); + Vector moveVector = mouseMovePoint - mouseDownPoint; + Vector hitVector = hitControlUIPos - centerPoint; + + Rect tmpRect = cacheRect; + if (hitControlType == PointControlType.LeftTop + || hitControlType == PointControlType.LeftBottom + || hitControlType == PointControlType.RightTop + || hitControlType == PointControlType.RightBottom) + { + if (isProportionalScaling) + { + double vectorAngle = Vector.AngleBetween(moveVector, hitVector); + double newLenght = Math.Cos(Math.PI / 180.0 * vectorAngle) * moveVector.Length; + + hitVector.Normalize(); + hitVector.X *= newLenght; + hitVector.Y *= newLenght; + rotatePoint = new Point(hitControlUIPos.X + hitVector.X, hitControlUIPos.Y + hitVector.Y); + } + } + + switch (hitControlType) + { + case PointControlType.LeftTop: + { + Point rightBottomPoint = rotateControlPoints[(int)PointControlType.RightBottom]; + Point rightBottomUIPos = GetRotateUIPoint(rightBottomPoint); + centerPoint = new Point((rotatePoint.X + rightBottomUIPos.X) / 2, (rotatePoint.Y + rightBottomUIPos.Y) / 2); + + Matrix rotateMatrix = new Matrix(); + rotateMatrix.RotateAt(-rotateAngle, centerPoint.X, centerPoint.Y); + + Point leftTopPoint = rotateMatrix.Transform(rotatePoint); + rightBottomPoint = rotateMatrix.Transform(rightBottomUIPos); + tmpRect = new Rect(leftTopPoint, rightBottomPoint); + } + break; + + case PointControlType.LeftBottom: + { + Point rightTopPoint = rotateControlPoints[(int)PointControlType.RightTop]; + Point rightTopUIPos = GetRotateUIPoint(rightTopPoint); + centerPoint = new Point((rotatePoint.X + rightTopUIPos.X) / 2, (rotatePoint.Y + rightTopUIPos.Y) / 2); + + Matrix rotateMatrix = new Matrix(); + rotateMatrix.RotateAt(-rotateAngle, centerPoint.X, centerPoint.Y); + + Point leftBottomPoint = rotateMatrix.Transform(rotatePoint); + rightTopPoint = rotateMatrix.Transform(rightTopUIPos); + tmpRect = new Rect(leftBottomPoint, rightTopPoint); + } + break; + + case PointControlType.RightTop: + { + Point leftBottomPoint = rotateControlPoints[(int)PointControlType.LeftBottom]; + Point leftBottomUIPos = GetRotateUIPoint(leftBottomPoint); + centerPoint = new Point((rotatePoint.X + leftBottomUIPos.X) / 2, (rotatePoint.Y + leftBottomUIPos.Y) / 2); + + Matrix rotateMatrix = new Matrix(); + rotateMatrix.RotateAt(-rotateAngle, centerPoint.X, centerPoint.Y); + + Point rightTopPoint = rotateMatrix.Transform(rotatePoint); + leftBottomPoint = rotateMatrix.Transform(leftBottomUIPos); + tmpRect = new Rect(leftBottomPoint, rightTopPoint); + } + break; + + case PointControlType.RightBottom: + { + Point leftTopPoint = rotateControlPoints[(int)PointControlType.LeftTop]; + Point leftTopUIPos = GetRotateUIPoint(leftTopPoint); + centerPoint = new Point((rotatePoint.X + leftTopUIPos.X) / 2, (rotatePoint.Y + leftTopUIPos.Y) / 2); + + Matrix rotateMatrix = new Matrix(); + rotateMatrix.RotateAt(-rotateAngle, centerPoint.X, centerPoint.Y); + + Point rightBottomPoint = rotateMatrix.Transform(rotatePoint); + leftTopPoint = rotateMatrix.Transform(leftTopUIPos); + tmpRect = new Rect(leftTopPoint, rightBottomPoint); + } + break; + + case PointControlType.Body: + case PointControlType.Line: + { + Point offsetPos = (Point)(mouseMovePoint - mouseDownPoint); + double left = cacheRect.Left + offsetPos.X; + double right = cacheRect.Right + offsetPos.X; + double top = cacheRect.Top + offsetPos.Y; + double bottom = cacheRect.Bottom + offsetPos.Y; + tmpRect = new Rect(new Point(left,top), new Point(right,bottom)); + } + break; + + default: + break; + } + + List tempPoints = new List + { + new Point(tmpRect.Left, tmpRect.Top), + new Point(tmpRect.Right, tmpRect.Top), + new Point(tmpRect.Right, tmpRect.Bottom), + new Point(tmpRect.Left, tmpRect.Bottom) + }; + + List boundPoint = new List(); + Point center = new Point((tmpRect.Left + tmpRect.Right) / 2, (tmpRect.Top + tmpRect.Bottom) / 2); + foreach (Point point in tempPoints) + { + float x = (float)(center.X + (point.X - center.X) * Math.Cos(rotateAngle * Math.PI / 180) - (point.Y - center.Y) * Math.Sin(rotateAngle * Math.PI / 180)); + float y = (float)(center.Y + (point.X - center.X) * Math.Sin(rotateAngle * Math.PI / 180) + (point.Y - center.Y) * Math.Cos(rotateAngle * Math.PI / 180)); + boundPoint.Add(new Point(x, y)); + } + + Rect boundRect = new Rect(new Point(boundPoint.Min(p => p.X), boundPoint.Min(p => p.Y)), new Point(boundPoint.Max(p => p.X), boundPoint.Max(p => p.Y))); + if (maxRect.Contains(boundRect)) + { + drawRect = tmpRect; + } + else + { + if(hitControlType == PointControlType.Body || hitControlType == PointControlType.Line) + { + Point boundRectCenterPos = new Point((boundRect.Left + boundRect.Right) / 2, (boundRect.Top + boundRect.Bottom) / 2); + Point maxRectCenterPos = new Point((maxRect.Left + maxRect.Right) / 2, (maxRect.Top + maxRect.Bottom) / 2); + Vector moveCenterVector = boundRectCenterPos - maxRectCenterPos; + Point moveOffsetPos = new Point(0, 0); + if (Math.Abs(moveCenterVector.X) > (maxRect.Width - boundRect.Width) / 2) + { + double moveLength = maxRectCenterPos.X - boundRectCenterPos.X; + moveOffsetPos.X = Math.Abs(moveLength) - (maxRect.Width - boundRect.Width) / 2; + if (moveLength < 0) + { + moveOffsetPos.X *= -1; + } + } + + if (Math.Abs(moveCenterVector.Y) > (maxRect.Height - boundRect.Height) / 2) + { + double moveLength = maxRectCenterPos.Y - boundRectCenterPos.Y; + moveOffsetPos.Y = Math.Abs(moveLength) - (maxRect.Height - boundRect.Height) / 2; + if (moveLength < 0) + { + moveOffsetPos.Y *= -1; + } + } + + drawRect = new Rect(tmpRect.Left + moveOffsetPos.X, tmpRect.Top + moveOffsetPos.Y, tmpRect.Width, tmpRect.Height); + } + } + + moveOffset = new Point(drawRect.X - cacheRect.X, drawRect.Y - cacheRect.Y); + return true; + } + + private Point GetRotateUIPoint(Point point) + { + Point centerPoint = new Point((rotateRect.Left + rotateRect.Right) / 2, (rotateRect.Top + rotateRect.Bottom) / 2); + Matrix rotateMatrix = new Matrix(); + rotateMatrix.RotateAt(rotateAngle, centerPoint.X, centerPoint.Y); + return rotateMatrix.Transform(point); + } + /// /// Provisional logic, to be further improved, not yet used: Draw the algorithm in the form of normal scaling (drag a point, only scale in one direction). /// @@ -574,7 +827,7 @@ protected bool OutSideScaling(Point mousePoint) { double left = 0, right = 0, top = 0, bottom = 0; double minHeight = RectMinHeight + 2 * rectPadding * currentZoom; - double minWidth = rectMinWidth + 2 * rectPadding * currentZoom; + double minWidth = RectMinWidth + 2 * rectPadding * currentZoom; Point centerPoint = new Point((cacheRect.Right + cacheRect.Left) / 2, (cacheRect.Bottom + cacheRect.Top) / 2); Point moveVector = (Point)(mousePoint - centerPoint); @@ -683,7 +936,7 @@ protected bool OutSideScaling(Point mousePoint) } break; - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: { left = cacheRect.Left; right = cacheRect.Right; @@ -905,7 +1158,7 @@ protected Point ProportionalScalingOffsetPos(Point movePoint) case PointControlType.RightMiddle: offsetPos = new Point(movePoint.X, Math.Abs(movePoint.X) * ratioX * (movePoint.X < 0 ? -1 : 1)); break; - case PointControlType.MiddlBottom: + case PointControlType.MiddleBottom: offsetPos = new Point(Math.Abs(movePoint.Y) * ratioY * (movePoint.Y < 0 ? 1 : -1), movePoint.Y); break; case PointControlType.MiddleTop: @@ -988,36 +1241,122 @@ protected void DrawCirclePoint(DrawingContext drawingContext, List protected void DrawSquarePoint(DrawingContext drawingContext, List ignoreList, int PointSize, Pen PointPen, SolidColorBrush BorderBrush) { - GeometryGroup controlGroup = new GeometryGroup(); - controlGroup.FillRule = FillRule.Nonzero; - List ignorePointsList = new List(); - // Get specific points - foreach (PointControlType type in ignoreList) + RotateTransform rotateTransform = new RotateTransform(rotateAngle, centerPoint.X, centerPoint.Y); + if (canRotate && !isInScaling) { - if ((int)type < controlPoints.Count) + Point currentRotationPoint = isInRotate ? dragRotationPoint : rotationPoint; + double angleInRadians = rotateAngle * (Math.PI / 180); + double sinValue = Math.Sin(angleInRadians); + double cosValue = Math.Cos(angleInRadians); + double rotatedX = 0; + double rotatedY = 0; + switch (pageRotation) { - ignorePointsList.Add(controlPoints[(int)type]); + case 0: + rotatedX = currentRotationPoint.X - pointSize * sinValue; + rotatedY = currentRotationPoint.Y + pointSize * cosValue; + break; + + case 1: + rotatedX = currentRotationPoint.X - pointSize * cosValue; + rotatedY = currentRotationPoint.Y + pointSize * sinValue; + break; + + case 2: + rotatedX = currentRotationPoint.X + pointSize * sinValue; + rotatedY = currentRotationPoint.Y - pointSize * cosValue; + break; + + case 3: + rotatedX = currentRotationPoint.X + pointSize * sinValue; + rotatedY = currentRotationPoint.Y - pointSize * cosValue; + break; + + default: + break; + } + + GeometryGroup rotateGroup = new GeometryGroup(); + LineGeometry moveLineGeometry = new LineGeometry(centerPoint, new Point(rotatedX, rotatedY)); + EllipseGeometry ellipseGeometry = new EllipseGeometry(currentRotationPoint, PointSize, pointSize); + rotateGroup.Children.Add(moveLineGeometry); + rotateGroup.Children.Add(ellipseGeometry); + if (!isInRotate) + { + rotateGroup.Children.Remove(moveLineGeometry); + LineGeometry stopLineGeometry = new LineGeometry(centerPoint, new Point(currentRotationPoint.X, currentRotationPoint.Y + pointSize)); + switch (pageRotation) + { + case 0: + stopLineGeometry = new LineGeometry(centerPoint, new Point(currentRotationPoint.X, currentRotationPoint.Y + pointSize)); + + break; + + case 1: + stopLineGeometry = new LineGeometry(centerPoint, new Point(currentRotationPoint.X - pointSize, currentRotationPoint.Y )); + + break; + + case 2: + stopLineGeometry = new LineGeometry(centerPoint, new Point(currentRotationPoint.X, currentRotationPoint.Y - pointSize)); + + break; + + case 3: + stopLineGeometry = new LineGeometry(centerPoint, new Point(currentRotationPoint.X + pointSize, currentRotationPoint.Y)); + break; + + default: + break; + } + + rotateGroup.Children.Add(stopLineGeometry); + drawingContext.PushTransform(rotateTransform); + } + + drawingContext?.DrawGeometry(BorderBrush, PointPen, rotateGroup); + if (!isInRotate) + { + + drawingContext.Pop(); } } - for (int i = 0; i < controlPoints.Count; i++) + if (!isInRotate) { - Point controlPoint = controlPoints[i]; - if (ignorePointsList.Contains(controlPoint)) + GeometryGroup controlGroup = new GeometryGroup(); + controlGroup.FillRule = FillRule.Nonzero; + List ignorePointsList = new List(); + // Get specific points + foreach (PointControlType type in ignoreList) { - continue; + if ((int)type < controlPoints.Count) + { + ignorePointsList.Add(controlPoints[(int)type]); + } + } + for (int i = 0; i < controlPoints.Count; i++) + { + Point controlPoint = controlPoints[i]; + if (ignorePointsList.Contains(controlPoint)) + { + continue; + } + RectangleGeometry rectPoint = new RectangleGeometry(new Rect(controlPoint.X - PointSize, controlPoint.Y - PointSize, + PointSize * 2, PointSize * 2), 1, 1); + controlGroup.Children.Add(rectPoint); } - RectangleGeometry rectPoint = new RectangleGeometry(new Rect(controlPoint.X - PointSize, controlPoint.Y - PointSize, - PointSize * 2, PointSize * 2), 1, 1); - controlGroup.Children.Add(rectPoint); + + drawingContext.PushTransform(rotateTransform); + drawingContext?.DrawGeometry(BorderBrush, PointPen, controlGroup); + drawingContext.Pop(); } - drawingContext?.DrawGeometry(BorderBrush, PointPen, controlGroup); } protected void DrawCropPoint(DrawingContext drawingContext, List ignoreList, int PointSize, Pen PointPen, SolidColorBrush BorderBrush) { //GeometryGroup controlGroup = new GeometryGroup(); //controlGroup.FillRule = FillRule.Nonzero; - clipThickness.Left = (SetDrawRect.Left - drawRect.Left)/currentZoom; + clipThickness.Left = (SetDrawRect.Left - drawRect.Left) / currentZoom; clipThickness.Top = (SetDrawRect.Top - drawRect.Top) / currentZoom; clipThickness.Right = (SetDrawRect.Right - drawRect.Right) / currentZoom; clipThickness.Bottom = (SetDrawRect.Bottom - drawRect.Bottom) / currentZoom; @@ -1055,7 +1394,7 @@ protected void DrawCropPoint(DrawingContext drawingContext, List /// Get the current set of ignore points /// diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Help/CommonHelper.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Help/CommonHelper.cs index cfa36c3..be1adc2 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Help/CommonHelper.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Help/CommonHelper.cs @@ -5,11 +5,34 @@ using System.Threading.Tasks; using System.Windows.Media; using System.Windows; +using ComPDFKitViewer; +using System.IO; +using System.Runtime.Remoting.Messaging; +using System.Windows.Media.Imaging; +using System.ComponentModel; +using ComPDFKit.PDFAnnotation; +using System.Windows.Input; +using System.Reflection; namespace ComPDFKit.Tool.Help { public static class CommonHelper { + private static Cursor _rotationCursor = null; + public static Cursor RotationCursor + { + get + { + if (_rotationCursor == null) + { + var assembly = Assembly.GetExecutingAssembly(); + Stream stream = assembly.GetManifestResourceStream("ComPDFKit.Tool.Resource.Cursor.Rotation.cur"); + _rotationCursor = new Cursor(stream); + } + return _rotationCursor; + } + } + /// /// Find the parent control of the target type of the object /// @@ -81,7 +104,7 @@ public static childItem FindVisualChild(DependencyObject obj) public static List FindVisualChildList(DependencyObject obj) where childItem : DependencyObject { - List children = new List (); + List children = new List(); try { for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) @@ -103,6 +126,83 @@ public static List FindVisualChildList(DependencyObject ob catch { return children; } } + public static PathGeometry GetPathIcon(string iconKey) + { + string pathIcon = "M18 3H2V15H5V18L10 15H18V3ZM5 6H11V7.5H5V6ZM5 9.5H15V11H5V9.5Z"; + try + { + TypeConverter typeCovert = TypeDescriptor.GetConverter(typeof(Geometry)); + if (CPDFViewer.StickyIconDict != null && CPDFViewer.StickyIconDict.ContainsKey(iconKey)) + { + pathIcon = CPDFViewer.StickyIconDict[iconKey]; + } + + return PathGeometry.CreateFromGeometry((Geometry)typeCovert.ConvertFrom(pathIcon)); + } + catch (Exception ex) + { + + } + + return new PathGeometry(); + } + + private static bool GetIconData(string iconName, Brush fillBrush, out string tempImagePath) + { + tempImagePath = string.Empty; + try + { + if (CPDFViewer.StickyIconDict != null && CPDFViewer.StickyIconDict.ContainsKey(iconName)) + { + PathGeometry iconGeometry = GetPathIcon(iconName); + DrawingVisual iconVisual = new DrawingVisual(); + DrawingContext iconContext = iconVisual.RenderOpen(); + iconContext.DrawGeometry(fillBrush, null, iconGeometry); + iconContext.Close(); + RenderTargetBitmap renderBitmap = new RenderTargetBitmap(32, 32, 96, 96, PixelFormats.Pbgra32); + renderBitmap.Render(iconVisual); + string tempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), Guid.NewGuid().ToString()); + + PngBitmapEncoder pngEncoder = new PngBitmapEncoder(); + using (FileStream fs = File.Create(tempPath)) + { + pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap)); + pngEncoder.Save(fs); + } + tempImagePath = tempPath; + return true; + } + } + catch (Exception ex) + { + + } + + return false; + } + + public static void UpdateStickyAP(CPDFTextAnnotation textAnnotation) + { + if (textAnnotation == null || textAnnotation.IsValid() == false) + { + return; + } + try + { + string iconName = textAnnotation.GetIconName(); + byte opacity = textAnnotation.GetTransparency(); + SolidColorBrush fillBrush = new SolidColorBrush(Color.FromArgb(opacity, textAnnotation.Color[0], textAnnotation.Color[1], textAnnotation.Color[2])); + + if (GetIconData(iconName, fillBrush, out string apPath) && File.Exists(apPath)) + { + textAnnotation.UpdateApWithImage(apPath, string.Empty, textAnnotation.GetRotation()); + File.Delete(apPath); + } + } + catch (Exception ex) + { + } + } } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Help/ParamConverter.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Help/ParamConverter.cs index 7f34b48..f893f1b 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Help/ParamConverter.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Help/ParamConverter.cs @@ -9,6 +9,8 @@ using ComPDFKit.Tool.SettingParam; using ComPDFKit.Tool.UndoManger; using ComPDFKit.Viewer.Helper; +using ComPDFKitViewer.Helper; +using ComPDFKitViewer; using System.Collections.Generic; using System.IO; using System.Linq; @@ -169,12 +171,47 @@ public static AnnotHistory CreateHistory(CPDFAnnotation cPDFAnnotation) return annotHistory; } - public static bool RemovePageAnnot(Dictionary> removeAnnots, CPDFDocument cPDFDocument) + public static bool RemovePageAnnot(Dictionary> removeAnnots, CPDFViewer cPDFViewer) { + CPDFDocument cPDFDocument = cPDFViewer.GetDocument(); if (cPDFDocument == null || removeAnnots.Count <= 0) { return false; } + + GroupHistory historyGroup = new GroupHistory(); + foreach (int pageIndex in removeAnnots.Keys) + { + CPDFPage pageCore = cPDFDocument.PageAtIndex(pageIndex); + List cPDFAnnotations = pageCore.GetAnnotations(); + foreach (int annotIndex in removeAnnots[pageIndex]) + { + CPDFAnnotation cPDFAnnotation = cPDFAnnotations.ElementAtOrDefault(annotIndex); + if (cPDFAnnotation != null) + { + AnnotParam annotParam = CPDFDataConverterToAnnotParam(cPDFDocument, pageIndex, cPDFAnnotation); + if (annotParam is StampParam stampParam) + { + if (stampParam.StampType == C_STAMP_TYPE.IMAGE_STAMP) + { + stampParam.CopyImageAnnot = CPDFAnnotation.CopyAnnot(cPDFAnnotation); + } + } + + AnnotHistory annotHistory = CreateHistory(cPDFAnnotation); + annotHistory.CurrentParam = annotParam; + annotHistory.PDFDoc = cPDFDocument; + annotHistory.Action = HistoryAction.Remove; + historyGroup.Histories.Add(annotHistory); + } + } + } + + if (historyGroup.Histories.Count > 0) + { + cPDFViewer.UndoManager.AddHistory(historyGroup); + } + foreach (int pageIndex in removeAnnots.Keys) { CPDFPage pageCore = cPDFDocument.PageAtIndex(pageIndex); @@ -188,7 +225,8 @@ public static bool RemovePageAnnot(Dictionary> removeAnnots, CPDF } } } - return false; + + return true; } public static FormField ConverterWidgetFormFlags(int Flags, bool IsHidden) @@ -311,10 +349,10 @@ public static AnnotParam CPDFDataConverterToAnnotParam(CPDFDocument cPDFDocument return annotParam; } - public static PDFEditParam CPDFDataConverterToPDFEitParam(CPDFDocument cPDFDocument, CPDFEditArea cPDFEditArea, int PageIndex) + public static PDFEditParam CPDFDataConverterToPDFEitParam(CPDFDocument cPDFDocument, CPDFEditArea cPDFEditArea, int pageIndex) { PDFEditParam annotParam = null; - if (cPDFEditArea == null && !cPDFEditArea.IsValid() && cPDFDocument == null && !cPDFDocument.IsValid() && PageIndex >= 0) + if (cPDFEditArea == null && !cPDFEditArea.IsValid() && cPDFDocument == null && !cPDFDocument.IsValid() && pageIndex >= 0) { return null; } @@ -323,11 +361,15 @@ public static PDFEditParam CPDFDataConverterToPDFEitParam(CPDFDocument cPDFDocum case CPDFEditType.None: break; case CPDFEditType.EditText: - annotParam = GetTextEditParam(cPDFDocument, cPDFEditArea as CPDFEditTextArea, PageIndex); + annotParam = GetTextEditParam(cPDFDocument, cPDFEditArea as CPDFEditTextArea, pageIndex); break; case CPDFEditType.EditImage: - annotParam = GetImageEditParam(cPDFDocument, cPDFEditArea as CPDFEditImageArea, PageIndex); + annotParam = GetImageEditParam(cPDFDocument, cPDFEditArea as CPDFEditImageArea, pageIndex); break; + case CPDFEditType.EditPath: + annotParam = GetPathEditParam(cPDFDocument, cPDFEditArea as CPDFEditPathArea, pageIndex); + break; + default: break; } @@ -337,7 +379,7 @@ public static PDFEditParam CPDFDataConverterToPDFEitParam(CPDFDocument cPDFDocum #region PDFEdit - internal static TextEditParam GetTextEditParam(CPDFDocument cPDFDocument, CPDFEditTextArea cPDFEditArea, int PageIndex) + internal static TextEditParam GetTextEditParam(CPDFDocument cPDFDocument, CPDFEditTextArea cPDFEditArea, int pageIndex) { TextEditParam textEditParam = new TextEditParam(); string fontName = "Helvetica"; @@ -354,10 +396,10 @@ internal static TextEditParam GetTextEditParam(CPDFDocument cPDFDocument, CPDFEd textEditParam.Transparency = transparency; textEditParam.TextAlign = cPDFEditArea.GetTextSectionAlign(); textEditParam.EditType = CPDFEditType.EditText; - CPDFPage docPage = cPDFDocument.PageAtIndex(PageIndex); - CPDFEditPage EditPage = docPage.GetEditPage(); - textEditParam.EditIndex = EditPage.GetEditAreaList().IndexOf(cPDFEditArea); - textEditParam.PageIndex = PageIndex; + CPDFPage docPage = cPDFDocument.PageAtIndex(pageIndex); + CPDFEditPage editPage = docPage.GetEditPage(); + textEditParam.EditIndex = editPage.GetEditAreaList().IndexOf(cPDFEditArea); + textEditParam.PageIndex = pageIndex; if(string.IsNullOrEmpty(cPDFEditArea.SelectText)) { @@ -373,18 +415,38 @@ internal static TextEditParam GetTextEditParam(CPDFDocument cPDFDocument, CPDFEd return textEditParam; } - internal static ImageEditParam GetImageEditParam(CPDFDocument cPDFDocument, CPDFEditImageArea cPDFEditArea, int PageIndex) + internal static ImageEditParam GetImageEditParam(CPDFDocument cPDFDocument, CPDFEditImageArea cPDFEditArea, int pageIndex) { ImageEditParam imageEditParam = new ImageEditParam(); imageEditParam.Transparency = cPDFEditArea.GetImageTransparency(); + imageEditParam.Rotate = cPDFEditArea.GetRotation(); + imageEditParam.ClipRect = cPDFEditArea.GetClipRect(); imageEditParam.EditType = CPDFEditType.EditImage; - CPDFPage docPage = cPDFDocument.PageAtIndex(PageIndex); - CPDFEditPage EditPage = docPage.GetEditPage(); - imageEditParam.EditIndex = EditPage.GetEditAreaList().IndexOf(cPDFEditArea); - imageEditParam.PageIndex = PageIndex; + + CPDFPage docPage = cPDFDocument.PageAtIndex(pageIndex); + CPDFEditPage editPage = docPage.GetEditPage(); + imageEditParam.EditIndex = editPage.GetEditAreaList().IndexOf(cPDFEditArea); + imageEditParam.PageIndex = pageIndex; return imageEditParam; } + internal static PathEditParam GetPathEditParam(CPDFDocument cPDFDocument, CPDFEditPathArea cPDFEditArea, int pageIndex) + { + PathEditParam pathEditParam = new PathEditParam(); + pathEditParam.Transparency = cPDFEditArea.GetTransparency(); + pathEditParam.Rotate = cPDFEditArea.GetRotation(); + pathEditParam.StrokeColor = cPDFEditArea.GetStrokeColor(); + pathEditParam.FillColor = cPDFEditArea.GetFillColor(); + pathEditParam.ClipRect = cPDFEditArea.GetClipRect(); + pathEditParam.EditType = CPDFEditType.EditPath; + + CPDFPage docPage = cPDFDocument.PageAtIndex(pageIndex); + CPDFEditPage editPage = docPage.GetEditPage(); + pathEditParam.EditIndex = editPage.GetEditAreaList().IndexOf(cPDFEditArea); + pathEditParam.PageIndex = pageIndex; + return pathEditParam; + } + #endregion #region Widegt @@ -941,7 +1003,7 @@ internal static AnnotParam AnnotConverter(CPDFDocument pdfDoc, CPDFAnnotation pd case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON: { CPDFPolygonAnnotation polygonAnnot= pdfAnnot as CPDFPolygonAnnotation; - if(polygonAnnot!=null && polygonAnnot.IsMeasured()) + if(polygonAnnot!=null) { return GetPolygonMeasureParam(polygonAnnot); } @@ -975,6 +1037,7 @@ internal static void GetAnnotCommonParam(CPDFAnnotation pdfAnnot, AnnotParam ann { annotParam.AnnotIndex = pdfAnnot.Page.GetAnnotCount() - 1; } + annotParam.PageIndex = pdfAnnot.Page.PageIndex; } @@ -1125,7 +1188,6 @@ private static AnnotParam GetPolygonParam(CPDFPolygonAnnotation polygonAnnot) } PolygonMeasureParam polygonParam = new PolygonMeasureParam(); - if (polygonAnnot.LineColor != null && polygonAnnot.LineColor.Length == 3) { polygonParam.LineColor = new byte[3] @@ -1316,6 +1378,12 @@ internal static InkParam GetInkParam(CPDFInkAnnotation inkAnnot) } } + if(inkAnnot.Dash!=null && inkAnnot.Dash.Length>0) + { + inkParam.Dash =new float[inkAnnot.Dash.Length]; + inkAnnot.Dash.CopyTo(inkParam.Dash, 0); + } + GetAnnotCommonParam(inkAnnot, inkParam); return inkParam; } @@ -1380,6 +1448,12 @@ internal static FreeTextParam GetFreeTextParam(CPDFFreeTextAnnotation freetextAn freetextParam.Alignment = freetextAnnot.Alignment; } + if (freetextAnnot.Dash != null && freetextAnnot.Dash.Length > 0) + { + freetextParam.Dash = new float[freetextAnnot.Dash.Length]; + freetextAnnot.Dash.CopyTo(freetextParam.Dash, 0); + } + GetAnnotCommonParam(freetextAnnot, freetextParam); return freetextParam; } @@ -1539,6 +1613,7 @@ internal static StickyNoteParam GetStickynoteParam(CPDFTextAnnotation stickyAnno }; } + stickyParam.IconName=stickyAnnot.GetIconName(); GetAnnotCommonParam(stickyAnnot, stickyParam); return stickyParam; @@ -1552,7 +1627,6 @@ internal static StampParam GetStampParam(CPDFStampAnnotation stampAnnot) } StampParam stampParam = new StampParam(); - C_STAMP_TYPE stampType = stampAnnot.GetStampType(); switch (stampType) { @@ -1582,6 +1656,7 @@ internal static StampParam GetStampParam(CPDFStampAnnotation stampAnnot) } break; case C_STAMP_TYPE.IMAGE_STAMP: + case C_STAMP_TYPE.UNKNOWN_STAMP: { stampParam.StampType = stampType; CRect rawRect = stampAnnot.GetRect(); @@ -1619,8 +1694,13 @@ internal static StampParam GetStampParam(CPDFStampAnnotation stampAnnot) return null; } - GetAnnotCommonParam(stampAnnot, stampParam); + stampParam.PageRotation = stampAnnot.Page.Rotation; + stampParam.Rotation = stampAnnot.AnnotationRotator.GetRotation(); + CRect sourceRect = new CRect(); + stampAnnot.GetSourceRect(ref sourceRect); + stampParam.SourceRect = sourceRect; + GetAnnotCommonParam(stampAnnot, stampParam); return stampParam; } @@ -1632,7 +1712,6 @@ internal static LinkParam GetLinkParam(CPDFLinkAnnotation linkAnnot, CPDFDocumen } LinkParam linkParam = new LinkParam(); - CPDFAction linkAction = linkAnnot.GetLinkAction(); if (linkAction != null) { @@ -1713,7 +1792,7 @@ internal static RedactParam GetRedactParam(CPDFRedactAnnotation redactAnnot) redactParam.FontColor = new byte[3] { redactAnnot.TextDa.FontColor[0], redactAnnot.TextDa.FontColor[1], redactAnnot.TextDa.FontColor[2] }; } - redactParam.FontName= redactAnnot.TextDa.FontName; + redactParam.FontName= redactAnnot.TextDa.FontName; redactParam.FontSize = redactAnnot.TextDa.FontSize; redactParam.Alignment=redactAnnot.TextAlignment; } @@ -1766,21 +1845,33 @@ internal static PolyLineMeasureParam GetPolyLineMeasureParam(CPDFPolylineAnnotat internal static PolygonMeasureParam GetPolygonMeasureParam(CPDFPolygonAnnotation polygonAnnot) { - if (polygonAnnot == null || polygonAnnot.IsValid() == false || polygonAnnot.IsMeasured() == false) + if (polygonAnnot == null || polygonAnnot.IsValid() == false) { return null; } PolygonMeasureParam measureParam = new PolygonMeasureParam(); - CPDFAreaMeasure areaMeasure = polygonAnnot.GetAreaMeasure(); - measureParam.measureInfo = areaMeasure.MeasureInfo; + if(polygonAnnot.IsMeasured()) + { + CPDFAreaMeasure areaMeasure = polygonAnnot.GetAreaMeasure(); + measureParam.measureInfo = areaMeasure.MeasureInfo; + CTextAttribute textAttr = polygonAnnot.GetTextAttribute(); + measureParam.FontName = textAttr.FontName; + measureParam.FontSize = textAttr.FontSize; + if (textAttr.FontColor != null && textAttr.FontColor.Length == 3) + { + measureParam.FontColor = new byte[] { textAttr.FontColor[0], textAttr.FontColor[1], textAttr.FontColor[2] }; + } + measureParam.IsBold = CFontNameHelper.IsBold(textAttr.FontName); + measureParam.IsItalic = CFontNameHelper.IsItalic(textAttr.FontName); + } if (polygonAnnot.LineColor != null && polygonAnnot.LineColor.Length == 3) { measureParam.LineColor = new byte[] { polygonAnnot.LineColor[0], polygonAnnot.LineColor[1], polygonAnnot.LineColor[2] }; } - if(polygonAnnot.BgColor!=null && polygonAnnot.BgColor.Length == 3) + if(polygonAnnot.HasBgColor && polygonAnnot.BgColor!=null && polygonAnnot.BgColor.Length == 3) { measureParam.HasFillColor = true; measureParam.FillColor = new byte[] { polygonAnnot.BgColor[0], polygonAnnot.BgColor[1], polygonAnnot.BgColor[2] }; @@ -1791,15 +1882,7 @@ internal static PolygonMeasureParam GetPolygonMeasureParam(CPDFPolygonAnnotation measureParam.LineWidth = polygonAnnot.LineWidth; measureParam.Transparency = polygonAnnot.Transparency; measureParam.LineDash = polygonAnnot.Dash; - CTextAttribute textAttr = polygonAnnot.GetTextAttribute(); - measureParam.FontName = textAttr.FontName; - measureParam.FontSize = textAttr.FontSize; - if (textAttr.FontColor != null && textAttr.FontColor.Length == 3) - { - measureParam.FontColor = new byte[] { textAttr.FontColor[0], textAttr.FontColor[1], textAttr.FontColor[2] }; - } - measureParam.IsBold = CFontNameHelper.IsBold(textAttr.FontName); - measureParam.IsItalic = CFontNameHelper.IsItalic(textAttr.FontName); + measureParam.BorderEffector = polygonAnnot.GetAnnotBorderEffector(); GetAnnotCommonParam(polygonAnnot, measureParam); return measureParam; @@ -2894,7 +2977,7 @@ internal static bool SetStampAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation { stampText = string.Empty; } - stampAnnot.SetStandardStamp(stampText, CurrentParam.Rotation); + stampAnnot.SetStandardStamp(stampText, CurrentParam.PageRotation); stampAnnot.SetRect(CurrentParam.ClientRect); } break; @@ -2915,7 +2998,7 @@ internal static bool SetStampAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation dateText, CurrentParam.TextStampShape, CurrentParam.TextStampColor, - CurrentParam.Rotation); + CurrentParam.PageRotation); stampAnnot.SetRect(CurrentParam.ClientRect); } break; @@ -2932,7 +3015,7 @@ internal static bool SetStampAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation imageData, imageWidth, imageHeight, - CurrentParam.Rotation); + CurrentParam.PageRotation); } } break; diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Properties/AssemblyInfo.cs index 0306ad6..b26385b 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Properties/AssemblyInfo.cs @@ -15,5 +15,5 @@ [assembly: Guid("a061ee7a-6704-4bd9-86ee-48ed5df75e2f")] -[assembly: AssemblyVersion("2.1.3.0")] -[assembly: AssemblyFileVersion("2.1.3.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Resource/Cursor/Rotation.cur b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Resource/Cursor/Rotation.cur new file mode 100644 index 0000000..a78e834 Binary files /dev/null and b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/Resource/Cursor/Rotation.cur differ diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam.cs index 310e40a..d7af2f6 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam.cs @@ -4,27 +4,31 @@ namespace ComPDFKit.Tool { - public class AnnotParam + public class AnnotParam { public string Content { get; set; } = string.Empty; public string Author { get; set; } = string.Empty; public string CreateTime { get; set; } = string.Empty; public string UpdateTime { get; set; } = string.Empty; - public C_ANNOTATION_TYPE CurrentType { get; set; } + public C_ANNOTATION_TYPE CurrentType { get; set; } public bool Locked { get; set; } /// /// The rectangle of the annotation within the PDF (PDF DPI) /// public CRect ClientRect { get; set; } - public int PageIndex { get; set; } - public int AnnotIndex { get; set; } - public byte Transparency { get; set; } + public int PageIndex { get; set; } + public int AnnotIndex { get; set; } + public byte Transparency + { + get; + set; + } = 255; public virtual bool CopyTo(AnnotParam transfer) { if (transfer == null) { - return false; + return false; } transfer.Content = Content; @@ -34,7 +38,7 @@ public virtual bool CopyTo(AnnotParam transfer) transfer.CurrentType = CurrentType; transfer.Locked = Locked; transfer.ClientRect = ClientRect; - transfer.CurrentType=CurrentType; + transfer.CurrentType = CurrentType; transfer.PageIndex = PageIndex; transfer.Transparency = Transparency; transfer.AnnotIndex = AnnotIndex; diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/FreeTextParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/FreeTextParam.cs index 5e45ce2..602a908 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/FreeTextParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/FreeTextParam.cs @@ -20,11 +20,11 @@ public FreeTextParam () public bool IsItalic { get; set; } public string FontName { get; set; } = string.Empty; public double FontSize { get; set; } - public C_TEXT_ALIGNMENT Alignment { get; set; } + public C_TEXT_ALIGNMENT Alignment { get; set; } + public float[] Dash { get; set; } public override bool CopyTo(AnnotParam transfer) { - FreeTextParam freetextTransfer = transfer as FreeTextParam; if (freetextTransfer == null) { @@ -51,6 +51,14 @@ public override bool CopyTo(AnnotParam transfer) freetextTransfer.FontColor = (byte[])FontColor.Clone(); } + freetextTransfer.Dash = null; + if (Dash != null) + { + float[] DashCopy = new float[Dash.Length]; + Dash.CopyTo(DashCopy, 0); + freetextTransfer.Dash = DashCopy; + } + freetextTransfer.HasBgColor = HasBgColor; freetextTransfer.LineWidth = LineWidth; freetextTransfer.IsBold = IsBold; diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/HighlightParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/HighlightParam.cs index 8e2eaeb..46a6a76 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/HighlightParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/HighlightParam.cs @@ -6,17 +6,17 @@ namespace ComPDFKit.Tool { - public class HighlightParam:AnnotParam + public class HighlightParam : AnnotParam { - public HighlightParam() + public HighlightParam() { CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT; } - public byte[] HighlightColor { get; set; } + public byte[] HighlightColor { get; set; } = new byte[3] { 255, 0, 0 }; - public List QuardRects { get; set; } + public List QuardRects { get; set; } public override bool CopyTo(AnnotParam transfer) { @@ -31,7 +31,7 @@ public override bool CopyTo(AnnotParam transfer) return false; } - if(HighlightColor!=null ) + if (HighlightColor != null) { highlightTransfer.HighlightColor = (byte[])HighlightColor.Clone(); } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/InkParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/InkParam.cs index 6c8c2e6..e550f62 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/InkParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/InkParam.cs @@ -15,7 +15,7 @@ public InkParam () public byte[] InkColor { get; set; } public double Thickness { get; set; } public List> InkPath { get; set; } - + public float[] Dash { get; set; } public override bool CopyTo(AnnotParam transfer) { InkParam inkTransfer = transfer as InkParam; @@ -51,7 +51,14 @@ public override bool CopyTo(AnnotParam transfer) inkTransfer.InkPath = inkPoints; } - + inkTransfer.Dash = null; + if (Dash != null) + { + float[] DashCopy=new float[Dash.Length]; + Dash.CopyTo(DashCopy,0); + inkTransfer.Dash = DashCopy; + } + return true; } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/LineMeasureParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/LineMeasureParam.cs index 83122f1..787bba7 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/LineMeasureParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/LineMeasureParam.cs @@ -12,24 +12,35 @@ namespace ComPDFKit.Tool { public class LineMeasureParam : AnnotParam { - public LineMeasureParam() + public LineMeasureParam() { CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_LINE; + Transparency = 255; } - public byte[] LineColor { get; set; } - public float LineWidth { get; set; } - public float[] LineDash { get; set; } + public byte[] LineColor { get; set; } = new byte[] { 255, 0, 0 }; + public float LineWidth { get; set; } = 2; + public float[] LineDash { get; set; } = new float[] { }; public CPoint HeadPoint { get; set; } public CPoint TailPoint { get; set; } - public C_LINE_TYPE HeadLineType { get; set; } - public C_LINE_TYPE TailLineType { get; set; } - public string FontName { get; set; } - public double FontSize { get; set; } - public byte[] FontColor { get; set; } - public bool IsBold { get; set; } - public bool IsItalic { get; set; } - public C_BORDER_STYLE BorderStyle { get; set; } + public C_LINE_TYPE HeadLineType { get; set; } = C_LINE_TYPE.LINETYPE_ARROW; + public C_LINE_TYPE TailLineType { get; set; } = C_LINE_TYPE.LINETYPE_ARROW; + public string FontName { get; set; } = "Arial"; + public double FontSize { get; set; } = 14; + public byte[] FontColor { get; set; } = new byte[] { 255, 0, 0 }; + public bool IsBold { get; set; } = false; + public bool IsItalic { get; set; } = false; + public C_BORDER_STYLE BorderStyle { get; set; } = C_BORDER_STYLE.BS_SOLID; public CPDFMeasureInfo measureInfo { get; set; } + = new CPDFMeasureInfo + { + Unit = CPDFMeasure.CPDF_CM, + Precision = CPDFMeasure.PRECISION_VALUE_TWO, + RulerBase = 1, + RulerBaseUnit = CPDFMeasure.CPDF_CM, + RulerTranslate = 1, + RulerTranslateUnit = CPDFMeasure.CPDF_CM, + CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH, + }; public override bool CopyTo(AnnotParam transfer) { @@ -75,7 +86,7 @@ public override bool CopyTo(AnnotParam transfer) RulerBase = measureInfo.RulerBase, RulerBaseUnit = measureInfo.RulerBaseUnit, RulerTranslateUnit = measureInfo.RulerTranslateUnit, - RulerTranslate= measureInfo.RulerTranslate, + RulerTranslate = measureInfo.RulerTranslate, CaptionType = measureInfo.CaptionType, }; polygonTransfer.measureInfo = cPDFMeasureInfo; diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolyLineMeasureParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolyLineMeasureParam.cs index f594429..2c34c47 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolyLineMeasureParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolyLineMeasureParam.cs @@ -15,18 +15,29 @@ public class PolyLineMeasureParam : AnnotParam public PolyLineMeasureParam() { CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE; + Transparency = 255; } - public byte[] LineColor { get; set; } - public float LineWidth { get; set; } + public byte[] LineColor { get; set; } = new byte[] { 255, 0, 0, }; + public float LineWidth { get; set; } = 2; public float[] LineDash { get; set; } public List SavePoints { get; set; } - public string FontName { get; set; } - public double FontSize { get; set; } - public byte[] FontColor { get; set; } + public string FontName { get; set; } = "Arial"; + public double FontSize { get; set; } = 14; + public byte[] FontColor { get; set; } = new byte[] { 255, 0, 0, }; public bool IsBold { get; set; } public bool IsItalic { get; set; } public C_BORDER_STYLE BorderStyle { get; set; } - public CPDFMeasureInfo measureInfo { get; set; } + public CPDFMeasureInfo measureInfo { get; set; } = + new CPDFMeasureInfo + { + Unit = CPDFMeasure.CPDF_CM, + Precision = CPDFMeasure.PRECISION_VALUE_TWO, + RulerBase = 1, + RulerBaseUnit = CPDFMeasure.CPDF_CM, + RulerTranslate = 1, + RulerTranslateUnit = CPDFMeasure.CPDF_CM, + CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH, + }; public override bool CopyTo(AnnotParam transfer) { @@ -78,7 +89,7 @@ public override bool CopyTo(AnnotParam transfer) RulerBaseUnit = measureInfo.RulerBaseUnit, RulerTranslateUnit = measureInfo.RulerTranslateUnit, CaptionType = measureInfo.CaptionType, - RulerTranslate= measureInfo.RulerTranslate, + RulerTranslate = measureInfo.RulerTranslate, }; polygonTransfer.measureInfo = cPDFMeasureInfo; } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolygonMeasureParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolygonMeasureParam.cs index 6fad9b9..d91a086 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolygonMeasureParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolygonMeasureParam.cs @@ -14,27 +14,46 @@ namespace ComPDFKit.Tool { public class PolygonMeasureParam : AnnotParam { - public PolygonMeasureParam() + public PolygonMeasureParam() { CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON; - } - public byte[] FillColor { get; set; } + } + + public byte[] FillColor { get; set; } = new byte[] { 255, 0, 0, }; public bool HasFillColor { get; set; } - public byte[] LineColor { get; set; } + public byte[] LineColor + { + get; + set; + } public float LineWidth { get; set; } public float[] LineDash { get; set; } - public List SavePoints { get; set; } + public List SavePoints { get; set; } public byte[] EndLineColor { get; set; } public double EndLineWidth { get; set; } public double EndTransparency { get; set; } public DashStyle EndLineDash { get; set; } + public CPDFBorderEffector BorderEffector + { + get; + set; + } public string FontName { get; set; } public double FontSize { get; set; } public byte[] FontColor { get; set; } public bool IsBold { get; set; } public bool IsItalic { get; set; } + public bool IsMeasure + { + get; + set; + } = true; public C_BORDER_STYLE BorderStyle { get; set; } - public CPDFMeasureInfo measureInfo { get; set; } + public CPDFMeasureInfo measureInfo + { + get; + set; + } public override bool CopyTo(AnnotParam transfer) { @@ -56,7 +75,9 @@ public override bool CopyTo(AnnotParam transfer) if (SavePoints != null) { - polygonTransfer.SavePoints.CopyTo(SavePoints.ToArray()); + CPoint[] pointArray = new CPoint[SavePoints.Count]; + SavePoints.CopyTo(pointArray); + polygonTransfer.SavePoints = pointArray.ToList(); } if (LineColor != null) @@ -66,7 +87,7 @@ public override bool CopyTo(AnnotParam transfer) if (LineDash != null) { - polygonTransfer.LineDash = (float[])LineDash.Clone(); + polygonTransfer.LineDash = (float[])LineDash.Clone(); } if (EndLineColor != null) @@ -84,24 +105,26 @@ public override bool CopyTo(AnnotParam transfer) polygonTransfer.FontColor = (byte[])FontColor.Clone(); } - if (measureInfo != null) + polygonTransfer.BorderEffector = BorderEffector; + + if (measureInfo != null && IsMeasure) { - CPDFMeasureInfo cPDFMeasureInfo =new CPDFMeasureInfo() + CPDFMeasureInfo cPDFMeasureInfo = new CPDFMeasureInfo() { - Factor=measureInfo.Factor, - Unit=measureInfo.Unit, - DecimalSymbol=measureInfo.DecimalSymbol, - ThousandSymbol=measureInfo.ThousandSymbol, - Display=measureInfo.Display, - Precision=measureInfo.Precision, - UnitPrefix=measureInfo.UnitPrefix, - UnitSuffix=measureInfo.UnitSuffix, - UnitPosition=measureInfo.UnitPosition, - RulerBase=measureInfo.RulerBase, - RulerBaseUnit=measureInfo.RulerBaseUnit, - RulerTranslateUnit=measureInfo.RulerTranslateUnit, - CaptionType=measureInfo.CaptionType, - RulerTranslate=measureInfo.RulerTranslate, + Factor = measureInfo.Factor, + Unit = measureInfo.Unit, + DecimalSymbol = measureInfo.DecimalSymbol, + ThousandSymbol = measureInfo.ThousandSymbol, + Display = measureInfo.Display, + Precision = measureInfo.Precision, + UnitPrefix = measureInfo.UnitPrefix, + UnitSuffix = measureInfo.UnitSuffix, + UnitPosition = measureInfo.UnitPosition, + RulerBase = measureInfo.RulerBase, + RulerBaseUnit = measureInfo.RulerBaseUnit, + RulerTranslateUnit = measureInfo.RulerTranslateUnit, + CaptionType = measureInfo.CaptionType, + RulerTranslate = measureInfo.RulerTranslate, }; polygonTransfer.measureInfo = cPDFMeasureInfo; } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/SquigglyParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/SquigglyParam.cs index 6ae2425..342177c 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/SquigglyParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/SquigglyParam.cs @@ -1,8 +1,6 @@ using ComPDFKit.Import; using ComPDFKit.PDFAnnotation; using System.Collections.Generic; -using System.Windows; -using System.Windows.Media; namespace ComPDFKit.Tool { @@ -12,7 +10,7 @@ public SquigglyParam () { CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY; } - public byte[] SquigglyColor { get; set; } + public byte[] SquigglyColor { get; set; } = new byte[3] { 255, 0, 0 }; public List QuardRects { get; set; } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StampParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StampParam.cs index 2d3abf9..0a4e1c9 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StampParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StampParam.cs @@ -1,24 +1,26 @@ -using ComPDFKit.PDFAnnotation; +using ComPDFKit.Import; +using ComPDFKit.PDFAnnotation; using System.IO; namespace ComPDFKit.Tool { public class StampParam:AnnotParam { - public StampParam () + public StampParam() { CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_STAMP; } - public string StampText { get; set; } = string.Empty; public string DateText { get; set; }= string.Empty; public C_STAMP_TYPE StampType { get; set; } public C_TEXTSTAMP_SHAPE TextStampShape { get; set; } public C_TEXTSTAMP_COLOR TextStampColor { get; set; } public MemoryStream ImageStream { get; set; } + public int PageRotation { get; set; } public int Rotation { get; set; } - + public CRect SourceRect { get; set; } + public CPDFAnnotation CopyImageAnnot { get; set; } public override bool CopyTo(AnnotParam transfer) { @@ -39,9 +41,11 @@ public override bool CopyTo(AnnotParam transfer) stampTransfer.TextStampColor = TextStampColor; stampTransfer.TextStampShape = TextStampShape; stampTransfer.ImageStream = ImageStream; - stampTransfer.Rotation = Rotation; - - return true; + stampTransfer.PageRotation = PageRotation; + stampTransfer.Rotation = Rotation; + stampTransfer.SourceRect = SourceRect; + stampTransfer.CopyImageAnnot = CopyImageAnnot; + return true; } - } + } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StickyNoteParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StickyNoteParam.cs index abe5267..9e93e59 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StickyNoteParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StickyNoteParam.cs @@ -11,6 +11,7 @@ public StickyNoteParam () } public byte[] StickyNoteColor { get; set; } + public string IconName { get; set; } = string.Empty; public override bool CopyTo(AnnotParam transfer) { @@ -30,6 +31,8 @@ public override bool CopyTo(AnnotParam transfer) stickynoteTransfer.StickyNoteColor = (byte[])StickyNoteColor.Clone(); } + stickynoteTransfer.IconName = IconName; + return true; } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StrikeoutParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StrikeoutParam.cs index acf5c1c..c99e0f0 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StrikeoutParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/StrikeoutParam.cs @@ -12,7 +12,7 @@ public StrikeoutParam () { CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT; } - public byte[] StrikeoutColor { get; set; } + public byte[] StrikeoutColor { get; set; } = new byte[3] { 255, 0, 0 }; public List QuardRects { get; set; } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/UnderlineParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/UnderlineParam.cs index e3f7a3c..35245e9 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/UnderlineParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/UnderlineParam.cs @@ -6,46 +6,46 @@ namespace ComPDFKit.Tool { - public class UnderlineParam:AnnotParam - { - public UnderlineParam () + public class UnderlineParam : AnnotParam + { + public UnderlineParam() { CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE; } - public byte[] UnderlineColor { get; set; } + public byte[] UnderlineColor { get; set; } = new byte[3] { 255, 0, 0 }; - public List QuardRects { get; set; } + public List QuardRects { get; set; } - public override bool CopyTo(AnnotParam transfer) - { - UnderlineParam underlineTransfer = transfer as UnderlineParam; - if (underlineTransfer == null) - { - return false; - } + public override bool CopyTo(AnnotParam transfer) + { + UnderlineParam underlineTransfer = transfer as UnderlineParam; + if (underlineTransfer == null) + { + return false; + } - if (!base.CopyTo(underlineTransfer)) - { - return false; - } + if (!base.CopyTo(underlineTransfer)) + { + return false; + } - if(UnderlineColor != null) - { + if (UnderlineColor != null) + { underlineTransfer.UnderlineColor = (byte[])UnderlineColor.Clone(); } - if (QuardRects != null) - { - List rectList = new List(); - foreach (CRect saveRect in QuardRects) - { - rectList.Add(saveRect); - } + if (QuardRects != null) + { + List rectList = new List(); + foreach (CRect saveRect in QuardRects) + { + rectList.Add(saveRect); + } - underlineTransfer.QuardRects = rectList; - } + underlineTransfer.QuardRects = rectList; + } - return true; - } - } + return true; + } + } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/DefaultSettingParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/DefaultSettingParam.cs index acc7cbd..13bb032 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/DefaultSettingParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/DefaultSettingParam.cs @@ -21,7 +21,7 @@ public class DefaultSettingParam #region Measure - public bool IsOpenMeasure = false; + public bool IsOpenMeasure { get; set; } = false; public bool IsCreateSquarePolygonMeasure = false; @@ -722,8 +722,7 @@ public DefaultSettingParam() InitFreeText(); InitCircle(); InitStickyNote(); - InitSound(); - + InitSound(); #endregion #region Widget @@ -746,6 +745,8 @@ public DefaultSettingParam() #endregion } + + public bool SetAnnotParam(AnnotParam annotParam) { bool IsOK = false; @@ -811,14 +812,14 @@ public bool SetAnnotParam(AnnotParam annotParam) { PolygonMeasureParamDef = annotParam as PolygonMeasureParam; IsOK = true; - } + } break; case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE: if (annotParam is PolyLineMeasureParam) { PolyLineMeasureParamDef = annotParam as PolyLineMeasureParam; IsOK = true; - } + } break; case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT: if (annotParam is HighlightParam) @@ -874,8 +875,7 @@ public bool SetAnnotParam(AnnotParam annotParam) SoundParamDef = annotParam as SoundParam; IsOK = true; } - break; - break; + break; case C_ANNOTATION_TYPE.C_ANNOTATION_MOVIE: break; case C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET: diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/ImageEditParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/ImageEditParam.cs index dab88e5..5aaddaf 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/ImageEditParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/ImageEditParam.cs @@ -15,20 +15,11 @@ public ImageEditParam() public override bool CopyTo(PDFEditParam transfer) { ImageEditParam imageTransfer = transfer as ImageEditParam; - if (imageTransfer == null) - { + if (imageTransfer == null || !base.CopyTo(imageTransfer)) return false; - } - if (!base.CopyTo(imageTransfer)) - { - return false; - } - - imageTransfer.ClipRect = ClipRect; imageTransfer.Rotate = Rotate; - return true; } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/PDFEditParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/PDFEditParam.cs index 6f9b2b8..5e31a2a 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/PDFEditParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/PDFEditParam.cs @@ -13,15 +13,13 @@ public class PDFEditParam public virtual bool CopyTo(PDFEditParam transfer) { if (transfer == null) - { return false; - } + transfer.PageIndex = PageIndex; transfer.EditIndex = EditIndex; transfer.EditType = EditType; transfer.Transparency = Transparency; transfer.ClientRect = ClientRect; - return true; } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/PathEditParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/PathEditParam.cs new file mode 100644 index 0000000..2ddb00d --- /dev/null +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/PathEditParam.cs @@ -0,0 +1,31 @@ +using ComPDFKit.Import; +using ComPDFKit.PDFPage; + +namespace ComPDFKit.Tool +{ + public class PathEditParam:PDFEditParam + { + public PathEditParam() + { + EditType = CPDFEditType.EditPath; + } + + public byte[] StrokeColor { get; set; } + public byte[] FillColor { get; set; } + public CRect ClipRect { get; set; } + public int Rotate { get; set; } + + public override bool CopyTo(PDFEditParam transfer) + { + PathEditParam pathTransfer = transfer as PathEditParam; + if (pathTransfer == null || !base.CopyTo(pathTransfer)) + return false; + + pathTransfer.StrokeColor = StrokeColor; + pathTransfer.FillColor = FillColor; + pathTransfer.ClipRect = ClipRect; + pathTransfer.Rotate = Rotate; + return true; + } + } +} diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/TextEditParam.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/TextEditParam.cs index 8acaeed..9849abc 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/TextEditParam.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/SettingParam/PDFEditParam/TextEditParam.cs @@ -19,26 +19,17 @@ public TextEditParam() public override bool CopyTo(PDFEditParam transfer) { TextEditParam texteditTransfer = transfer as TextEditParam; - if (texteditTransfer == null) - { + if (texteditTransfer == null || !base.CopyTo(texteditTransfer)) return false; - } - - if (!base.CopyTo(texteditTransfer)) - { - return false; - } texteditTransfer.FontSize = FontSize; if (FontColor != null) - { texteditTransfer.FontColor = (byte[])FontColor.Clone(); - } + texteditTransfer.TextAlign = TextAlign; texteditTransfer.FontName = FontName; texteditTransfer.IsItalic = IsItalic; texteditTransfer.IsBold = IsBold; - return true; } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/FreeTextAnnotHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/FreeTextAnnotHistory.cs index 4890532..05699b7 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/FreeTextAnnotHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/FreeTextAnnotHistory.cs @@ -1,6 +1,7 @@ using ComPDFKit.PDFAnnotation; using ComPDFKit.PDFPage; using ComPDFKit.Tool.Help; +using ComPDFKitViewer.Annot; using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper; namespace ComPDFKit.Tool.UndoManger @@ -80,10 +81,7 @@ internal override bool Add() } textAttr.FontColor = fontColor; textAttr.FontSize = (float)currentParam.FontSize; - textAttr.FontName = ObtainFontName( - GetFontType(currentParam.FontName), - currentParam.IsBold, - currentParam.IsItalic); + textAttr.FontName = currentParam.FontName; textAnnot.SetFreetextDa(textAttr); @@ -98,6 +96,12 @@ internal override bool Add() { textAnnot.SetContent(currentParam.Content); } + + if (currentParam.Dash != null && currentParam.Dash.Length > 0) + { + textAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, currentParam.Dash); + } + textAnnot.SetIsLocked(currentParam.Locked); textAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime()); textAnnot.UpdateAp(); @@ -176,10 +180,7 @@ internal override bool Update(bool isUndo) if(updateParam.FontName != checkParam.FontName) { CTextAttribute textAttr = textAnnot.FreeTextDa; - bool isBold = IsBold(textAttr.FontName); - bool isItalic = IsItalic(textAttr.FontName); - FontType fontType = GetFontType(updateParam.FontName); - textAttr.FontName = ObtainFontName(fontType, isBold, isItalic); + textAttr.FontName = updateParam.FontName; textAnnot.SetFreetextDa(textAttr); } @@ -199,24 +200,6 @@ internal override bool Update(bool isUndo) textAnnot.SetFreetextDa(textAttr); } } - - if(updateParam.IsBold != checkParam.IsBold) - { - CTextAttribute textAttr = textAnnot.FreeTextDa; - bool isItalic = IsItalic(textAttr.FontName); - FontType fontType = GetFontType(textAttr.FontName); - textAttr.FontName = ObtainFontName(fontType, updateParam.IsBold, isItalic); - textAnnot.SetFreetextDa(textAttr); - } - - if(updateParam.IsItalic != checkParam.IsItalic) - { - CTextAttribute textAttr = textAnnot.FreeTextDa; - bool isBold = IsBold(textAttr.FontName); - FontType fontType = GetFontType(textAttr.FontName); - textAttr.FontName = ObtainFontName(fontType, isBold, updateParam.IsItalic); - textAnnot.SetFreetextDa(textAttr); - } if (!updateParam.ClientRect.Equals(checkParam.ClientRect)) { @@ -238,6 +221,15 @@ internal override bool Update(bool isUndo) textAnnot.SetIsLocked(updateParam.Locked); } + if (updateParam.Dash != null && updateParam.Dash.Length > 0) + { + textAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, updateParam.Dash); + } + else + { + textAnnot.SetBorderStyle(C_BORDER_STYLE.BS_SOLID, new float[0]); + } + textAnnot.SetModifyDate(PDFHelp.GetCurrentPdfTime()); textAnnot.UpdateAp(); diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/HighlightAnnotHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/HighlightAnnotHistory.cs index b0ade13..abb581a 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/HighlightAnnotHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/HighlightAnnotHistory.cs @@ -39,7 +39,6 @@ public override void SetAnnotIndex(int newIndex) } } - internal override bool Add() { HighlightParam currentParam = CurrentParam as HighlightParam; diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/InkAnnotHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/InkAnnotHistory.cs index fed7711..255372f 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/InkAnnotHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/InkAnnotHistory.cs @@ -69,6 +69,12 @@ internal override bool Add() { inkAnnot.SetContent(currentParam.Content); } + + if (currentParam.Dash != null && currentParam.Dash.Length > 0) + { + inkAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED,currentParam.Dash); + } + inkAnnot.SetIsLocked(currentParam.Locked); inkAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime()); inkAnnot.UpdateAp(); @@ -124,6 +130,15 @@ internal override bool Update(bool isUndo) inkAnnot.SetInkPath(updateParam.InkPath); } + if (updateParam.Dash!=null && updateParam.Dash.Length>0) + { + inkAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED,updateParam.Dash); + } + else + { + inkAnnot.SetBorderStyle(C_BORDER_STYLE.BS_SOLID,new float[0]); + } + if (updateParam.Transparency != checkParam.Transparency) { inkAnnot.SetTransparency((byte)updateParam.Transparency); diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolyLineMeasureAnnotHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolyLineMeasureAnnotHistory.cs index 254bda5..c34f1e1 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolyLineMeasureAnnotHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolyLineMeasureAnnotHistory.cs @@ -11,7 +11,7 @@ namespace ComPDFKit.Tool.UndoManger { - internal class PolyLineMeasureAnnotHistory : AnnotHistory + public class PolyLineMeasureAnnotHistory : AnnotHistory { public override int GetAnnotIndex() { diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolygonAnnotHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolygonAnnotHistory.cs new file mode 100644 index 0000000..bf3dcad --- /dev/null +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolygonAnnotHistory.cs @@ -0,0 +1,242 @@ +using ComPDFKit.PDFAnnotation; +using ComPDFKit.PDFPage; +using ComPDFKit.Tool.Help; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComPDFKit.Tool.UndoManger +{ + public class PolygonAnnotHistory : AnnotHistory + { + public override int GetAnnotIndex() + { + if (CurrentParam != null) + { + return CurrentParam.AnnotIndex; + } + return base.GetAnnotIndex(); + } + + public override int GetPageIndex() + { + if (CurrentParam != null) + { + return CurrentParam.PageIndex; + } + return base.GetPageIndex(); + } + + public override void SetAnnotIndex(int newIndex) + { + if (CurrentParam != null) + { + CurrentParam.AnnotIndex = newIndex; + } + + if (PreviousParam != null) + { + PreviousParam.AnnotIndex = newIndex; + } + } + + internal override bool Add() + { + PolygonMeasureParam currentParam = CurrentParam as PolygonMeasureParam; + if (CurrentParam == null || PDFDoc == null || !PDFDoc.IsValid()) + { + return false; + } + + CPDFPage pdfPage = PDFDoc.PageAtIndex(currentParam.PageIndex); + CPDFPolygonAnnotation polygonAnnot = pdfPage?.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON) as CPDFPolygonAnnotation; + + if (polygonAnnot != null) + { + int annotIndex = pdfPage.GetAnnotCount() - 1; + + if (currentParam.HasFillColor) + { + if (currentParam.FillColor != null && currentParam.FillColor.Length == 3) + { + polygonAnnot.SetBgColor(currentParam.FillColor); + } + } + if (currentParam.LineColor != null && currentParam.LineColor.Length == 3) + { + polygonAnnot.SetLineColor(currentParam.LineColor); + } + + polygonAnnot.SetTransparency((byte)currentParam.Transparency); + polygonAnnot.SetLineWidth(currentParam.LineWidth); + + polygonAnnot.SetPoints(currentParam.SavePoints); + polygonAnnot.SetRect(currentParam.ClientRect); + + if (currentParam.LineDash != null) + { + if (currentParam.LineDash.Length == 0) + { + polygonAnnot.SetBorderStyle(C_BORDER_STYLE.BS_SOLID, new float[0]); + } + else + { + List floatArray = new List(); + foreach (float num in currentParam.LineDash) + { + floatArray.Add(num); + } + polygonAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, floatArray.ToArray()); + } + } + + if (!string.IsNullOrEmpty(currentParam.Author)) + { + polygonAnnot.SetAuthor(currentParam.Author); + } + + if (!string.IsNullOrEmpty(currentParam.Content)) + { + polygonAnnot.SetContent(currentParam.Content); + } + + polygonAnnot.SetIsLocked(currentParam.Locked); + polygonAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime()); + polygonAnnot.UpdateAp(); + polygonAnnot.ReleaseAnnot(); + + if (currentParam != null) + { + currentParam.AnnotIndex = annotIndex; + } + + if (PreviousParam != null) + { + PreviousParam.AnnotIndex = annotIndex; + } + return true; + } + return true; + } + + internal override bool Update(bool isUndo) + { + if (CurrentParam as PolygonMeasureParam == null || PreviousParam as PolygonMeasureParam == null) + { + return false; + } + + if (MakeAnnotValid(CurrentParam)) + { + CPDFPolygonAnnotation polygonAnnot = Annot as CPDFPolygonAnnotation; + if (polygonAnnot == null || !polygonAnnot.IsValid() || !polygonAnnot.IsMeasured()) + { + return false; + } + + + PolygonMeasureParam updateParam = (isUndo ? PreviousParam : CurrentParam) as PolygonMeasureParam; + PolygonMeasureParam checkParam = (isUndo ? CurrentParam : PreviousParam) as PolygonMeasureParam; + + if (!CheckArrayEqual(updateParam.LineColor, checkParam.LineColor)) + { + if (updateParam.LineColor != null && updateParam.LineColor.Length == 3) + { + polygonAnnot.SetLineColor(updateParam.LineColor); + } + } + + if (!CheckArrayEqual(updateParam.FillColor, checkParam.FillColor)) + { + if (updateParam.HasFillColor) + { + if (updateParam.FillColor != null && updateParam.FillColor.Length == 3) + { + polygonAnnot.SetBgColor(updateParam.FillColor); + } + } + else + { + polygonAnnot.ClearBgColor(); + } + + if (updateParam.Transparency != checkParam.Transparency) + { + polygonAnnot.SetTransparency((byte)updateParam.Transparency); + } + + if (updateParam.LineWidth != checkParam.LineWidth) + { + polygonAnnot.SetLineWidth((byte)updateParam.LineWidth); + } + + if (!CheckArrayEqual(updateParam.LineDash, checkParam.LineDash)) + { + if (updateParam.LineDash != null) + { + if (updateParam.LineDash.Length == 0) + { + polygonAnnot.SetBorderStyle(C_BORDER_STYLE.BS_SOLID, new float[0]); + } + else + { + List floatArray = new List(); + foreach (float num in updateParam.LineDash) + { + floatArray.Add(num); + } + polygonAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, floatArray.ToArray()); + } + } + } + + + if (!updateParam.SavePoints.SequenceEqual(checkParam.SavePoints)) + { + polygonAnnot.SetPoints(updateParam.SavePoints); + } + + if (!updateParam.ClientRect.Equals(checkParam.ClientRect)) + { + polygonAnnot.SetRect(updateParam.ClientRect); + } + + + if (updateParam.Author != checkParam.Author) + { + polygonAnnot.SetAuthor(updateParam.Author); + } + + if (updateParam.Content != checkParam.Content) + { + polygonAnnot.SetContent(updateParam.Content); + } + + + if (updateParam.Locked != checkParam.Locked) + { + polygonAnnot.SetIsLocked(updateParam.Locked); + } + } + polygonAnnot.SetModifyDate(PDFHelp.GetCurrentPdfTime()); + + polygonAnnot.UpdateAp(); + + return true; + } + return false; + } + + internal override bool Remove() + { + if (MakeAnnotValid(CurrentParam)) + { + Annot.RemoveAnnot(); + return true; + } + return false; + } + } +} \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolygonMeasureAnnotHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolygonMeasureAnnotHistory.cs index cdb7aa7..d5b0a50 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolygonMeasureAnnotHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/PolygonMeasureAnnotHistory.cs @@ -2,17 +2,13 @@ using ComPDFKit.PDFAnnotation; using ComPDFKit.PDFPage; using ComPDFKit.Tool.Help; -using ComPDFKitViewer.Annot; -using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using static ComPDFKit.PDFAnnotation.CTextAttribute; namespace ComPDFKit.Tool.UndoManger { - internal class PolygonMeasureAnnotHistory : AnnotHistory + public class PolygonMeasureAnnotHistory : AnnotHistory { public override int GetAnnotIndex() { @@ -31,6 +27,7 @@ public override int GetPageIndex() } return base.GetPageIndex(); } + public override void SetAnnotIndex(int newIndex) { if (CurrentParam != null) @@ -43,6 +40,7 @@ public override void SetAnnotIndex(int newIndex) PreviousParam.AnnotIndex = newIndex; } } + internal override bool Add() { PolygonMeasureParam currentParam = CurrentParam as PolygonMeasureParam; @@ -56,7 +54,6 @@ internal override bool Add() if (polygonAnnot != null) { int annotIndex = pdfPage.GetAnnotCount() - 1; - if (currentParam.HasFillColor) { if (currentParam.FillColor != null && currentParam.FillColor.Length == 3) @@ -70,12 +67,11 @@ internal override bool Add() polygonAnnot.SetLineColor(currentParam.LineColor); } - polygonAnnot.SetTransparency((byte)currentParam.Transparency); + polygonAnnot.SetTransparency(currentParam.Transparency); polygonAnnot.SetLineWidth(currentParam.LineWidth); - polygonAnnot.SetPoints(currentParam.SavePoints); + polygonAnnot.SetAnnotBorderEffector(currentParam.BorderEffector); polygonAnnot.SetRect(currentParam.ClientRect); - if (currentParam.LineDash != null) { if (currentParam.LineDash.Length == 0) @@ -89,28 +85,33 @@ internal override bool Add() { floatArray.Add(num); } + polygonAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, floatArray.ToArray()); } } - CTextAttribute textAttribute = new CTextAttribute(); - textAttribute.FontColor = currentParam.FontColor; - textAttribute.FontSize = (float)currentParam.FontSize; - textAttribute.FontName = CFontNameHelper.ObtainFontName(CFontNameHelper.GetFontType(currentParam.FontName), - currentParam.IsBold, - currentParam.IsItalic); - polygonAnnot.SetTextAttribute(textAttribute); - if (currentParam.measureInfo != null) + if(polygonAnnot.IsMeasured()) { - CPDFAreaMeasure polygonMeasure = polygonAnnot.GetAreaMeasure(); - if (polygonMeasure != null) + CTextAttribute textAttribute = new CTextAttribute(); + textAttribute.FontColor = currentParam.FontColor; + textAttribute.FontSize = (float)currentParam.FontSize; + textAttribute.FontName = CFontNameHelper.ObtainFontName(CFontNameHelper.GetFontType(currentParam.FontName), + currentParam.IsBold, + currentParam.IsItalic); + polygonAnnot.SetTextAttribute(textAttribute); + if (currentParam.measureInfo != null) { - polygonMeasure.SetMeasureInfo(currentParam.measureInfo); - polygonMeasure.SetMeasureScale(currentParam.measureInfo.RulerBase, currentParam.measureInfo.RulerBaseUnit, - currentParam.measureInfo.RulerTranslate, currentParam.measureInfo.RulerTranslateUnit); - polygonMeasure.UpdateAnnotMeasure(); + CPDFAreaMeasure polygonMeasure = polygonAnnot.GetAreaMeasure(); + if (polygonMeasure != null) + { + polygonMeasure.SetMeasureInfo(currentParam.measureInfo); + polygonMeasure.SetMeasureScale(currentParam.measureInfo.RulerBase, currentParam.measureInfo.RulerBaseUnit, + currentParam.measureInfo.RulerTranslate, currentParam.measureInfo.RulerTranslateUnit); + polygonMeasure.UpdateAnnotMeasure(); + } } } + if (!string.IsNullOrEmpty(currentParam.Author)) { polygonAnnot.SetAuthor(currentParam.Author); @@ -120,6 +121,7 @@ internal override bool Add() { polygonAnnot.SetContent(currentParam.Content); } + polygonAnnot.SetIsLocked(currentParam.Locked); polygonAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime()); polygonAnnot.UpdateAp(); @@ -129,6 +131,7 @@ internal override bool Add() { currentParam.AnnotIndex = annotIndex; } + if (PreviousParam != null) { PreviousParam.AnnotIndex = annotIndex; @@ -137,6 +140,7 @@ internal override bool Add() } return false; } + internal override bool Update(bool isUndo) { if (CurrentParam as PolygonMeasureParam == null || PreviousParam as PolygonMeasureParam == null) @@ -146,7 +150,7 @@ internal override bool Update(bool isUndo) if (MakeAnnotValid(CurrentParam)) { CPDFPolygonAnnotation polygonAnnot = Annot as CPDFPolygonAnnotation; - if (polygonAnnot == null || !polygonAnnot.IsValid() || !polygonAnnot.IsMeasured()) + if (polygonAnnot == null || !polygonAnnot.IsValid()) { return false; } @@ -208,12 +212,16 @@ internal override bool Update(bool isUndo) polygonAnnot.SetPoints(updateParam.SavePoints); } + if(!updateParam.BorderEffector.Equals(checkParam.BorderEffector)) + { + polygonAnnot.SetAnnotBorderEffector(updateParam.BorderEffector); + } + if (!updateParam.ClientRect.Equals(checkParam.ClientRect)) { polygonAnnot.SetRect(updateParam.ClientRect); } - if (updateParam.Author != checkParam.Author) { polygonAnnot.SetAuthor(updateParam.Author); @@ -228,19 +236,23 @@ internal override bool Update(bool isUndo) { polygonAnnot.SetIsLocked(updateParam.Locked); } - if (updateParam.measureInfo != checkParam.measureInfo) + + if (polygonAnnot.IsMeasured()) { - CPDFAreaMeasure polygonMeasure = polygonAnnot.GetAreaMeasure(); - if (polygonMeasure != null) + if (updateParam.measureInfo != checkParam.measureInfo) { - polygonMeasure.SetMeasureInfo(updateParam.measureInfo); - polygonMeasure.SetMeasureScale(updateParam.measureInfo.RulerBase, updateParam.measureInfo.RulerBaseUnit, - updateParam.measureInfo.RulerTranslate, updateParam.measureInfo.RulerTranslateUnit); - polygonMeasure.UpdateAnnotMeasure(); + CPDFAreaMeasure polygonMeasure = polygonAnnot.GetAreaMeasure(); + if (polygonMeasure != null) + { + polygonMeasure.SetMeasureInfo(updateParam.measureInfo); + polygonMeasure.SetMeasureScale(updateParam.measureInfo.RulerBase, updateParam.measureInfo.RulerBaseUnit, + updateParam.measureInfo.RulerTranslate, updateParam.measureInfo.RulerTranslateUnit); + polygonMeasure.UpdateAnnotMeasure(); + } } } - polygonAnnot.SetModifyDate(PDFHelp.GetCurrentPdfTime()); + polygonAnnot.SetModifyDate(PDFHelp.GetCurrentPdfTime()); polygonAnnot.UpdateAp(); return true; diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/SquigglyAnnotHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/SquigglyAnnotHistory.cs index 3a6db17..f4e7b12 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/SquigglyAnnotHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/SquigglyAnnotHistory.cs @@ -40,12 +40,11 @@ public override void SetAnnotIndex(int newIndex) internal override bool Add() { SquigglyParam currentParam = CurrentParam as SquigglyParam; - - if (currentParam == null || PDFDoc == null || !PDFDoc.IsValid()) { return false; } + CPDFPage pdfPage = PDFDoc.PageAtIndex(currentParam.PageIndex); CPDFSquigglyAnnotation squigglyAnnot = pdfPage?.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY) as CPDFSquigglyAnnotation; if (squigglyAnnot != null) diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/StampAnnotHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/StampAnnotHistory.cs index eee9fac..53ac95a 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/StampAnnotHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/StampAnnotHistory.cs @@ -1,7 +1,10 @@ -using ComPDFKit.PDFAnnotation; +using ComPDFKit.Import; +using ComPDFKit.PDFAnnotation; using ComPDFKit.PDFPage; using ComPDFKit.Tool.Help; +using System; using System.IO; +using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; @@ -43,7 +46,6 @@ public override void SetAnnotIndex(int newIndex) internal override bool Add() { StampParam currentParam = CurrentParam as StampParam; - if (currentParam == null || PDFDoc == null || !PDFDoc.IsValid()) { return false; @@ -59,13 +61,24 @@ internal override bool Add() return false; } - CPDFPage pdfPage = PDFDoc.PageAtIndex(currentParam.PageIndex); - CPDFStampAnnotation stampAnnot = pdfPage?.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP) as CPDFStampAnnotation; - + CPDFPage pdfPage = PDFDoc.PageAtIndex(currentParam.PageIndex); + if (pdfPage == null) + return false; + + CPDFStampAnnotation stampAnnot; + if (currentParam.StampType == C_STAMP_TYPE.IMAGE_STAMP && currentParam.CopyImageAnnot != null) + { + stampAnnot = CPDFAnnotation.AddCopyAnnotToPage(PDFDoc, pdfPage, currentParam.CopyImageAnnot) as CPDFStampAnnotation; + } + else + { + stampAnnot = pdfPage.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP) as CPDFStampAnnotation; + } + if (stampAnnot != null) { int annotIndex = pdfPage.GetAnnotCount() - 1; - switch(currentParam.StampType) + switch (currentParam.StampType) { case C_STAMP_TYPE.STANDARD_STAMP: { @@ -74,10 +87,11 @@ internal override bool Add() { stampText = string.Empty; } + stampAnnot.SetStandardStamp(stampText, pdfPage.Rotation); - stampAnnot.SetRect(currentParam.ClientRect); } break; + case C_STAMP_TYPE.TEXT_STAMP: { string dateText = currentParam.DateText; @@ -86,45 +100,62 @@ internal override bool Add() { dateText = string.Empty; } + if (stampText == null) { stampText = string.Empty; } + stampAnnot.SetTextStamp( stampText, dateText, currentParam.TextStampShape, currentParam.TextStampColor, pdfPage.Rotation); - stampAnnot.SetRect(currentParam.ClientRect); } break; + case C_STAMP_TYPE.IMAGE_STAMP: - { - byte[] imageData = null; - int imageWidth = 0; - int imageHeight = 0; - PDFHelp.ImageStreamToByte(currentParam.ImageStream, ref imageData, ref imageWidth, ref imageHeight); - if (imageData != null && imageWidth > 0 && imageHeight > 0) - { - stampAnnot.SetRect(currentParam.ClientRect); - stampAnnot.SetImageStamp( - imageData, - imageWidth, - imageHeight, - pdfPage.Rotation); + { + if(currentParam.CopyImageAnnot == null) + { + byte[] imageData = null; + int imageWidth = 0; + int imageHeight = 0; + PDFHelp.ImageStreamToByte(currentParam.ImageStream, ref imageData, ref imageWidth, ref imageHeight); + if (imageData != null && imageWidth > 0 && imageHeight > 0) + { + stampAnnot.SetSourceRect(currentParam.SourceRect); + stampAnnot.AnnotationRotator.SetRotation(currentParam.Rotation); + stampAnnot.SetImageStamp( + imageData, + imageWidth, + imageHeight, + pdfPage.Rotation); + } } - } - break; + } + break; default: break; } - stampAnnot.SetTransparency((byte)currentParam.Transparency); - + if (currentParam.StampType != C_STAMP_TYPE.IMAGE_STAMP || currentParam.CopyImageAnnot != null) + { + stampAnnot.SetSourceRect(currentParam.SourceRect); + stampAnnot.AnnotationRotator.SetRotation(currentParam.Rotation); + } + + stampAnnot.SetTransparency(currentParam.Transparency); + string imagePath = string.Empty; + if (currentParam.Transparency <255 && GetAnnotOpacityImage(stampAnnot, currentParam.Transparency / 255.0, 5, out imagePath) && File.Exists(imagePath)) + { + stampAnnot.SetImageStamp(imagePath, string.Empty); + File.Delete(imagePath); + } - if (!string.IsNullOrEmpty(currentParam.Author)) + if (!string.IsNullOrEmpty(currentParam.Author)) { stampAnnot.SetAuthor(currentParam.Author); } @@ -170,18 +201,29 @@ internal override bool Update(bool isUndo) StampParam updateParam = (isUndo ? PreviousParam : CurrentParam) as StampParam; StampParam checkParam = (isUndo ? CurrentParam : PreviousParam) as StampParam; - - if (updateParam.Transparency != checkParam.Transparency) + if (updateParam.Transparency != checkParam.Transparency) { - stampAnnot.SetTransparency((byte)updateParam.Transparency); - } + stampAnnot.SetTransparency(updateParam.Transparency); + string imagePath = string.Empty; + if (GetAnnotOpacityImage(stampAnnot, updateParam.Transparency/255.0, 5, out imagePath) && File.Exists(imagePath)) + { + stampAnnot.SetImageStamp(imagePath, string.Empty); + File.Delete(imagePath); + } + } + + if (!updateParam.SourceRect.Equals(checkParam.SourceRect)) + { + stampAnnot.SetSourceRect(updateParam.SourceRect); + stampAnnot.AnnotationRotator.SetRotation(updateParam.Rotation); + } - if (!updateParam.ClientRect.Equals(checkParam.ClientRect)) + if (updateParam.Rotation != checkParam.Rotation) { - stampAnnot.SetRect(updateParam.ClientRect); + stampAnnot.AnnotationRotator.SetRotation(updateParam.Rotation); } - if (updateParam.Author != checkParam.Author) + if (updateParam.Author != checkParam.Author) { stampAnnot.SetAuthor(updateParam.Author); } @@ -213,5 +255,64 @@ internal override bool Remove() } return false; } - } + + private bool GetAnnotOpacityImage(CPDFStampAnnotation annot, double opacity, double zoom, out string imagePath) + { + imagePath = string.Empty; + if (annot == null || annot.IsValid() == false) + { + return false; + } + + try + { + CRect rawRect = annot.GetRect(); + Rect drawRect = new Rect(0, 0, (int)(rawRect.width() * 96.0 / 72.0 * zoom), (int)(rawRect.height() * 96.0 / 72.0 * zoom)); + + byte[] imageData = new byte[(int)drawRect.Width * (int)drawRect.Height * 4]; + annot.RenderAnnot((int)drawRect.Width, (int)drawRect.Height, imageData); + + int stride = ((int)drawRect.Width) * 4; + for (int i = 0; i < (int)(drawRect.Height); i++) + { + for (int j = 0; j < (int)(drawRect.Width); j++) + { + byte b = imageData[i * stride + j * 4]; + byte g = imageData[i * stride + j * 4 + 1]; + byte r = imageData[i * stride + j * 4 + 2]; + byte a = imageData[i * stride + j * 4 + 3]; + + if (a == 0 && b == 255 && g == 255 && r == 255) + { + continue; + } + + if (a == 0 && b == 0 && g == 0 && r == 0) + { + continue; + } + + imageData[i * stride + j * 4 + 3] = (byte)(opacity * 255); + } + } + + WriteableBitmap writeImage = new WriteableBitmap((int)drawRect.Width, (int)drawRect.Height, 96, 96, PixelFormats.Bgra32, null); + writeImage.WritePixels(new Int32Rect(0, 0, (int)drawRect.Width, (int)drawRect.Height), imageData, stride, 0); + string tempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), Guid.NewGuid().ToString()); + PngBitmapEncoder pngEncoder = new PngBitmapEncoder(); + using (FileStream fs = File.Create(tempPath)) + { + pngEncoder.Frames.Add(BitmapFrame.Create(writeImage)); + pngEncoder.Save(fs); + } + imagePath = tempPath; + return true; + } + catch (Exception ex) + { + + } + return false; + } + } } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/StickyNoteAnnotHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/StickyNoteAnnotHistory.cs index 502031e..e8bc10a 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/StickyNoteAnnotHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/StickyNoteAnnotHistory.cs @@ -68,9 +68,15 @@ internal override bool Add() { stickynoteAnnot.SetContent(currentParam.Content); } + + if (string.IsNullOrEmpty(currentParam.IconName) == false) + { + stickynoteAnnot.SetIconName(currentParam.IconName); + } + stickynoteAnnot.SetIsLocked(currentParam.Locked); stickynoteAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime()); - stickynoteAnnot.UpdateAp(); + CommonHelper.UpdateStickyAP(stickynoteAnnot); stickynoteAnnot.ReleaseAnnot(); if (currentParam != null) @@ -134,13 +140,18 @@ internal override bool Update(bool isUndo) stickynoteAnnot.SetContent(updateParam.Content); } + if(updateParam.IconName!=checkParam.IconName && !string.IsNullOrEmpty(updateParam.IconName)) + { + stickynoteAnnot.SetIconName(updateParam.IconName); + } + if (updateParam.Locked != checkParam.Locked) { stickynoteAnnot.SetIsLocked(updateParam.Locked); } stickynoteAnnot.SetModifyDate(PDFHelp.GetCurrentPdfTime()); - stickynoteAnnot.UpdateAp(); + CommonHelper.UpdateStickyAP(stickynoteAnnot); return true; } diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/ComboBoxHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/ComboBoxHistory.cs index b03d182..6930bc5 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/ComboBoxHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/ComboBoxHistory.cs @@ -84,12 +84,9 @@ internal override bool Add() } textAttr.FontColor = fontColor; textAttr.FontSize = (float)currentParam.FontSize; - textAttr.FontName = ObtainFontName( - GetFontType(currentParam.FontName), - currentParam.IsBold, - currentParam.IsItalic); + textAttr.FontName = currentParam.FontName; - comboboxWidget.SetTextAttribute(textAttr); + comboboxWidget.SetTextAttribute(textAttr); if(currentParam.OptionItems!=null && currentParam.OptionItems.Count > 0) { @@ -198,11 +195,8 @@ internal override bool Update(bool isUndo) if (updateParam.FontName != checkParam.FontName) { CTextAttribute textAttr = comboboxWidget.GetTextAttribute(); - bool isBold = IsBold(textAttr.FontName); - bool isItalic = IsItalic(textAttr.FontName); - FontType fontType = GetFontType(updateParam.FontName); - textAttr.FontName = ObtainFontName(fontType, isBold, isItalic); - comboboxWidget.SetTextAttribute(textAttr); + textAttr.FontName = updateParam.FontName; + comboboxWidget.SetTextAttribute(textAttr); } if (updateParam.FontSize != checkParam.FontSize) @@ -222,24 +216,6 @@ internal override bool Update(bool isUndo) } } - if (updateParam.IsBold != checkParam.IsBold) - { - CTextAttribute textAttr = comboboxWidget.GetTextAttribute(); - bool isItalic = IsItalic(textAttr.FontName); - FontType fontType = GetFontType(textAttr.FontName); - textAttr.FontName = ObtainFontName(fontType, updateParam.IsBold, isItalic); - comboboxWidget.SetTextAttribute(textAttr); - } - - if (updateParam.IsItalic != checkParam.IsItalic) - { - CTextAttribute textAttr = comboboxWidget.GetTextAttribute(); - bool isBold = IsBold(textAttr.FontName); - FontType fontType = GetFontType(textAttr.FontName); - textAttr.FontName = ObtainFontName(fontType, isBold, updateParam.IsItalic); - comboboxWidget.SetTextAttribute(textAttr); - } - if (updateParam.OptionItems != null) { int optionsCount = comboboxWidget.GetItemsCount(); diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/ListBoxHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/ListBoxHistory.cs index c308b5b..587cb02 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/ListBoxHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/ListBoxHistory.cs @@ -84,12 +84,9 @@ internal override bool Add() } textAttr.FontColor = fontColor; textAttr.FontSize = (float)currentParam.FontSize; - textAttr.FontName = ObtainFontName( - GetFontType(currentParam.FontName), - currentParam.IsBold, - currentParam.IsItalic); + textAttr.FontName = currentParam.FontName; - listboxWidget.SetTextAttribute(textAttr); + listboxWidget.SetTextAttribute(textAttr); if (currentParam.OptionItems != null && currentParam.OptionItems.Count > 0) { @@ -198,11 +195,8 @@ internal override bool Update(bool isUndo) if (updateParam.FontName != checkParam.FontName) { CTextAttribute textAttr = listboxWidget.GetTextAttribute(); - bool isBold = IsBold(textAttr.FontName); - bool isItalic = IsItalic(textAttr.FontName); - FontType fontType = GetFontType(updateParam.FontName); - textAttr.FontName = ObtainFontName(fontType, isBold, isItalic); - listboxWidget.SetTextAttribute(textAttr); + textAttr.FontName = updateParam.FontName; + listboxWidget.SetTextAttribute(textAttr); } if (updateParam.FontSize != checkParam.FontSize) @@ -222,25 +216,6 @@ internal override bool Update(bool isUndo) } } - - if (updateParam.IsBold != checkParam.IsBold) - { - CTextAttribute textAttr = listboxWidget.GetTextAttribute(); - bool isItalic = IsItalic(textAttr.FontName); - FontType fontType = GetFontType(textAttr.FontName); - textAttr.FontName = ObtainFontName(fontType, updateParam.IsBold, isItalic); - listboxWidget.SetTextAttribute(textAttr); - } - - if (updateParam.IsItalic != checkParam.IsItalic) - { - CTextAttribute textAttr = listboxWidget.GetTextAttribute(); - bool isBold = IsBold(textAttr.FontName); - FontType fontType = GetFontType(textAttr.FontName); - textAttr.FontName = ObtainFontName(fontType, isBold, updateParam.IsItalic); - listboxWidget.SetTextAttribute(textAttr); - } - if (updateParam.OptionItems != null) { int optionsCount = listboxWidget.GetItemsCount(); diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/PushButtonHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/PushButtonHistory.cs index daf2246..0724843 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/PushButtonHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/PushButtonHistory.cs @@ -92,12 +92,9 @@ internal override bool Add() } textAttr.FontColor = fontColor; textAttr.FontSize = (float)currentParam.FontSize; - textAttr.FontName = ObtainFontName( - GetFontType(currentParam.FontName), - currentParam.IsBold, - currentParam.IsItalic); + textAttr.FontName = currentParam.FontName; - pushbuttonWidget.SetTextAttribute(textAttr); + pushbuttonWidget.SetTextAttribute(textAttr); switch (currentParam.Action) { @@ -215,11 +212,8 @@ internal override bool Update(bool isUndo) if (updateParam.FontName != checkParam.FontName) { CTextAttribute textAttr = pushbutton.GetTextAttribute(); - bool isBold = IsBold(textAttr.FontName); - bool isItalic = IsItalic(textAttr.FontName); - FontType fontType = GetFontType(updateParam.FontName); - textAttr.FontName = ObtainFontName(fontType, isBold, isItalic); - pushbutton.SetTextAttribute(textAttr); + textAttr.FontName = updateParam.FontName; + pushbutton.SetTextAttribute(textAttr); } if (updateParam.FontSize != checkParam.FontSize) @@ -239,24 +233,6 @@ internal override bool Update(bool isUndo) } } - if (updateParam.IsBold != checkParam.IsBold) - { - CTextAttribute textAttr = pushbutton.GetTextAttribute(); - bool isItalic = IsItalic(textAttr.FontName); - FontType fontType = GetFontType(textAttr.FontName); - textAttr.FontName = ObtainFontName(fontType, updateParam.IsBold, isItalic); - pushbutton.SetTextAttribute(textAttr); - } - - if (updateParam.IsItalic != checkParam.IsItalic) - { - CTextAttribute textAttr = pushbutton.GetTextAttribute(); - bool isBold = IsBold(textAttr.FontName); - FontType fontType = GetFontType(textAttr.FontName); - textAttr.FontName = ObtainFontName(fontType, isBold, updateParam.IsItalic); - pushbutton.SetTextAttribute(textAttr); - } - switch (updateParam.Action) { case C_ACTION_TYPE.ACTION_TYPE_GOTO: diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/TextBoxHistory.cs b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/TextBoxHistory.cs index 5ca3134..c64d9b3 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/TextBoxHistory.cs +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/UndoManger/FormHistory/TextBoxHistory.cs @@ -86,12 +86,9 @@ internal override bool Add() } textAttr.FontColor = fontColor; textAttr.FontSize = (float)currentParam.FontSize; - textAttr.FontName = ObtainFontName( - GetFontType(currentParam.FontName), - currentParam.IsBold, - currentParam.IsItalic); + textAttr.FontName = currentParam.FontName; - textWidget.SetTextAttribute(textAttr); + textWidget.SetTextAttribute(textAttr); textWidget.SetJustification(currentParam.Alignment); textWidget.SetBorderWidth((float)currentParam.LineWidth); @@ -185,11 +182,8 @@ internal override bool Update(bool isUndo) if (updateParam.FontName != checkParam.FontName) { CTextAttribute textAttr = textWidget.GetTextAttribute(); - bool isBold = IsBold(textAttr.FontName); - bool isItalic = IsItalic(textAttr.FontName); - FontType fontType = GetFontType(updateParam.FontName); - textAttr.FontName = ObtainFontName(fontType, isBold, isItalic); - textWidget.SetTextAttribute(textAttr); + textAttr.FontName = updateParam.FontName; + textWidget.SetTextAttribute(textAttr); } if (updateParam.FontSize != checkParam.FontSize) @@ -209,24 +203,6 @@ internal override bool Update(bool isUndo) } } - if (updateParam.IsBold != checkParam.IsBold) - { - CTextAttribute textAttr = textWidget.GetTextAttribute(); - bool isItalic = IsItalic(textAttr.FontName); - FontType fontType = GetFontType(textAttr.FontName); - textAttr.FontName = ObtainFontName(fontType, updateParam.IsBold, isItalic); - textWidget.SetTextAttribute(textAttr); - } - - if (updateParam.IsItalic != checkParam.IsItalic) - { - CTextAttribute textAttr = textWidget.GetTextAttribute(); - bool isBold = IsBold(textAttr.FontName); - FontType fontType = GetFontType(textAttr.FontName); - textAttr.FontName = ObtainFontName(fontType, isBold, updateParam.IsItalic); - textWidget.SetTextAttribute(textAttr); - } - if (updateParam.Alignment != checkParam.Alignment) { textWidget.SetJustification(updateParam.Alignment); diff --git a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/packages.config b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/packages.config index 7fe0bcf..4a7fc06 100644 --- a/ComPDFKit for Windows/Examples/ComPDFKit.Tool/packages.config +++ b/ComPDFKit for Windows/Examples/ComPDFKit.Tool/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/AnnotationControl/AnnotationControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/AnnotationControl/AnnotationControl.xaml.cs index 821f2b7..47dcce7 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/AnnotationControl/AnnotationControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/AnnotationControl/AnnotationControl.xaml.cs @@ -20,6 +20,8 @@ using ComPDFKit.Tool.Help; using ComPDFKit.Tool.DrawTool; using System.Collections.Generic; +using ComPDFKitViewer.BaseObject; +using ComPDFKitViewer; namespace ComPDFKit.Controls.PDFControl { @@ -96,7 +98,7 @@ public AnnotationControl() { CPDFAnnotationType.Highlight, CPDFAnnotationType.Underline, CPDFAnnotationType.Strikeout, CPDFAnnotationType.Squiggly, CPDFAnnotationType.Freehand, CPDFAnnotationType.FreeText, - CPDFAnnotationType.Note, CPDFAnnotationType.Circle, CPDFAnnotationType.Square, + CPDFAnnotationType.Note, CPDFAnnotationType.Circle, CPDFAnnotationType.Square, CPDFAnnotationType.Polygon, CPDFAnnotationType.Arrow, CPDFAnnotationType.Line, CPDFAnnotationType.Image, CPDFAnnotationType.Stamp, CPDFAnnotationType.Signature, CPDFAnnotationType.Link, CPDFAnnotationType.Audio @@ -182,7 +184,15 @@ private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEvent CPDFSignatureUI signatureProperty = new CPDFSignatureUI(); signatureProperty.SetFormProperty(annotParam, PDFViewControl, baseWidget.GetAnnotData().Annot); PropertyContainer.Child = signatureProperty; - } + } + } + } + else + { + BaseAnnot baseAnnot = PDFViewControl.GetCacheHitTestWidget(); + if (baseAnnot != null) + { + AnnotData annotData = baseAnnot.GetAnnotData(); } } } @@ -191,8 +201,7 @@ private void UserControl_Unloaded(object sender, RoutedEventArgs e) { PDFViewControl.MouseRightButtonDownHandler -= PDFViewControl_MouseRightButtonDownHandler; } - - + private void AnnotationBarControl_Loaded(object sender, RoutedEventArgs e) { AnnotationBarControl.AnnotationPropertyChanged -= AnnotationBarControl_AnnotationPropertyChanged; @@ -206,9 +215,7 @@ private void AnnotationBarControl_Unloaded(object sender, RoutedEventArgs e) { AnnotationBarControl.AnnotationPropertyChanged -= AnnotationBarControl_AnnotationPropertyChanged; AnnotationBarControl.AnnotationCancel -= AnnotationBarControl_AnnotationCancel; - - } - + } #endregion #region Annotation @@ -224,16 +231,24 @@ public void InitialPDFViewControl(PDFViewControl newPDFViewer) panelState.PropertyChanged -= PanelState_PropertyChanged; panelState.PropertyChanged += PanelState_PropertyChanged; PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged -= UndoManager_PropertyChanged; - PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged += UndoManager_PropertyChanged; - PDFAnnotationControl.ClearAnnotationBar -= PdfAnnotationControl_ClearAnnotationBar; + PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged += UndoManager_PropertyChanged; + PDFViewControl.MouseLeftButtonUpHandler -= PDFToolManager_MouseLeftButtonUpHandler; PDFViewControl.MouseLeftButtonUpHandler += PDFToolManager_MouseLeftButtonUpHandler; PDFViewControl.PDFViewTool.AnnotChanged -= PDFViewTool_AnnotChanged; PDFViewControl.PDFViewTool.AnnotChanged += PDFViewTool_AnnotChanged; + + OnPropertyChanged("CanRedo"); + OnPropertyChanged("CanUndo"); + } + + private void PDFToolManager_CreatePolygonFinished(object sender, EventArgs e) + { + PDFAnnotationControl.ClearPanel(); } private void PDFViewTool_AnnotChanged(object sender, object e) - { - OnAnnotEditHandler?.Invoke(this, EventArgs.Empty); + { + OnAnnotEditHandler?.Invoke(this, EventArgs.Empty); } private void PDFToolManager_MouseLeftButtonUpHandler(object sender, MouseEventObject e) @@ -242,6 +257,10 @@ private void PDFToolManager_MouseLeftButtonUpHandler(object sender, MouseEventOb { OnAnnotEditHandler?.Invoke(this, EventArgs.Empty); } + if(PDFViewControl.GetCacheHitTestAnnot() != null) + { + PDFAnnotationControl.ShowTempAnnotPanel(); + } } private void PDFViewControl_MouseRightButtonDownHandler(object sender, ComPDFKit.Tool.MouseEventObject e) @@ -514,11 +533,11 @@ protected void OnPropertyChanged([CallerMemberName] string name = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } - - + private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e) { OnPropertyChanged(e.PropertyName); + OnCanSaveChanged?.Invoke(this, CanSave); } private void PanelState_PropertyChanged(object sender, PropertyChangedEventArgs e) @@ -574,6 +593,9 @@ private void CommandBinding_Executed_Undo(object sender, ExecutedRoutedEventArgs if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null && CanUndo) { PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager?.Undo(); + PDFViewControl.PDFToolManager.ClearSelect(); + PDFViewControl.PDFViewTool.GetCPDFViewer().UpdateAnnotFrame(); + (BotaContainer.Child as CPDFBOTABarControl).LoadAnnotationList(); } } @@ -582,6 +604,9 @@ private void CommandBinding_Executed_Redo(object sender, ExecutedRoutedEventArgs if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null && CanRedo) { PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager?.Redo(); + PDFViewControl.PDFToolManager.ClearSelect(); + PDFViewControl.PDFViewTool.GetCPDFViewer().UpdateAnnotFrame(); + (BotaContainer.Child as CPDFBOTABarControl).LoadAnnotationList(); } } diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/CPDFAnnotationPreviewerControl.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/CPDFAnnotationPreviewerControl.xaml index d8ab8f0..221cff7 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/CPDFAnnotationPreviewerControl.xaml +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/CPDFAnnotationPreviewerControl.xaml @@ -76,7 +76,14 @@ - + + + + + M24.7273 23.2727H8.72729C3.91419 23.2727 0 19.3586 0 14.5455C0.00552784 12.5867 0.667305 10.6864 1.87963 9.14788C3.09195 7.60941 4.78488 6.52158 6.688 6.05817C7.48868 4.25647 8.79432 2.72541 10.447 1.65024C12.0996 0.57507 14.0284 0.00187249 16 0C21.1651 0 25.4444 3.86619 26.0961 8.85673C27.7564 9.17689 29.2536 10.0648 30.3308 11.3682C31.408 12.6715 31.9982 14.3091 32 16C32 20.0102 28.7375 23.2727 24.7273 23.2727ZM9.08364 7.89673C8.98631 8.13157 8.82913 8.3368 8.62777 8.49196C8.4264 8.64713 8.18789 8.74682 7.936 8.78108C6.54427 8.97521 5.26941 9.66525 4.34584 10.7243C3.42227 11.7834 2.91208 13.1403 2.90908 14.5455C2.90908 17.7542 5.51854 20.3637 8.72729 20.3637H24.7273C27.1331 20.3637 29.091 18.4058 29.091 16C29.091 13.5942 27.1331 11.6364 24.7273 11.6364C24.3415 11.6364 23.9716 11.4831 23.6988 11.2103C23.426 10.9376 23.2727 10.5676 23.2727 10.1818C23.2727 6.17163 20.0102 2.90908 16 2.90908C14.4961 2.91037 13.0294 3.37703 11.8012 4.24503C10.573 5.11304 9.64358 6.33984 9.14037 7.75709C9.12322 7.80434 9.1043 7.85091 9.08364 7.89673Z + + + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/CPDFAnnotationPreviewerControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/CPDFAnnotationPreviewerControl.xaml.cs index 9fa42e0..201c97c 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/CPDFAnnotationPreviewerControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/CPDFAnnotationPreviewerControl.xaml.cs @@ -152,6 +152,12 @@ public void DrawFreehandPreview(CPDFAnnotationData annotationData) SharpPath.StrokeThickness = freehandData.Thickness; } + public void DrawCloudPreview() + { + CollapsedAll(); + gdPolygon.Visibility = Visibility.Visible; + } + public void DrawNotePreview(CPDFAnnotationData annotationData) { CollapsedAll(); @@ -176,10 +182,63 @@ public void DrawFreeTextPreview(CPDFFreeTextData freeTextData) string fontStyle = string.Empty; CPDFFont.GetFamilyStyleName(freeTextData.FontFamily, ref fontFamily, ref fontStyle); - FreeText.FontFamily = new FontFamily(fontFamily); + FreeText.FontFamily = new FontFamily(fontFamily); FreeText.FontSize = freeTextData.FontSize / 1.2; FreeText.Foreground = new SolidColorBrush(freeTextData.BorderColor); FreeText.Opacity = freeTextData.Opacity; } + + private Path DrawCloudLine(Point startPoint, Point endPoint, double radius, double angle, Brush strokeColor, double strokeThickness, bool isUpward) + { + double lineLength = Math.Sqrt(Math.Pow(endPoint.X - startPoint.X, 2) + Math.Pow(endPoint.Y - startPoint.Y, 2)); + double arcLength = 2 * Math.PI * radius * (angle / 360); + int arcCount = (int)Math.Ceiling(lineLength / arcLength); + Vector direction = new Vector(endPoint.X - startPoint.X, endPoint.Y - startPoint.Y); + + direction.Normalize(); + direction *= arcLength; + Point currentPoint = startPoint; + + // 创建一个完整的PathGeometry + PathGeometry pathGeometry = new PathGeometry(); + PathFigure pathFigure = new PathFigure + { + StartPoint = currentPoint, + IsClosed = false + }; + + for (int i = 0; i < arcCount; i++) + { + // Calculate the end point of the arc + Point nextPoint = new Point(currentPoint.X + direction.X, currentPoint.Y + direction.Y); + + ArcSegment arcSegment = new ArcSegment + { + Point = nextPoint, + Size = new Size(radius, radius), + SweepDirection = isUpward ? SweepDirection.Clockwise : SweepDirection.Counterclockwise, // 控制圆弧方向 + IsLargeArc = angle > 180 + }; + + // Add the ArcSegment to the path + pathFigure.Segments.Add(arcSegment); + + // Update currentPoint to be the end point of the arc + currentPoint = nextPoint; + } + + // 将所有圆弧段添加到一个PathFigure中 + pathGeometry.Figures.Add(pathFigure); + + // 创建最终的Path对象 + Path cloudPath = new Path + { + Stroke = strokeColor, + StrokeThickness = strokeThickness, + Data = pathGeometry + }; + + return cloudPath; + } } } diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationData/CPDFAnnotationData.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationData/CPDFAnnotationData.cs index 4e0d53e..1cd6671 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationData/CPDFAnnotationData.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationData/CPDFAnnotationData.cs @@ -82,7 +82,8 @@ public static class CPDFAnnotationDictionary { "Signature", CPDFAnnotationType.Signature }, { "Link", CPDFAnnotationType.Link }, {"Audio", CPDFAnnotationType.Audio }, - {"Image", CPDFAnnotationType.Image } + {"Image", CPDFAnnotationType.Image }, + {"Polygon", CPDFAnnotationType.Polygon} }; public static Dictionary GetLineTypeFromIndex = new Dictionary() @@ -126,7 +127,8 @@ public bool IsSolid } private int _dashSpacing = 1; - public int DashSpacing { + public int DashSpacing + { get => _dashSpacing; set { @@ -155,7 +157,7 @@ public abstract class CPDFAnnotationData public class CPDFMarkupData : CPDFAnnotationData { - public double Opacity = 1; + public double Opacity = 255; public Color Color = Color.FromRgb(255, 0, 0); } @@ -168,6 +170,22 @@ public class CPDFShapeData : CPDFAnnotationData public DashStyle DashStyle = DashStyles.Solid; } + public class CPDFPolygonData : CPDFAnnotationData + { + public Color BorderColor = Color.FromRgb(255, 0, 0); + public Color FillColor = Color.FromRgb(255, 255, 255); + public CPDFBorderEffector BorderEffector + { + get; + set; + } = new CPDFBorderEffector(C_BORDER_TYPE.C_BORDER_TYPE_Cloud, C_BORDER_INTENSITY.C_INTENSITY_ONE); + public C_BORDER_STYLE BorderStyle = C_BORDER_STYLE.BS_SOLID; + public double Opacity = 1; + public int Thickness = 1; + public bool IsMeasured = false; + public DashStyle DashStyle = DashStyles.Solid; + } + public class CPDFLineShapeData : CPDFAnnotationData { public Color BorderColor = Color.FromRgb(255, 0, 0); @@ -278,7 +296,7 @@ public string TypeText { get { - if(Type == C_STAMP_TYPE.TEXT_STAMP) + if (Type == C_STAMP_TYPE.TEXT_STAMP) { return "Text Stamp"; } diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListControl/CPDFAnnotationListControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListControl/CPDFAnnotationListControl.xaml.cs index a89069b..1047fe7 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListControl/CPDFAnnotationListControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListControl/CPDFAnnotationListControl.xaml.cs @@ -13,7 +13,7 @@ using ComPDFKit.Controls.PDFControlUI; using System.Windows.Input; using System; -using System.Linq; +using ComPDFKit.Import; namespace ComPDFKit.Controls.PDFControl { @@ -97,8 +97,8 @@ private void AnnotationList_DeleteItemHandler(object sender, Dictionary annotList = GetAnnotCommentList(i, pdfViewer.PDFViewTool.GetCPDFViewer().GetDocument()); List annotCoreList = pdfViewer?.GetCPDFViewer()?.GetDocument()?.PageAtIndex(i, false)?.GetAnnotations(); if (annotList != null && annotList.Count > 0) @@ -153,6 +154,10 @@ public void LoadAnnotationList() { foreach (AnnotParam annot in annotList) { + if(annot.ClientRect.height() == 0 && annot.ClientRect.width() == 0) + { + continue; + } CPDFAnnotation annotCore = annotCoreList[annot.AnnotIndex]; if (annotCore == null || annotCore.IsReplyAnnot() || annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_LINK) { @@ -170,10 +175,10 @@ public void LoadAnnotationList() List replyAnnotations = annotCore?.GetReplies(); if (replyAnnotations != null && replyAnnotations.Count > 0) - { + { foreach (CPDFTextAnnotation replyAnnot in replyAnnotations) { - if (replyAnnot == null || replyAnnot.IsMarkedStateAnnot()) + if (replyAnnot == null) { continue; } diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnoationListUI.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnoationListUI.xaml deleted file mode 100644 index 9a22c1a..0000000 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnoationListUI.xaml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - M17.7782 5.75646L14.2427 2.22093L13.0052 3.45837L15.4802 5.93333L14.4195 6.99399L11.9446 4.51903L10.1768 - 6.28679L12.6518 8.76175L11.5911 9.82241L9.11615 7.34745L7.34838 9.11522L9.82334 11.5902L8.76268 - 12.6508L6.28772 10.1759L4.51996 11.9436L6.99492 14.4186L5.93426 15.4793L3.4593 13.0043L2.22186 - 14.2417L5.75739 17.7773L17.7782 5.75646ZM15.3033 1.16027L14.2427 0.0996094L13.182 1.16027L1.1612 - 13.1811L0.100539 14.2417L1.1612 15.3024L4.69673 18.8379L5.75739 19.8986L6.81805 18.8379L18.8389 - 6.81712L19.8995 5.75646L18.8389 4.6958L15.3033 1.16027Z - - - - - - - M0.5 3C0.5 1.89543 1.39543 1 2.5 1C3.33934 1 4.05793 1.51704 4.35462 2.25H15.6454C15.9421 1.51704 16.6607 1 - 17.5 1C18.6046 1 19.5 1.89543 19.5 3C19.5 3.83934 18.983 4.55793 18.25 4.85462V17V17.75H17.5H13.7011L14.5167 - 18.5765L13.5138 19.5928L11.4986 17.5505L10.9972 17.0423L11.4986 16.5342L13.5138 14.4918L14.5167 15.5082L13.7847 - 16.25H16.75V4.85462C16.2487 4.65168 15.8483 4.25135 15.6454 3.75H4.35462C4.15168 4.25135 3.75135 4.65168 3.25 - 4.85462V16.25H6.25V15H7.75V19H6.25V17.75H2.5H1.75V17V4.85462C1.01704 4.55793 0.5 3.83934 0.5 3Z - - - - - - - - - - - - - - - - - - - diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnoationListUI.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnoationListUI.xaml.cs deleted file mode 100644 index 494d96e..0000000 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnoationListUI.xaml.cs +++ /dev/null @@ -1,239 +0,0 @@ -using ComPDFKit.PDFAnnotation; -using ComPDFKit.Tool; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Text.RegularExpressions; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Input; -using ComPDFKit.Controls.Helper; - -namespace ComPDFKit.Controls.PDFControlUI -{ - public partial class CPDFAnnoationListUI : UserControl - { - public class BindAnnotationResult : INotifyPropertyChanged - { - public int PageIndex { get; set; } - - public int AnnotIndex { get => annotationData.AnnotIndex; } - - public string CreateDate - { - get - { - if (Regex.IsMatch(annotationData.CreateTime, "(?<=D\\:)[0-9]+(?=[\\+\\-])")) - { - string dateStr = Regex.Match(annotationData.CreateTime, "(?<=D\\:)[0-9]+(?=[\\+\\-])").Value; - return (dateStr.Substring(0, 4) + "-" + dateStr.Substring(4, 2) + "-" + dateStr.Substring(6, 2) + ", " + dateStr.Substring(8, 2) + ":" + - dateStr.Substring(10, 2)); - } - else - { - return String.Empty; - } - } - } - - public string Note - { - get => annotationData.Content; - } - - public C_ANNOTATION_TYPE CurrentAnnotationType - { - get => annotationData.CurrentType; - } - - public AnnotParam annotationData { get; set; } - - public event PropertyChangedEventHandler PropertyChanged; - protected void OnPropertyChanged(string propertyName) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - } - - internal class AnnotationBindData - { - public BindAnnotationResult BindProperty { get; set; } - public AnnotationBindData() - { - BindProperty = new BindAnnotationResult(); - } - public int ShowPageIndex { get { return BindProperty.PageIndex + 1; } set { BindProperty.PageIndex = value; } } - } - - private ObservableCollection annotationList = new ObservableCollection(); - - public event EventHandler AnnotationSelectionChanged; - - public event EventHandler>> DeleteItemHandler; - - private ContextMenu popContextMenu; - private bool enableSelectEvent = true; - - public CPDFAnnoationListUI() - { - InitializeComponent(); - ICollectionView groupView = CollectionViewSource.GetDefaultView(annotationList); - groupView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotationBindData.ShowPageIndex))); - popContextMenu = new ContextMenu(); - MenuItem deleteMenu = new MenuItem(); - deleteMenu.Header = LanguageHelper.BotaManager.GetString("Menu_Delete"); - deleteMenu.Click -= DeleteMenu_Click; - deleteMenu.Click += DeleteMenu_Click; - popContextMenu.Items.Add(deleteMenu); - MenuItem deleteAllMenu = new MenuItem(); - deleteAllMenu.Header = LanguageHelper.BotaManager.GetString("Menu_DeleteAll"); - deleteAllMenu.Click -= DeleteAllMenu_Click; - deleteAllMenu.Click += DeleteAllMenu_Click; - popContextMenu.Items.Add(deleteAllMenu); - } - - private void DeleteAllMenu_Click(object sender, RoutedEventArgs e) - { - try - { - Dictionary> delDict = new Dictionary>(); - - foreach (AnnotationBindData bindData in annotationList) - { - if (delDict.ContainsKey(bindData.BindProperty.PageIndex) == false) - { - delDict[bindData.BindProperty.PageIndex] = new List(); - } - delDict[bindData.BindProperty.PageIndex].Add(bindData.BindProperty.AnnotIndex); - } - - if (delDict.Count > 0) - { - DeleteItemHandler?.Invoke(this, delDict); - } - } - catch (Exception ex) - { - - } - } - - private void DeleteMenu_Click(object sender, RoutedEventArgs e) - { - try - { - if (AnnotationList != null && AnnotationList.SelectedIndex >= 0) - { - AnnotationBindData bindData = annotationList[AnnotationList.SelectedIndex]; - - Dictionary> delDict = new Dictionary>(); - delDict[bindData.BindProperty.PageIndex] = new List() - { - bindData.BindProperty.AnnotIndex - }; - DeleteItemHandler?.Invoke(this, delDict); - } - } - catch (Exception ex) - { - - } - } - - public void SetAnnotationList(List results) - { - annotationList.Clear(); - AnnotationList.ContextMenu = null; - if (results == null || results.Count == 0) - { - AnnotationList.ItemsSource = null; - NoContentText.Visibility = Visibility.Visible; - return; - } - - foreach (BindAnnotationResult item in results) - { - annotationList.Add(new AnnotationBindData() - { - BindProperty = item - }); - } - AnnotationList.ItemsSource = annotationList; - if (annotationList.Count > 0) - { - AnnotationList.ContextMenu = popContextMenu; - } - AnnotationList.Visibility = Visibility.Visible; - NoContentText.Visibility = Visibility.Collapsed; - } - - private void AnnotationListControl_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - if (enableSelectEvent) - { - try - { - AnnotationSelectionChanged?.Invoke(this, (e.AddedItems[0] as AnnotationBindData).BindProperty); - } - catch { } - } - } - - public void CancelSelected() - { - AnnotationList.SelectedIndex = -1; - } - - public void SelectAnnotationChanged(int annotationIndex = -1) - { - - AnnotationList.SelectedIndex = annotationIndex; - } - - public void SelectAnnotationChanged(int pageIIndex, int annotIndex) - { - if (annotationList != null && annotationList.Count > 0) - { - for (int i = 0; i < annotationList.Count; i++) - { - AnnotationBindData data = annotationList[i]; - if (data.BindProperty.PageIndex == pageIIndex && data.BindProperty.AnnotIndex == annotIndex) - { - enableSelectEvent = false; - AnnotationList.SelectedIndex = i; - enableSelectEvent = true; - break; - } - } - } - } - - private void AnnotationList_ContextMenuOpening(object sender, ContextMenuEventArgs e) - { - try - { - MenuItem checkMenu = popContextMenu.Items[0] as MenuItem; - if (checkMenu != null) - { - checkMenu.IsEnabled = true; - } - if (AnnotationList != null && AnnotationList.SelectedIndex == -1) - { - checkMenu.IsEnabled = false; - } - - } - catch (Exception ex) - { - - } - } - - private void AnnotationList_MouseRightButtonDown(object sender, MouseButtonEventArgs e) - { - CancelSelected(); - } - } -} diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnotationListUI.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnotationListUI.xaml index 05145e5..025c93d 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnotationListUI.xaml +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnotationListUI.xaml @@ -161,6 +161,13 @@ + + + + M15.4546 17.0455H5.45456C2.44637 17.0455 0 14.5991 0 11.5909C0.0034549 10.3667 0.417066 9.17898 1.17477 8.21743C1.93247 7.25588 2.99055 6.57599 4.18 6.28636C4.68042 5.16029 5.49645 4.20338 6.52935 3.5314C7.56225 2.85942 8.76776 2.50117 10 2.5C13.2282 2.5 15.9028 4.91637 16.31 8.03546C17.3477 8.23556 18.2835 8.7905 18.9567 9.6051C19.63 10.4197 19.9989 11.4432 20 12.5C20 15.0064 17.9609 17.0455 15.4546 17.0455ZM5.67728 7.43546C5.61644 7.58223 5.5182 7.7105 5.39235 7.80748C5.2665 7.90446 5.11743 7.96676 4.96 7.98818C4.09017 8.10951 3.29338 8.54078 2.71615 9.2027C2.13892 9.86461 1.82005 10.7127 1.81818 11.5909C1.81818 13.5964 3.44909 15.2273 5.45456 15.2273H15.4546C16.9582 15.2273 18.1818 14.0036 18.1818 12.5C18.1818 10.9964 16.9582 9.77273 15.4546 9.77273C15.2135 9.77273 14.9822 9.67695 14.8117 9.50646C14.6412 9.33598 14.5455 9.10474 14.5455 8.86363C14.5455 6.35727 12.5064 4.31818 10 4.31818C9.06005 4.31898 8.14337 4.61065 7.37576 5.15315C6.60815 5.69565 6.02724 6.4624 5.71273 7.34818C5.70201 7.37771 5.69019 7.40682 5.67728 7.43546Z + + + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs index 7370586..1c6b965 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs @@ -26,7 +26,6 @@ namespace ComPDFKit.Controls.PDFControl { public partial class CPDFAnnotationControl : UserControl { - private bool isTempPanel = false; private CPDFAnnotationType currentAnnotationType = CPDFAnnotationType.Unknown; @@ -44,6 +43,7 @@ public partial class CPDFAnnotationControl : UserControl private CPDFShapeUI pdfCircleUI; private CPDFShapeUI pdfLineUI; private CPDFShapeUI pdfArrowUI; + private CPDFCloudUI pdfCloudUI; private CPDFFreehandUI pdfFreehandUI; private CPDFFreeTextUI pdfFreeTextUI; private CPDFNoteUI pdfNoteUI; @@ -116,7 +116,7 @@ private void AnnotationControl_Loaded(object sender, RoutedEventArgs e) private void AnnotationControl_Unloaded(object sender, RoutedEventArgs e) { - UnLoadPDFViewHandler(); + UnLoadPDFViewHandler(); } private UIElement GetAnnotationPanel() @@ -154,6 +154,11 @@ private void ChangeAnnotationData() (annotationPanel as CPDFShapeUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged; SetAnnotationProperty((annotationPanel as CPDFShapeUI).GetShapeData()); break; + case CPDFAnnotationType.Polygon: + (annotationPanel as CPDFCloudUI).PropertyChanged -= CPDFAnnotationControl_PropertyChanged; + (annotationPanel as CPDFCloudUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged; + SetAnnotationProperty((annotationPanel as CPDFCloudUI).GetPolygonData()); + break; case CPDFAnnotationType.Note: (annotationPanel as CPDFNoteUI).PropertyChanged -= CPDFAnnotationControl_PropertyChanged; (annotationPanel as CPDFNoteUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged; @@ -261,8 +266,10 @@ private void SetAnnotationProperty(CPDFAnnotationData pdfAnnotationData = null) case CPDFAnnotationType.Square: { CPDFShapeData squareData = pdfAnnotationData as CPDFShapeData; - annotHandlerEventArgs = new SquareParam(); - annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE; + annotHandlerEventArgs = new SquareParam() + { + CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE + }; byte[] LineColor = new byte[] { squareData.BorderColor.R, squareData.BorderColor.G, squareData.BorderColor.B }; (annotHandlerEventArgs as SquareParam).LineColor = LineColor; if (squareData.FillColor != Colors.Transparent) @@ -276,6 +283,7 @@ private void SetAnnotationProperty(CPDFAnnotationData pdfAnnotationData = null) ParamConverter.ParseDashStyle(squareData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle); (annotHandlerEventArgs as SquareParam).LineDash = LineDash; (annotHandlerEventArgs as SquareParam).BorderStyle = BorderStyle; + (annotHandlerEventArgs as SquareParam).Author = CPDFMarkupData.Author; (annotHandlerEventArgs as SquareParam).Content = squareData.Note; pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE); @@ -284,45 +292,87 @@ private void SetAnnotationProperty(CPDFAnnotationData pdfAnnotationData = null) case CPDFAnnotationType.Circle: { - CPDFShapeData cicleData = pdfAnnotationData as CPDFShapeData; - annotHandlerEventArgs = new CircleParam(); - annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE; - byte[] LineColor = new byte[] { cicleData.BorderColor.R, cicleData.BorderColor.G, cicleData.BorderColor.B }; - (annotHandlerEventArgs as CircleParam).LineColor = LineColor; - if (cicleData.FillColor != Colors.Transparent) + CPDFShapeData circleData = pdfAnnotationData as CPDFShapeData; + byte[] LineColor = new byte[] { circleData.BorderColor.R, circleData.BorderColor.G, circleData.BorderColor.B }; + + annotHandlerEventArgs = new CircleParam + { + CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE + }; + + if (annotHandlerEventArgs is CircleParam circleParam) { - byte[] BgColor = new byte[] { cicleData.FillColor.R, cicleData.FillColor.G, cicleData.FillColor.B }; - (annotHandlerEventArgs as CircleParam).BgColor = BgColor; - (annotHandlerEventArgs as CircleParam).HasBgColor = true; + circleParam.LineColor = LineColor; + if (circleData.FillColor != Colors.Transparent) + { + byte[] BgColor = new byte[] { circleData.FillColor.R, circleData.FillColor.G, circleData.FillColor.B }; + circleParam.BgColor = BgColor; + circleParam.HasBgColor = true; + } + circleParam.LineWidth = circleData.Thickness; + circleParam.Transparency = Convert.ToByte(circleData.Opacity * 255); + ParamConverter.ParseDashStyle(circleData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle); + circleParam.LineDash = LineDash; + circleParam.BorderStyle = BorderStyle; + circleParam.Author = CPDFMarkupData.Author; + circleParam.Content = circleData.Note; } - (annotHandlerEventArgs as CircleParam).LineWidth = cicleData.Thickness; - (annotHandlerEventArgs as CircleParam).Transparency = Convert.ToByte(cicleData.Opacity * 255); - ParamConverter.ParseDashStyle(cicleData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle); - (annotHandlerEventArgs as CircleParam).LineDash = LineDash; - (annotHandlerEventArgs as CircleParam).BorderStyle = BorderStyle; - (annotHandlerEventArgs as CircleParam).Author = CPDFMarkupData.Author; - (annotHandlerEventArgs as CircleParam).Content = cicleData.Note; pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE); } break; + case CPDFAnnotationType.Polygon: + { + CPDFPolygonData polygonData = pdfAnnotationData as CPDFPolygonData; + pdfViewerControl.PDFViewTool.GetDefaultSettingParam().IsCreateSquarePolygonMeasure = false; + annotHandlerEventArgs = new PolygonMeasureParam() + { + CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON + }; + if (annotHandlerEventArgs is PolygonMeasureParam polygonMeasureParam) + { + polygonMeasureParam.LineColor = new byte[] { polygonData.BorderColor.R, polygonData.BorderColor.G, polygonData.BorderColor.B }; + polygonMeasureParam.HasFillColor = true; + if(polygonData.FillColor.A == 0) + { + polygonMeasureParam.HasFillColor = false; + } + polygonMeasureParam.FillColor = new byte[] { polygonData.FillColor.R, polygonData.FillColor.G, polygonData.FillColor.B }; + polygonMeasureParam.BorderStyle = polygonData.BorderStyle; + ParamConverter.ParseDashStyle(polygonData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle); + polygonMeasureParam.LineDash = LineDash; + polygonMeasureParam.BorderEffector = polygonData.BorderEffector; + polygonMeasureParam.LineWidth = polygonData.Thickness; + polygonMeasureParam.Transparency = (byte)(polygonData.Opacity / 100 * 255.0); + polygonMeasureParam.IsMeasure = false; + polygonMeasureParam.Content = polygonData.Note; + polygonMeasureParam.Author = CPDFMarkupData.Author; + } + pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON); + } + break; case CPDFAnnotationType.Arrow: case CPDFAnnotationType.Line: { CPDFLineShapeData lineData = pdfAnnotationData as CPDFLineShapeData; - annotHandlerEventArgs = new LineParam(); - annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_LINE; - byte[] LineColor = new byte[] { lineData.BorderColor.R, lineData.BorderColor.G, lineData.BorderColor.B }; - (annotHandlerEventArgs as LineParam).LineColor = LineColor; - (annotHandlerEventArgs as LineParam).LineWidth = lineData.Thickness; - (annotHandlerEventArgs as LineParam).Transparency = Convert.ToByte(lineData.Opacity * 255); - ParamConverter.ParseDashStyle(lineData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle); - (annotHandlerEventArgs as LineParam).LineDash = LineDash; - (annotHandlerEventArgs as LineParam).BorderStyle = BorderStyle; - (annotHandlerEventArgs as LineParam).HeadLineType = lineData.LineType.HeadLineType; - (annotHandlerEventArgs as LineParam).TailLineType = lineData.LineType.TailLineType; - (annotHandlerEventArgs as LineParam).Author = CPDFMarkupData.Author; - (annotHandlerEventArgs as LineParam).Content = lineData.Note; + annotHandlerEventArgs = new LineParam() + { + CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_LINE + }; + if (annotHandlerEventArgs is LineParam lineParam) + { + byte[] LineColor = new byte[] { lineData.BorderColor.R, lineData.BorderColor.G, lineData.BorderColor.B }; + lineParam.LineColor = LineColor; + lineParam.LineWidth = lineData.Thickness; + lineParam.Transparency = Convert.ToByte(lineData.Opacity * 255); + ParamConverter.ParseDashStyle(lineData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle); + lineParam.LineDash = LineDash; + lineParam.BorderStyle = BorderStyle; + lineParam.HeadLineType = lineData.LineType.HeadLineType; + lineParam.TailLineType = lineData.LineType.TailLineType; + lineParam.Author = CPDFMarkupData.Author; + lineParam.Content = lineData.Note; + } pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINE); } break; @@ -331,12 +381,15 @@ private void SetAnnotationProperty(CPDFAnnotationData pdfAnnotationData = null) { CPDFNoteData noteData = pdfAnnotationData as CPDFNoteData; annotHandlerEventArgs = new StickyNoteParam(); - annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_TEXT; - byte[] StickyNoteColor = new byte[] { noteData.BorderColor.R, noteData.BorderColor.G, noteData.BorderColor.B }; - (annotHandlerEventArgs as StickyNoteParam).StickyNoteColor = StickyNoteColor; - (annotHandlerEventArgs as StickyNoteParam).Content = noteData.Note; - (annotHandlerEventArgs as StickyNoteParam).Transparency = 255; - (annotHandlerEventArgs as StickyNoteParam).Author = CPDFMarkupData.Author; + if (annotHandlerEventArgs is StickyNoteParam stickyNoteParam) + { + annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_TEXT; + byte[] StickyNoteColor = new byte[] { noteData.BorderColor.R, noteData.BorderColor.G, noteData.BorderColor.B }; + stickyNoteParam.StickyNoteColor = StickyNoteColor; + stickyNoteParam.Content = noteData.Note; + stickyNoteParam.Transparency = 255; + stickyNoteParam.Author = CPDFMarkupData.Author; + } pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_TEXT); } break; @@ -344,14 +397,20 @@ private void SetAnnotationProperty(CPDFAnnotationData pdfAnnotationData = null) case CPDFAnnotationType.Freehand: { CPDFFreehandData freehandData = pdfAnnotationData as CPDFFreehandData; - annotHandlerEventArgs = new InkParam(); - annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_INK; - byte[] LineColor = new byte[] { freehandData.BorderColor.R, freehandData.BorderColor.G, freehandData.BorderColor.B }; - (annotHandlerEventArgs as InkParam).InkColor = LineColor; - (annotHandlerEventArgs as InkParam).Thickness = freehandData.Thickness; - (annotHandlerEventArgs as InkParam).Transparency = Convert.ToByte(freehandData.Opacity * 255); - (annotHandlerEventArgs as InkParam).Content = freehandData.Note; - (annotHandlerEventArgs as InkParam).Author = CPDFMarkupData.Author; + annotHandlerEventArgs = new InkParam() + { + CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_INK + }; + if (annotHandlerEventArgs is InkParam inkParam) + { + byte[] LineColor = new byte[] { freehandData.BorderColor.R, freehandData.BorderColor.G, freehandData.BorderColor.B }; + inkParam.InkColor = LineColor; + inkParam.Thickness = freehandData.Thickness; + inkParam.Transparency = Convert.ToByte(freehandData.Opacity * 255); + inkParam.Content = freehandData.Note; + inkParam.Author = CPDFMarkupData.Author; + } + pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_INK); } break; @@ -359,57 +418,66 @@ private void SetAnnotationProperty(CPDFAnnotationData pdfAnnotationData = null) case CPDFAnnotationType.FreeText: { CPDFFreeTextData freeTextData = pdfAnnotationData as CPDFFreeTextData; - annotHandlerEventArgs = new FreeTextParam(); - annotHandlerEventArgs.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT; - (annotHandlerEventArgs as FreeTextParam).Transparency = Convert.ToByte(freeTextData.Opacity * 255); - (annotHandlerEventArgs as FreeTextParam).FontName = freeTextData.FontFamily.ToString(); - - byte[] FontColor = new byte[] { freeTextData.BorderColor.R, freeTextData.BorderColor.G, freeTextData.BorderColor.B }; - (annotHandlerEventArgs as FreeTextParam).FontColor = FontColor; - (annotHandlerEventArgs as FreeTextParam).FontSize = freeTextData.FontSize; - - string postScriptName = string.Empty; - CPDFFont.GetPostScriptName(pdfFreeTextUI.CPDFFontControl.FontFamilyValue, pdfFreeTextUI.CPDFFontControl.FontStyleValue, ref postScriptName); - (annotHandlerEventArgs as FreeTextParam).FontName = postScriptName; - switch (freeTextData.TextAlignment) + annotHandlerEventArgs = new FreeTextParam() { - case TextAlignment.Left: - (annotHandlerEventArgs as FreeTextParam).Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_LEFT; - break; - case TextAlignment.Right: - (annotHandlerEventArgs as FreeTextParam).Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_RIGHT; - break; - case TextAlignment.Center: - (annotHandlerEventArgs as FreeTextParam).Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_CENTER; - break; - default: - break; + CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT + }; + if (annotHandlerEventArgs is FreeTextParam freeTextParam) + { + freeTextParam.Transparency = Convert.ToByte(freeTextData.Opacity * 255); + freeTextParam.FontName = freeTextData.FontFamily.ToString(); + + byte[] FontColor = new byte[] { freeTextData.BorderColor.R, freeTextData.BorderColor.G, freeTextData.BorderColor.B }; + freeTextParam.FontColor = FontColor; + freeTextParam.FontSize = freeTextData.FontSize; + + string postScriptName = string.Empty; + CPDFFont.GetPostScriptName(pdfFreeTextUI.CPDFFontControl.FontFamilyValue, pdfFreeTextUI.CPDFFontControl.FontStyleValue, ref postScriptName); + freeTextParam.FontName = postScriptName; + switch (freeTextData.TextAlignment) + { + case TextAlignment.Left: + freeTextParam.Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_LEFT; + break; + case TextAlignment.Right: + freeTextParam.Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_RIGHT; + break; + case TextAlignment.Center: + freeTextParam.Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_CENTER; + break; + default: + break; + } + freeTextParam.Content = freeTextData.Note; + freeTextParam.Author = CPDFMarkupData.Author; } - (annotHandlerEventArgs as FreeTextParam).Content = freeTextData.Note; - (annotHandlerEventArgs as FreeTextParam).Author = CPDFMarkupData.Author; + pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT); } break; case CPDFAnnotationType.Stamp: { - StampParam stampParam = new StampParam(); - stampParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_STAMP; - CPDFStampData stampData = pdfAnnotationData as CPDFStampData; - SetStamp(ref stampParam, stampData); - annotHandlerEventArgs = stampParam; - pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP); - - byte[] imageData = null; - int imageWidth = 0; - int imageHeight = 0; - PDFHelp.ImageStreamToByte(stampParam.ImageStream, ref imageData, ref imageWidth, ref imageHeight); - if (imageData != null && imageWidth > 0 && imageHeight > 0) + StampParam stampParam = new StampParam() { - pdfViewerControl.PDFViewTool.GetCPDFViewer().SetMouseImageMaxSize(200, 300); - pdfViewerControl.SetStampMouseImage(imageData, imageWidth, imageHeight); - } - + CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_STAMP + }; + if(pdfAnnotationData is CPDFStampData stampData) + { + SetStamp(ref stampParam, stampData); + annotHandlerEventArgs = stampParam; + pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP); + + byte[] imageData = null; + int imageWidth = 0; + int imageHeight = 0; + PDFHelp.ImageStreamToByte(stampParam.ImageStream, ref imageData, ref imageWidth, ref imageHeight); + if (imageData != null && imageWidth > 0 && imageHeight > 0) + { + pdfViewerControl.PDFViewTool.GetCPDFViewer().SetMouseImageMaxSize(200, 300); + pdfViewerControl.SetStampMouseImage(imageData, imageWidth, imageHeight); + } + } pdfViewerControl.SetIsVisibleCustomMouse(true); pdfViewerControl.SetIsShowStampMouse(true); } @@ -589,7 +657,7 @@ public void SetSignature(ref AnnotParam annotParam, CPDFSignatureData stamp) annotParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_STAMP; (annotParam as StampParam).Transparency = 255; (annotParam as StampParam).StampType = C_STAMP_TYPE.IMAGE_STAMP; - if (!string.IsNullOrEmpty(stamp.SourcePath) && File.Exists(stamp.SourcePath)) + if (!string.IsNullOrEmpty(stamp.SourcePath)) { BitmapImage image = new BitmapImage(new Uri(stamp.SourcePath)); PngBitmapEncoder encoder = new PngBitmapEncoder(); @@ -643,6 +711,7 @@ public void SetSignature(ref AnnotParam annotParam, CPDFSignatureData stamp) break; } } + private List> GetPoints(string Path) { StrokeCollection Strokes; @@ -698,6 +767,7 @@ private void SetStamp(ref StampParam stampParam, CPDFStampData stamp) public void AnnotationCancel() { + this.pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_NONE); this.pdfViewerControl.SetToolType(ToolType.Pan); pdfViewerControl.SetIsShowStampMouse(false); pdfViewerControl.SetIsVisibleCustomMouse(false); @@ -761,6 +831,13 @@ public void InitAnnotationPanel(CPDFAnnotationType annotationType) annotationPanel = pdfCircleUI; (annotationPanel as CPDFShapeUI).InitWithAnnotationType(annotationType); break; + case CPDFAnnotationType.Polygon: + if (pdfCloudUI == null) + { + pdfCloudUI = new CPDFCloudUI(); + } + annotationPanel = pdfCloudUI; + break; case CPDFAnnotationType.Arrow: if (pdfArrowUI == null) { @@ -1092,6 +1169,17 @@ public void CreatTempAnnotationPanel(BaseAnnot baseAnnot) (tempAnnotationPanel as CPDFLinkUI).SetPresentAnnotAttrib(annotParam as LinkParam, baseAnnot.GetAnnotData().Annot as CPDFLinkAnnotation, pdfViewerControl, pdfViewerControl.PDFToolManager.GetDocument().PageCount); } break; + case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON: + { + tempAnnotationPanel = new CPDFCloudUI(); + AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam( + pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument(), + baseAnnot.GetAnnotData().PageIndex, + baseAnnot.GetAnnotData().Annot + ); + (tempAnnotationPanel as CPDFCloudUI).SetPresentAnnotAttrib(annotParam as PolygonMeasureParam, baseAnnot.GetAnnotData().Annot as CPDFPolygonAnnotation, pdfViewerControl, pdfViewerControl.PDFToolManager.GetDocument().PageCount); + } + break; case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND: tempAnnotationPanel = null; break; @@ -1115,7 +1203,7 @@ private void ShowCurrentAnnotPanel() { if (annotationPanel is CPDFFreehandUI) { - if(pdfViewerControl.PDFToolManager.GetToolType() == ToolType.Customize) + if (pdfViewerControl.PDFToolManager.GetToolType() == ToolType.Customize) { (annotationPanel as CPDFFreehandUI)?.SetEraseCheck(true); return; @@ -1123,7 +1211,7 @@ private void ShowCurrentAnnotPanel() else { (annotationPanel as CPDFFreehandUI)?.SetEraseCheck(false); - } + } } SetAnnotationPanel(annotationPanel); @@ -1142,7 +1230,7 @@ private void ShowCurrentAnnotPanel() } } - private void ShowTempAnnotPanel() + public void ShowTempAnnotPanel() { BaseAnnot baseAnnot = pdfViewerControl.GetCacheHitTestAnnot(); if (baseAnnot != null) diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCloudUI.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCloudUI.xaml new file mode 100644 index 0000000..35d9524 --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCloudUI.xaml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCloudUI.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCloudUI.xaml.cs new file mode 100644 index 0000000..81f3011 --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCloudUI.xaml.cs @@ -0,0 +1,339 @@ +using ComPDFKit.Controls.Common; +using ComPDFKit.Controls.Data; +using ComPDFKit.Controls.PDFControl; +using ComPDFKit.PDFAnnotation; +using ComPDFKit.Tool; +using ComPDFKit.Tool.Help; +using ComPDFKit.Tool.UndoManger; +using ComPDFKitViewer.Helper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Controls; +using System.Windows.Media; + +namespace ComPDFKit.Controls.PDFControlUI +{ + /// + /// Interaction logic for CPDFCloudUI.xaml + /// + public partial class CPDFCloudUI : UserControl + { + bool IsLoadedData = false; + + private AnnotParam annotParam; + private CPDFAnnotation annotCore; + private PDFViewControl viewControl; + public event EventHandler PropertyChanged; + + public CPDFCloudUI() + { + InitializeComponent(); + + ctlBorderColorPicker.ColorChanged -= CtlBorderColorPicker_ColorChanged; + ctlFillColorPicker.ColorChanged -= CtlFillColorPicker_ColorChanged; + CPDFOpacityControl.OpacityChanged -= CPDFOpacityControl_OpacityChanged; + CPDFThicknessControl.ThicknessChanged -= CPDFThicknessControl_ThicknessChanged; + CPDFLineShapeControl.LineShapeChanged -= CPDFLineShapeControl_LineShapeChanged; + ctlLineStyle.LineStyleChanged -= CtlLineStyle_LineStyleChanged; + + ctlBorderColorPicker.ColorChanged += CtlBorderColorPicker_ColorChanged; + ctlFillColorPicker.ColorChanged += CtlFillColorPicker_ColorChanged; + CPDFOpacityControl.OpacityChanged += CPDFOpacityControl_OpacityChanged; + CPDFThicknessControl.ThicknessChanged += CPDFThicknessControl_ThicknessChanged; + CPDFLineShapeControl.LineShapeChanged += CPDFLineShapeControl_LineShapeChanged; + ctlLineStyle.LineStyleChanged += CtlLineStyle_LineStyleChanged; + + CPDFAnnotationPreviewerControl.DrawCloudPreview(); + } + + private void CtlLineStyle_LineStyleChanged(object sender, EventArgs e) + { + if (annotParam == null) + { + PropertyChanged?.Invoke(this, GetPolygonData()); + } + else + { + if (annotCore != null && annotCore.IsValid()) + { + float[] dashArray = null; + C_BORDER_STYLE borderStyle; + if (ctlLineStyle.DashStyle == DashStyles.Solid || ctlLineStyle.DashStyle == null) + { + dashArray = new float[0]; + borderStyle = C_BORDER_STYLE.BS_SOLID; + } + else + { + List floatArray = new List(); + foreach (double num in ctlLineStyle.DashStyle.Dashes) + { + floatArray.Add((float)num); + } + dashArray = floatArray.ToArray(); + borderStyle = C_BORDER_STYLE.BS_DASHDED; + } + + if (viewControl != null && viewControl.PDFViewTool != null) + { + PolygonMeasureAnnotHistory history = new PolygonMeasureAnnotHistory(); + history.PDFDoc = viewControl.GetCPDFViewer().GetDocument(); + history.Action = HistoryAction.Update; + CPDFPolygonAnnotation polygonAnnotation = annotCore as CPDFPolygonAnnotation; + if (polygonAnnotation == null || polygonAnnotation.Dash.SequenceEqual(dashArray)) return; + history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, polygonAnnotation); + polygonAnnotation.SetBorderStyle(borderStyle, dashArray); + history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, polygonAnnotation); + viewControl.GetCPDFViewer().UndoManager.AddHistory(history); + + annotCore.UpdateAp(); + viewControl.UpdateAnnotFrame(); + } + } + } + } + + private void CPDFLineShapeControl_LineShapeChanged(object sender, CPDFBorderEffector e) + { + if (annotParam == null) + { + PropertyChanged?.Invoke(this, GetPolygonData()); + } + if (IsLoadedData) + { + if (annotCore != null && annotCore.IsValid() && annotCore is CPDFPolygonAnnotation polygonAnnotation) + { + PolygonMeasureAnnotHistory history = new PolygonMeasureAnnotHistory(); + history.PDFDoc = viewControl.GetCPDFViewer().GetDocument(); + history.Action = HistoryAction.Update; + history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, polygonAnnotation); + polygonAnnotation.SetAnnotBorderEffector(e); + history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, polygonAnnotation); + viewControl.GetCPDFViewer().UndoManager.AddHistory(history); + + annotCore.UpdateAp(); + viewControl.UpdateAnnotFrame(); + } + } + } + + private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e) + { + if (annotParam == null) + { + PropertyChanged?.Invoke(this, GetPolygonData()); + } + if (IsLoadedData) + { + if (annotCore != null && annotCore.IsValid() && annotCore is CPDFPolygonAnnotation polygonAnnotation) + { + PolygonMeasureAnnotHistory history = new PolygonMeasureAnnotHistory(); + history.PDFDoc = viewControl.GetCPDFViewer().GetDocument(); + history.Action = HistoryAction.Update; + history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, annotCore); + polygonAnnotation.SetLineWidth((sender as CPDFThicknessControl).Thickness); + history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, annotCore); + viewControl.GetCPDFViewer().UndoManager.AddHistory(history); + + annotCore.UpdateAp(); + viewControl.UpdateAnnotFrame(); + } + } + } + + private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e) + { + if (annotParam == null) + { + PropertyChanged?.Invoke(this, GetPolygonData()); + } + if (IsLoadedData) + { + if (annotCore != null && annotCore.IsValid()) + { + double opacity = (sender as CPDFOpacityControl).OpacityValue / 100.0; + if (opacity > 0 && opacity <= 1) + { + opacity *= 255; + } + + PolygonMeasureAnnotHistory history = new PolygonMeasureAnnotHistory(); + history.PDFDoc = viewControl.GetCPDFViewer().GetDocument(); + history.Action = HistoryAction.Update; + history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, annotCore); + annotCore.SetTransparency((byte)opacity); + history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, annotCore); + viewControl.GetCPDFViewer().UndoManager.AddHistory(history); + + annotCore.UpdateAp(); + viewControl.UpdateAnnotFrame(); + } + } + } + + private void CtlFillColorPicker_ColorChanged(object sender, EventArgs e) + { + if (annotParam == null) + { + PropertyChanged?.Invoke(this, GetPolygonData()); + } + if (IsLoadedData) + { + if (annotCore != null && annotCore.IsValid()) + { + if (annotCore is CPDFPolygonAnnotation polygonAnnotation) + { + PolygonMeasureAnnotHistory history = new PolygonMeasureAnnotHistory(); + history.PDFDoc = viewControl.GetCPDFViewer().GetDocument(); + history.Action = HistoryAction.Update; + history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, polygonAnnotation); + + SolidColorBrush brush = (sender as ColorPickerControl)?.Brush as SolidColorBrush; + polygonAnnotation.SetBgColor(new byte[3] + { + brush.Color.R, + brush.Color.G, + brush.Color.B + }); + + if(brush.Color.A == 0) + { + polygonAnnotation.ClearBgColor(); + } + + history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, polygonAnnotation); + viewControl.GetCPDFViewer().UndoManager.AddHistory(history); + + annotCore.UpdateAp(); + viewControl.UpdateAnnotFrame(); + } + } + } + } + + private void CtlBorderColorPicker_ColorChanged(object sender, EventArgs e) + { + if (annotParam == null) + { + PropertyChanged?.Invoke(this, GetPolygonData()); + } + if (IsLoadedData) + { + if (annotCore != null && annotCore.IsValid()) + { + if (annotCore is CPDFPolygonAnnotation polygonAnnotation) + { + PolygonMeasureAnnotHistory history = new PolygonMeasureAnnotHistory(); + history.PDFDoc = viewControl.GetCPDFViewer().GetDocument(); + history.Action = HistoryAction.Update; + history.PreviousParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, polygonAnnotation); + + SolidColorBrush brush = (sender as ColorPickerControl)?.Brush as SolidColorBrush; + polygonAnnotation.SetLineColor(new byte[3] + { + brush.Color.R, + brush.Color.G, + brush.Color.B + }); + + history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, polygonAnnotation); + + annotCore.UpdateAp(); + viewControl.GetCPDFViewer().UndoManager.AddHistory(history); + viewControl.UpdateAnnotFrame(); + } + } + } + } + + public void SetPresentAnnotAttrib(PolygonMeasureParam polygonParam, CPDFPolygonAnnotation annotation, PDFViewControl view, int PageCount) + { + annotParam = polygonParam; + annotCore = annotation; + viewControl = view; + if (polygonParam == null) + { + return; + } + + Color lineColor = Color.FromRgb(polygonParam.LineColor[0], polygonParam.LineColor[1], polygonParam.LineColor[2]); + Color fillColor; + if (annotation.HasBgColor) + { + fillColor = Color.FromRgb(polygonParam.FillColor[0], polygonParam.FillColor[1], polygonParam.FillColor[2]); + } + else + { + fillColor = Colors.Transparent; + } + + ctlBorderColorPicker.SetCheckedForColor(lineColor); + ctlFillColorPicker.SetCheckedForColor(fillColor); + + double opacity = polygonParam.Transparency / 255.0 * 100.0; + CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity); + + float thickness = polygonParam.LineWidth; + CPDFThicknessControl.Thickness = (int)Math.Ceiling(thickness); + + CPDFLineShapeControl.BorderEffector = annotation.GetAnnotBorderEffector(); + if (polygonParam.BorderStyle == C_BORDER_STYLE.BS_SOLID) + { + ctlLineStyle.DashStyle = DashStyles.Solid; + } + else + { + List dashArray = new List(); + foreach (double num in polygonParam.LineDash) + { + dashArray.Add(num); + } + ctlLineStyle.DashStyle = new DashStyle(dashArray, 0); + } + + NoteTextBox.Text = polygonParam.Content; + } + + public CPDFAnnotationData GetPolygonData() + { + CPDFPolygonData polygonData = new CPDFPolygonData + { + AnnotationType = CPDFAnnotationType.Polygon, + BorderColor = ((SolidColorBrush)ctlBorderColorPicker.Brush).Color, + FillColor = ((SolidColorBrush)ctlFillColorPicker.Brush).Color, + BorderEffector = CPDFLineShapeControl.BorderEffector, + DashStyle = ctlLineStyle.DashStyle, + IsMeasured = false, + Thickness = CPDFThicknessControl.Thickness, + Opacity = CPDFOpacityControl.OpacityValue, + Note = NoteTextBox.Text + }; + + return polygonData; + } + + private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e) + { + IsLoadedData = true; + } + + private void UserControl_Unloaded(object sender, System.Windows.RoutedEventArgs e) + { + IsLoadedData = false; + } + + private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e) + { + if (IsLoadedData) + { + if (annotCore != null && annotCore.IsValid()) + { + annotCore.SetContent(NoteTextBox.Text); + annotCore.UpdateAp(); + viewControl?.UpdateAnnotFrame(); + } + } + } + } +} diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCreateSignatureDialog.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCreateSignatureDialog.xaml index 26bbfef..7e64b61 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCreateSignatureDialog.xaml +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCreateSignatureDialog.xaml @@ -376,22 +376,17 @@ VerticalContentAlignment="Center" Grid.ColumnSpan="2" FontSize="45"/> - - + - - - - - - - + + + - + - - - - - - - - - - - + + + + + - - - - - - - M13.4957 3.18186L11.0208 0.706987C10.6303 0.316463 9.99531 0.318287 9.60254 0.711062L1.96623 8.34737L0.944556 13.2581L5.85532 12.2365L13.4916 4.60015C13.8844 + + + + + + + + + + + + + M13.4957 3.18186L11.0208 0.706987C10.6303 0.316463 9.99531 0.318287 9.60254 0.711062L1.96623 8.34737L0.944556 13.2581L5.85532 12.2365L13.4916 4.60015C13.8844 4.20737 13.8862 3.57239 13.4957 3.18186ZM10.3096 1.41807L12.7844 3.89295L11.9714 4.70585L9.49654 2.23098L10.3096 1.41807ZM8.78532 2.94212L11.2602 5.41699L5.73071 10.9458C5.45073 10.4059 5.10425 9.92877 4.69144 9.51596C4.27669 9.10121 3.79698 8.75341 3.25399 8.47274L8.78532 2.94212ZM2.77914 9.35888L2.23707 11.9659L4.84581 11.423C4.61097 10.9675 4.32252 10.5694 3.98026 10.2271C3.63668 9.88356 3.23687 9.59421 2.77914 9.35888ZM0 @@ -50,47 +50,47 @@ 12.699C8.60834 12.5616 8.26493 12.4956 7.79583 12.5001L7.49924 12.5113C7.39531 12.5178 7.2863 12.5272 7.17215 12.5394L6.81426 12.5844C6.75203 12.5933 6.6885 12.6029 6.62366 12.6132L6.21896 12.6835L5.78265 12.7706L5.31442 12.8744L4.81393 12.9951L4.28087 13.1324L3.41952 13.3696L2.80364 13.5486L2.15407 13.7442L1.11584 14.0687L0 14.4304Z - - - - - - - M7.71094 14L15.2031 6.5L9.5 0.796875L0.890625 9.40625C0.765625 9.53125 0.670573 9.67839 0.605469 9.84766C0.540365 10.0169 0.507812 10.1927 0.507812 + + + + + + + M7.71094 14L15.2031 6.5L9.5 0.796875L0.890625 9.40625C0.765625 9.53125 0.670573 9.67839 0.605469 9.84766C0.540365 10.0169 0.507812 10.1927 0.507812 10.375C0.507812 10.5573 0.540365 10.7331 0.605469 10.9023C0.670573 11.0716 0.768229 11.2214 0.898438 11.3516L3.53906 14H7.71094ZM8.5 11.7969L4.20312 7.5L9.5 2.20312L13.7969 6.5L8.5 11.7969ZM3.95312 13H7.28906L7.79688 12.5L3.5 8.20312L1.60156 10.1016C1.53385 10.1693 1.5 10.2604 1.5 10.375C1.5 10.4896 1.53646 10.5833 1.60938 10.6562L3.95312 13ZM16 14V13H10.0182L9 14H16ZM1.06227 13L2 14H0V13H1.06227Z - - - - - - - - - - - - - + + + - - - + + + + + + + + + + + + + + + + + + - - - + + + + - - - - - - - + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs index a0b6c69..ec2dbe3 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFMarkupUI.xaml.cs @@ -39,7 +39,7 @@ private AnnotHistory GetAnnotHistory() switch (markupAnnot.Type) { case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT: - return new LineAnnotHistory(); + return new HighlightAnnotHistory(); case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE: return new UnderlineAnnotHistory(); case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT: diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml index 23c764b..4f03329 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml @@ -42,7 +42,7 @@ - + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs index 561f23a..8d230e6 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFShapeUI.xaml.cs @@ -419,8 +419,7 @@ public CPDFAnnotationData GetShapeData() pdfShapeData.DashStyle = CPDFLineStyleControl.DashStyle; pdfShapeData.Note = NoteTextBox.Text; return pdfShapeData; - } - + } else { CPDFLineShapeData pdfLineShapeData = new CPDFLineShapeData(); diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/BarControl/CPDFAnnotationBarControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/BarControl/CPDFAnnotationBarControl.xaml.cs index 9976d6d..662e73a 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/BarControl/CPDFAnnotationBarControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/BarControl/CPDFAnnotationBarControl.xaml.cs @@ -132,12 +132,12 @@ private void CreateAnnotationButton(ToggleButton toggleButton) }; canvas.Children.Add(path); } - + else if (toggleButton.Tag.ToString() == CPDFAnnotationType.Note.ToString()) { annotationGeometry = Geometry.Parse("M18 3H2V15H5V18L10 15H18V3ZM5 6H11V7.5H5V6ZM5 9.5H15V11H5V9.5Z"); Path path = new Path - { + { Width = 20, Height = 20, Data = annotationGeometry, @@ -172,6 +172,20 @@ private void CreateAnnotationButton(ToggleButton toggleButton) canvas.Children.Add(path); } + else if (toggleButton.Tag.ToString() == CPDFAnnotationType.Polygon.ToString()) + { + annotationGeometry = Geometry.Parse("M15.4546 15.0455H5.45456C2.44637 15.0455 0 12.5991 0 9.59091C0.0034549 8.36671 0.417066 7.17898 1.17477 6.21743C1.93247 5.25588 2.99055 4.57599 4.18 4.28636C4.68042 3.16029 5.49645 2.20338 6.52935 1.5314C7.56225 0.859419 8.76776 0.50117 10 0.5C13.2282 0.5 15.9028 2.91637 16.31 6.03546C17.3477 6.23556 18.2835 6.7905 18.9567 7.6051C19.63 8.41971 19.9989 9.44319 20 10.5C20 13.0064 17.9609 15.0455 15.4546 15.0455ZM5.67728 5.43546C5.61644 5.58223 5.5182 5.7105 5.39235 5.80748C5.2665 5.90446 5.11743 5.96676 4.96 5.98818C4.09017 6.10951 3.29338 6.54078 2.71615 7.2027C2.13892 7.86461 1.82005 8.71266 1.81818 9.59091C1.81818 11.5964 3.44909 13.2273 5.45456 13.2273H15.4546C16.9582 13.2273 18.1818 12.0036 18.1818 10.5C18.1818 8.99639 16.9582 7.77273 15.4546 7.77273C15.2135 7.77273 14.9822 7.67695 14.8117 7.50646C14.6412 7.33598 14.5455 7.10474 14.5455 6.86363C14.5455 4.35727 12.5064 2.31818 10 2.31818C9.06005 2.31898 8.14337 2.61065 7.37576 3.15315C6.60815 3.69565 6.02724 4.4624 5.71273 5.34818C5.70201 5.37771 5.69019 5.40682 5.67728 5.43546Z"); + Path path = new Path + { + Width = 20, + Height = 20, + VerticalAlignment = VerticalAlignment.Center, + Data = annotationGeometry, + Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#43474D")) + }; + canvas.Children.Add(path); + } + else if (toggleButton.Tag.ToString() == CPDFAnnotationType.Arrow.ToString()) { annotationGeometry = Geometry.Parse("M16.7501 10V3.25H10.0001V4.75H14.1894L1.46973 17.4697L2.53039 18.5303L15.2501 5.81066V10H16.7501Z"); @@ -330,7 +344,7 @@ private void ToggleButton_Click(object sender, RoutedEventArgs e) { AnnotationPropertyChanged?.Invoke(sender, CPDFAnnotationDictionary.GetAnnotationFromTag[(sender as ToggleButton).Tag.ToString()]); CurrentMode = (sender as ToggleButton).Tag.ToString(); - if(CurrentMode == "Image") + if (CurrentMode == "Image") { (sender as ToggleButton).IsChecked = false; } @@ -367,7 +381,7 @@ private ToggleButton FindToggleButtonByTag(DependencyObject parent, string tag) } public void SetAnnotationType(CPDFAnnotationType annotationType) - { + { ToggleButton toggleButton = FindToggleButtonByTag(this, annotationType.ToString()); if (toggleButton != null) { @@ -375,7 +389,7 @@ public void SetAnnotationType(CPDFAnnotationType annotationType) ClearToolState(toggleButton); AnnotationPropertyChanged?.Invoke(toggleButton, CPDFAnnotationDictionary.GetAnnotationFromTag[toggleButton.Tag.ToString()]); CurrentMode = toggleButton.Tag.ToString(); - } + } } public void InitAnnotationBar(CPDFAnnotationType[] annotationProperties) diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/BarControl/CPDFMeasureBarControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/BarControl/CPDFMeasureBarControl.xaml.cs index 80d966f..a70f0c4 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/BarControl/CPDFMeasureBarControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/BarControl/CPDFMeasureBarControl.xaml.cs @@ -19,7 +19,7 @@ public partial class CPDFMeasureBarControl : UserControl #region Data private bool isFirstLoad = true; - + private static string line = LanguageHelper.ToolBarManager.GetString("Button_Line"); private static string multiline = LanguageHelper.ToolBarManager.GetString("Button_Multiline"); private static string polygonal = LanguageHelper.ToolBarManager.GetString("Button_Polygonal"); @@ -35,11 +35,15 @@ public partial class CPDFMeasureBarControl : UserControl private PDFViewControl pdfViewer; - private MeasurePropertyControl measurePropertyControl = null; private MeasureControl measureControl = null; - private enum MeasureType + private AnnotParam createLineMeasureParam = null; + private AnnotParam createPolyLineMeasureParam = null; + private AnnotParam createPolygonMeasureParam = null; + private AnnotParam createRectangleMeasureParam = null; + + public enum MeasureType { UnKnown = -1, Line, @@ -151,6 +155,32 @@ public void InitWithPDFViewer(PDFViewControl pdfViewer, MeasurePropertyControl F this.pdfViewer = pdfViewer; measurePropertyControl = FromProperty; measureControl = parentControl; + + measurePropertyControl.LineMeasureParamChanged -= MeasurePropertyControl_LineMeasureParamChanged; + measurePropertyControl.LineMeasureParamChanged -= MeasurePropertyControl_LineMeasureParamChanged; + measurePropertyControl.PolygonMeasureParamChanged -= MeasurePropertyControl_PolygonMeasureParamChanged; + + measurePropertyControl.PolyLineMeasureParamChanged += MeasurePropertyControl_PolyLineMeasureParamChanged; + measurePropertyControl.PolyLineMeasureParamChanged += MeasurePropertyControl_PolyLineMeasureParamChanged; + measurePropertyControl.PolygonMeasureParamChanged += MeasurePropertyControl_PolygonMeasureParamChanged; + } + + private void MeasurePropertyControl_PolygonMeasureParamChanged(object sender, PolygonMeasureParam e) + { + createPolygonMeasureParam = e; + pdfViewer.SetAnnotParam(e); + } + + private void MeasurePropertyControl_PolyLineMeasureParamChanged(object sender, PolyLineMeasureParam e) + { + createPolyLineMeasureParam = e; + pdfViewer.SetAnnotParam(e); + } + + private void MeasurePropertyControl_LineMeasureParamChanged(object sender, LineMeasureParam e) + { + createLineMeasureParam = e; + pdfViewer.SetAnnotParam(e); } public void ClearAllToolState() @@ -170,7 +200,7 @@ public bool ToolChecked() { if (child is ToggleButton toggle) { - if (toggle.IsChecked==true) + if (toggle.IsChecked == true) { return true; } @@ -188,6 +218,32 @@ private void ClearToolState(UIElement sender) toggle.IsChecked = false; } } + measurePropertyControl.CurrentCreateType = C_ANNOTATION_TYPE.C_ANNOTATION_NONE; + } + + public AnnotParam GetAnnotParam(MeasureType measureType) + { + AnnotParam currentParam = null; + switch (measureType) + { + case MeasureType.UnKnown: + break; + case MeasureType.Line: + currentParam = CreateLine(); + break; + case MeasureType.Multiline: + currentParam = CreateMultiline(); + break; + case MeasureType.Polygonal: + currentParam = CreatePolygonal(); + break; + case MeasureType.Rectangles: + currentParam = CreateRectangles(); + break; + default: + break; + } + return currentParam; } private void MeasureBtn_Click(object sender, RoutedEventArgs e) @@ -196,25 +252,7 @@ private void MeasureBtn_Click(object sender, RoutedEventArgs e) ClearToolState(sender as ToggleButton); if ((bool)(sender as ToggleButton).IsChecked) { - switch (StringToType((sender as ToggleButton).Tag.ToString())) - { - case MeasureType.UnKnown: - break; - case MeasureType.Line: - annotParam = CreateLine(); - break; - case MeasureType.Multiline: - annotParam = CreateMultiline(); - break; - case MeasureType.Polygonal: - annotParam = CreatePolygonal(); - break; - case MeasureType.Rectangles: - annotParam = CreateRectangles(); - break; - default: - break; - } + annotParam = GetAnnotParam(StringToType((sender as ToggleButton).Tag.ToString())); } else { @@ -232,35 +270,15 @@ private void MeasureBtn_Click(object sender, RoutedEventArgs e) #endregion #region Create Form - private AnnotParam CreateLine() { pdfViewer.SetToolType(ToolType.CreateAnnot); pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINE); - LineMeasureParam lineMeasureParam = new LineMeasureParam(); - lineMeasureParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_LINE; - lineMeasureParam.LineColor = new byte[] { 255, 0, 0, }; - lineMeasureParam.LineWidth = 2; - lineMeasureParam.Transparency = 255; - lineMeasureParam.FontColor = new byte[] { 255, 0, 0, }; - lineMeasureParam.FontName = "Arial"; - lineMeasureParam.FontSize = 14; - lineMeasureParam.HeadLineType = C_LINE_TYPE.LINETYPE_ARROW; - lineMeasureParam.TailLineType = C_LINE_TYPE.LINETYPE_ARROW; - lineMeasureParam.measureInfo = new CPDFMeasureInfo + if (createLineMeasureParam == null) { - Unit = CPDFMeasure.CPDF_CM, - Precision = CPDFMeasure.PRECISION_VALUE_TWO, - RulerBase = 1, - RulerBaseUnit = CPDFMeasure.CPDF_CM, - RulerTranslate = 1, - RulerTranslateUnit = CPDFMeasure.CPDF_CM, - CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH, - }; - pdfViewer.SetAnnotParam(lineMeasureParam); - //pdfViewer?.ClearSelectAnnots(); - //pdfViewer?.SetMouseMode(MouseModes.AnnotCreate); - //pdfViewer?.SetToolParam(lineMeasureArgs); + createLineMeasureParam = new LineMeasureParam(); + } + pdfViewer.SetAnnotParam(createLineMeasureParam); measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_DISTANCE_MEASURE); measureControl.SetInfoPanelVisble(true, false); var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting(); @@ -270,42 +288,21 @@ private AnnotParam CreateLine() measureSetting.RulerBaseUnit, measureSetting.RulerTranslate, measureSetting.RulerTranslateUnit)); - return lineMeasureParam; + return createLineMeasureParam; } + private AnnotParam CreateMultiline() { pdfViewer.SetToolType(ToolType.CreateAnnot); pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE); - PolyLineMeasureParam polyLineMeasureParam = new PolyLineMeasureParam(); - polyLineMeasureParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE; - polyLineMeasureParam.LineColor = new byte[] { 255, 0, 0, }; - polyLineMeasureParam.LineWidth = 2; - polyLineMeasureParam.Transparency = 255; - polyLineMeasureParam.FontColor = new byte[] { 255, 0, 0, }; - polyLineMeasureParam.FontName = "Arial"; - polyLineMeasureParam.FontSize = 14; - polyLineMeasureParam.measureInfo = new CPDFMeasureInfo + + if (createPolyLineMeasureParam == null) { - Unit = CPDFMeasure.CPDF_CM, - Precision = CPDFMeasure.PRECISION_VALUE_TWO, - RulerBase = 1, - RulerBaseUnit = CPDFMeasure.CPDF_CM, - RulerTranslate = 1, - RulerTranslateUnit = CPDFMeasure.CPDF_CM, - CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH, - }; - pdfViewer.SetAnnotParam(polyLineMeasureParam); - //PolyLineMeasureArgs polyLineMeasureArgs = new PolyLineMeasureArgs(); - //polyLineMeasureArgs.LineColor = Colors.Red; - //polyLineMeasureArgs.LineWidth = 2; - //polyLineMeasureArgs.Transparency = 1; - //polyLineMeasureArgs.FontColor = Colors.Red; - //polyLineMeasureArgs.FontName = "Arial"; - //polyLineMeasureArgs.FontSize = 14; - // pdfViewer?.ClearSelectAnnots(); - // pdfViewer?.SetMouseMode(MouseModes.AnnotCreate); - // pdfViewer?.SetToolParam(polyLineMeasureArgs); + createPolyLineMeasureParam = new PolyLineMeasureParam(); + } + + pdfViewer.SetAnnotParam(createPolyLineMeasureParam); measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_PERIMETER_MEASURE); measureControl.SetInfoPanelVisble(true, false); var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting(); @@ -315,14 +312,11 @@ private AnnotParam CreateMultiline() measureSetting.RulerBaseUnit, measureSetting.RulerTranslate, measureSetting.RulerTranslateUnit)); - return polyLineMeasureParam; + return createPolyLineMeasureParam; } - private AnnotParam CreatePolygonal() + private AnnotParam CreatePolygonalParam() { - pdfViewer.PDFViewTool.GetDefaultSettingParam().IsCreateSquarePolygonMeasure = false; - pdfViewer.SetToolType(ToolType.CreateAnnot); - pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON); PolygonMeasureParam polygonMeasureParam = new PolygonMeasureParam(); polygonMeasureParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON; polygonMeasureParam.LineColor = new byte[] { 255, 0, 0, }; @@ -331,6 +325,7 @@ private AnnotParam CreatePolygonal() polygonMeasureParam.FontColor = new byte[] { 255, 0, 0, }; polygonMeasureParam.FontName = "Arial"; polygonMeasureParam.FontSize = 14; + polygonMeasureParam.IsMeasure = true; polygonMeasureParam.measureInfo = new CPDFMeasureInfo { Unit = CPDFMeasure.CPDF_CM, @@ -341,18 +336,21 @@ private AnnotParam CreatePolygonal() RulerTranslateUnit = CPDFMeasure.CPDF_CM, CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH | CPDFCaptionType.CPDF_CAPTION_AREA, }; - pdfViewer.SetAnnotParam(polygonMeasureParam); - // PolygonMeasureArgs polygonMeasureArgs = new PolygonMeasureArgs(); - // polygonMeasureArgs.LineColor = Colors.Red; - // polygonMeasureArgs.LineWidth = 2; - // polygonMeasureArgs.Transparency = 1; - // polygonMeasureArgs.FontColor = Colors.Red; - // polygonMeasureArgs.FillColor = Colors.Transparent; - // polygonMeasureArgs.FontName = "Arial"; - // polygonMeasureArgs.FontSize = 14; - // pdfViewer?.ClearSelectAnnots(); - // pdfViewer?.SetMouseMode(MouseModes.AnnotCreate); - // pdfViewer?.SetToolParam(polygonMeasureArgs); + polygonMeasureParam.BorderStyle = C_BORDER_STYLE.BS_SOLID; + polygonMeasureParam.BorderEffector = null; + return polygonMeasureParam; + } + + private AnnotParam CreatePolygonal() + { + pdfViewer.PDFViewTool.GetDefaultSettingParam().IsCreateSquarePolygonMeasure = false; + pdfViewer.SetToolType(ToolType.CreateAnnot); + pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON); + if(createPolygonMeasureParam == null) + { + createPolygonMeasureParam = CreatePolygonalParam(); + } + pdfViewer.SetAnnotParam(createPolygonMeasureParam); measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE); measureControl.SetInfoPanelVisble(true, false); var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting(); @@ -363,14 +361,11 @@ private AnnotParam CreatePolygonal() measureSetting.RulerTranslate, measureSetting.RulerTranslateUnit)); // return polygonMeasureArgs; - return polygonMeasureParam; + return createPolygonMeasureParam; } - private AnnotParam CreateRectangles() + private AnnotParam CreateRectangleParam() { - pdfViewer.PDFViewTool.GetDefaultSettingParam().IsCreateSquarePolygonMeasure = true; - pdfViewer.SetToolType(ToolType.CreateAnnot); - pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON); PolygonMeasureParam polygonMeasureParam = new PolygonMeasureParam(); polygonMeasureParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON; polygonMeasureParam.LineColor = new byte[] { 255, 0, 0, }; @@ -389,32 +384,22 @@ private AnnotParam CreateRectangles() RulerTranslateUnit = CPDFMeasure.CPDF_CM, CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH | CPDFCaptionType.CPDF_CAPTION_AREA, }; - pdfViewer.SetAnnotParam(polygonMeasureParam); - measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE); - // PolygonMeasureArgs rectPolygonMeasureArgs = new PolygonMeasureArgs(); - // rectPolygonMeasureArgs.LineColor = Colors.Red; - // rectPolygonMeasureArgs.IsOnlyDrawRect = true; - // rectPolygonMeasureArgs.LineWidth = 2; - // rectPolygonMeasureArgs.Transparency = 1; - // rectPolygonMeasureArgs.FontColor = Colors.Red; - // rectPolygonMeasureArgs.FillColor = Colors.Transparent; - // rectPolygonMeasureArgs.FontName = "Arial"; - // rectPolygonMeasureArgs.FontSize = 14; - // pdfViewer?.ClearSelectAnnots(); - // pdfViewer?.SetMouseMode(MouseModes.AnnotCreate); - // pdfViewer?.SetToolParam(rectPolygonMeasureArgs); - // measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE); - // measureControl.SetInfoPanelVisble(true, false); - // measureControl.SetMeasureScale(CPDFMeasureType.CPDF_AREA_MEASURE, - // string.Format("{0} {1} = {2} {3}", - // MeasureSetting.RulerBase, - // MeasureSetting.RulerBaseUnit, - // MeasureSetting.RulerTranslate, - // MeasureSetting.RulerTranslateUnit)); - // return rectPolygonMeasureArgs; return polygonMeasureParam; } + private AnnotParam CreateRectangles() + { + pdfViewer.PDFViewTool.GetDefaultSettingParam().IsCreateSquarePolygonMeasure = true; + pdfViewer.SetToolType(ToolType.CreateAnnot); + pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON); + if(createRectangleMeasureParam == null) + { + createPolygonMeasureParam = CreateRectangleParam(); + } + pdfViewer.SetAnnotParam(createPolygonMeasureParam); + measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE); + return createPolygonMeasureParam; + } -#endregion + #endregion } } \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/BaseControl/MessageBoxEx.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/BaseControl/MessageBoxEx.cs new file mode 100644 index 0000000..4d46cfb --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/BaseControl/MessageBoxEx.cs @@ -0,0 +1,532 @@ +using System; +using System.Windows.Forms; +using System.Runtime.InteropServices; +using ComPDFKit.Controls.Helper; + +namespace ComPDFKit.Controls.Common +{ + public class MessageBoxEx + { + private static string[] okstring = new string[] { LanguageHelper.CompressManager.GetString("Main_Ok")}; + private static string[] ok = okstring; + + private static string[] okcancelstring = new string[] { LanguageHelper.CompressManager.GetString("Main_Ok") , LanguageHelper.CompressManager.GetString("Main_Cancel")}; + private static string[] okcancel = okcancelstring; + + private static string[] abortretryignorestring = new string[] { LanguageHelper.CompressManager.GetString("Main_MenuHelp_About") , "Retry", "Ignore" }; + private static string[] abortretryignore = abortretryignorestring; + + private static string[] yesnocancelstring = new string[] { LanguageHelper.CompressManager.GetString("Main_Yes"), LanguageHelper.CompressManager.GetString("Main_No"), LanguageHelper.CompressManager.GetString("Main_Cancel") }; + private static string[] yesnocancel = yesnocancelstring; + + private static string[] yesnostring = new string[] { LanguageHelper.CompressManager.GetString("Main_Yes"), LanguageHelper.CompressManager.GetString("Main_No") }; + private static string[] yesno = yesnostring; + + private static string[] retrycancelstring = new string[] { "Retry", LanguageHelper.CompressManager.GetString("Main_Cancel") }; + private static string[] retrycancel = retrycancelstring; + + public static DialogResult Show(string text,string[] buttonTitles = null) + { + if(buttonTitles!=null&&buttonTitles.Length==1) + { + ok = buttonTitles; + } + else + { + ok = okstring; + } + + myProc = new HookProc(OK); + SetHook(); + DialogResult result = MessageBox.Show(text, Application.ProductName,MessageBoxButtons.OK); + + UnHook(); + + return result; + } + + public static DialogResult Show(string text,string title,string[] buttonTitles = null) + { + if (buttonTitles != null && buttonTitles.Length == 1) + { + ok = buttonTitles; + } + else + { + ok = okstring; + } + + myProc = new HookProc(OK); + SetHook(); + DialogResult result = MessageBox.Show(text,title); + UnHook(); + + return result; + } + + public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, string[] buttonTitles=null) + { + switch (buttons) + { + case MessageBoxButtons.OK: + if (buttonTitles != null && buttonTitles.Length == 1) + { + ok = buttonTitles; + } + else + { + ok = okstring; + } + myProc = new HookProc(OK); + break; + case MessageBoxButtons.OKCancel: + if (buttonTitles != null && buttonTitles.Length == 2) + { + okcancel = buttonTitles; + } + else + { + okcancel = okcancelstring; + } + myProc = new HookProc(OKCancel); + break; + case MessageBoxButtons.AbortRetryIgnore: + if (buttonTitles != null && buttonTitles.Length == 3) + { + abortretryignore = buttonTitles; + } + else + { + abortretryignore = abortretryignorestring; + } + myProc = new HookProc(AbortRetryIgnore); + break; + case MessageBoxButtons.YesNoCancel: + if (buttonTitles != null && buttonTitles.Length == 3) + { + yesnocancel = buttonTitles; + } + else + { + yesnocancel = yesnocancelstring; + } + myProc = new HookProc(YesNoCancel); + break; + case MessageBoxButtons.YesNo: + if (buttonTitles != null && buttonTitles.Length == 2) + { + yesno = buttonTitles; + } + else + { + yesno = yesnostring; + } + myProc = new HookProc(YesNo); + break; + case MessageBoxButtons.RetryCancel: + if (buttonTitles != null && buttonTitles.Length == 2) + { + retrycancel = buttonTitles; + } + else + { + retrycancel = retrycancelstring; + } + myProc = new HookProc(RetryCancel); + break; + default: + break; + } + + SetHook(); + DialogResult result = MessageBox.Show(text, string.IsNullOrEmpty(caption)?Application.ProductName:caption, buttons); + UnHook(); + return result; + } + + public static DialogResult Show(string text, string caption, MessageBoxButtons buttons,MessageBoxIcon icons,string[] buttonTitles = null) + { + switch (buttons) + { + case MessageBoxButtons.OK: + if (buttonTitles != null && buttonTitles.Length == 1) + { + ok = buttonTitles; + } + else + { + ok = okstring; + } + myProc = new HookProc(OK); + break; + case MessageBoxButtons.OKCancel: + if (buttonTitles != null && buttonTitles.Length == 2) + { + okcancel = buttonTitles; + } + else + { + okcancel = okcancelstring; + } + myProc = new HookProc(OKCancel); + break; + case MessageBoxButtons.AbortRetryIgnore: + if (buttonTitles != null && buttonTitles.Length == 3) + { + abortretryignore = buttonTitles; + } + else + { + abortretryignore = abortretryignorestring; + } + myProc = new HookProc(AbortRetryIgnore); + break; + case MessageBoxButtons.YesNoCancel: + if (buttonTitles != null && buttonTitles.Length == 3) + { + yesnocancel = buttonTitles; + } + else + { + yesnocancel = yesnocancelstring; + } + myProc = new HookProc(YesNoCancel); + break; + case MessageBoxButtons.YesNo: + if (buttonTitles != null && buttonTitles.Length == 2) + { + yesno = buttonTitles; + } + else + { + yesno = yesnostring; + } + myProc = new HookProc(YesNo); + break; + case MessageBoxButtons.RetryCancel: + if (buttonTitles != null && buttonTitles.Length == 2) + { + retrycancel = buttonTitles; + } + else + { + retrycancel = retrycancelstring; + } + myProc = new HookProc(RetryCancel); + break; + default: + break; + } + SetHook(); + DialogResult result = MessageBox.Show(text, string.IsNullOrEmpty(caption) ? Application.ProductName : caption, buttons, icons); + UnHook(); + return result; + } + + public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, + MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, string[] buttonTitles=null) + { + switch (buttons) + { + case MessageBoxButtons.OK: + if (buttonTitles != null && buttonTitles.Length == 1) + { + ok = buttonTitles; + } + else + { + ok = okstring; + } + myProc = new HookProc(OK); + break; + case MessageBoxButtons.OKCancel: + if (buttonTitles != null && buttonTitles.Length == 2) + { + okcancel = buttonTitles; + } + else + { + okcancel = okcancelstring; + } + myProc = new HookProc(OKCancel); + break; + case MessageBoxButtons.AbortRetryIgnore: + if (buttonTitles != null && buttonTitles.Length == 3) + { + abortretryignore = buttonTitles; + } + else + { + abortretryignore = abortretryignorestring; + } + myProc = new HookProc(AbortRetryIgnore); + break; + case MessageBoxButtons.YesNoCancel: + if (buttonTitles != null && buttonTitles.Length == 3) + { + yesnocancel = buttonTitles; + } + else + { + yesnocancel = yesnocancelstring; + } + myProc = new HookProc(YesNoCancel); + break; + case MessageBoxButtons.YesNo: + if (buttonTitles != null && buttonTitles.Length == 2) + { + yesno = buttonTitles; + } + else + { + yesno = yesnostring; + } + myProc = new HookProc(YesNo); + break; + case MessageBoxButtons.RetryCancel: + if (buttonTitles != null && buttonTitles.Length == 2) + { + retrycancel = buttonTitles; + } + else + { + retrycancel = retrycancelstring; + } + myProc = new HookProc(RetryCancel); + break; + default: + break; + } + + DialogResult result = MessageBox.Show(text, string.IsNullOrEmpty(caption) ? Application.ProductName : caption, buttons, icon, defaultButton); + + return result; + } + + public enum HookType + { + Keyboard = 2, + CBT = 5, + Mouse = 7, + }; + + [DllImport("kernel32.dll")] + static extern int GetCurrentThreadId(); + [DllImport("user32.dll")] + static extern int GetDlgItem(IntPtr hDlg, int nIDDlgItem); + [DllImport("user32", EntryPoint = "SetDlgItemText")] + static extern int SetDlgItemTextA(IntPtr hDlg, int nIDDlgItem, string lpString); + + [DllImport("user32.dll", EntryPoint = "SetWindowTextW", CharSet = CharSet.Unicode)] + private static extern bool SetWindowText(IntPtr hWnd, string lpString); + [DllImport("user32.dll")] + static extern void UnhookWindowsHookEx(IntPtr handle); + [DllImport("user32.dll")] + static extern IntPtr SetWindowsHookEx(int idHook, [MarshalAs(UnmanagedType.FunctionPtr)] HookProc lpfn, IntPtr hInstance, int threadID); + [DllImport("user32.dll")] + static extern IntPtr CallNextHookEx(IntPtr handle, int code, IntPtr wparam, IntPtr lparam); + + + static IntPtr _nextHookPtr; + ////must be global, or it will be Collected by GC, then no callback func can be used for the Hook + static HookProc myProc = new HookProc(MyHookProc); + + private delegate IntPtr HookProc(int code, IntPtr wparam, IntPtr lparam); + + private static IntPtr OK(int code, IntPtr wparam, IntPtr lparam) + { + IntPtr hChildWnd; + if (code == 5)//HCBT_ACTIVATE = 5 + { + hChildWnd = wparam; + + var index = (IntPtr)GetDlgItem(hChildWnd,1); + if (index != IntPtr.Zero) + { + SetWindowText(index, ok[0]); + } + } + else + CallNextHookEx(_nextHookPtr, code, wparam, lparam); + + return IntPtr.Zero; + } + + private static IntPtr OKCancel(int code, IntPtr wparam, IntPtr lparam) + { + IntPtr hChildWnd; + bool result = false; + if (code == 5)//HCBT_ACTIVATE = 5 + { + hChildWnd = wparam; + + IntPtr index = (IntPtr)GetDlgItem(hChildWnd, 1); + if (index != IntPtr.Zero) + { + result = SetWindowText(index, okcancel[0]); + } + index = (IntPtr)GetDlgItem(hChildWnd, 2); + if (index != IntPtr.Zero) + { + result = SetWindowText(index, okcancel[1]); + } + } + else + CallNextHookEx(_nextHookPtr, code, wparam, lparam); + + return IntPtr.Zero; + } + + private static IntPtr RetryCancel(int code, IntPtr wparam, IntPtr lparam) + { + IntPtr hChildWnd; + if (code == 5)//HCBT_ACTIVATE = 5 + { + hChildWnd = wparam; + + var index = (IntPtr)GetDlgItem(hChildWnd,4); + if (index!=IntPtr.Zero) + { + SetWindowText(index, retrycancel[0]); + } + index = (IntPtr)GetDlgItem(hChildWnd, 2); + if (GetDlgItem(hChildWnd, 2) != 0) + { + SetWindowText(index, retrycancel[1]); + } + } + else + CallNextHookEx(_nextHookPtr, code, wparam, lparam); + return IntPtr.Zero; + } + + private static IntPtr YesNo(int code, IntPtr wparam, IntPtr lparam) + { + IntPtr hChildWnd; + if (code == 5)//HCBT_ACTIVATE = 5 + { + hChildWnd = wparam; + + var index = (IntPtr)GetDlgItem(hChildWnd, 6); + if (index!=IntPtr.Zero) + { + SetWindowText(index, yesno[0]); + } + index = (IntPtr)GetDlgItem(hChildWnd, 7); + if (index != IntPtr.Zero) + { + SetWindowText(index, yesno[1]); + } + } + else + CallNextHookEx(_nextHookPtr, code, wparam, lparam); + return IntPtr.Zero; + } + private static IntPtr YesNoCancel(int code, IntPtr wparam, IntPtr lparam) + { + IntPtr hChildWnd; + if (code == 5)//HCBT_ACTIVATE = 5 + { + hChildWnd = wparam; + + var index = (IntPtr)GetDlgItem(hChildWnd, 6); + if (index != IntPtr.Zero) + { + SetWindowText(index,yesnocancel[0]); + } + + index = (IntPtr)GetDlgItem(hChildWnd, 7); + if (index != IntPtr.Zero) + { + SetWindowText(index, yesnocancel[1]); + } + + index = (IntPtr)GetDlgItem(hChildWnd, 2); + if (index != IntPtr.Zero) + { + SetWindowText(index, yesnocancel[2]); + } + } + else + CallNextHookEx(_nextHookPtr, code, wparam, lparam); + return IntPtr.Zero; + } + + private static IntPtr AbortRetryIgnore(int code, IntPtr wparam, IntPtr lparam) + { + IntPtr hChildWnd; + if (code == 5)//HCBT_ACTIVATE = 5 + { + hChildWnd = wparam; + + var index = (IntPtr)GetDlgItem(hChildWnd, 3); + if (index != IntPtr.Zero) + { + SetWindowText(index, abortretryignore[0]); + } + + index = (IntPtr)GetDlgItem(hChildWnd, 4); + if (index != IntPtr.Zero) + { + SetWindowText(index, abortretryignore[1]); + } + + index = (IntPtr)GetDlgItem(hChildWnd, 5); + if (index != IntPtr.Zero) + { + SetWindowText(index, abortretryignore[2]); + } + } + else + CallNextHookEx(_nextHookPtr, code, wparam, lparam); + return IntPtr.Zero; + } + + private static IntPtr MyHookProc(int code, IntPtr wparam, IntPtr lparam) + { + IntPtr hChildWnd;// msgbox is "child" + // notification that a window is about to be activated + // window handle is wParam + if (code == 5)//HCBT_ACTIVATE = 5 + { + // set window handles of messagebox + hChildWnd = wparam; + //to get the text of yes button + + for(int i=0;i<21;i++) + { + if (GetDlgItem(hChildWnd, i) != 0) + SetDlgItemTextA(hChildWnd,i,string.Format("Item {0}",i)); + } + } + else + { + CallNextHookEx(_nextHookPtr, code, wparam, lparam);// otherwise, continue with any possible chained hooks + } + + return IntPtr.Zero; + } + + public static void SetHook() + { + try + { + if (_nextHookPtr != IntPtr.Zero)//Hooked already + { + return; + } + _nextHookPtr = SetWindowsHookEx((int)HookType.CBT, myProc, IntPtr.Zero, GetCurrentThreadId()); + } + catch { } + } + + public static void UnHook() + { + if (_nextHookPtr != IntPtr.Zero) + { + UnhookWindowsHookEx(_nextHookPtr); + _nextHookPtr = IntPtr.Zero; + } + } + } +} diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/Helper/CommonHelper.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/Helper/CommonHelper.cs index 4928994..6f07618 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/Helper/CommonHelper.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/Helper/CommonHelper.cs @@ -59,6 +59,15 @@ public static string ParseLicenseXML() public static class CommonHelper { + [DllImport("shell32.dll", ExactSpelling = true)] + private static extern void ILFree(IntPtr pidlList); + + [DllImport("shell32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] + private static extern IntPtr ILCreateFromPathW(string pszPath); + + [DllImport("shell32.dll", ExactSpelling = true)] + private static extern int SHOpenFolderAndSelectItems(IntPtr pidlList, uint cild, IntPtr children, uint dwFlags); + public static bool IsImageCorrupted(string imagePath) { try @@ -116,8 +125,6 @@ public static byte[] ConvertBrushToByteArray(Brush brush) } } - - public static int GetBitmapPointer(Bitmap bitmap) { IntPtr hBitmap = bitmap.GetHbitmap(); @@ -366,6 +373,64 @@ internal static byte[] ConvertBitmapToByteArray(Bitmap bitmap) } } + public static string CreateFilePath(string path) + { + int i = 1; + string oldDestName = path; + do + { + if (File.Exists(path)) + { + int lastDot = oldDestName.LastIndexOf('.'); + + string fileExtension = string.Empty; + + string fileName = oldDestName; + + if (lastDot > 0) + { + fileExtension = fileName.Substring(lastDot); + + fileName = fileName.Substring(0, lastDot); + } + + path = fileName + string.Format(@"({0})", i) + fileExtension; + } + + ++i; + } while (File.Exists(path)); + + return path; + } + + public static void ExplorerFile(string filePath) + { + try + { + if (!File.Exists(filePath) && !Directory.Exists(filePath)) + return; + + if (Directory.Exists(filePath)) + Process.Start(@"explorer.exe", "/select,\"" + filePath + "\""); + else + { + IntPtr pidlList = ILCreateFromPathW(filePath); + if (pidlList != IntPtr.Zero) + { + try + { + Marshal.ThrowExceptionForHR(SHOpenFolderAndSelectItems(pidlList, 0, IntPtr.Zero, 0)); + } + finally + { + ILFree(pidlList); + } + } + } + } + catch { } + } + internal static class PageEditHelper { public static T FindVisualParent(DependencyObject obj) where T : class diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/Helper/LanguageHelper.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/Helper/LanguageHelper.cs index 34c8d97..917c11f 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/Helper/LanguageHelper.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/Helper/LanguageHelper.cs @@ -13,5 +13,6 @@ public abstract class LanguageHelper public static ResourceManager DocInfoManager= new ResourceManager("ComPDFKit.Controls.Strings.DocInfo", Assembly.GetExecutingAssembly()); public static ResourceManager SecurityManager= new ResourceManager("ComPDFKit.Controls.Strings.Security", Assembly.GetExecutingAssembly()); public static ResourceManager DocEditorManager= new ResourceManager("ComPDFKit.Controls.Strings.DocEditor", Assembly.GetExecutingAssembly()); + public static ResourceManager CompressManager = new ResourceManager("ComPDFKit.Controls.Strings.Compress", Assembly.GetExecutingAssembly()); } } \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/HomePage/FeaturesListControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/HomePage/FeaturesListControl.xaml.cs index 4430568..7de515a 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/HomePage/FeaturesListControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/HomePage/FeaturesListControl.xaml.cs @@ -1,20 +1,9 @@ using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; -using System.Linq; using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using ComPDFKit.Controls.Helper; namespace ComPDFKit.Controls.PDFControl diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/HomePage/HomePageControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/HomePage/HomePageControl.xaml.cs index a47dec2..858817c 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/HomePage/HomePageControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/HomePage/HomePageControl.xaml.cs @@ -13,6 +13,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using ComPDFKit.Controls.Compress; using ComPDFKit.Controls.Helper; using Path = System.Windows.Shapes.Path; @@ -159,7 +160,11 @@ private void FeaturesListControl_SelectionChanged(object sender, CustomItem e) } case "Compress": { - System.Diagnostics.Process.Start("https://www.compdf.com/contact-sales"); + CompressDialog compressDialog = new CompressDialog() + { + Owner = parentWindow + }; + compressDialog.ShowDialog(); break; } case "Measurement": @@ -167,6 +172,7 @@ private void FeaturesListControl_SelectionChanged(object sender, CustomItem e) OpenFileEvent?.Invoke(this, new OpenFileEventArgs(FileOperationType.OpenFileDirectly, MeasurementFileName, e.Feature)); break; } + default: break; } @@ -192,6 +198,7 @@ private void CreateCustomItems() { customItems = new List() { + new CustomItem{ IconCanvas = compressCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Compress"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Compress"), Feature = "Compress"}, new CustomItem{ IconCanvas = viewerCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Viewer"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Viewer"), Feature = "Viewer"}, new CustomItem{ IconCanvas = annotationsCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Annotations"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Annotations"), Feature = "Annotations"}, new CustomItem{ IconCanvas = formsCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Forms"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Forms"), Feature = "Forms"}, @@ -203,7 +210,6 @@ private void CreateCustomItems() new CustomItem{ IconCanvas = redactionCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Redaction"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Redaction"), Feature = "Redaction"}, new CustomItem{ IconCanvas = compareDocumentsCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_DocCompare"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_DocCompare"), Feature = "Compare Documents"}, new CustomItem{ IconCanvas = conversionCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Conversion"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Conversion"), Feature = "Conversion"}, - new CustomItem{ IconCanvas = compressCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Compress"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Compress"), Feature = "Compress"}, new CustomItem{ IconCanvas = measurementCanvas,TitleText = LanguageHelper.CommonManager.GetString("Func_Measurement"), DescriptionText= LanguageHelper.CommonManager.GetString("FuncDetail_Measurement"), Feature = "Measurement"}, }; } diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PasswordControl/PasswordWindow.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PasswordControl/PasswordWindow.xaml.cs index 7e117c9..931d7fe 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PasswordControl/PasswordWindow.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PasswordControl/PasswordWindow.xaml.cs @@ -23,6 +23,8 @@ public partial class PasswordWindow : Window public delegate void DialogCloseEventHandler(object sender, PasswordEventArgs e); public event DialogCloseEventHandler DialogClosed; + public string Password { get; private set; } + public PasswordWindow() { InitializeComponent(); @@ -67,6 +69,7 @@ private void PasswordDialog_Confirmed(object sender, string e) if (pdfDoc.IsLocked == false) { PasswordEventArgs passwordEventArgs = new PasswordEventArgs(e); + Password = e; CloseWindow(passwordEventArgs); } else @@ -81,6 +84,7 @@ private void PasswordDialog_Confirmed(object sender, string e) if(pdfDoc.CheckOwnerPassword(e)) { PasswordEventArgs passwordEventArgs = new PasswordEventArgs(e); + Password = e; CloseWindow(passwordEventArgs); } else diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PropertyControl/ColorPickerControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PropertyControl/ColorPickerControl.xaml.cs index 9fd04a9..c51725e 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PropertyControl/ColorPickerControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PropertyControl/ColorPickerControl.xaml.cs @@ -25,8 +25,7 @@ public Visibility TransparentBtnProperty // Using a DependencyProperty as the backing store for TransparentBtnProperty. This enables animation, styling, binding, etc... public static readonly DependencyProperty TransparentBtnPropertyProperty = DependencyProperty.Register("TransparentBtnProperty", typeof(Visibility), typeof(ColorPickerControl), new PropertyMetadata(Visibility.Visible)); - - + public void SetIsChecked(int index) { switch (index) @@ -97,7 +96,7 @@ public List GetButtonColor() public bool GetTransparentBtnVisibility() { - if (TransparentBtn.Visibility == Visibility.Visible) + if (TransparentBtnProperty == Visibility.Visible) { return true; } diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PropertyControl/PDFLineStyle/CPDFCloudStyleControl.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PropertyControl/PDFLineStyle/CPDFCloudStyleControl.xaml new file mode 100644 index 0000000..13d4d18 --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PropertyControl/PDFLineStyle/CPDFCloudStyleControl.xaml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PropertyControl/PDFLineStyle/CPDFCloudStyleControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PropertyControl/PDFLineStyle/CPDFCloudStyleControl.xaml.cs new file mode 100644 index 0000000..7521daa --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Common/PropertyControl/PDFLineStyle/CPDFCloudStyleControl.xaml.cs @@ -0,0 +1,102 @@ +using ComPDFKit.PDFAnnotation; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace ComPDFKit.Controls.Common +{ + /// + /// Interaction logic for CPDFCloudStyleControl.xaml + /// + public partial class CPDFCloudStyleControl : UserControl + { + private const string streat = "Streat"; + private const string cloud1 = "Cloud1"; + private const string cloud2 = "Cloud2"; + + private bool isChecked = false; + + public event EventHandler LineShapeChanged; + + private CPDFBorderEffector _borderEffector = new CPDFBorderEffector(C_BORDER_TYPE.C_BORDER_TYPE_Cloud, C_BORDER_INTENSITY.C_INTENSITY_TWO); + public CPDFBorderEffector BorderEffector + { + get + { + return _borderEffector; + } + set + { + _borderEffector = value; + + rdoStreat.Checked -= rdoShape_Checked; + rdoCloud1.Checked -= rdoShape_Checked; + rdoCloud2.Checked -= rdoShape_Checked; + + if (_borderEffector == null) + { + rdoStreat.IsChecked = true; + } + else if (_borderEffector.BorderType == C_BORDER_TYPE.C_BORDER_TYPE_Cloud) + { + if (_borderEffector.BorderIntensity == C_BORDER_INTENSITY.C_INTENSITY_TWO) + { + rdoCloud1.IsChecked = true; + } + else if (_borderEffector.BorderIntensity == C_BORDER_INTENSITY.C_INTENSITY_ONE) + { + rdoCloud2.IsChecked = true; + } + else + { + rdoStreat.IsChecked = true; + } + } + else + { + rdoStreat.IsChecked = true; + } + + // 恢复事件处理程序 + rdoStreat.Checked += rdoShape_Checked; + rdoCloud1.Checked += rdoShape_Checked; + rdoCloud2.Checked += rdoShape_Checked; + } + } + + public CPDFCloudStyleControl() + { + DataContext = this; + InitializeComponent(); + } + + private void rdoShape_Checked(object sender, RoutedEventArgs e) + { + switch ((sender as RadioButton).Tag) + { + case streat: + BorderEffector = new CPDFBorderEffector(C_BORDER_TYPE.C_BORDER_TYPE_STRAIGHT, C_BORDER_INTENSITY.C_INTENSITY_ZERO); + break; + case cloud1: + BorderEffector = new CPDFBorderEffector(C_BORDER_TYPE.C_BORDER_TYPE_Cloud, C_BORDER_INTENSITY.C_INTENSITY_TWO); + break; + case cloud2: + BorderEffector = new CPDFBorderEffector(C_BORDER_TYPE.C_BORDER_TYPE_Cloud, C_BORDER_INTENSITY.C_INTENSITY_ONE); + break; + } + LineShapeChanged?.Invoke(this, BorderEffector); + } + } +} diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Compdfkit.Controls.csproj b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Compdfkit.Controls.csproj index a5eeab8..53b1ab6 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Compdfkit.Controls.csproj +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Compdfkit.Controls.csproj @@ -87,11 +87,17 @@ true - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll + + + ..\packages\WindowsAPICodePack-Core.1.1.1\lib\Microsoft.WindowsAPICodePack.dll + + + ..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll ..\packages\Nager.Country.4.0.0\lib\netstandard2.0\Nager.Country.dll @@ -141,6 +147,9 @@ ReplyStatusControl.xaml + + CPDFCloudUI.xaml + CPDFFreehandUI.xaml @@ -179,6 +188,7 @@ MatrixRadioControl.xaml + PageNumberControl.xaml @@ -286,6 +296,9 @@ CPDFFontUI.xaml + + CPDFCloudStyleControl.xaml + CPDFLocationControl.xaml @@ -316,6 +329,9 @@ WritableComboBoxControl.xaml + + CompressDialog.xaml + AddCertificationControl.xaml @@ -389,6 +405,12 @@ CPDFImageRotateUI.xaml + + PDFPathEditControl.xaml + + + CPDFTextMarkupUI.xaml + PDFTextEditControl.xaml @@ -573,6 +595,14 @@ CPDFScalingUI.xaml + + SnapshotMenu.xaml + + + True + True + Compress.resx + FileGridListWithPageRangeControl.xaml @@ -646,9 +676,11 @@ ResXFileCodeGenerator Bota.Designer.cs + Designer Bota.resx + Designer ResXFileCodeGenerator @@ -656,6 +688,14 @@ Common.resx + Designer + + + ResXFileCodeGenerator + Compress.Designer.cs + + + Compress.resx ResXFileCodeGenerator @@ -667,7 +707,6 @@ ResXFileCodeGenerator DocInfo.Designer.cs - Designer DocInfo.resx @@ -678,6 +717,7 @@ PropertyPanel.resx + Designer ResXFileCodeGenerator @@ -788,6 +828,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -983,6 +1027,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -1023,6 +1071,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -1104,6 +1156,14 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -1310,6 +1370,10 @@ MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -1350,11 +1414,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Compress/CompressDialog.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Compress/CompressDialog.xaml new file mode 100644 index 0000000..2fc2172 --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Compress/CompressDialog.xaml @@ -0,0 +1,447 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Compress/CompressDialog.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Compress/CompressDialog.xaml.cs new file mode 100644 index 0000000..1fd4267 --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Compress/CompressDialog.xaml.cs @@ -0,0 +1,778 @@ +using ComPDFKit.Controls.Common; +using ComPDFKit.Controls.Helper; +using ComPDFKit.PDFDocument; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Drawing; +using System.IO; +using System.Text.RegularExpressions; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Interop; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using DragEventArgs = System.Windows.DragEventArgs; +using Microsoft.WindowsAPICodePack.Dialogs; +using System.Threading.Tasks; +using System.Globalization; +using System.Windows.Data; + +namespace ComPDFKit.Controls.Compress +{ + public partial class CompressDialog : Window + { + private CPDFDocument tempDocument; + private List pathlist = new List(); + private float quality = 45; + private int compressindex = -1; + private IntPtr compressingIntpr = IntPtr.Zero; + private string compressingfilepath = ""; + private CPDFDocument.GetPageIndexDelegate indexDelegate = null; + private delegate void RefreshPageIndex(int pageIndex); + private bool stopClose = false; + private bool isCanceled = false; + + public ObservableCollection CompressDatas { get; set; } + + public CompressDialog() + { + InitializeComponent(); + SetLangText(); + rbtnMedium.IsChecked = true; + CompressDatas = new ObservableCollection(); + CompressListView.ItemsSource = CompressDatas; + } + + private BitmapSource GetImagePath(string filePath, out IntPtr bitmapHandle) + { + try + { + Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(filePath); + Bitmap bitmap = ico.ToBitmap(); + + bitmapHandle = bitmap.GetHbitmap(); + BitmapSource bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(bitmapHandle, IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); + return bitmapSource; + } + catch + { + bitmapHandle = IntPtr.Zero; + return null; + } + } + + private void SetLangText() + { + this.Title = LanguageHelper.CompressManager.GetString("CompressStr"); + btnAddFile.Content = LanguageHelper.CompressManager.GetString("Main_AddFile"); + + btnRemove.Content = LanguageHelper.CompressManager.GetString("Main_RemoveAll"); + btnMoveUp.Content = LanguageHelper.CompressManager.GetString("Merge_MoveUp"); + btnMoveDown.Content = LanguageHelper.CompressManager.GetString("Merge_MoveDown"); + btnCompress.Content = LanguageHelper.CompressManager.GetString("CompressStr"); + btnCancel.Content = LanguageHelper.CompressManager.GetString("Main_Cancel"); + + groupBox1Text.Text = LanguageHelper.CompressManager.GetString("Compress_OptimizationQuality"); + rbtnLow.Content = LanguageHelper.CompressManager.GetString("Compress_Low"); + rbtnMedium.Content = LanguageHelper.CompressManager.GetString("Compress_Medium"); + rbtnMedium.IsChecked = true; + rbtnHigh.Content = LanguageHelper.CompressManager.GetString("Compress_High"); + rbtnCustom.Content = LanguageHelper.CompressManager.GetString("Compress_Custom"); + + PathHeader.Header = LanguageHelper.CompressManager.GetString("FileInfo_Location"); + ProgressHeader.Header = LanguageHelper.CompressManager.GetString("Convert_Progress"); + FileName.Header = LanguageHelper.CompressManager.GetString("Main_FileName"); + SizeHeader.Header = LanguageHelper.CompressManager.GetString("FileInfo_Size"); + + lbTotalFiles.Content = string.Format(LanguageHelper.CompressManager.GetString("Merge_TotalPage"), 0); + } + + private void btnAddFile_Click(object sender, RoutedEventArgs e) + { + OpenFileDialog file = new OpenFileDialog(); + file.Multiselect = true; + file.Filter = "PDF Files (*.pdf)|*.pdf"; + if (file.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + var files = file.FileNames; + for (int i = 0; i < files.Length; i++) + { + AddFiletoList(files[i]); + } + + UpdateMoveButtonState(); + } + } + + private void AddFiletoList(string filePath) + { + string password = ""; + if (pathlist.Contains(filePath) || Path.GetExtension(filePath).ToLower() != ".pdf") + { + return; + } + + CPDFDocument doc = CPDFDocument.InitWithFilePath(filePath); + if (doc == null) + { + MessageBoxEx.Show(LanguageHelper.CompressManager.GetString("Main_OpenFileFailedWarning")); + return; + } + + if (doc.IsLocked) + { + PasswordWindow passwordWindow = new PasswordWindow(); + passwordWindow.InitDocument(doc); + passwordWindow.Owner = Window.GetWindow(this); + passwordWindow.PasswordDialog.SetShowText(filePath + " is encrypted."); + passwordWindow.ShowDialog(); + if (doc.IsLocked) + { + doc.Release(); + return; + } + + password = passwordWindow.Password; + } + + pathlist.Add(filePath); + BitmapSource bitmapSource = GetImagePath(doc.FilePath, out IntPtr bitmapHandle); + CompressDataItem newdata = new CompressDataItem() + { + Name = doc.FileName, + Size = CommonHelper.GetFileSize(filePath), + Progress = "0/" + doc.PageCount, + Path = doc.FilePath, + PageCount = doc.PageCount, + ImagePath = bitmapSource + + }; + AddListViewItem(newdata, password); + doc.Release(); + UpdateTotalCount(); + } + + private void UpdateTotalCount() + { + lbTotalFiles.Content = string.Format(LanguageHelper.CompressManager.GetString("Merge_TotalPage"), CompressListView.Items.Count); + if (CompressListView.Items.Count == 0) + btnCompress.IsEnabled = false; + else + btnCompress.IsEnabled = true; + } + + private void AddListViewItem(CompressDataItem data, string password) + { + if (!string.IsNullOrEmpty(password)) + data.PassWord = password; + + CompressDatas.Add(data); + UpdateTotalCount(); + } + + private void btnRemove_Click(object sender, RoutedEventArgs e) + { + if (CompressListView.SelectedItems.Count > 0) + { + List pages = new List(); + foreach (var selectedItem in CompressListView.SelectedItems) + { + var imageItem = (CompressDataItem)selectedItem; + int index = CompressListView.Items.IndexOf(imageItem); + pages.Add(index); + } + pages.Sort(); + + for (int i = pages.Count - 1; i >= 0; i--) + { + int index = pages[i]; + string path = ((CompressDataItem)CompressListView.Items[index]).Path; + pathlist.Remove(path); + CompressDatas.RemoveAt(index); + } + } + else + { + CompressDatas.Clear(); + pathlist.Clear(); + } + UpdateTotalCount(); + } + + private void btnChoosePage_Click(object sender, RoutedEventArgs e) + { + + } + + private async void btnCompress_Click(object sender, RoutedEventArgs e) + { + if ((bool)rbtnLow.IsChecked) + quality = 10; + else if ((bool)rbtnMedium.IsChecked) + quality = 40; + else if ((bool)rbtnHigh.IsChecked) + quality = 80; + else + { + int q = 0; + bool r = int.TryParse(txtQuality.Text, out q); + if (!r || q > 100 || q < 0) + { + MessageBoxEx.Show(LanguageHelper.CompressManager.GetString("Compress_NumberErrorWarning")); + txtQuality.Focus(); + return; + } + quality = q; + } + + CommonOpenFileDialog commonFileDialog = new CommonOpenFileDialog(LanguageHelper.CompressManager.GetString("Main_OpenFolderNoteWarning")); + commonFileDialog.IsFolderPicker = true; + if (commonFileDialog.ShowDialog() == CommonFileDialogResult.Ok) + { + if (string.IsNullOrEmpty(commonFileDialog.FileName)) + { + MessageBoxEx.Show(LanguageHelper.CompressManager.GetString("Main_NoSelectedFilesWarning"), + LanguageHelper.CompressManager.GetString("Main_HintWarningTitle"), + MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); + return; + } + } + else + return; + + stopClose = true; + groupBox1.IsEnabled = false; + btnAddFile.IsEnabled = false; + btnCompress.IsEnabled = false; + btnRemove.Content = LanguageHelper.CompressManager.GetString("Main_RemoveAll"); + btnRemove.IsEnabled = false; + btnMoveDown.IsEnabled = false; + btnMoveUp.IsEnabled = false; + bool isFailed = false; + string selectedFile = ""; + for (int i = 0; i < CompressListView.Items.Count; i++) + { + var item = (CompressDataItem)CompressListView.Items[i]; + string path = item.Path; + if (isCanceled) + { + item.Progress = LanguageHelper.CompressManager.GetString("Main_Interrupt"); + continue; + } + + CPDFDocument doc = CPDFDocument.InitWithFilePath(path); + if (doc.IsLocked && item.PassWord != null && !string.IsNullOrEmpty(item.PassWord)) + { + doc.UnlockWithPassword(item.PassWord.ToString()); + } + + var filename = doc.FileName + " compressed"; + var filepath = commonFileDialog.FileName + "\\" + filename + ".pdf"; + filepath = CommonHelper.CreateFilePath(filepath); + selectedFile = compressingfilepath = filepath; + + indexDelegate += GetIndex; + compressingIntpr = doc.CompressFile_Init(quality, indexDelegate); + GC.KeepAlive(indexDelegate); + compressindex = i; + tempDocument = doc; + var r = await Task.Run(() => { return doc.CompressFile_Start(compressingIntpr, filepath); }); + if (!r) + { + item.Progress = LanguageHelper.CompressManager.GetString("Main_FailedState"); + doc.Release(); + if (File.Exists(filepath)) + File.Delete(filepath); + isFailed = true; + continue; + } + compressingfilepath = ""; + doc.Release(); + } + + int itemCount = CompressListView.Items.Count; + if (!isFailed) + { + System.Diagnostics.Process.Start("explorer", "/select,\"" + selectedFile + "\""); + } + + isCanceled = false; + compressindex = -1; + stopClose = false; + btnAddFile.IsEnabled = true; + btnCompress.IsEnabled = true; + btnRemove.Content = LanguageHelper.CompressManager.GetString("Main_Delete"); + btnRemove.IsEnabled = true; + btnMoveDown.IsEnabled = true; + btnMoveUp.IsEnabled = true; + groupBox1.IsEnabled = true; + } + + private int GetIndex(int pageindex) + { + try + { + if (Dispatcher.CheckAccess() == false) + { + return Dispatcher.Invoke(new CPDFDocument.GetPageIndexDelegate(delegate (int s) + { + if (CompressListView.Items.Count >= compressindex) + { + if (CompressListView.Items[compressindex] is CompressDataItem dataItem) + { + dataItem.Progress = pageindex + "/" + dataItem.PageCount; + if (pageindex == dataItem.PageCount - 1) + { + dataItem.Progress = LanguageHelper.CompressManager.GetString("Main_CompletedState"); + } + } + } + return 0; + }), pageindex).ToString().Length; + } + else + { + if (CompressListView.Items.Count >= compressindex) + { + if (CompressListView.Items[compressindex] is CompressDataItem dataItem) + { + dataItem.Progress = pageindex + "/" + dataItem.PageCount; + if (pageindex == dataItem.PageCount - 1) + { + dataItem.Progress = LanguageHelper.CompressManager.GetString("Main_CompletedState"); + } + } + } + return 0; + } + } + catch { return -1; } + } + + private void btnCancel_Click(object sender, RoutedEventArgs e) + { + try + { + if (compressindex != -1 && !compressingIntpr.Equals(IntPtr.Zero)) + { + if (MessageBoxEx.Show(LanguageHelper.CompressManager.GetString("CompressInterruptWarning"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes && tempDocument != null) + { + tempDocument.CompressFile_Cancel(compressingIntpr); + isCanceled = true; + if (File.Exists(compressingfilepath)) + File.Delete(compressingfilepath); + } + } + else + { + this.Close(); + this.DialogResult = false; + } + } + catch { } + } + + private void ConverterListView_DragOver(object sender, DragEventArgs e) + { + var files = (Array)e.Data.GetData(System.Windows.DataFormats.FileDrop); + int count = 0; + string pdf = "pdf"; + foreach (string file in files) + { + string text = Path.GetExtension(file); + if (text.IndexOf(pdf, StringComparison.OrdinalIgnoreCase) >= 0) + { + count++; + } + } + if (count < 1) + { + e.Effects = System.Windows.DragDropEffects.None; + Mouse.SetCursor(System.Windows.Input.Cursors.No); + } + else + { + e.Effects = System.Windows.DragDropEffects.Copy; + Mouse.SetCursor(System.Windows.Input.Cursors.Arrow); + } + + return; + } + + private void ConverterListView_Drop(object sender, DragEventArgs e) + { + var files = (Array)e.Data.GetData(System.Windows.DataFormats.FileDrop); + if (files != null && files.Length > 0) + { + var Files = (string[])files; + for (int i = 0; i < Files.Length; i++) + { + AddFiletoList(Files[i]); + } + } + } + + private void ConverterListView_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) + { + + } + + private void ConverterListView_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + DependencyObject element = (DependencyObject)e.OriginalSource; + if (element is Thumb thumb) + { + GridViewColumnHeader gridViewColumnHeader = CommonHelper.ViewportHelper.FindVisualParent(thumb); + if (gridViewColumnHeader != null && gridViewColumnHeader.Content != null) + { + GridViewColumn column = FindGridViewColumn(gridViewColumnHeader.Content.ToString(), CompressListView); + if (column != null) + { + if (column.Header == LanguageHelper.CompressManager.GetString("Main_FileName") && column.ActualWidth > 240) + { + TextBlock textBlock = FindTextBlockInCellTemplate(column); + if (textBlock != null) + { + textBlock.MaxWidth = textBlock.Width = column.ActualWidth - 20; + TxbName_SizeChanged(textBlock, null); + } + } + } + } + } + } + + private TextBlock FindTextBlockInCellTemplate(GridViewColumn column) + { + DataTemplate dataTemplate = column.CellTemplate; + if (dataTemplate != null) + { + FrameworkElement frameworkElement = dataTemplate.LoadContent() as FrameworkElement; + if (frameworkElement != null) + { + return CommonHelper.ViewportHelper.FindVisualChild(frameworkElement); + } + } + + return null; + } + + private GridViewColumn FindGridViewColumn(string columnHeader, System.Windows.Controls.ListView listView) + { + GridView gridView = listView.View as GridView; + if (gridView != null) + { + foreach (var column in gridView.Columns) + { + GridViewColumn gvColumn = column as GridViewColumn; + if (gvColumn != null && gvColumn.Header.ToString() == columnHeader) + { + return gvColumn; + } + } + } + + return null; + } + + private void UpdateMoveButtonState() + { + if (compressindex != -1 && !compressingIntpr.Equals(IntPtr.Zero)) + { + return; + } + + if (CompressListView.Items.Count > 0 && CompressListView.SelectedItems.Count > 0) + { + btnRemove.Content = LanguageHelper.CompressManager.GetString("Main_Delete"); ; + int count = CompressListView.Items.Count; + if (CompressListView.SelectedItems.Contains(CompressListView.Items[CompressListView.Items.Count - 1])) + { + btnMoveDown.IsEnabled = false; + } + else + btnMoveDown.IsEnabled = true; + if (CompressListView.SelectedItems.Contains(CompressListView.Items[0])) + btnMoveUp.IsEnabled = false; + else + btnMoveUp.IsEnabled = true; + } + else + { + btnRemove.Content = LanguageHelper.CompressManager.GetString("Main_RemoveAll"); + btnMoveDown.IsEnabled = false; + btnMoveUp.IsEnabled = false; + } + } + + private void ConverterListView_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + UpdateMoveButtonState(); + } + private void UpdateColumnsWidth(System.Windows.Controls.ListView listView) + { + int autoFillColumnIndex = (listView.View as System.Windows.Controls.GridView).Columns.Count - 1; + if (listView.ActualWidth == Double.NaN) + { + listView.Measure(new System.Windows.Size(Double.PositiveInfinity, Double.PositiveInfinity)); + } + double remainingSpace = listView.ActualWidth; + for (int i = 0; i < (listView.View as System.Windows.Controls.GridView).Columns.Count; i++) + { + if (i != autoFillColumnIndex) + { + remainingSpace -= (listView.View as System.Windows.Controls.GridView).Columns[i].ActualWidth; + (listView.View as System.Windows.Controls.GridView).Columns[autoFillColumnIndex].Width = remainingSpace >= 0 ? remainingSpace : 0; + } + } + } + + private void ConverterListView_Loaded(object sender, RoutedEventArgs e) + { + UpdateColumnsWidth(sender as System.Windows.Controls.ListView); + } + + private void ConverterListView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + var pos = e.GetPosition(CompressListView); + var result = VisualTreeHelper.HitTest(CompressListView, pos); + if (result != null) + { + var listBoxItem = CommonHelper.ViewportHelper.FindVisualParent(result.VisualHit); + if (listBoxItem == null) + { + CompressListView.SelectedItems.Clear(); + } + } + CompressListView.Focus(); + } + + private void ConverterListView_SizeChanged(object sender, SizeChangedEventArgs e) + { + UpdateColumnsWidth(sender as System.Windows.Controls.ListView); + } + + private void TxbName_SizeChanged(object sender, SizeChangedEventArgs e) + { + + } + + private void PART_HeaderGripper_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) + { + + } + + private void rbtnAllPage_Checked(object sender, RoutedEventArgs e) + { + + } + + private void rbtnCurrentPage_Checked(object sender, RoutedEventArgs e) + { + + } + + private void rbtnOldPageOnly_Checked(object sender, RoutedEventArgs e) + { + + } + + private void RbtnEvenPageOnly_Checked(object sender, RoutedEventArgs e) + { + + } + + public class CompressDataItem : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + private string passWord; + + public string PassWord { get; set; } + + public BitmapSource ImagePath { get; set; } + + public string Name { get; set; } + public string Size { get; set; } + + public string Path { get; set; } + public int PageCount { get; set; } + + private string progress; + + public string Progress + { + get { return progress; } + set + { + progress = value; + OnPropertyChanged("Progress"); + } + } + } + + private void btnMoveDown_Click(object sender, RoutedEventArgs e) + { + try + { + var items = CompressListView.SelectedItems; + if (items.Count > 0) + { + List indexs = new List(); + foreach (var selectedItem in CompressListView.SelectedItems) + { + var imageItem = (CompressDataItem)selectedItem; + int index = CompressListView.Items.IndexOf(imageItem); + indexs.Add(index); + } + + indexs.Sort(); + for (int i = 0; i < indexs.Count; i++) + { + var index = indexs[indexs.Count - 1 - i]; + var item = CompressDatas[index]; + CompressDatas.RemoveAt(index); + CompressDatas.Insert(index + 1, item); + } + + CompressListView.SelectedItems.Clear(); + + for (int i = 0; i < indexs.Count; i++) + { + CompressListView.SelectedItems.Add(CompressListView.Items[indexs[i] + 1]); + } + } + } + catch (Exception ex) + { + } + } + + private void btnMoveUp_Click(object sender, RoutedEventArgs e) + { + try + { + var items = CompressListView.SelectedItems; + if (items.Count > 0) + { + List indexs = new List(); + foreach (var selectedItem in CompressListView.SelectedItems) + { + var imageItem = (CompressDataItem)selectedItem; + int index = CompressListView.Items.IndexOf(imageItem); + indexs.Add(index); + } + indexs.Sort(); + + for (int i = 0; i < indexs.Count; i++) + { + var index = indexs[i]; + var item = CompressDatas[index]; + CompressDatas.RemoveAt(index); + CompressDatas.Insert(index - 1, item); + } + + CompressListView.SelectedItems.Clear(); + + for (int i = 0; i < indexs.Count; i++) + { + CompressListView.SelectedItems.Add(CompressListView.Items[indexs[i] - 1]); + } + } + } + catch (Exception ex) + { + + } + } + + private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e) + { + Regex regex = new Regex("[^0-9]+"); + if (regex.IsMatch(e.Text)) + { + e.Handled = true; + } + } + + private void TextBox_TextChanged(object sender, TextChangedEventArgs e) + { + if (sender is System.Windows.Controls.TextBox textBox) + { + if (!string.IsNullOrEmpty(textBox.Text)) + { + int value = int.Parse(textBox.Text); + + if (value < 1) + { + textBox.Text = "1"; + textBox.Select(textBox.Text.Length, 0); + } + else if (value > 100) + { + textBox.Text = "100"; + textBox.Select(textBox.Text.Length, 0); + } + } + else + { + textBox.Text = "1"; + textBox.Select(textBox.Text.Length, 0); + } + } + } + } + + public class MaxWidthToTextTrimmingConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values.Length == 2 && values[0] is double maxWidth && values[1] is string text) + { + if (maxWidth >= MeasureTextWidth(text)) + { + return TextTrimming.None; + } + else + { + return TextTrimming.CharacterEllipsis; + } + } + + return TextTrimming.None; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotSupportedException(); + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + + private double MeasureTextWidth(string text) + { + var formattedText = new FormattedText( + text, + CultureInfo.CurrentCulture, + System.Windows.FlowDirection.LeftToRight, + new Typeface("Arial"), + 12, + System.Windows.Media.Brushes.Black); + + return formattedText.WidthIncludingTrailingWhitespace; + } + } +} diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/ContentEditCOntrol/ContentEditControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/ContentEditCOntrol/ContentEditControl.xaml.cs index 3ad8ad0..ba9e5e3 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/ContentEditCOntrol/ContentEditControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/ContentEditCOntrol/ContentEditControl.xaml.cs @@ -28,6 +28,7 @@ using OpenFileDialog = Microsoft.Win32.OpenFileDialog; using UserControl = System.Windows.Controls.UserControl; using System.Linq; +using ComPDFKit.Tool.UndoManger; namespace ComPDFKit.Controls.PDFControl { @@ -152,7 +153,7 @@ public void ClearPDFEditState(ToggleButton ignoreBtn = null) } PdfViewControl.PDFToolManager.SetCreateContentEditType(CPDFEditType.None); - PdfViewControl.PDFViewTool.SetCurrentEditType(CPDFEditType.EditText | CPDFEditType.EditImage); + PdfViewControl.PDFViewTool.SetCurrentEditType(CPDFEditType.EditText | CPDFEditType.EditImage | CPDFEditType.EditPath); PdfViewControl.PDFViewTool.GetCPDFViewer().SetIsVisibleCustomMouse(false); PdfViewControl.PDFViewTool.GetCPDFViewer().SetIsShowStampMouse(false); PdfViewControl.PDFViewTool.SelectedEditAreaForIndex(-1, -1); @@ -253,33 +254,69 @@ public void PDFView_KeyDown(object sender, KeyEventArgs e) return; } + Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame()); + if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control) && Keyboard.Modifiers.HasFlag(ModifierKeys.Alt)) + { + if(e.Key == Key.S) + { + bool result = textArea.AddStrikethrough(); + if (result) + { + PDFEditHistory editHistory = new PDFEditHistory(); + CPDFPage page = PdfViewControl.PDFViewTool.GetCPDFViewer().GetDocument().PageAtIndex(pageIndex); + editHistory.EditPage = page.GetEditPage(); + editHistory.PageIndex = pageIndex; + PdfViewControl.PDFViewTool.GetCPDFViewer().UndoManager.AddHistory(editHistory); + UpdateEditArea(oldRect, textArea); + } + + e.Handled = true; + } + } + if (Keyboard.Modifiers == ModifierKeys.Control) { if (e.Key == Key.Left) { textArea.GetPreWordCharPlace(); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } if (e.Key == Key.Right) { textArea.GetNextWordCharPlace(); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } if (e.Key == Key.Up) { textArea.GetSectionBeginCharPlace(); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } if (e.Key == Key.Down) { textArea.GetSectionEndCharPlace(); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); + e.Handled = true; + } + + if (e.Key == Key.U) + { + bool result = textArea.AddUnderline(); + if(result) + { + PDFEditHistory editHistory = new PDFEditHistory(); + CPDFPage page = PdfViewControl.PDFViewTool.GetCPDFViewer().GetDocument().PageAtIndex(pageIndex); + editHistory.EditPage = page.GetEditPage(); + editHistory.PageIndex = pageIndex; + PdfViewControl.PDFViewTool.GetCPDFViewer().UndoManager.AddHistory(editHistory); + UpdateEditArea(oldRect, textArea); + } + e.Handled = true; } } @@ -296,7 +333,7 @@ public void PDFView_KeyDown(object sender, KeyEventArgs e) textArea.GetPrevCharPlace(); endPoint = GetPoint(textArea); textArea.GetSelectChars(startPoint, endPoint); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } @@ -305,7 +342,7 @@ public void PDFView_KeyDown(object sender, KeyEventArgs e) textArea.GetNextCharPlace(); endPoint = GetPoint(textArea); textArea.GetSelectChars(startPoint, endPoint); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } @@ -314,7 +351,7 @@ public void PDFView_KeyDown(object sender, KeyEventArgs e) textArea.GetUpCharPlace(); endPoint = GetPoint(textArea); textArea.GetSelectChars(startPoint, endPoint); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } @@ -323,7 +360,7 @@ public void PDFView_KeyDown(object sender, KeyEventArgs e) textArea.GetDownCharPlace(); endPoint = GetPoint(textArea); textArea.GetSelectChars(startPoint, endPoint); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } } @@ -333,14 +370,14 @@ public void PDFView_KeyDown(object sender, KeyEventArgs e) if (e.SystemKey == Key.Up) { textArea.GetLineBeginCharPlace(); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } if (e.SystemKey == Key.Down) { textArea.GetLineEndCharPlace(); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } } @@ -390,7 +427,7 @@ public void PDFView_KeyDown(object sender, KeyEventArgs e) textArea.GetPreWordCharPlace(); endPoint = GetPoint(textArea); textArea.GetSelectChars(startPoint, endPoint); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } @@ -399,7 +436,7 @@ public void PDFView_KeyDown(object sender, KeyEventArgs e) textArea.GetNextWordCharPlace(); endPoint = GetPoint(textArea); textArea.GetSelectChars(startPoint, endPoint); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } @@ -408,7 +445,7 @@ public void PDFView_KeyDown(object sender, KeyEventArgs e) textArea.GetSectionBeginCharPlace(); endPoint = GetPoint(textArea); textArea.GetSelectChars(startPoint, endPoint); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } @@ -417,7 +454,7 @@ public void PDFView_KeyDown(object sender, KeyEventArgs e) textArea.GetSectionEndCharPlace(); endPoint = GetPoint(textArea); textArea.GetSelectChars(startPoint, endPoint); - UpdateTextArea(textArea); + UpdateEditArea(oldRect, textArea); e.Handled = true; } } @@ -499,7 +536,6 @@ private void PDFTextEditButton_Click(object sender, RoutedEventArgs e) PdfViewControl.PDFViewTool.SetCurrentEditType(CPDFEditType.EditText); } } - } private void PDFImageEditButton_Click(object sender, RoutedEventArgs e) @@ -534,6 +570,8 @@ private void UndoBtn_Click(object sender, RoutedEventArgs e) if (PdfViewControl != null && PdfViewControl.PDFViewTool != null) { PdfViewControl.PDFViewTool.GetCPDFViewer()?.UndoManager?.Undo(); + PdfViewControl.PDFViewTool.SelectedEditAreaForIndex(-1, -1, false); + PdfViewControl.PDFViewTool.ClearLastSelectChars(); PdfViewControl.PDFViewTool.GetCPDFViewer().UpdateRenderFrame(); } } @@ -543,6 +581,8 @@ private void RedoBtn_Click(object sender, RoutedEventArgs e) if (PdfViewControl != null && PdfViewControl.PDFViewTool != null) { PdfViewControl.PDFViewTool.GetCPDFViewer()?.UndoManager?.Redo(); + PdfViewControl.PDFViewTool.SelectedEditAreaForIndex(-1, -1, false); + PdfViewControl.PDFViewTool.ClearLastSelectChars(); PdfViewControl.PDFViewTool.GetCPDFViewer().UpdateRenderFrame(); } } @@ -594,21 +634,11 @@ private CPoint GetPoint(CPDFEditTextArea textArea) } /// - /// Update the text appearance after the text area is changed - /// - private void UpdateTextArea(CPDFEditTextArea textArea) - { - Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame()); - PdfViewControl.PDFViewTool.UpdateRender(oldRect, textArea); - } - - /// - /// Update the image appearance after the image area is changed + /// Update the edit area appearance after the edit area is changed /// - private void UpdateImageArea(CPDFEditImageArea imageArea) + private void UpdateEditArea(Rect oldRect, CPDFEditArea editArea) { - Rect oldRect = DataConversionForWPF.CRectConversionForRect(imageArea.GetFrame()); - PdfViewControl.PDFViewTool.UpdateRender(oldRect, imageArea); + PdfViewControl.PDFViewTool.UpdateRender(oldRect, editArea); } private void PdfViewControl_MouseRightButtonDownHandler(object sender, MouseEventObject e) @@ -626,6 +656,9 @@ private void PdfViewControl_MouseRightButtonDownHandler(object sender, MouseEven case MouseHitTestType.ImageEdit: CreateImageEditMenu(sender, ref ContextMenu); break; + case MouseHitTestType.PathEdit: + CreatePathEditMenu(sender, ref ContextMenu); + break; case MouseHitTestType.Unknown: List pageInts = new List(); List editAreas = PdfViewControl.PDFToolManager.GetSelectedEditAreaListObject(ref pageInts); @@ -654,7 +687,6 @@ protected void OnPropertyChanged([CallerMemberName] string name = null) PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } - public void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e) { OnPropertyChanged(e.PropertyName); @@ -669,11 +701,15 @@ public void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs private void AppendOpacityMenu(MenuItem parentMenu, CPDFEditArea editArea, CPDFEditType editType) { + if (editArea == null) + return; + List opacityList = new List() { 25,50,75,100 }; + Rect oldRect = DataConversionForWPF.CRectConversionForRect(editArea.GetFrame()); foreach (int opacity in opacityList) { MenuItem opacityMenu = new MenuItem(); @@ -685,16 +721,22 @@ private void AppendOpacityMenu(MenuItem parentMenu, CPDFEditArea editArea, CPDFE CPDFEditImageArea editImageArea = editArea as CPDFEditImageArea; editImageArea?.SetImageTransparency((byte)Math.Ceiling(opacity * 255 / 100D)); pdfContentEditControl.RefreshThumb(); - UpdateImageArea(editImageArea); + UpdateEditArea(oldRect, editImageArea); } else if (editArea != null && editType == CPDFEditType.EditText) { CPDFEditTextArea editTextArea = editArea as CPDFEditTextArea; editTextArea?.SetCharsFontTransparency((byte)Math.Ceiling(opacity * 255 / 100D)); - pdfContentEditControl.RefreshThumb(); - UpdateTextArea(editTextArea); + UpdateEditArea(oldRect, editTextArea); + } + else if (editArea != null && editType == CPDFEditType.EditPath) + { + CPDFEditPathArea editPathArea = editArea as CPDFEditPathArea; + editPathArea?.SetTransparency((byte)Math.Ceiling(opacity * 255 / 100D)); + UpdateEditArea(oldRect, editPathArea); } }; + parentMenu.Items.Add(opacityMenu); } } @@ -732,6 +774,9 @@ private void PDFToolManager_MouseLeftButtonUpHandler(object sender, MouseEventOb else if (editAreas != null && editAreas.Count != 0) { List editTextAreas = editAreas.OfType().ToList(); + List editImageAreas = editAreas.OfType().ToList(); + List editPathAreas = editAreas.OfType().ToList(); + editTextAreas.ForEach(textArea => textArea.SelectAllChars()); if (editAreas.Count == editTextAreas.Count) { @@ -741,14 +786,22 @@ private void PDFToolManager_MouseLeftButtonUpHandler(object sender, MouseEventOb pdfContentEditControl.SetPDFTextEditData(editParams, true); PropertyContainer.Child = pdfContentEditControl; } - else if (editTextAreas.Count == 0) + else if (editAreas.Count == editImageAreas.Count) { - List editParams = editAreas. + List editParams = editImageAreas. Select(area => ParamConverter.CPDFDataConverterToPDFEitParam(PdfViewControl.PDFToolManager.GetDocument(), area, pageInts.FirstOrDefault())). Cast().ToList(); pdfContentEditControl.SetPDFImageEditData(editParams); PropertyContainer.Child = pdfContentEditControl; } + else if (editAreas.Count == editPathAreas.Count) + { + List editParams = editPathAreas. + Select(area => ParamConverter.CPDFDataConverterToPDFEitParam(PdfViewControl.PDFToolManager.GetDocument(), area, pageInts.FirstOrDefault())). + Cast().ToList(); + pdfContentEditControl.SetPDFPathEditData(editParams); + PropertyContainer.Child = pdfContentEditControl; + } else { pdfContentEditControl.ClearContentControl(); @@ -787,8 +840,7 @@ private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEvent pdfContentEditControl.SetPDFTextEditData(new List { (TextEditParam)pDFEditParam }, true); PropertyContainer.Child = pdfContentEditControl; } - - else if (editAreaArea.Type == CPDFEditType.EditImage && PdfViewControl != null) + else if (editAreaArea.Type == CPDFEditType.EditImage) { UIElement pageView = sender as UIElement; if (pageView != null) @@ -800,10 +852,17 @@ private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEvent pdfContentEditControl.SetPDFImageEditData(new List { (ImageEditParam)pDFEditParam }); PropertyContainer.Child = pdfContentEditControl; } - - else + else if (editAreaArea.Type == CPDFEditType.EditPath) { - + UIElement pageView = sender as UIElement; + if (pageView != null) + { + pageView.MouseLeftButtonUp -= PageView_MouseLeftButtonUp; + pageView.MouseLeftButtonUp += PageView_MouseLeftButtonUp; + } + PDFEditParam pDFEditParam = ParamConverter.CPDFDataConverterToPDFEitParam(PdfViewControl.PDFToolManager.GetDocument(), editAreaArea, pageIndex); + pdfContentEditControl.SetPDFPathEditData(new List { (PathEditParam)pDFEditParam }); + PropertyContainer.Child = pdfContentEditControl; } } } @@ -841,6 +900,7 @@ private void CommandBinding_Executed_Undo(object sender, ExecutedRoutedEventArgs if (PdfViewControl != null && PdfViewControl.PDFViewTool != null && CanUndo) { PdfViewControl.PDFViewTool.GetCPDFViewer()?.UndoManager?.Undo(); + PdfViewControl.PDFViewTool.GetCPDFViewer().UpdateRenderFrame(); } } @@ -849,6 +909,7 @@ private void CommandBinding_Executed_Redo(object sender, ExecutedRoutedEventArgs if (PdfViewControl != null && PdfViewControl.PDFViewTool != null && CanRedo) { PdfViewControl.PDFViewTool.GetCPDFViewer()?.UndoManager?.Redo(); + PdfViewControl.PDFViewTool.GetCPDFViewer().UpdateRenderFrame(); } } @@ -878,17 +939,22 @@ private void CreateImageEditMenu(object sender, ref ContextMenu menu) { int index = -1; CPDFEditImageArea imageArea = PdfViewControl.PDFToolManager.GetSelectedEditAreaObject(ref index) as CPDFEditImageArea; + if (imageArea == null) + return; + + menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender }); + menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender }); + menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender }); + menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender }); MenuItem rotateLeftMenu = new MenuItem(); rotateLeftMenu.Header = LanguageHelper.CommonManager.GetString("Menu_RotateLeft"); rotateLeftMenu.Click += (o, p) => { - if (imageArea != null) - { - imageArea.Rotate(-90); - pdfContentEditControl.RefreshThumb(); - UpdateImageArea(imageArea); - } + Rect oldRect = DataConversionForWPF.CRectConversionForRect(imageArea.GetFrame()); + imageArea.Rotate(90); + pdfContentEditControl.RefreshThumb(); + UpdateEditArea(oldRect,imageArea); }; menu.Items.Add(rotateLeftMenu); @@ -896,12 +962,10 @@ private void CreateImageEditMenu(object sender, ref ContextMenu menu) rotateRightMenu.Header = LanguageHelper.CommonManager.GetString("Menu_RotateRight"); rotateRightMenu.Click += (o, p) => { - if (imageArea != null) - { - imageArea.Rotate(90); + Rect oldRect = DataConversionForWPF.CRectConversionForRect(imageArea.GetFrame()); + imageArea.Rotate(-90); pdfContentEditControl.RefreshThumb(); - UpdateImageArea(imageArea); - } + UpdateEditArea(oldRect, imageArea); }; menu.Items.Add(rotateRightMenu); @@ -909,42 +973,40 @@ private void CreateImageEditMenu(object sender, ref ContextMenu menu) replaceMenu.Header = LanguageHelper.CommonManager.GetString("Menu_Replace"); replaceMenu.Click += (o, p) => { - if (imageArea != null) + OpenFileDialog openFileDialog = new OpenFileDialog(); + openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;"; + if (openFileDialog.ShowDialog() == true) { - OpenFileDialog openFileDialog = new OpenFileDialog(); - openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;"; - if (openFileDialog.ShowDialog() == true) - { - int imageWidth = 0; - int imageHeight = 0; - byte[] imageData = null; + int imageWidth = 0; + int imageHeight = 0; + byte[] imageData = null; - BitmapFrame frame = null; - BitmapDecoder decoder = BitmapDecoder.Create(new Uri(openFileDialog.FileName), BitmapCreateOptions.None, BitmapCacheOption.Default); - if (decoder.Frames.Count > 0) + BitmapFrame frame = null; + BitmapDecoder decoder = BitmapDecoder.Create(new Uri(openFileDialog.FileName), BitmapCreateOptions.None, BitmapCacheOption.Default); + if (decoder.Frames.Count > 0) + { + frame = decoder.Frames[0]; + } + if (frame != null) + { + imageData = new byte[frame.PixelWidth * frame.PixelHeight * 4]; + if (frame.Format != PixelFormats.Bgra32) { - frame = decoder.Frames[0]; + FormatConvertedBitmap covert = new FormatConvertedBitmap(frame, PixelFormats.Bgra32, frame.Palette, 0); + covert.CopyPixels(imageData, frame.PixelWidth * 4, 0); } - if (frame != null) + else { - imageData = new byte[frame.PixelWidth * frame.PixelHeight * 4]; - if (frame.Format != PixelFormats.Bgra32) - { - FormatConvertedBitmap covert = new FormatConvertedBitmap(frame, PixelFormats.Bgra32, frame.Palette, 0); - covert.CopyPixels(imageData, frame.PixelWidth * 4, 0); - } - else - { - frame.CopyPixels(imageData, frame.PixelWidth * 4, 0); - } - imageWidth = frame.PixelWidth; - imageHeight = frame.PixelHeight; + frame.CopyPixels(imageData, frame.PixelWidth * 4, 0); } - - imageArea.ReplaceImageArea(imageArea.GetFrame(), imageData, imageWidth, imageHeight); - pdfContentEditControl.RefreshThumb(); - UpdateImageArea(imageArea); + imageWidth = frame.PixelWidth; + imageHeight = frame.PixelHeight; } + + Rect oldRect = DataConversionForWPF.CRectConversionForRect(imageArea.GetFrame()); + imageArea.ReplaceImageArea(imageArea.GetFrame(), imageData, imageWidth, imageHeight); + pdfContentEditControl.RefreshThumb(); + UpdateEditArea(oldRect, imageArea); } }; menu.Items.Add(replaceMenu); @@ -989,9 +1051,10 @@ private void CreateImageEditMenu(object sender, ref ContextMenu menu) horizonMirror.Header = LanguageHelper.CommonManager.GetString("Menu_HFlip"); horizonMirror.Click += (o, p) => { - imageArea?.HorizontalMirror(); + Rect oldRect = DataConversionForWPF.CRectConversionForRect(imageArea.GetFrame()); + imageArea.HorizontalMirror(); pdfContentEditControl.RefreshThumb(); - UpdateImageArea(imageArea); + UpdateEditArea(oldRect, imageArea); }; menu.Items.Add(horizonMirror); @@ -1001,9 +1064,10 @@ private void CreateImageEditMenu(object sender, ref ContextMenu menu) { if (imageArea != null) { - imageArea?.VerticalMirror(); + Rect oldRect = DataConversionForWPF.CRectConversionForRect(imageArea.GetFrame()); + imageArea.VerticalMirror(); pdfContentEditControl.RefreshThumb(); - UpdateImageArea(imageArea); + UpdateEditArea(oldRect, imageArea); } }; menu.Items.Add(verticalMirror); @@ -1017,12 +1081,77 @@ private void CreateImageEditMenu(object sender, ref ContextMenu menu) PdfViewControl.PDFViewTool.SetCropMode(!PdfViewControl.PDFViewTool.GetIsCropMode()); } }; + menu.Items.Add(cropMenu); + } + + private void CreatePathEditMenu(object sender, ref ContextMenu menu) + { + int index = -1; + CPDFEditPathArea pathArea = PdfViewControl.PDFToolManager.GetSelectedEditAreaObject(ref index) as CPDFEditPathArea; + if (pathArea == null) + return; menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender }); menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender }); menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender }); menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender }); + + MenuItem rotateLeftMenu = new MenuItem(); + rotateLeftMenu.Header = LanguageHelper.CommonManager.GetString("Menu_RotateLeft"); + rotateLeftMenu.Click += (o, p) => + { + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathArea.GetFrame()); + pathArea.Rotate(90); + UpdateEditArea(oldRect, pathArea); + }; + menu.Items.Add(rotateLeftMenu); + + MenuItem rotateRightMenu = new MenuItem(); + rotateRightMenu.Header = LanguageHelper.CommonManager.GetString("Menu_RotateRight"); + rotateRightMenu.Click += (o, p) => + { + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathArea.GetFrame()); + pathArea.Rotate(-90); + UpdateEditArea(oldRect, pathArea); + }; + menu.Items.Add(rotateRightMenu); + + MenuItem opacityMenu = new MenuItem(); + opacityMenu.Header = LanguageHelper.CommonManager.GetString("Menu_Opacity"); + menu.Items.Add(opacityMenu); + AppendOpacityMenu(opacityMenu, pathArea, CPDFEditType.EditPath); + + MenuItem horizonMirror = new MenuItem(); + horizonMirror.Header = LanguageHelper.CommonManager.GetString("Menu_HFlip"); + horizonMirror.Click += (o, p) => + { + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathArea.GetFrame()); + pathArea.HorizontalMirror(); + UpdateEditArea(oldRect, pathArea); + }; + menu.Items.Add(horizonMirror); + + MenuItem verticalMirror = new MenuItem(); + verticalMirror.Header = LanguageHelper.CommonManager.GetString("Menu_VFlip"); + verticalMirror.Click += (o, p) => + { + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathArea.GetFrame()); + pathArea.VerticalMirror(); + UpdateEditArea(oldRect, pathArea); + }; + menu.Items.Add(verticalMirror); + + MenuItem cropMenu = new MenuItem(); + cropMenu.Header = LanguageHelper.CommonManager.GetString("Menu_Crop"); + cropMenu.Click += (o, p) => + { + if (pathArea != null) + { + PdfViewControl.PDFViewTool.SetCropMode(!PdfViewControl.PDFViewTool.GetIsCropMode()); + } + }; + menu.Items.Add(cropMenu); } private void CreateMultiTextEditMenu(object sender, ref ContextMenu menu) diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFContentEditControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFContentEditControl.xaml.cs index c490dca..3337b18 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFContentEditControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFContentEditControl.xaml.cs @@ -8,9 +8,9 @@ namespace ComPDFKit.Controls.Edit public partial class PDFContentEditControl : UserControl { #region - private PDFImageEditControl PDFImageEditControl = new PDFImageEditControl(); private PDFTextEditControl PDFTextEditControl = new PDFTextEditControl(); + private PDFPathEditControl PDFPathEditControl = new PDFPathEditControl(); public PDFViewControl ViewControl { get; private set; } public PDFEditParam EditEvent { get; set; } @@ -24,10 +24,11 @@ public PDFContentEditControl() public void InitWithPDFViewer(PDFViewControl newPDFView) { ViewControl = newPDFView; - PDFImageEditControl.InitWithPDFViewer(newPDFView.PDFViewTool); PDFTextEditControl.InitWithPDFViewer(newPDFView.PDFViewTool); + PDFImageEditControl.InitWithPDFViewer(newPDFView.PDFViewTool); + PDFPathEditControl.InitWithPDFViewer(newPDFView.PDFViewTool); } - + public void SetRotationText(float rotation) { PDFImageEditControl.SetRotationText(rotation); @@ -66,6 +67,11 @@ public void SetPDFImageEditData(List editEvent) ContentEditContainer.Child = PDFImageEditControl; } + public void SetPDFPathEditData(List editEvent) + { + PDFPathEditControl.SetPDFPathEditData(editEvent); + ContentEditContainer.Child = PDFPathEditControl; + } //public void SetPDFImageMultiEditData(List editEventList) //{ diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageEditControl/PDFImageEditControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageEditControl/PDFImageEditControl.xaml.cs index d26c0ba..4e3cbc4 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageEditControl/PDFImageEditControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageEditControl/PDFImageEditControl.xaml.cs @@ -72,37 +72,43 @@ private void PDFImageEditControl_Unloaded(object sender, RoutedEventArgs e) #endregion #region Property changed - private void ToolView_SelectedDataChanged(object sender, SelectedAnnotData e) + + private void ImageCut() { - if (ToolView.GetIsCropMode()) - { - GetImageArea(out List imageAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); - if (imageAreas.Count == 0 || pdfPage == null || editPage == null) - return; + GetImageArea(out List imageAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); + if (imageAreas.Count == 0 || pdfPage == null || editPage == null) + return; - SelectedRect selectedRect = ToolView.GetSelectedRectForEditAreaObject(imageAreas[0]); - if (selectedRect == null) - return; + SelectedRect selectedRect = ToolView.GetSelectedRectForEditAreaObject(imageAreas[0]); + if (selectedRect == null) + return; - Rect oldRect = DataConversionForWPF.CRectConversionForRect(imageAreas[0].GetFrame()); - double currentZoom = ToolView.GetCPDFViewer().CurrentRenderFrame.ZoomFactor; - Rect rect = selectedRect.GetRect(); - Rect maxRect = selectedRect.GetMaxRect(); - Rect pdfRect = new Rect((rect.X - maxRect.X) / currentZoom, (rect.Y - maxRect.Y) / currentZoom, rect.Width / currentZoom, rect.Height / currentZoom); - pdfRect = DpiHelper.StandardRectToPDFRect(pdfRect); - CRect newCRect = new CRect((float)pdfRect.Left, (float)pdfRect.Bottom, (float)pdfRect.Right, (float)pdfRect.Top); - if(imageAreas[0].CutWithRect(newCRect)) - { - PDFEditHistory editHistory = new PDFEditHistory(); - editHistory.EditPage = editPage; - editHistory.PageIndex = pdfPage.PageIndex; + Rect oldRect = DataConversionForWPF.CRectConversionForRect(imageAreas[0].GetFrame()); + double currentZoom = ToolView.GetCPDFViewer().CurrentRenderFrame.ZoomFactor; + Rect rect = selectedRect.GetRect(); + Rect maxRect = selectedRect.GetMaxRect(); + Rect pdfRect = new Rect((rect.X - maxRect.X) / currentZoom, (rect.Y - maxRect.Y) / currentZoom, rect.Width / currentZoom, rect.Height / currentZoom); + pdfRect = DpiHelper.StandardRectToPDFRect(pdfRect); + CRect newCRect = new CRect((float)pdfRect.Left, (float)pdfRect.Bottom, (float)pdfRect.Right, (float)pdfRect.Top); + if (imageAreas[0].CutWithRect(newCRect)) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; - ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); - ToolView.UpdateRender(oldRect, imageAreas[0]); - } + ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); + ToolView.UpdateRender(oldRect, imageAreas[0]); + } - editPage.EndEdit(); - SetImageThumb(); + editPage.EndEdit(); + SetImageThumb(); + } + + private void ToolView_SelectedDataChanged(object sender, SelectedAnnotData e) + { + if (ToolView.GetIsCropMode()) + { + ImageCut(); } } @@ -165,7 +171,6 @@ public void SetImageTransparency(double transparency) public void SetPDFImageEditData(List newEvents) { - EditEvents = newEvents.Where(newEvent => newEvent.EditIndex >= 0 && newEvent.EditType == CPDFEditType.EditImage).ToList(); if (EditEvents.Count > 0) @@ -572,6 +577,7 @@ private void GetImageArea(out List imageAreas, out CPDFPage p { return; } + try { foreach (var EditEvent in EditEvents) diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageUI/CPDFImageFlipUI.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageUI/CPDFImageFlipUI.xaml.cs index 7a789a8..034078d 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageUI/CPDFImageFlipUI.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageUI/CPDFImageFlipUI.xaml.cs @@ -12,20 +12,6 @@ public CPDFImageFlipUI() InitializeComponent(); } - #region Property - public Orientation Orientation - { - get - { - return ImageFlipUI.Orientation; - } - set - { - ImageFlipUI.Orientation = value; - } - } - #endregion - #region UI Event private void FlipVertical_Click(object sender, RoutedEventArgs e) { diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageUI/CPDFImageRotateUI.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageUI/CPDFImageRotateUI.xaml.cs index 3212314..726d1a0 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageUI/CPDFImageRotateUI.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFImageEdit/PDFImageUI/CPDFImageRotateUI.xaml.cs @@ -31,12 +31,12 @@ public Orientation Orientation private void RotateLeftBtn_Click(object sender, RoutedEventArgs e) { - RotationChanged?.Invoke(this, -90); + RotationChanged?.Invoke(this, 90); } private void RotateRightBtn_Click(object sender, RoutedEventArgs e) { - RotationChanged?.Invoke(this, 90); + RotationChanged?.Invoke(this, -90); } #endregion diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFPathEdit/PDFPathEditControl/PDFPathEditControl.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFPathEdit/PDFPathEditControl/PDFPathEditControl.xaml new file mode 100644 index 0000000..92dc404 --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFPathEdit/PDFPathEditControl/PDFPathEditControl.xaml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 25% + 50% + 75% + 100% + + 100% + + + M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z + + + + + + + + + + + + + + + + + + + + + + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFPathEdit/PDFPathEditControl/PDFPathEditControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFPathEdit/PDFPathEditControl/PDFPathEditControl.xaml.cs new file mode 100644 index 0000000..2f1e33c --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFPathEdit/PDFPathEditControl/PDFPathEditControl.xaml.cs @@ -0,0 +1,604 @@ +using ComPDFKit.Import; +using ComPDFKit.PDFDocument; +using ComPDFKit.PDFPage; +using ComPDFKit.PDFPage.Edit; +using ComPDFKit.Tool; +using ComPDFKit.Tool.UndoManger; +using ComPDFKit.Viewer.Helper; +using ComPDFKitViewer; +using System; +using System.Collections.Generic; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Input; +using ComPDFKit.Tool.DrawTool; +using ComPDFKitViewer.Helper; +using System.Linq; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using ComPDFKit.Tool.SettingParam; +using System.Windows.Media; + +namespace ComPDFKit.Controls.Edit +{ + public partial class PDFPathEditControl : UserControl, INotifyPropertyChanged + { + #region property + public CPDFViewerTool ToolView { get; set; } + public List EditEvents { get; set; } = new List(); + + private Visibility _onlySingleVisible = Visibility.Collapsed; + public Visibility OnlySingleVisible + { + get => _onlySingleVisible; + set => UpdateProper(ref _onlySingleVisible, value); + } + + #endregion + + public PDFPathEditControl() + { + DataContext = this; + InitializeComponent(); + Loaded += PDPathEditControl_Loaded; + Unloaded += PDFPathEditControl_Unloaded; + } + + #region Load unload custom control + + private void PDPathEditControl_Loaded(object sender, RoutedEventArgs e) + { + RotateUI.RotationChanged -= RotateUI_RotationChanged; + FlipUI.FlipChanged -= FlipUI_FlipChanged; + RotateUI.RotationChanged += RotateUI_RotationChanged; + FlipUI.FlipChanged += FlipUI_FlipChanged; + ToolView.SelectedDataChanged -= ToolView_SelectedDataChanged; + ToolView.SelectedDataChanged += ToolView_SelectedDataChanged; + + StrokeColorUI.ColorChanged -= StrokeColorUI_ColorChanged; + StrokeColorUI.ColorChanged += StrokeColorUI_ColorChanged; + + FillColorUI.ColorChanged -= FillColorUI_ColorChanged; + FillColorUI.ColorChanged += FillColorUI_ColorChanged; + } + + private void StrokeColorUI_ColorChanged(object sender, EventArgs e) + { + SolidColorBrush newBrush = StrokeColorUI.Brush as SolidColorBrush; + GetPathArea(out List pathAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); + if (pathAreas.Count == 0 || pdfPage == null || editPage == null) + return; + + if (ToolView.CurrentEditAreaObject() != null) + { + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathAreas[0].GetFrame()); + bool result = pathAreas[0].SetStrokeColor(new byte[] { newBrush.Color.R, newBrush.Color.G, newBrush.Color.B}); + if (result) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); + ToolView.UpdateRender(oldRect, pathAreas[0]); + } + } + else + { + GroupHistory groupHistory = new GroupHistory(); + foreach (CPDFEditPathArea pathArea in pathAreas) + { + if (pathArea.SetStrokeColor(new byte[] { newBrush.Color.R, newBrush.Color.G, newBrush.Color.B })) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + groupHistory.Histories.Add(editHistory); + } + + ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory); + ToolView.GetCPDFViewer()?.UpdateRenderFrame(); + } + } + + editPage.EndEdit(); + if (EditEvents.Count > 0 && newBrush != null) + { + byte[] Color = new byte[3]; + Color[0] = newBrush.Color.R; + Color[1] = newBrush.Color.G; + Color[2] = newBrush.Color.B; + EditEvents.FirstOrDefault().StrokeColor = Color; + DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam(); + defaultSettingParam.SetPDFEditParamm(EditEvents.FirstOrDefault()); + } + } + + private void FillColorUI_ColorChanged(object sender, EventArgs e) + { + SolidColorBrush newBrush = FillColorUI.Brush as SolidColorBrush; + GetPathArea(out List pathAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); + if (pathAreas.Count == 0 || pdfPage == null || editPage == null) + return; + + if (ToolView.CurrentEditAreaObject() != null) + { + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathAreas[0].GetFrame()); + bool result = pathAreas[0].SetFillColor(new byte[] { newBrush.Color.R, newBrush.Color.G, newBrush.Color.B }); + if (result) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); + ToolView.UpdateRender(oldRect, pathAreas[0]); + } + } + else + { + GroupHistory groupHistory = new GroupHistory(); + foreach (CPDFEditPathArea pathArea in pathAreas) + { + if (pathArea.SetFillColor(new byte[] { newBrush.Color.R, newBrush.Color.G, newBrush.Color.B })) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + groupHistory.Histories.Add(editHistory); + } + + ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory); + ToolView.GetCPDFViewer()?.UpdateRenderFrame(); + } + } + + editPage.EndEdit(); + if (EditEvents.Count > 0 && newBrush != null) + { + byte[] Color = new byte[3]; + Color[0] = newBrush.Color.R; + Color[1] = newBrush.Color.G; + Color[2] = newBrush.Color.B; + EditEvents.FirstOrDefault().FillColor = Color; + DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam(); + defaultSettingParam.SetPDFEditParamm(EditEvents.FirstOrDefault()); + } + } + + private void PDFPathEditControl_Unloaded(object sender, RoutedEventArgs e) + { + RotateUI.RotationChanged -= RotateUI_RotationChanged; + FlipUI.FlipChanged -= FlipUI_FlipChanged; + } + + #endregion + + #region Property changed + + private void PathCut() + { + GetPathArea(out List pathAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); + if (pathAreas.Count == 0 || pdfPage == null || editPage == null) + return; + + SelectedRect selectedRect = ToolView.GetSelectedRectForEditAreaObject(pathAreas[0]); + if (selectedRect == null) + return; + + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathAreas[0].GetFrame()); + double currentZoom = ToolView.GetCPDFViewer().CurrentRenderFrame.ZoomFactor; + Rect rect = selectedRect.GetRect(); + Rect maxRect = selectedRect.GetMaxRect(); + Rect pdfRect = new Rect((rect.X - maxRect.X) / currentZoom, (rect.Y - maxRect.Y) / currentZoom, rect.Width / currentZoom, rect.Height / currentZoom); + pdfRect = DpiHelper.StandardRectToPDFRect(pdfRect); + CRect newCRect = new CRect((float)pdfRect.Left, (float)pdfRect.Bottom, (float)pdfRect.Right, (float)pdfRect.Top); + if (pathAreas[0].CutWithRect(newCRect)) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + + ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); + ToolView.UpdateRender(oldRect, pathAreas[0]); + } + + editPage.EndEdit(); + } + + private void ToolView_SelectedDataChanged(object sender, SelectedAnnotData e) + { + if (ToolView.GetIsCropMode()) + { + PathCut(); + } + } + + #endregion + + #region Init PDFViewer + public void InitWithPDFViewer(CPDFViewerTool newPDFView) + { + ToolView = newPDFView; + } + #endregion + + #region public method + + //public void SetRotationText(float rotation) + //{ + // RotationTxb.Text = rotation.ToString(CultureInfo.CurrentCulture); + //} + + #endregion + + #region Path Edit + + private void SetPathTransparency(double transparency) + { + PathOpacitySlider.Value = transparency / 255D; + OpacityTextBox.Text = string.Format("{0}%", (int)(Math.Round(PathOpacitySlider.Value * 100))); + } + + public void SetPDFPathEditData(List newEvents) + { + EditEvents = newEvents.Where(newEvent => newEvent.EditIndex >= 0 && newEvent.EditType == CPDFEditType.EditPath).ToList(); + if (EditEvents.Count == 0) + return; + + PathEditParam defaultEvent = EditEvents.FirstOrDefault(); + + SetPathTransparency(defaultEvent.Transparency); + RotationTxb.Text = defaultEvent.Rotate.ToString(); + + StrokeColorUI.SetCheckedForColor(Color.FromRgb( + defaultEvent.StrokeColor[0], + defaultEvent.StrokeColor[1], + defaultEvent.StrokeColor[2])); + + FillColorUI.SetCheckedForColor(Color.FromRgb( + defaultEvent.FillColor[0], + defaultEvent.FillColor[1], + defaultEvent.FillColor[2])); + + if (EditEvents.Count == 1) + { + OnlySingleVisible = Visibility.Visible; + } + else + { + OnlySingleVisible = Visibility.Collapsed; + } + } + + #endregion + + #region Property changed + + private void FlipUI_FlipChanged(object sender, bool e) + { + GetPathArea(out List pathAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); + if (pathAreas.Count == 0 || pdfPage == null || editPage == null) + return; + + if (ToolView.CurrentEditAreaObject() != null) + { + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathAreas[0].GetFrame()); + bool result; + if (e) + { + result = pathAreas[0].VerticalMirror(); + } + else + { + result = pathAreas[0].HorizontalMirror(); + } + + if (result) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); + ToolView.UpdateRender(oldRect, pathAreas[0]); + } + } + else + { + GroupHistory groupHistory = new GroupHistory(); + foreach (CPDFEditPathArea pathArea in pathAreas) + { + bool result; + if (e) + { + result = pathArea.VerticalMirror(); + } + else + { + result = pathArea.HorizontalMirror(); + } + + if (result) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + groupHistory.Histories.Add(editHistory); + } + } + + ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory); + ToolView.GetCPDFViewer()?.UpdateRenderFrame(); + } + + editPage.EndEdit(); + } + + private void RotateUI_RotationChanged(object sender, double e) + { + GetPathArea(out List pathAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); + if (pathAreas.Count == 0 || pdfPage == null || editPage == null) + return; + + if (ToolView.CurrentEditAreaObject() != null) + { + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathAreas[0].GetFrame()); + if (pathAreas[0].Rotate((int)e)) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); + ToolView.UpdateRender(oldRect, pathAreas[0]); + } + } + else + { + GroupHistory groupHistory = new GroupHistory(); + foreach (CPDFEditPathArea pathArea in pathAreas) + { + if (pathArea.Rotate((int)e)) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + groupHistory.Histories.Add(editHistory); + } + } + + ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory); + ToolView.GetCPDFViewer()?.UpdateRenderFrame(); + } + + editPage.EndEdit(); + RotationTxb.Text = pathAreas.FirstOrDefault().GetRotation().ToString(); + } + + private void Slider_DragStarted(object sender, DragStartedEventArgs e) + { + Slider slider = sender as Slider; + if (slider != null) + { + slider.Tag = "false"; + } + } + + private void SliderOpacity_DragCompleted(object sender, DragCompletedEventArgs e) + { + Slider slider = sender as Slider; + if (slider != null) + { + slider.Tag = "true"; + } + + GetPathArea(out List pathAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); + if (pathAreas.Count == 0 || pdfPage == null || editPage == null) + return; + + if (ToolView.CurrentEditAreaObject() != null) + { + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathAreas[0].GetFrame()); + if (pathAreas[0].SetTransparency((byte)(PathOpacitySlider.Value * 255))) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); + ToolView.UpdateRender(oldRect, pathAreas[0]); + } + } + else + { + GroupHistory groupHistory = new GroupHistory(); + foreach (CPDFEditPathArea pathArea in pathAreas) + { + if (pathArea.SetTransparency((byte)(PathOpacitySlider.Value * 255))) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + groupHistory.Histories.Add(editHistory); + } + } + + ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory); + ToolView.GetCPDFViewer()?.UpdateRenderFrame(); + } + + editPage.EndEdit(); + } + + private void SliderOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + Slider slider = sender as Slider; + if (OpacityTextBox != null) + { + OpacityTextBox.Text = string.Format("{0}%", (int)(PathOpacitySlider.Value * 100)); + } + + if (slider != null && slider.Tag != null && slider.Tag.ToString() == "false") + { + return; + } + + GetPathArea(out List pathAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); + if (pathAreas.Count == 0 || pdfPage == null || editPage == null) + return; + + if (ToolView.CurrentEditAreaObject() != null) + { + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathAreas[0].GetFrame()); + if (pathAreas[0].SetTransparency((byte)(PathOpacitySlider.Value * 255))) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); + ToolView.UpdateRender(oldRect, pathAreas[0]); + } + } + else + { + GroupHistory groupHistory = new GroupHistory(); + foreach (CPDFEditPathArea pathArea in pathAreas) + { + if (pathArea.SetTransparency((byte)(PathOpacitySlider.Value * 255))) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + groupHistory.Histories.Add(editHistory); + } + } + + ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory); + ToolView.GetCPDFViewer()?.UpdateRenderFrame(); + } + + editPage.EndEdit(); + } + + private void PathClipBtn_Click(object sender, RoutedEventArgs e) + { + ToolView.SetCropMode(!ToolView.GetIsCropMode()); + } + + private void OpacityComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBoxItem selectItem = OpacityComboBox.SelectedItem as ComboBoxItem; + if (selectItem != null && selectItem.Content != null) + { + if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double newOpacity)) + { + OpacityTextBox.Text = selectItem.Content.ToString(); + PathOpacitySlider.Value = newOpacity / 100.0; + } + } + } + + private void GetPathArea(out List pathAreas, out CPDFPage pdfPage, out CPDFEditPage editPage) + { + pathAreas = new List(); + editPage = null; + pdfPage = null; + if (ToolView == null || EditEvents.Count == 0) + { + return; + } + + try + { + foreach (var EditEvent in EditEvents) + { + CPDFViewer pdfViewer = ToolView.GetCPDFViewer(); + CPDFDocument pdfDoc = pdfViewer.GetDocument(); + pdfPage = pdfDoc.PageAtIndex(EditEvent.PageIndex); + editPage = pdfPage.GetEditPage(); + List editAreas = editPage.GetEditAreaList(); + if (editAreas != null && editAreas.Count > EditEvent.EditIndex) + { + pathAreas.Add(editAreas[EditEvent.EditIndex] as CPDFEditPathArea); + } + } + } + catch (Exception ex) + { + + } + } + + private void SetAbsRotation(double absRotation) + { + GetPathArea(out List pathAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); + if (pathAreas.Count == 0 || pdfPage == null || editPage == null) + return; + + if (ToolView.CurrentEditAreaObject() != null) + { + Rect oldRect = DataConversionForWPF.CRectConversionForRect(pathAreas[0].GetFrame()); + int rotation = (int)absRotation - pathAreas[0].GetRotation(); + if (pathAreas[0].Rotate(rotation)) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); + ToolView.UpdateRender(oldRect, pathAreas[0]); + } + } + else + { + GroupHistory groupHistory = new GroupHistory(); + foreach (CPDFEditPathArea pathArea in pathAreas) + { + int rotation = (int)absRotation - pathArea.GetRotation(); + if (pathArea.Rotate(rotation)) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + groupHistory.Histories.Add(editHistory); + } + } + + ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory); + ToolView.GetCPDFViewer()?.UpdateRenderFrame(); + } + + editPage.EndEdit(); + } + + private void RotationTxb_LostFocus(object sender, RoutedEventArgs e) + { + if (!double.TryParse(RotationTxb.Text, out double rotation)) + { + return; + } + SetAbsRotation(rotation); + } + + private void RotationTxb_PreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + RotationTxb_LostFocus(null, null); + } + } + #endregion + + public event PropertyChangedEventHandler PropertyChanged; + protected bool UpdateProper(ref T properValue, + T newValue, + [CallerMemberName] string properName = "") + { + if (object.Equals(properValue, newValue)) + return false; + + properValue = newValue; + OnPropertyChanged(properName); + return true; + } + + protected void OnPropertyChanged([CallerMemberName] string propertyName = "") => + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } +} diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditControl/PDFTextEditControl.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditControl/PDFTextEditControl.xaml index f909159..07a4c1b 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditControl/PDFTextEditControl.xaml +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditControl/PDFTextEditControl.xaml @@ -93,12 +93,13 @@ - - - + - + + + + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditControl/PDFTextEditControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditControl/PDFTextEditControl.xaml.cs index d7461cf..3385ab9 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditControl/PDFTextEditControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditControl/PDFTextEditControl.xaml.cs @@ -24,7 +24,6 @@ public partial class PDFTextEditControl : UserControl, INotifyPropertyChanged public CPDFViewerTool ToolView { get; private set; } public List EditEvents { get; set; } - public event PropertyChangedEventHandler PropertyChanged; private bool _isMultiSelected = true; @@ -53,7 +52,6 @@ public PDFTextEditControl() DataContext = this; InitializeComponent(); Loaded += PDFTextEditControl_Loaded; - } #region Init PDFView @@ -92,8 +90,11 @@ public void SetPDFTextEditData(List newEvents) TextStyleUI.SelectFontName(defaultEvent.FontName); TextStyleUI.SetFontStyle(defaultEvent.IsBold, defaultEvent.IsItalic); TextStyleUI.SetFontSize(defaultEvent.FontSize); - OpacityTextBox.Text = string.Format("{0}%", (int)(Math.Ceiling(defaultEvent.Transparency * 100 / 255D))); + + FontOpacitySlider.Tag = "false"; FontOpacitySlider.Value = ((int)(Math.Ceiling(defaultEvent.Transparency * 100 / 255D))) / 100D; + FontOpacitySlider.Tag = "true"; + TextAlignUI.SetFontAlign(defaultEvent.TextAlign); if (defaultEvent.FontColor != null && defaultEvent.FontColor.Length == 3) { @@ -143,12 +144,7 @@ public void SetPDFTextEditData(List newEvents) private void SliderOpacity_DragCompleted(object sender, DragCompletedEventArgs e) { - Slider slider = sender as Slider; - if (slider != null) - { - slider.Tag = "true"; - } - + FontOpacitySlider.Tag = "true"; GetTextArea(out List textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); if (textAreas.Count == 0 || pdfPage == null || editPage == null) return; @@ -211,13 +207,12 @@ private void SliderOpacity_DragCompleted(object sender, DragCompletedEventArgs e private void SliderOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { - Slider slider = sender as Slider; if (OpacityTextBox != null && FontOpacitySlider != null) { - OpacityTextBox.Text = string.Format("{0}%", (int)(FontOpacitySlider.Value * 100)); + OpacityTextBox.Text = string.Format("{0}%", (int)(FontOpacitySlider.Value * 100D)); } - if (slider != null && slider.Tag != null && slider.Tag.ToString() == "false") + if (FontOpacitySlider.Tag == null || FontOpacitySlider.Tag.ToString() == "false") { return; } @@ -284,24 +279,21 @@ private void SliderOpacity_ValueChanged(object sender, RoutedPropertyChangedEven private void Slider_DragStarted(object sender, DragStartedEventArgs e) { - Slider slider = sender as Slider; - if (slider != null) - { - slider.Tag = "false"; - } + FontOpacitySlider.Tag = "false"; } #endregion #region Loaded private void PDFTextEditControl_Loaded(object sender, RoutedEventArgs e) { - TextStyleUI.TextFontChanged -= TextStyleUI_TextFontChanged; TextStyleUI.TextBoldChanged -= TextStyleUI_TextBoldChanged; TextStyleUI.TextItalicChanged -= TextStyleUI_TextItalicChanged; TextStyleUI.TextSizeChanged -= TextStyleUI_TextSizeChanged; TextAlignUI.TextAlignChanged -= TextAlignUI_TextAlignChanged; FontColorUI.ColorChanged -= FontColorUI_ColorChanged; + TextMarkupUI.TextUnderlineChanged -= TextMarkupUI_TextUnderlineChanged; + TextMarkupUI.TextStrikethroughChanged -= TextMarkupUI_TextStrikethroughChanged; TextStyleUI.TextFontChanged += TextStyleUI_TextFontChanged; TextStyleUI.TextBoldChanged += TextStyleUI_TextBoldChanged; @@ -309,6 +301,8 @@ private void PDFTextEditControl_Loaded(object sender, RoutedEventArgs e) TextStyleUI.TextSizeChanged += TextStyleUI_TextSizeChanged; TextAlignUI.TextAlignChanged += TextAlignUI_TextAlignChanged; FontColorUI.ColorChanged += FontColorUI_ColorChanged; + TextMarkupUI.TextUnderlineChanged += TextMarkupUI_TextUnderlineChanged; + TextMarkupUI.TextStrikethroughChanged += TextMarkupUI_TextStrikethroughChanged; IsMultiSelected = ToolView.GetIsMultiSelected(); ShowBorder = ToolView.GetEditPen() == null || ToolView.GetEditPen().Thickness != 0; @@ -317,7 +311,6 @@ private void PDFTextEditControl_Loaded(object sender, RoutedEventArgs e) #endregion #region Property changed - private void TextStyleUI_TextSizeChanged(object sender, double e) { GetTextArea(out List textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); @@ -750,12 +743,129 @@ private void OpacityComboBox_SelectionChanged(object sender, SelectionChangedEve { if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double newOpacity)) { - OpacityTextBox.Text = selectItem.Content.ToString(); FontOpacitySlider.Value = newOpacity / 100.0; } } } + private void TextMarkupUI_TextUnderlineChanged(object sender, bool e) + { + GetTextArea(out List textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); + if (textAreas.Count == 0 || pdfPage == null || editPage == null) + return; + + if (ToolView.CurrentEditAreaObject() != null) + { + bool result; + Rect oldRect = DataConversionForWPF.CRectConversionForRect(textAreas[0].GetFrame()); + if(e) + { + result = textAreas[0].AddUnderline(); + } + else + { + result = textAreas[0].RemoveUnderline(); + } + + if (result) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); + ToolView.UpdateRender(oldRect, textAreas[0]); + } + } + else + { + GroupHistory groupHistory = new GroupHistory(); + foreach (CPDFEditTextArea textArea in textAreas) + { + bool result; + if (e) + { + result = textArea.AddUnderline(); + } + else + { + result = textArea.RemoveUnderline(); + } + + if (result) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + groupHistory.Histories.Add(editHistory); + } + } + + ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory); + ToolView.GetCPDFViewer()?.UpdateRenderFrame(); + } + + editPage.EndEdit(); + } + + private void TextMarkupUI_TextStrikethroughChanged(object sender, bool e) + { + GetTextArea(out List textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage); + if (textAreas.Count == 0 || pdfPage == null || editPage == null) + return; + + if (ToolView.CurrentEditAreaObject() != null) + { + bool result; + Rect oldRect = DataConversionForWPF.CRectConversionForRect(textAreas[0].GetFrame()); + if (e) + { + result = textAreas[0].AddStrikethrough(); + } + else + { + result = textAreas[0].RemoveStrikethrough(); + } + + if (result) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory); + ToolView.UpdateRender(oldRect, textAreas[0]); + } + } + else + { + GroupHistory groupHistory = new GroupHistory(); + foreach (CPDFEditTextArea textArea in textAreas) + { + bool result; + if (e) + { + result = textArea.AddStrikethrough(); + } + else + { + result = textArea.RemoveStrikethrough(); + } + + if (result) + { + PDFEditHistory editHistory = new PDFEditHistory(); + editHistory.EditPage = editPage; + editHistory.PageIndex = pdfPage.PageIndex; + groupHistory.Histories.Add(editHistory); + } + } + + ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory); + ToolView.GetCPDFViewer()?.UpdateRenderFrame(); + } + + editPage.EndEdit(); + } + #endregion #region Text Edit @@ -768,6 +878,7 @@ private void GetTextArea(out List textAreas, out CPDFPage pdfP { return; } + if (EditEvents != null && EditEvents.Count>0 ) { try @@ -790,15 +901,6 @@ private void GetTextArea(out List textAreas, out CPDFPage pdfP } } - else - { - CPDFViewer pdfViewer = ToolView.GetCPDFViewer(); - CPDFDocument pdfDoc = pdfViewer.GetDocument(); - pdfPage = pdfDoc.PageAtIndex(0); - editPage = pdfPage.GetEditPage(); - editPage.BeginEdit(CPDFEditType.EditText); - editPage.EndEdit(); - } } #endregion diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditUI/CPDFTextMarkupUI.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditUI/CPDFTextMarkupUI.xaml new file mode 100644 index 0000000..a5cae9a --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditUI/CPDFTextMarkupUI.xaml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditUI/CPDFTextMarkupUI.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditUI/CPDFTextMarkupUI.xaml.cs new file mode 100644 index 0000000..017e6c8 --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Edit/PDFTextEdit/PDFTextEditUI/CPDFTextMarkupUI.xaml.cs @@ -0,0 +1,37 @@ +using System; +using System.Windows; +using System.Windows.Controls; + +namespace ComPDFKit.Controls.Edit +{ + public partial class CPDFTextMarkupUI : UserControl + { + public event EventHandler TextUnderlineChanged; + public event EventHandler TextStrikethroughChanged; + + public CPDFTextMarkupUI() + { + InitializeComponent(); + } + + private void AddUnderline_Click(object sender, RoutedEventArgs e) + { + TextUnderlineChanged?.Invoke(this, true); + } + + private void RemoveUnderline_Click(object sender, RoutedEventArgs e) + { + TextUnderlineChanged?.Invoke(this, false); + } + + private void AddStrikethrough_Click(object sender, RoutedEventArgs e) + { + TextStrikethroughChanged?.Invoke(this, true); + } + + private void RemoveStrikethrough_Click(object sender, RoutedEventArgs e) + { + TextStrikethroughChanged?.Invoke(this, false); + } + } +} diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Form/FormControl/FormControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Form/FormControl/FormControl.xaml.cs index ad00d18..6c3b039 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Form/FormControl/FormControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Form/FormControl/FormControl.xaml.cs @@ -294,6 +294,9 @@ public void InitWithPDFViewer(PDFViewControl pDFViewControl) panelState.PropertyChanged -= PanelState_PropertyChanged; panelState.PropertyChanged += PanelState_PropertyChanged; + + OnPropertyChanged("CanRedo"); + OnPropertyChanged("CanUndo"); } public void SetBOTAContainer(CPDFBOTABarControl botaControl) diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasureControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasureControl.xaml.cs index 316d949..d8e879f 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasureControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasureControl.xaml.cs @@ -26,31 +26,33 @@ namespace ComPDFKit.Controls.Measure public partial class MeasureControl : UserControl { public MeasurePropertyControl measurePropertyControl = new MeasurePropertyControl(); + private CPDFDisplaySettingsControl displaySettingsControl; private PDFViewControl PdfViewControl = new PDFViewControl(); private PanelState panelState = PanelState.GetInstance(); - + private CPDFAnnotation currentAnnot = null; public event EventHandler ExpandEvent; public event EventHandler OnAnnotEditHandler; - public MeasureControl() { InitializeComponent(); } - + #region Init PDFViewer public void InitWithPDFViewer(PDFViewControl pdfViewControl) { PdfViewControl = pdfViewControl; - //PdfViewControl.PDFView = pdfViewer; + //PdfViewControl.PDFView = pdfViewer; + measurePropertyControl.InitWithPDFViewer(pdfViewControl); PDFMeasureTool.InitWithPDFViewer(pdfViewControl, measurePropertyControl, this); FloatPageTool.InitWithPDFViewer(pdfViewControl); + PDFGrid.Child = PdfViewControl; panelState.PropertyChanged -= PanelState_PropertyChanged; @@ -65,9 +67,9 @@ public void InitWithPDFViewer(PDFViewControl pdfViewControl) PdfViewControl.MouseLeftButtonUpHandler += PDFToolManager_MouseLeftButtonUpHandler; PdfViewControl.MouseMoveHandler += PDFToolManager_MouseMoveHandler; pdfViewControl.MouseRightButtonDownHandler += PDFToolManager_MouseRightButtonDownHandler; - panelState.PropertyChanged += PanelState_PropertyChanged; + panelState.PropertyChanged += PanelState_PropertyChanged; SetInfoPanelVisble(false, false); - SettingPanel.PdfViewControl= pdfViewControl; + SettingPanel.PdfViewControl = pdfViewControl; } private void MeasureSetting_MeasureChanged(object sender, MeasureEventArgs e) @@ -102,7 +104,7 @@ private void PDFToolManager_MouseRightButtonDownHandler(object sender, MouseEven } PdfViewControl.SetRightMenu(ContextMenu); } - + private void CreateAnnotContextMenu(object sender, ref ContextMenu menu, C_ANNOTATION_TYPE annotType) { switch (annotType) @@ -130,13 +132,13 @@ private void CreateAnnotContextMenu(object sender, ref ContextMenu menu, C_ANNOT break; } } - + private void CreateMeasureContextMenu(object sender, ref ContextMenu menu) { menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender }); - + MenuItem menuItem = new MenuItem(); - menuItem.Header = "Measurement Settings"; + menuItem.Header = LanguageHelper.PropertyPanelManager.GetString("Title_Settings"); menuItem.Click += (item, param) => { if (currentAnnot is CPDFLineAnnotation annotation) @@ -146,21 +148,33 @@ private void CreateMeasureContextMenu(object sender, ref ContextMenu menu) SetInfoPanelVisble(false, true); }; menu.Items.Add(menuItem); - + MenuItem propertyItem = new MenuItem(); - propertyItem.Header = "Properties"; + propertyItem.Header = LanguageHelper.CommonManager.GetString("Tooltip_Prop"); propertyItem.Click += (item, param) => { + BaseAnnot baseAnnot = PdfViewControl.GetCacheHitTestAnnot(); + if (baseAnnot != null) + { + AnnotData annotData = baseAnnot.GetAnnotData(); + AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam( + PdfViewControl.GetCPDFViewer().GetDocument(), annotData.PageIndex, annotData.Annot); + measurePropertyControl.SetPropertyForMeasureCreate(annotParam, annotData.Annot, PdfViewControl); + SetMeasureInfoPanel(annotData.Annot, annotParam); + currentAnnot = annotData.Annot; + } + panelState.RightPanel = PanelState.RightPanelState.PropertyPanel; + SetInfoPanelVisble(true, false); }; menu.Items.Add(propertyItem); } - + private void CreateSelectTextContextMenu(object sender, ref ContextMenu menu) { menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender }); } - + private void CreateSelectImageContextMenu(object sender, ref ContextMenu menu) { if (menu == null) @@ -253,6 +267,7 @@ private void CopyImage_Click(object sender, RoutedEventArgs e) private void PDFToolManager_MouseMoveHandler(object sender, MouseEventObject e) { + } private void PDFToolManager_MouseLeftButtonUpHandler(object sender, MouseEventObject e) @@ -270,23 +285,23 @@ private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEvent { AnnotData annotData = baseAnnot.GetAnnotData(); AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam( - PdfViewControl.GetCPDFViewer().GetDocument(), annotData.PageIndex, annotData.Annot); + PdfViewControl.GetCPDFViewer().GetDocument(), annotData.PageIndex, annotData.Annot); measurePropertyControl.SetPropertyForMeasureCreate(annotParam, annotData.Annot, PdfViewControl); SetMeasureInfoPanel(annotData.Annot, annotParam); currentAnnot = annotData.Annot; - } + } panelState.RightPanel = PanelState.RightPanelState.PropertyPanel; - // measurePropertyControl.SetPropertyForMeasureCreate(LineArgs, e); SetInfoPanelVisble(true, false); } - private void SetMeasureInfoPanel(CPDFAnnotation annot,AnnotParam param = null) + private void SetMeasureInfoPanel(CPDFAnnotation annot, AnnotParam param = null) { - if (annot == null) + if (annot == null || !annot.IsValid()) { return; } + try { if (annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_LINE) @@ -308,8 +323,8 @@ private void SetMeasureInfoPanel(CPDFAnnotation annot,AnnotParam param = null) SetMeasureInfoType(CPDFMeasureType.CPDF_PERIMETER_MEASURE); } } - - if(annot.Type== C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON) + + if (annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON) { CPDFPolygonAnnotation Annot = annot as CPDFPolygonAnnotation; CPDFAreaMeasure polygonMeasure = Annot.GetAreaMeasure(); @@ -317,7 +332,7 @@ private void SetMeasureInfoPanel(CPDFAnnotation annot,AnnotParam param = null) CPDFCaptionType CaptionType = measureInfo.CaptionType; bool IsArea = false; bool IsLength = false; - if ((CaptionType& CPDFCaptionType.CPDF_CAPTION_AREA)== CPDFCaptionType.CPDF_CAPTION_AREA) + if ((CaptionType & CPDFCaptionType.CPDF_CAPTION_AREA) == CPDFCaptionType.CPDF_CAPTION_AREA) { IsArea = true; } @@ -501,7 +516,7 @@ private void MeasureInfoPanel_SettingClick(object sender, EventArgs e) } SettingPanel.ReturnToInfoPanel = true; SetInfoPanelVisble(false, true); - if(currentAnnot != null) + if (currentAnnot != null) { AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam( PdfViewControl.GetCPDFViewer().GetDocument(), currentAnnot.Page.PageIndex, currentAnnot); @@ -511,7 +526,7 @@ private void MeasureInfoPanel_SettingClick(object sender, EventArgs e) private CPDFMeasureInfo GetMeasureInfoFromParam(AnnotParam param) { - if(param is LineMeasureParam lineParam) + if (param is LineMeasureParam lineParam) { return lineParam.measureInfo; } @@ -548,7 +563,7 @@ public void SetMeasureInfoType(CPDFMeasureType measureType) { InfoPanel?.SetMeasureType(measureType); } - + public void SetBOTAContainer(CPDFBOTABarControl botaControl) { this.BotaContainer.Child = botaControl; @@ -556,7 +571,7 @@ public void SetBOTAContainer(CPDFBOTABarControl botaControl) public void SetMeasureScale(CPDFMeasureType measureType, string scale) { - InfoPanel?.SetMeasureScale(measureType,scale); + InfoPanel?.SetMeasureScale(measureType, scale); } } } diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasureInfoPanel.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasureInfoPanel.xaml.cs index 556d2d6..b15b8e2 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasureInfoPanel.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasureInfoPanel.xaml.cs @@ -2,20 +2,12 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Drawing.Drawing2D; using System.Globalization; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using ComPDFKit.Controls.Helper; using ComPDFKit.PDFAnnotation; using ComPDFKit.Tool; @@ -92,7 +84,6 @@ public void SetMeasureType(CPDFMeasureType newType) TypeConverter typeCovert = TypeDescriptor.GetConverter(typeof(Geometry)); MeasureIcon.Data = PathGeometry.CreateFromGeometry((Geometry)typeCovert.ConvertFrom(IconsDict.ElementAt(iconIndex).Value)); MeasureTitelText.Text = IconsDict.ElementAt(iconIndex).Key; - switch(newType) { case CPDFMeasureType.CPDF_DISTANCE_MEASURE: @@ -136,6 +127,9 @@ public void ClearMeasureInfo() public void SetMeasureInfo(CPDFAnnotation annot) { + if (annot == null || !annot.IsValid()) + return; + if (annot is CPDFLineAnnotation lineAnnot) { SetLineMeasureInfo(lineAnnot); diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasurePropertyControl.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasurePropertyControl.xaml index 6b771d8..93f0509 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasurePropertyControl.xaml +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasurePropertyControl.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:ComPDFKit.Controls.Measure" xmlns:common="clr-namespace:ComPDFKit.Controls.Common" mc:Ignorable="d" - d:DesignHeight="450" d:DesignWidth="800" Background="#FAFCFF"> + d:DesignHeight="800" d:DesignWidth="300" Background="#FAFCFF"> diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasurePropertyControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasurePropertyControl.xaml.cs index e121695..1693efc 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasurePropertyControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/MeasurePropertyControl.xaml.cs @@ -16,15 +16,50 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using ComPDFKitViewer; namespace ComPDFKit.Controls.Measure { public partial class MeasurePropertyControl : UserControl { + StraightnessProperty straightnessProperty = new StraightnessProperty(); + MultilineProperty multilineProperty = new MultilineProperty(); + PolygonalProperty polygonProperty = new PolygonalProperty(); + AnnotParam currentParam = null; + + public event EventHandler LineMeasureParamChanged; + public event EventHandler PolyLineMeasureParamChanged; + public event EventHandler PolygonMeasureParamChanged; + + public C_ANNOTATION_TYPE CurrentCreateType + { + get; + set; + } = C_ANNOTATION_TYPE.C_ANNOTATION_NONE; + private UIElement currentPanel = null; + private PDFViewControl pdfViewerControl; + public MeasurePropertyControl() { InitializeComponent(); + straightnessProperty.LineMeasureParamChanged -= StraightnessProperty_LineMeasureParamChanged; + multilineProperty.PolyLineMeasureParamChanged -= MultilineProperty_PolyLineMeasureParamChanged; + polygonProperty.PolygonMeasureParamChanged -= PolygonProperty_PolygonMeasureParamChanged; + + multilineProperty.PolyLineMeasureParamChanged += MultilineProperty_PolyLineMeasureParamChanged; + straightnessProperty.LineMeasureParamChanged += StraightnessProperty_LineMeasureParamChanged; + polygonProperty.PolygonMeasureParamChanged += PolygonProperty_PolygonMeasureParamChanged; + } + + private void PolygonProperty_PolygonMeasureParamChanged(object sender, PolygonMeasureParam e) + { + PolygonMeasureParamChanged?.Invoke(this, e); + } + + private void MultilineProperty_PolyLineMeasureParamChanged(object sender, PolyLineMeasureParam e) + { + PolyLineMeasureParamChanged?.Invoke(this, e); } public void SetPropertyForMeasureCreate(AnnotParam param, CPDFAnnotation annot, PDFViewControl viewControl) @@ -34,41 +69,59 @@ public void SetPropertyForMeasureCreate(AnnotParam param, CPDFAnnotation annot, ClearMeasurePanel(); return; } + + if(annot == null) + { + CurrentCreateType = param.CurrentType; + currentParam = param; + } switch (param.CurrentType) { case C_ANNOTATION_TYPE.C_ANNOTATION_LINE: - StraightnessProperty straightnessProperty = new StraightnessProperty(); - if(param is LineMeasureParam lineMeasureParam) { - straightnessProperty.SetAnnotParam(lineMeasureParam, annot, viewControl); + if (param is LineMeasureParam lineMeasureParam) + { + straightnessProperty.SetAnnotParam(lineMeasureParam, annot, viewControl); + SetMeasurePanel(straightnessProperty); + return; + } } - currentPanel = straightnessProperty; break; + case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE: - MultilineProperty multilineProperty = new MultilineProperty(); if (param is PolyLineMeasureParam polyLineMeasureParam) { multilineProperty.SetAnnotParam(polyLineMeasureParam, annot, viewControl); + SetMeasurePanel(multilineProperty); + return; } - currentPanel = multilineProperty; break; + case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON: - PolygonalProperty polygonProperty = new PolygonalProperty(); - if (param is PolygonMeasureParam polygonMeasureParam) + if (param is PolygonMeasureParam polygonMeasureParam && (annot ==null || (annot as CPDFPolygonAnnotation).IsMeasured())) { polygonProperty.SetAnnotParam(polygonMeasureParam, annot, viewControl); + SetMeasurePanel(polygonProperty); + return; } - currentPanel = polygonProperty; break; + default: break; } - SetMeasurePanel(currentPanel); + + ClearMeasurePanel(); + } + + private void StraightnessProperty_LineMeasureParamChanged(object sender, LineMeasureParam e) + { + LineMeasureParamChanged?.Invoke(this, e); } private void SetMeasurePanel(UIElement newChild) { + currentPanel = newChild; MeasurePropertyPanel.Child = newChild; } @@ -78,6 +131,84 @@ public void ClearMeasurePanel() MeasurePropertyPanel.Child = null; } + internal void InitWithPDFViewer(PDFViewControl pdfViewControl) + { + if (this.pdfViewerControl != null) + { + UnLoadPDFViewHandler(); + } + this.pdfViewerControl = pdfViewControl; + LoadPDFViewHandler(); + } + + private void LoadPDFViewHandler() + { + if (pdfViewerControl != null) + { + pdfViewerControl.MouseLeftButtonDown -= PdfViewerControl_MouseLeftButtonDown; + pdfViewerControl.MouseLeftButtonDown += PdfViewerControl_MouseLeftButtonDown; + } + } + + private void PdfViewerControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + SetAnnotEventData(); + } + + private void SetAnnotEventData() + { + if (pdfViewerControl.GetCacheHitTestAnnot() == null) + { + if (pdfViewerControl != null && (pdfViewerControl.PDFToolManager.GetToolType() == ToolType.CreateAnnot)) + { + switch (CurrentCreateType) + { + case C_ANNOTATION_TYPE.C_ANNOTATION_LINE: + straightnessProperty.Annotation = null; + straightnessProperty.SetAnnotParam(currentParam as LineMeasureParam, null, pdfViewerControl); + break; + case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE: + multilineProperty.Annotation = null; + multilineProperty.SetAnnotParam(currentParam as PolyLineMeasureParam, null, pdfViewerControl); + break; + case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON: + polygonProperty.Annotation = null; + polygonProperty.SetAnnotParam(currentParam as PolygonMeasureParam, null, pdfViewerControl); + break; + } + ShowCreateAnnotPanel(); + } + else + { + ClearMeasurePanel(); + } + } + } + + private void ShowCreateAnnotPanel() + { + switch (CurrentCreateType) + { + case C_ANNOTATION_TYPE.C_ANNOTATION_NONE: + break; + case C_ANNOTATION_TYPE.C_ANNOTATION_LINE: + currentPanel = straightnessProperty; + break; + case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON: + currentPanel = polygonProperty; + break; + case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE: + currentPanel = multilineProperty; + break; + } + SetMeasurePanel(currentPanel); + } + + private void UnLoadPDFViewHandler() + { + + } + //public void SetPorpertyForMeasureModify(AnnotAttribEvent annotEvent) //{ diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/MultilineProperty.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/MultilineProperty.xaml index 58e44bd..4f0642a 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/MultilineProperty.xaml +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/MultilineProperty.xaml @@ -7,6 +7,7 @@ mc:Ignorable="d" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded" + d:DesignHeight="800" d:DesignWidth="300" > @@ -20,7 +21,7 @@ - + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/MultilineProperty.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/MultilineProperty.xaml.cs index 7b4aa2a..a73bd98 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/MultilineProperty.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/MultilineProperty.xaml.cs @@ -19,6 +19,8 @@ using ComPDFKit.Controls.PDFControl; using ComPDFKit.Tool; using CFontNameHelper = ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper; +using System.Runtime.CompilerServices; +using System.IO.Ports; namespace ComPDFKit.Controls.Measure.Property { @@ -32,13 +34,14 @@ public partial class MultilineProperty : UserControl }; bool IsLoadedData = false; - + private PolyLineMeasureParam polyLineMeasureParam; - - public CPDFPolylineAnnotation Annotation{ get; set; } - - public PDFViewControl ViewControl{ get; set; } + public CPDFPolylineAnnotation Annotation { get; set; } + + public PDFViewControl ViewControl { get; set; } + + public event EventHandler PolyLineMeasureParamChanged; public MultilineProperty() { InitializeComponent(); @@ -48,6 +51,11 @@ private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (IsLoadedData) { + if (Annotation == null) + { + polyLineMeasureParam.Content = NoteTextBox.Text; + PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam); + } if (Annotation != null && ViewControl != null) { Annotation.SetContent(NoteTextBox.Text); @@ -85,7 +93,14 @@ private void FontStyleCombox_SelectionChanged(object sender, SelectionChangedEve default: break; } - if(Annotation != null) + if (Annotation == null) + { + polyLineMeasureParam.IsBold = isBold; + polyLineMeasureParam.IsItalic = isItalic; + PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam); + } + + if (Annotation != null) { CTextAttribute textAttribute = Annotation.GetTextAttribute(); var fontType = CFontNameHelper.GetFontType((FontCombox.SelectedItem as ComboBoxItem).Content.ToString()); @@ -101,9 +116,16 @@ private void FontCombox_SelectionChanged(object sender, SelectionChangedEventArg { if (IsLoadedData) { + ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem; + if (Annotation == null) + { + var fontType = CFontNameHelper.GetFontType(selectItem.Content.ToString()); + string FontName = CFontNameHelper.ObtainFontName(fontType, polyLineMeasureParam.IsBold, polyLineMeasureParam.IsItalic); + polyLineMeasureParam.FontName = FontName; + PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam); + } if (Annotation != null && ViewControl != null) { - ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem; if (selectItem != null && selectItem.Content != null) { CTextAttribute textAttr = Annotation.GetTextAttribute(); @@ -125,6 +147,11 @@ private void FontSizeCombox_SelectionChanged(object sender, SelectionChangedEven { if (FontSizeComboBox.SelectedItem != null) { + if (Annotation == null) + { + polyLineMeasureParam.FontSize = (float)Convert.ToDouble(FontSizeComboBox.SelectedItem); + PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam); + } if (Annotation != null && ViewControl != null) { CTextAttribute textAttribute = Annotation.GetTextAttribute(); @@ -141,12 +168,18 @@ private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e) { if (IsLoadedData) { + SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush; + byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; + + if (Annotation == null) + { + polyLineMeasureParam.LineColor = color; + PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam); + } if (Annotation != null && ViewControl != null) { - SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush; if (checkBrush != null) { - byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; Annotation.SetLineColor(color); Annotation.UpdateAp(); ViewControl.UpdateAnnotFrame(); @@ -159,9 +192,15 @@ private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e) { if (IsLoadedData) { + double opacity = CPDFOpacityControl.OpacityValue / 100.0; + + if (Annotation == null) + { + polyLineMeasureParam.Transparency = (byte)(opacity * 255); + PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam); + } if (Annotation != null && ViewControl != null) { - double opacity = CPDFOpacityControl.OpacityValue / 100.0; if (opacity > 0 && opacity <= 1) { opacity = opacity * 255; @@ -180,6 +219,11 @@ private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e) { if (IsLoadedData) { + if (Annotation == null) + { + polyLineMeasureParam.LineWidth = (byte)CPDFThicknessControl.Thickness; + PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam); + } if (Annotation != null && ViewControl != null) { Annotation.SetLineWidth(CPDFThicknessControl.Thickness); @@ -192,25 +236,35 @@ private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e) private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e) { if (!IsLoadedData) return; - if (Annotation != null && ViewControl != null) + float[] dashArray = null; + C_BORDER_STYLE borderStyle; + if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == null) { - float[] dashArray = null; - C_BORDER_STYLE borderStyle; - if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == null) + dashArray = new float[0]; + borderStyle = C_BORDER_STYLE.BS_SOLID; + } + else + { + List floatArray = new List(); + foreach (double num in CPDFLineStyleControl.DashStyle.Dashes) { - dashArray = new float[0]; - borderStyle = C_BORDER_STYLE.BS_SOLID; - } - else - { - List floatArray = new List(); - foreach (double num in CPDFLineStyleControl.DashStyle.Dashes) - { - floatArray.Add((float)num); - } - dashArray = floatArray.ToArray(); - borderStyle = C_BORDER_STYLE.BS_DASHDED; + floatArray.Add((float)num); } + dashArray = floatArray.ToArray(); + borderStyle = C_BORDER_STYLE.BS_DASHDED; + } + + if (Annotation == null) + { + polyLineMeasureParam.BorderStyle = borderStyle; + polyLineMeasureParam.LineDash = dashArray; + + PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam); + } + + if (Annotation != null && ViewControl != null) + { + Annotation.SetBorderStyle(borderStyle, dashArray); Annotation.UpdateAp(); ViewControl.UpdateAnnotFrame(); @@ -221,20 +275,30 @@ private void FontColorPickerControl_ColorChanged(object sender, EventArgs e) { if (!IsLoadedData) return; SolidColorBrush checkBrush = FontColorPickerControl.GetBrush() as SolidColorBrush; - if (checkBrush != null && Annotation != null && ViewControl != null) + if (checkBrush != null) { byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; - if (Annotation != null) + + if (Annotation == null) { - CTextAttribute textAttribute = Annotation.GetTextAttribute(); - textAttribute.FontColor = color; - Annotation.SetTextAttribute(textAttribute); - Annotation.UpdateAp(); - ViewControl.UpdateAnnotFrame(); + polyLineMeasureParam.FontColor = color; + PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam); + } + + if (Annotation != null && ViewControl != null) + { + if (Annotation != null) + { + CTextAttribute textAttribute = Annotation.GetTextAttribute(); + textAttribute.FontColor = color; + Annotation.SetTextAttribute(textAttribute); + Annotation.UpdateAp(); + ViewControl.UpdateAnnotFrame(); + } } } } - + public void SetFontStyle(bool isBold, bool isItalic) { if (isBold == false && isItalic == false) @@ -266,7 +330,7 @@ private void SetFontSize(double size) int index = SizeList.IndexOf((int)size); FontSizeComboBox.SelectedIndex = index; } - + public void SetFontName(string fontName) { foreach (ComboBoxItem item in FontCombox.Items) @@ -302,7 +366,7 @@ public void SetAnnotParam(PolyLineMeasureParam param, CPDFAnnotation annot, PDFV { return; } - + Color lineColor = Color.FromRgb(param.LineColor[0], param.LineColor[1], param.LineColor[2]); BorderColorPickerControl.SetCheckedForColor(lineColor); CPDFThicknessControl.Thickness = (int)param.LineWidth; @@ -323,7 +387,7 @@ public void SetAnnotParam(PolyLineMeasureParam param, CPDFAnnotation annot, PDFV CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity); NoteTextBox.Text = param.Content; SetFontSize(param.FontSize); - SetFontStyle(param.IsBold,param.IsItalic); + SetFontStyle(param.IsBold, param.IsItalic); SetFontName(param.FontName); } } diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/PolygonalProperty.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/PolygonalProperty.xaml.cs index 039ab50..38bf1b9 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/PolygonalProperty.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/PolygonalProperty.xaml.cs @@ -19,6 +19,7 @@ using ComPDFKit.PDFAnnotation; using ComPDFKit.Tool; using CFontNameHelper = ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper; +using System.Runtime.CompilerServices; namespace ComPDFKit.Controls.Measure.Property { @@ -30,15 +31,16 @@ public partial class PolygonalProperty : UserControl }; bool IsLoadedData = false; - + private PolygonMeasureParam polygonMeasureParam; - - public CPDFPolygonAnnotation Annotation{ get; set; } - - public PDFViewControl ViewControl{ get; set; } + public CPDFPolygonAnnotation Annotation { get; set; } + + public PDFViewControl ViewControl { get; set; } //private AnnotAttribEvent PolygonalEvent { get; set; } + public event EventHandler PolygonMeasureParamChanged; + public PolygonalProperty() { @@ -49,6 +51,11 @@ private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (IsLoadedData) { + if (Annotation == null) + { + polygonMeasureParam.Content = NoteTextBox.Text; + PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam); + } if (Annotation != null && ViewControl != null) { Annotation.SetContent(NoteTextBox.Text); @@ -86,7 +93,15 @@ private void FontStyleCombox_SelectionChanged(object sender, SelectionChangedEve default: break; } - if(Annotation != null) + + if (Annotation == null) + { + polygonMeasureParam.IsBold = isBold; + polygonMeasureParam.IsItalic = isItalic; + PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam); + } + + if (Annotation != null) { CTextAttribute textAttribute = Annotation.GetTextAttribute(); var fontType = CFontNameHelper.GetFontType((FontCombox.SelectedItem as ComboBoxItem).Content.ToString()); @@ -104,6 +119,11 @@ private void FontSizeCombox_SelectionChanged(object sender, SelectionChangedEven { if (FontSizeComboBox.SelectedItem != null) { + if (Annotation == null) + { + polygonMeasureParam.FontSize = (float)Convert.ToDouble(FontSizeComboBox.SelectedItem); + PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam); + } if (Annotation != null && ViewControl != null) { CTextAttribute textAttribute = Annotation.GetTextAttribute(); @@ -120,9 +140,16 @@ private void FontCombox_SelectionChanged(object sender, SelectionChangedEventArg { if (IsLoadedData) { + ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem; + if (Annotation == null) + { + var fontType = CFontNameHelper.GetFontType(selectItem.Content.ToString()); + string FontName = CFontNameHelper.ObtainFontName(fontType, polygonMeasureParam.IsBold, polygonMeasureParam.IsItalic); + polygonMeasureParam.FontName = FontName; + PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam); + } if (Annotation != null && ViewControl != null) { - ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem; if (selectItem != null && selectItem.Content != null) { CTextAttribute textAttr = Annotation.GetTextAttribute(); @@ -156,12 +183,17 @@ private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e) { if (IsLoadedData) { - if (Annotation != null && ViewControl != null) + if (BorderColorPickerControl.GetBrush() is SolidColorBrush checkBrush) { - SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush; - if (checkBrush != null) + byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; + + if (Annotation == null) + { + polygonMeasureParam.LineColor = color; + PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam); + } + if (Annotation != null && ViewControl != null) { - byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; Annotation.SetLineColor(color); Annotation.UpdateAp(); ViewControl.UpdateAnnotFrame(); @@ -174,13 +206,33 @@ private void FillColorPickerControl_ColorChanged(object sender, EventArgs e) { if (IsLoadedData) { - if (Annotation != null && ViewControl != null) + SolidColorBrush checkBrush = FillColorPickerControl.GetBrush() as SolidColorBrush; + if (checkBrush != null) { - SolidColorBrush checkBrush = FillColorPickerControl.GetBrush() as SolidColorBrush; - if (checkBrush != null) + byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; + if (Annotation == null) { - byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; - Annotation.SetBgColor(color); + polygonMeasureParam.FillColor = color; + if (checkBrush.Color != Colors.Transparent) + { + polygonMeasureParam.HasFillColor = true; + } + else + { + polygonMeasureParam.HasFillColor = false; + } + PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam); + } + if (Annotation != null && ViewControl != null) + { + if (checkBrush.Color == Colors.Transparent) + { + Annotation.ClearBgColor(); + } + else + { + Annotation.SetBgColor(color); + } Annotation.UpdateAp(); ViewControl.UpdateAnnotFrame(); } @@ -192,13 +244,19 @@ private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e) { if (IsLoadedData) { + double opacity = CPDFOpacityControl.OpacityValue / 100.0; + if (opacity > 0 && opacity <= 1) + { + opacity = opacity * 255; + } + + if (Annotation == null) + { + polygonMeasureParam.Transparency = (byte)opacity; + PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam); + } if (Annotation != null && ViewControl != null) { - double opacity = CPDFOpacityControl.OpacityValue / 100.0; - if (opacity > 0 && opacity <= 1) - { - opacity = opacity * 255; - } if (Math.Abs(opacity - Annotation.GetTransparency()) > 0.01) { Annotation.SetTransparency((byte)opacity); @@ -212,25 +270,33 @@ private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e) private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e) { if (!IsLoadedData) return; - if (Annotation != null && ViewControl != null) + float[] dashArray = null; + C_BORDER_STYLE borderStyle; + if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == null) { - float[] dashArray = null; - C_BORDER_STYLE borderStyle; - if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == null) - { - dashArray = new float[0]; - borderStyle = C_BORDER_STYLE.BS_SOLID; - } - else + dashArray = new float[0]; + borderStyle = C_BORDER_STYLE.BS_SOLID; + } + else + { + List floatArray = new List(); + foreach (double num in CPDFLineStyleControl.DashStyle.Dashes) { - List floatArray = new List(); - foreach (double num in CPDFLineStyleControl.DashStyle.Dashes) - { - floatArray.Add((float)num); - } - dashArray = floatArray.ToArray(); - borderStyle = C_BORDER_STYLE.BS_DASHDED; + floatArray.Add((float)num); } + dashArray = floatArray.ToArray(); + borderStyle = C_BORDER_STYLE.BS_DASHDED; + } + if (Annotation == null) + { + polygonMeasureParam.BorderStyle = borderStyle; + polygonMeasureParam.LineDash = dashArray; + + PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam); + } + if (Annotation != null && ViewControl != null) + { + Annotation.SetBorderStyle(borderStyle, dashArray); Annotation.UpdateAp(); ViewControl.UpdateAnnotFrame(); @@ -241,16 +307,26 @@ private void FontColorPickerControl_ColorChanged(object sender, EventArgs e) { if (!IsLoadedData) return; SolidColorBrush checkBrush = FontColorPickerControl.GetBrush() as SolidColorBrush; - if (checkBrush != null && Annotation != null && ViewControl != null) + if (checkBrush != null) { byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; - if (Annotation != null) + if (Annotation == null) { - CTextAttribute textAttribute = Annotation.GetTextAttribute(); - textAttribute.FontColor = color; - Annotation.SetTextAttribute(textAttribute); - Annotation.UpdateAp(); - ViewControl.UpdateAnnotFrame(); + polygonMeasureParam.FontColor = color; + PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam); + } + + if (Annotation != null && ViewControl != null) + { + + if (Annotation != null) + { + CTextAttribute textAttribute = Annotation.GetTextAttribute(); + textAttribute.FontColor = color; + Annotation.SetTextAttribute(textAttribute); + Annotation.UpdateAp(); + ViewControl.UpdateAnnotFrame(); + } } } } @@ -286,7 +362,7 @@ private void SetFontSize(double size) int index = SizeList.IndexOf((int)size); FontSizeComboBox.SelectedIndex = index; } - + public void SetFontName(string fontName) { foreach (ComboBoxItem item in FontCombox.Items) @@ -308,9 +384,36 @@ public void SetAnnotParam(PolygonMeasureParam param, CPDFAnnotation annot, PDFVi { return; } - + Color lineColor = Color.FromRgb(param.LineColor[0], param.LineColor[1], param.LineColor[2]); BorderColorPickerControl.SetCheckedForColor(lineColor); + if(Annotation != null) + { + if (!Annotation.HasBgColor) + { + FillColorPickerControl.SetCheckedForColor(Colors.Transparent); + } + else + { + Color fillColor = Color.FromRgb(param.FillColor[0], param.FillColor[1], param.FillColor[2]); + FillColorPickerControl.SetCheckedForColor(fillColor); + } + } + else + { + if (!param.HasFillColor) + { + FillColorPickerControl.SetCheckedForColor(Colors.Transparent); + } + else + { + Color fillColor = Color.FromRgb(param.FillColor[0], param.FillColor[1], param.FillColor[2]); + FillColorPickerControl.SetCheckedForColor(fillColor); + } + } + Color FontColor = Color.FromRgb(param.FontColor[0], param.FontColor[1], param.FontColor[2]); + FontColorPickerControl.SetCheckedForColor(FontColor); + if (polygonMeasureParam.BorderStyle == C_BORDER_STYLE.BS_SOLID) { CPDFLineStyleControl.DashStyle = DashStyles.Solid; @@ -328,7 +431,7 @@ public void SetAnnotParam(PolygonMeasureParam param, CPDFAnnotation annot, PDFVi CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity); NoteTextBox.Text = param.Content; SetFontSize(param.FontSize); - SetFontStyle(param.IsBold,param.IsItalic); + SetFontStyle(param.IsBold, param.IsItalic); SetFontName(param.FontName); } } diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/StraightnessProperty.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/StraightnessProperty.xaml index 181c962..5649aef 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/StraightnessProperty.xaml +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/StraightnessProperty.xaml @@ -9,7 +9,7 @@ mc:Ignorable="d" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded" - > + d:DesignHeight="800" d:DesignWidth="300"> diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/StraightnessProperty.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/StraightnessProperty.xaml.cs index fa74f02..44dee2d 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/StraightnessProperty.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Measure/Property/StraightnessProperty.xaml.cs @@ -21,6 +21,7 @@ using ComPDFKit.Controls.PDFControl; using ComPDFKit.Tool; using CFontNameHelper = ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper; +using System.IO.Ports; namespace ComPDFKit.Controls.Measure.Property { @@ -35,10 +36,16 @@ public partial class StraightnessProperty : UserControl bool IsLoadedData = false; private LineMeasureParam lineMeasureParam; - - public CPDFLineAnnotation Annotation{ get; set; } - - public PDFViewControl ViewControl{ get; set; } + + public CPDFLineAnnotation Annotation + { + get; + set; + } + + public PDFViewControl ViewControl { get; set; } + + public event EventHandler LineMeasureParamChanged; public StraightnessProperty() { @@ -47,8 +54,14 @@ public StraightnessProperty() private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e) { + if (IsLoadedData) { + if (Annotation == null) + { + lineMeasureParam.Content = NoteTextBox.Text; + LineMeasureParamChanged?.Invoke(sender, lineMeasureParam); + } if (Annotation != null && ViewControl != null) { Annotation.SetContent(NoteTextBox.Text); @@ -61,6 +74,7 @@ private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e) private void FontStyleCombox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!IsLoadedData) return; + int selectIndex = Math.Max(0, FontStyleCombox.SelectedIndex); bool isBold = false; bool isItalic = false; @@ -86,7 +100,13 @@ private void FontStyleCombox_SelectionChanged(object sender, SelectionChangedEve default: break; } - if(Annotation != null) + if (Annotation == null) + { + lineMeasureParam.IsBold = isBold; + lineMeasureParam.IsItalic = isItalic; + LineMeasureParamChanged?.Invoke(sender, lineMeasureParam); + } + if (Annotation != null) { CTextAttribute textAttribute = Annotation.GetTextAttribute(); var fontType = CFontNameHelper.GetFontType((FontCombox.SelectedItem as ComboBoxItem).Content.ToString()); @@ -102,8 +122,14 @@ private void FontSizeComboBox_SelectionChanged(object sender, SelectionChangedEv { if (IsLoadedData) { + if (FontSizeComboBox.SelectedItem != null) { + if (Annotation == null) + { + lineMeasureParam.FontSize = (float)Convert.ToDouble(FontSizeComboBox.SelectedItem); + LineMeasureParamChanged?.Invoke(sender, lineMeasureParam); + } if (Annotation != null && ViewControl != null) { CTextAttribute textAttribute = Annotation.GetTextAttribute(); @@ -119,10 +145,18 @@ private void FontSizeComboBox_SelectionChanged(object sender, SelectionChangedEv private void FontCombox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (IsLoadedData) - { + { + ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem; + if (Annotation == null) + { + var fontType = CFontNameHelper.GetFontType(selectItem.Content.ToString()); + string FontName = CFontNameHelper.ObtainFontName(fontType, lineMeasureParam.IsBold, lineMeasureParam.IsItalic); + lineMeasureParam.FontName = FontName; + LineMeasureParamChanged?.Invoke(sender, lineMeasureParam); + } + if (Annotation != null && ViewControl != null) { - ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem; if (selectItem != null && selectItem.Content != null) { CTextAttribute textAttr = Annotation.GetTextAttribute(); @@ -140,14 +174,20 @@ private void FontCombox_SelectionChanged(object sender, SelectionChangedEventArg private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e) { + SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush; + byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; + if (IsLoadedData) - { + { + if (Annotation == null) + { + lineMeasureParam.LineColor = color; + LineMeasureParamChanged?.Invoke(sender, lineMeasureParam); + } if (Annotation != null && ViewControl != null) { - SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush; if (checkBrush != null) { - byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; Annotation.SetLineColor(color); Annotation.UpdateAp(); ViewControl.UpdateAnnotFrame(); @@ -158,11 +198,18 @@ private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e) private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e) { + if (IsLoadedData) { + double opacity = CPDFOpacityControl.OpacityValue / 100.0; + + if (Annotation == null) + { + lineMeasureParam.Transparency = (byte)(opacity * 255); + LineMeasureParamChanged?.Invoke(sender, lineMeasureParam); + } if (Annotation != null && ViewControl != null) { - double opacity = CPDFOpacityControl.OpacityValue / 100.0; if (opacity > 0 && opacity <= 1) { opacity = opacity * 255; @@ -186,7 +233,7 @@ public void SetAnnotParam(LineMeasureParam param, CPDFAnnotation annot, PDFViewC { return; } - + Color lineColor = Color.FromRgb(param.LineColor[0], param.LineColor[1], param.LineColor[2]); BorderColorPickerControl.SetCheckedForColor(lineColor); CPDFThicknessControl.Thickness = (int)param.LineWidth; @@ -213,10 +260,10 @@ public void SetAnnotParam(LineMeasureParam param, CPDFAnnotation annot, PDFViewC CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity); NoteTextBox.Text = param.Content; SetFontSize(param.FontSize); - SetFontStyle(param.IsBold,param.IsItalic); + SetFontStyle(param.IsBold, param.IsItalic); SetFontName(param.FontName); } - + public void SetFontName(string fontName) { foreach (ComboBoxItem item in FontCombox.Items) @@ -263,6 +310,11 @@ private void SetFontSize(double size) private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e) { + if (Annotation == null) + { + lineMeasureParam.LineWidth = (byte)CPDFThicknessControl.Thickness; + LineMeasureParamChanged?.Invoke(sender, lineMeasureParam); + } if (IsLoadedData) { if (Annotation != null && ViewControl != null) @@ -276,26 +328,34 @@ private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e) private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e) { + if (!IsLoadedData) return; - if (Annotation != null && ViewControl != null) + float[] dashArray = null; + C_BORDER_STYLE borderStyle; + if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == null) { - float[] dashArray = null; - C_BORDER_STYLE borderStyle; - if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == null) - { - dashArray = new float[0]; - borderStyle = C_BORDER_STYLE.BS_SOLID; - } - else + dashArray = new float[0]; + borderStyle = C_BORDER_STYLE.BS_SOLID; + } + else + { + List floatArray = new List(); + foreach (double num in CPDFLineStyleControl.DashStyle.Dashes) { - List floatArray = new List(); - foreach (double num in CPDFLineStyleControl.DashStyle.Dashes) - { - floatArray.Add((float)num); - } - dashArray = floatArray.ToArray(); - borderStyle = C_BORDER_STYLE.BS_DASHDED; + floatArray.Add((float)num); } + dashArray = floatArray.ToArray(); + borderStyle = C_BORDER_STYLE.BS_DASHDED; + } + + if (Annotation == null) + { + lineMeasureParam.BorderStyle = borderStyle; + lineMeasureParam.LineDash = dashArray; + LineMeasureParamChanged?.Invoke(sender, lineMeasureParam); + } + if (Annotation != null && ViewControl != null) + { Annotation.SetBorderStyle(borderStyle, dashArray); Annotation.UpdateAp(); ViewControl.UpdateAnnotFrame(); @@ -305,13 +365,22 @@ private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e) private void CPDFArrowControl_ArrowChanged(object sender, EventArgs e) { if (!IsLoadedData) return; + LineType lineType = new LineType() + { + HeadLineType = CPDFArrowControl.LineType.HeadLineType, + TailLineType = CPDFArrowControl.LineType.TailLineType + }; + + if (Annotation == null) + { + lineMeasureParam.HeadLineType = lineType.HeadLineType; + lineMeasureParam.TailLineType = lineType.TailLineType; + LineMeasureParamChanged?.Invoke(sender, lineMeasureParam); + } + if (Annotation != null && ViewControl != null) { - LineType lineType = new LineType() - { - HeadLineType = CPDFArrowControl.LineType.HeadLineType, - TailLineType = CPDFArrowControl.LineType.TailLineType - }; + Annotation.SetLineType(lineType.HeadLineType, lineType.TailLineType); Annotation.UpdateAp(); ViewControl.UpdateAnnotFrame(); @@ -322,9 +391,15 @@ private void FontColorPickerControl_ColorChanged(object sender, EventArgs e) { if (!IsLoadedData) return; SolidColorBrush checkBrush = FontColorPickerControl.GetBrush() as SolidColorBrush; + byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; + + if (Annotation == null) + { + lineMeasureParam.FontColor = color; + LineMeasureParamChanged?.Invoke(sender, lineMeasureParam); + } if (checkBrush != null && Annotation != null && ViewControl != null) { - byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B }; if (Annotation != null) { CTextAttribute textAttribute = Annotation.GetTextAttribute(); diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchControl/CPDFSearchControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchControl/CPDFSearchControl.xaml.cs index 6cb2bf1..38ee6df 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchControl/CPDFSearchControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchControl/CPDFSearchControl.xaml.cs @@ -289,6 +289,7 @@ private void SearchInput_SearchEvent(object sender, string e) pdfView.GetDocument().WriteToLoadedPath(); } } + keyWord = e; textSearch.TextSearchDocument = pdfView.GetDocument(); SearchResult.ClearSearchResult(); @@ -300,7 +301,19 @@ private void SearchInput_SearchEvent(object sender, string e) keyWord = e; textSearch.TextSearchDocument = pdfView.GetDocument(); - textSearch.SearchText(e, C_Search_Options.Search_Case_Insensitive, ViewControl.Password); + + C_Search_Options options = C_Search_Options.Search_Case_Insensitive; + if(!CaseChb.IsChecked) + { + options |= C_Search_Options.Search_Case_Sensitive; + } + + if(MatchChb.IsChecked) + { + options |= C_Search_Options.Search_Match_Whole_Word; + } + + textSearch.SearchText(e, options, ViewControl.Password); } else if (ReplaceTog.IsChecked == true) { diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchUI/CPDFSearchInputUI.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchUI/CPDFSearchInputUI.xaml index b50a112..7ac0dc6 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchUI/CPDFSearchInputUI.xaml +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchUI/CPDFSearchInputUI.xaml @@ -48,7 +48,7 @@ diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchUI/CPDFSearchResultUI.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchUI/CPDFSearchResultUI.xaml.cs index eaef3f3..8b55f2b 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchUI/CPDFSearchResultUI.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFSearch/PDFSearchUI/CPDFSearchResultUI.xaml.cs @@ -59,7 +59,7 @@ public void ClearSearchResult() ResultListControl.Visibility = Visibility.Collapsed; NoResultText.Visibility = Visibility.Visible; } - + public void AddSearchResult(BindSearchResult result) { if (result == null) @@ -161,7 +161,7 @@ public class BindSearchResult /// The page rotation angle. /// public int PageRotate { get; set; } - public object RefData { get; set; } + public object RefData { get; set; } } internal class TextBindData @@ -203,6 +203,59 @@ public static void SetDocumentBind(DependencyObject obj, FlowDocument value) } }); + public static int MapIndexToContent(string a, string b, int indexInA) + { + if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(b) || indexInA < 0 || indexInA >= a.Length) + { + return -1; + } + + int indexInB = 0; + int aIndexCounter = 0; + + // Iterate over b and match characters to those in a + for (int i = 0; i < b.Length; i++) + { + if (b[i] != ' ') + { + if (aIndexCounter == indexInA) + { + indexInB = i; + break; + } + aIndexCounter++; + } + } + + return indexInB; + } + + public static string RestoreStringWithSpaces(string a, string b, int startIndexInB) + { + if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(b) || startIndexInB < 0 || startIndexInB >= b.Length) + { + return string.Empty; + } + a = Regex.Replace(a, @"[\r\n\s]", ""); + int aIndex = 0; + string result = string.Empty; + + for (int i = startIndexInB; i < b.Length && aIndex < a.Length; i++) + { + if (b[i] == ' ') + { + result += ' '; + } + else + { + result += a[aIndex]; + aIndex++; + } + } + + return result; + } + /// /// Get document stream data /// @@ -216,44 +269,56 @@ public static FlowDocument GetFlowDocument(string content, string keyword, Color Paragraph textPara = new Paragraph(); Document.Blocks.Add(textPara); List indexList = new List(); - content = Regex.Replace(content, "[\r\n]", " "); - if (keyword.Length > 0) + content = Regex.Replace(content, @"[\r\n]", " "); + int originalIndex = -1; + string contentForMatch = Regex.Replace(content, @"[\r\n\s]", ""); + string keywordForMatch = Regex.Replace(keyword, @"\s", ""); + + if (keywordForMatch.Length > 0) { - for (int i = 0; i < content.Length && i >= 0;) + for (int i = 0, offset = 0; i < contentForMatch.Length && i >= 0;) { - i = content.IndexOf(keyword, i, StringComparison.OrdinalIgnoreCase); + i = contentForMatch.IndexOf(keywordForMatch, i, StringComparison.OrdinalIgnoreCase); if (i == -1) { break; } - if (indexList.Contains(i) == false) + + originalIndex = content.IndexOf(keyword, offset, StringComparison.OrdinalIgnoreCase); + if (originalIndex != -1 && !indexList.Contains(originalIndex)) + { + indexList.Add(originalIndex); + offset = originalIndex + keyword.Length; + i += keywordForMatch.Length; + } + else if(originalIndex == -1) { - indexList.Add(i); + originalIndex = MapIndexToContent(contentForMatch, content, i); + indexList.Add(originalIndex); + offset = originalIndex + keyword.Length; + i += keywordForMatch.Length; } - i += keyword.Length; } } + if(originalIndex != -1) + { + keyword = RestoreStringWithSpaces(keyword, content, originalIndex); + } + List splitList = new List(); int lastIndex = -1; foreach (int index in indexList) { - string prevStr = string.Empty; - if (lastIndex == -1) - { - prevStr = content.Substring(0, index); - } - else - { - prevStr = content.Substring(lastIndex + keyword.Length, index - lastIndex - 1); - } + string prevStr = lastIndex == -1 ? content.Substring(0, index) : content.Substring(lastIndex + keyword.Length, index - lastIndex - keyword.Length); if (prevStr != string.Empty) { splitList.Add(prevStr); } - + splitList.Add(content.Substring(index, keyword.Length)); lastIndex = index; } + if (indexList.Count > 0) { lastIndex = indexList[indexList.Count - 1]; @@ -262,6 +327,11 @@ public static FlowDocument GetFlowDocument(string content, string keyword, Color splitList.Add(content.Substring(lastIndex + keyword.Length)); } } + else + { + splitList.Add(content); + } + TextBlock addBlock = new TextBlock(); foreach (string textappend in splitList) { @@ -278,5 +348,6 @@ public static FlowDocument GetFlowDocument(string content, string keyword, Color return Document; } + } } diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFViewControl/PDFViewControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFViewControl/PDFViewControl.xaml.cs index e78c180..6383b0f 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFViewControl/PDFViewControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/PDFView/PDFViewControl/PDFViewControl.xaml.cs @@ -14,12 +14,13 @@ using System.Windows.Controls; using System.Windows.Input; using ComPDFKit.Controls.Helper; -using ComPDFKit.Tool.DrawTool; using SplitMode = ComPDFKit.Controls.PDFControlUI.CPDFViewModeUI.SplitMode; using System.Threading; using System.Threading.Tasks; using ComPDFKitViewer.Annot; using System.IO; +using ComPDFKit.Import; +using ComPDFKit.PDFPage; namespace ComPDFKit.Controls.PDFControl { @@ -34,6 +35,7 @@ public partial class PDFViewControl : UserControl public string Password { get; set; } = string.Empty; public CPDFViewerTool PDFViewTool { get; private set; } + public CPDFToolManager PDFToolManager { get; private set; } public CPDFViewerTool FocusPDFViewTool { get; private set; } @@ -44,9 +46,11 @@ public partial class PDFViewControl : UserControl public event EventHandler MouseLeftButtonUpHandler; public event EventHandler MouseMoveHandler; public event EventHandler MouseRightButtonDownHandler; - public event EventHandler MouseWheelZoomHandler; + public event EventHandler MouseWheelZoomHandler; public event EventHandler DrawChanged; + public PageSelectedData SnapshotData { get; private set; } + //private ContextMenu RightMenu; #region Properties @@ -57,6 +61,7 @@ public partial class PDFViewControl : UserControl private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 }; #endregion + public PDFViewControl() { InitializeComponent(); @@ -78,6 +83,7 @@ public PDFViewControl() PDFViewTool.GetCPDFViewer().MouseWheelZoomHandler -= PDFViewControl_MouseWheelZoomHandler; PDFViewTool.GetCPDFViewer().MouseMove -= PDFViewControl_MouseMove; PDFViewTool.DrawChanged -= PDFViewTool_DrawChanged; + PDFViewTool.PageSelectedChanged -= PDFViewTool_PageSelectedChanged; PDFToolManager.MouseLeftButtonDownHandler -= PDFToolManager_MouseLeftButtonDownHandler; PDFToolManager.MouseLeftButtonUpHandler -= PDFToolManager_MouseLeftButtonUpHandler; PDFToolManager.MouseMoveHandler -= PDFToolManager_MouseMoveHandler; @@ -87,6 +93,7 @@ public PDFViewControl() PDFViewTool.GetCPDFViewer().MouseWheelZoomHandler += PDFViewControl_MouseWheelZoomHandler; PDFViewTool.GetCPDFViewer().MouseMove += PDFViewControl_MouseMove; PDFViewTool.DrawChanged += PDFViewTool_DrawChanged; + PDFViewTool.PageSelectedChanged += PDFViewTool_PageSelectedChanged; PDFToolManager.MouseLeftButtonDownHandler += PDFToolManager_MouseLeftButtonDownHandler; PDFToolManager.MouseLeftButtonUpHandler += PDFToolManager_MouseLeftButtonUpHandler; PDFToolManager.MouseMoveHandler += PDFToolManager_MouseMoveHandler; @@ -95,6 +102,7 @@ public PDFViewControl() splitViewerTool.SizeChanged -= SplitViewerTool_SizeChanged; splitViewerTool.GetCPDFViewer().MouseWheelZoomHandler -= SplitPDFViewControl_MouseWheelZoomHandler; splitViewerTool.DrawChanged -= PDFViewTool_DrawChanged; + splitViewerTool.PageSelectedChanged -= PDFViewTool_PageSelectedChanged; splitToolManager.MouseLeftButtonDownHandler -= PDFToolManager_MouseLeftButtonDownHandler; splitToolManager.MouseLeftButtonUpHandler -= PDFToolManager_MouseLeftButtonUpHandler; splitToolManager.MouseMoveHandler -= PDFToolManager_MouseMoveHandler; @@ -103,20 +111,34 @@ public PDFViewControl() splitViewerTool.SizeChanged += SplitViewerTool_SizeChanged; splitViewerTool.GetCPDFViewer().MouseWheelZoomHandler += SplitPDFViewControl_MouseWheelZoomHandler; splitViewerTool.DrawChanged += PDFViewTool_DrawChanged; + splitViewerTool.PageSelectedChanged += PDFViewTool_PageSelectedChanged; splitToolManager.MouseLeftButtonDownHandler += PDFToolManager_MouseLeftButtonDownHandler; splitToolManager.MouseLeftButtonUpHandler += PDFToolManager_MouseLeftButtonUpHandler; splitToolManager.MouseMoveHandler += PDFToolManager_MouseMoveHandler; splitToolManager.MouseRightButtonDownHandler += PDFToolManager_MouseRightButtonDownHandler; + GetCPDFViewer().OnRenderFinish -= PDFViewControl_OnRenderFinish; + GetCPDFViewer().OnRenderFinish += PDFViewControl_OnRenderFinish; + SetCursor(); } - + + private void PDFViewControl_OnRenderFinish(object sender, EventArgs e) + { + SetCursorStatus(); + } + private void PDFViewTool_DrawChanged(object sender, EventArgs e) { FocusPDFViewToolChanged?.Invoke(this, EventArgs.Empty); DrawChanged?.Invoke(sender, e); } + private void PDFViewTool_PageSelectedChanged(object sender, PageSelectedData e) + { + SnapshotData = e; + } + public ContextMenu GetRightMenu() { FocusPDFViewTool.ContextMenu?.Items.Clear(); @@ -312,7 +334,6 @@ public void SetCropMode(bool isCrop) viewerTool?.GetCPDFViewer()?.UpdateRenderFrame(); splitViewerTool?.GetCPDFViewer()?.UpdateRenderFrame(); - } public void SetToolType(ToolType type) @@ -529,6 +550,38 @@ private void PDFView_GotFocus(object sender, RoutedEventArgs e) } } + private void ReloadDocument() + { + viewerTool?.GetCPDFViewer()?.UpdateVirtualNodes(); + splitViewerTool?.GetCPDFViewer()?.UpdateVirtualNodes(); + viewerTool?.GetCPDFViewer()?.UpdateRenderFrame(); + splitViewerTool?.GetCPDFViewer()?.UpdateRenderFrame(); + } + + public void CropPage(CPDFDisplayBox cropBox, Rect cropRect, List pagesList) + { + bool needLoad = false; + CPDFDocument doc = FocusPDFViewTool.GetCPDFViewer().GetDocument(); + + foreach (int pageIndex in pagesList) + { + if (pageIndex < 0 || pageIndex > doc.PageCount) + { + continue; + } + CPDFPage CropPage = doc.PageAtIndex(pageIndex); + CRect rect = new CRect((float)cropRect.X, (float)(cropRect.Y + cropRect.Height), (float)(cropRect.X + cropRect.Width), (float)cropRect.Y); + CropPage.CropPage(cropBox, rect); + CropPage.ReleaseAllAnnotations(); + needLoad = true; + } + + if (needLoad) + { + ReloadDocument(); + } + } + #region Private Command Methods private double CheckZoomLevel(double zoom, bool IsGrowth) { @@ -598,8 +651,80 @@ private void PDFView_MouseDown(object sender, MouseButtonEventArgs e) } } + private void SetCursorStatus() + { + List toolTypes = new List + { + ToolType.Viewer, + ToolType.Pan + }; + + ToolType currentMode = PDFViewTool.GetToolType(); + Cursor newCursor = Cursors.Arrow; + + if (toolTypes.Contains(currentMode)) + { + BaseAnnot hitAnnot = GetCPDFViewer().AnnotHitTest(); + if (hitAnnot != null) + { + if (hitAnnot is LinkAnnot || hitAnnot is BaseWidget) + { + newCursor = Cursors.Hand; + } + else + { + newCursor = annotEditCursor; + } + } + else + { + if (!PDFViewTool.IsSelectRectMousePoint()) + { + newCursor = (PDFToolManager.GetToolType() == ToolType.Pan) ? panToolCursor : Cursors.Arrow; + + if (PDFViewTool.IsText()) + { + newCursor = Cursors.IBeam; + } + } + } + + if (currentMode == ToolType.CreateAnnot) + { + List annotTypes = new List + { + C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT, + C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE, + C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY, + C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT + }; + + if (GetCPDFViewer().AnnotHitTest() == null && PDFViewTool.IsText() && annotTypes.Contains(toolManager.GetAnnotType())) + { + newCursor = Cursors.IBeam; + } + else + { + if (newCursor == Cursors.IBeam || newCursor == panToolCursor || newCursor == Cursors.Arrow) + { + newCursor = annotEditCursor; + } + } + } + } + + GetCPDFViewer().Cursor = newCursor; + } + private void PDFViewControl_MouseMove(object sender, MouseEventArgs e) { + if (GetCPDFViewer().IsRendering) + { + GetCPDFViewer().Cursor = Cursors.Wait; + FocusPDFViewTool.ContextMenu?.Items.Clear(); + return; + } + if (isAutomaticScroll) { middleMovePoint = e.GetPosition(this); @@ -666,7 +791,7 @@ private void PDFViewControl_MouseMove(object sender, MouseEventArgs e) { newCursor = Cursors.IBeam; } - cursorSet = true; + cursorSet = true; } } @@ -685,6 +810,7 @@ private void PDFViewControl_MouseMove(object sender, MouseEventArgs e) C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY, C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT }; + if (GetCPDFViewer().AnnotHitTest() == null && PDFViewTool.IsText() && annotTypes.Contains(toolManager.GetAnnotType())) { newCursor = Cursors.IBeam; diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/PageEdit/PDFPageEdit/CPDFPageEditControl.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/PageEdit/PDFPageEdit/CPDFPageEditControl.xaml.cs index e7010e9..8bd95fd 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/PageEdit/PDFPageEdit/CPDFPageEditControl.xaml.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/PageEdit/PDFPageEdit/CPDFPageEditControl.xaml.cs @@ -1219,6 +1219,7 @@ public void PopulateThumbnailList() item.VerticalContentAlignment = VerticalAlignment.Center; bindPageList.Add(item); } + PageEditListBox.ItemsSource = bindPageList; } diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Printer/PrinterDialog.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Printer/PrinterDialog.xaml index f9f4880..c0e81f4 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Printer/PrinterDialog.xaml +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Printer/PrinterDialog.xaml @@ -81,15 +81,17 @@ + FontSize="14" + Text="{Binding Converter={StaticResource CommonResourceConverter},ConverterParameter=Printer_Oritation}"> + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Properties/AssemblyInfo.cs index 2a252f9..eeed83b 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Properties/AssemblyInfo.cs @@ -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")] diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Snapshot/SnapshotMenu.xaml b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Snapshot/SnapshotMenu.xaml new file mode 100644 index 0000000..993a216 --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Snapshot/SnapshotMenu.xaml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Snapshot/SnapshotMenu.xaml.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Snapshot/SnapshotMenu.xaml.cs new file mode 100644 index 0000000..9f5036f --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Snapshot/SnapshotMenu.xaml.cs @@ -0,0 +1,311 @@ +using ComPDFKit.Controls.Common; +using ComPDFKit.Controls.Helper; +using ComPDFKit.Controls.PDFControl; +using ComPDFKit.Import; +using ComPDFKit.PDFDocument; +using ComPDFKit.PDFPage; +using ComPDFKit.Tool; +using ComPDFKitViewer; +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.IO; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +namespace ComPDFKit.Controls.Snapshot +{ + public partial class SnapshotMenu : UserControl + { + public SnapshotEditToolArgs SnapToolArgs { get; set; } + public PDFViewControl PdfViewer { get; set; } + public event EventHandler> SnapToolEvent; + + public SnapshotMenu() + { + InitializeComponent(); + SetLangText(); + } + + private void SetLangText() + { + ToolTipService.SetToolTip(ReSnapshotBtn, LanguageHelper.CompressManager.GetString("ContentSelection_CancelDo")); + ToolTipService.SetToolTip(SnapshotPrintBtn, LanguageHelper.CompressManager.GetString("Main_Print")); + ToolTipService.SetToolTip(SnapshotSaveBtn, LanguageHelper.CompressManager.GetString("ContentSelection_Output")); + ToolTipService.SetToolTip(SnapshotCloseBtn, LanguageHelper.CompressManager.GetString("ContentSelection_Exit")); + ToolTipService.SetToolTip(SnapshotCopyBtn, LanguageHelper.CompressManager.GetString("Main_Copy")); + ToolTipService.SetToolTip(SnapshotCorpBtn, LanguageHelper.CompressManager.GetString("Main_Crop")); + ToolTipService.SetToolTip(SnapshotCorpBtn2, LanguageHelper.CompressManager.GetString("Main_Crop")); + } + + private void Button_ReSnapshot(object sender, RoutedEventArgs e) + { + if(SnapToolArgs!=null) + { + SnapToolArgs.ReSnapshot(); + } + } + + private void Button_SnapshotClose(object sender, RoutedEventArgs e) + { + if(SnapToolEvent!=null) + { + KeyValuePair param = new KeyValuePair("CloseSnap",null); + SnapToolEvent.Invoke(this, param); + } + } + + private void Button_SnapshotCopy(object sender, RoutedEventArgs e) + { + if (SnapToolArgs != null) + { + SnapToolArgs.SaveSnapshotToClipboard(); + if (SnapToolEvent != null) + { + KeyValuePair param = new KeyValuePair("CloseSnap", null); + SnapToolEvent.Invoke(this, param); + } + } + } + + private int CropPageUI { get; set; } + + private void Button_SnapshotCorp(object sender, RoutedEventArgs e) + { + if (MessageBoxEx.Show(LanguageHelper.CompressManager.GetString("Corp_Customize_PRM") + " ", LanguageHelper.CompressManager.GetString("Corp_Customize"), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) + { + if (SnapToolArgs != null && PdfViewer != null) + { + List cropPageList = new List(); + Rect rect = SnapToolArgs.GetSnapshotPDFRect(out int pageIndexex); + cropPageList.Add(pageIndexex); + PdfViewer?.CropPage(CPDFDisplayBox.CropBox, rect, cropPageList); + PdfViewer.FocusPDFViewTool.GetCPDFViewer().GoToPage(pageIndexex); + KeyValuePair param = new KeyValuePair("Save", null); + SnapToolEvent.Invoke(this, param); + + if (SnapToolEvent != null) + { + param = new KeyValuePair("CloseSnap", null); + SnapToolEvent.Invoke(this, param); + } + } + } + } + + private void Button_SnapshotSave(object sender, RoutedEventArgs e) + { + if (SnapToolArgs != null && PdfViewer != null && PdfViewer.PDFToolManager != null) + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "jpg|*.jpg|png|*.png"; + dlg.FileName = PdfViewer.GetCPDFViewer().GetDocument().FileName; + if(dlg.FileName==null ||dlg.FileName.Trim().Length==0) + { + dlg.FileName = "Blank" + DateTime.Now.ToString("yyyyMMddHHmmss"); + } + + if (dlg.ShowDialog() == true) + { + string fileName = dlg.FileName; + WriteableBitmap saveBitmap= SnapToolArgs.GetSnapshotImage(); + if(saveBitmap!=null) + { + if (dlg.SafeFileName.ToLower().EndsWith(".jpg")) + { + Stream saveStream = dlg.OpenFile(); + JpegBitmapEncoder jpgEncoder = new JpegBitmapEncoder(); + BitmapFrame frame = BitmapFrame.Create(saveBitmap); + jpgEncoder.Frames.Add(frame); + jpgEncoder.Save(saveStream); + saveStream.Dispose(); + } + else if (dlg.SafeFileName.ToLower().EndsWith(".png")) + { + Stream saveStream = dlg.OpenFile(); + PngBitmapEncoder pngEncoder = new PngBitmapEncoder(); + BitmapFrame frame = BitmapFrame.Create(saveBitmap); + pngEncoder.Frames.Add(frame); + pngEncoder.Save(saveStream); + saveStream.Dispose(); + } + + CommonHelper.ExplorerFile(dlg.FileName); + } + + if (SnapToolEvent != null) + { + KeyValuePair param = new KeyValuePair("CloseSnap", null); + SnapToolEvent.Invoke(this, param); + } + } + } + } + + private void Button_PrintSnapshot(object sender, RoutedEventArgs e) + { + if (SnapToolArgs != null) + { + try + { + WriteableBitmap saveBitmap = SnapToolArgs.GetSnapshotImage(); + if (saveBitmap != null) + { + PrintDialog printDlg = new PrintDialog(); + if (printDlg.ShowDialog() == true) + { + DrawingVisual visualItem = new DrawingVisual(); + DrawingContext drawContext = visualItem.RenderOpen(); + drawContext.DrawImage(saveBitmap, new Rect(0, 0, saveBitmap.Width, saveBitmap.Height)); + drawContext.Close(); + printDlg.PrintVisual(visualItem, "Snapshot"); + } + } + + if (SnapToolEvent != null) + { + KeyValuePair param = new KeyValuePair("CloseSnap", null); + SnapToolEvent.Invoke(this, param); + } + } + catch (Exception ex) + { + + } + } + } + } + + public class SnapshotToolArgs + { + public Color LineColor; + public Color BgColor; + public double LineWidth; + public double Transparency; + public DashStyle LineDash; + public bool HasBgColor; + + public SnapshotToolArgs() + { + LineDash = new DashStyle(); + HasBgColor = true; + LineColor = Color.FromRgb(49, 106, 197); + BgColor = Color.FromRgb(153, 193, 218); + LineWidth = 1; + Transparency = 0.75; + } + } + + public class SnapshotEditToolArgs : SnapshotToolArgs + { + public Color HighLightColor; + public Color ControlPointColor; + public UserControl ToolPanel; + public PDFViewControl Viewer { get; set; } + + public SnapshotEditToolArgs() : base() + { + HighLightColor = Colors.Transparent; + ControlPointColor = Color.FromRgb(71, 126, 222); + } + + public void ReSnapshot() + { + Viewer.FocusPDFViewTool.CleanPageSelectedRect(); + } + + public void SaveSnapshotToClipboard() + { + WriteableBitmap snapImage = GetSnapshotImage(); + if (snapImage != null) + { + try + { + Clipboard.SetImage(snapImage); + } + catch (Exception ex) + { + + } + } + } + + public WriteableBitmap GetSnapshotImage() + { + if (Viewer != null && Viewer.SnapshotData != null) + { + CPDFDocument pdfDoc = Viewer.GetCPDFViewer().GetDocument(); + PageSelectedData snapData = Viewer.SnapshotData; + CPDFViewer pdfViewer = Viewer.GetCPDFViewer(); + if (snapData.SelectRect.IsEmpty == false) + { + try + { + CPDFPage pdfPage = pdfDoc.PageAtIndex(snapData.PageIndex); + double zoom = pdfViewer.GetZoom(); + Rect snapRect = snapData.SelectRect; + DrawMode drawMode = pdfViewer.GetDrawModes(); + uint bgColor = 0xFFFFFFFF; + int flag = 1; + switch (drawMode) + { + case DrawMode.Soft: + bgColor = 0xFFFFEFB2; + break; + case DrawMode.Green: + bgColor = 0xFFCBE9CE; + break; + case DrawMode.Dark: + bgColor = 0xFF000000; + flag = flag | 0x08 | 0x10000; + break; + case DrawMode.Normal: + bgColor = 0xFFFFFFFF; + break; + case DrawMode.Custom: + bgColor = pdfViewer.GetPDFBackground(); + break; + default: + break; + } + byte[] imageData = new byte[(int)snapRect.Width * (int)snapRect.Height * 4]; + pdfPage.RenderPageBitmapWithMatrix((float)(zoom * 96D / 72D), new CRect( + (float)snapRect.Left, + (float)snapRect.Bottom, + (float)snapRect.Right, + (float)snapRect.Top), + bgColor, + imageData, + flag, + true); + WriteableBitmap snapBitmap = new WriteableBitmap((int)snapRect.Width, (int)snapRect.Height, 96, 96, PixelFormats.Bgra32, null); + snapBitmap.WritePixels(new Int32Rect(0, 0, (int)snapRect.Width, (int)snapRect.Height), imageData, snapBitmap.BackBufferStride, 0); + return snapBitmap; + } + catch (Exception ex) + { + + } + } + } + + return null; + } + + public Rect GetSnapshotPDFRect(out int pageIndex) + { + pageIndex = -1; + if (Viewer != null && Viewer.SnapshotData != null) + { + PageSelectedData snapData = Viewer.SnapshotData; + + pageIndex = snapData.PageIndex; + return snapData.RawRect; + } + + return Rect.Empty; + } + } +} diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Bota.Designer.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Bota.Designer.cs index 3e9e76d..d6aa626 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Bota.Designer.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Bota.Designer.cs @@ -160,7 +160,7 @@ internal static string Chb_Case { } /// - /// Looks up a localized string similar to Match Whole Word. + /// Looks up a localized string similar to Whole Words Only. /// internal static string Chb_Match { get { @@ -241,7 +241,7 @@ internal static string Menu_DelAllAnnot { } /// - /// Looks up a localized string similar to Delete a replies. + /// Looks up a localized string similar to Delete all replies. /// internal static string Menu_DelAllReply { get { diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Bota.resx b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Bota.resx index e498129..fa263df 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Bota.resx +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Bota.resx @@ -244,7 +244,7 @@ Ignore Case - Match Whole Word + Whole Words Only Search diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.Designer.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.Designer.cs index 5debd19..97c01aa 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.Designer.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.Designer.cs @@ -988,7 +988,7 @@ internal static string Printer_OnlyOdd { } /// - /// Looks up a localized string similar to Oritation. + /// Looks up a localized string similar to Orientation. /// internal static string Printer_Oritation { get { @@ -1419,6 +1419,15 @@ internal static string Tooltip_Search { } } + /// + /// Looks up a localized string similar to Content Selection Tool. + /// + internal static string Tooltip_Select { + get { + return ResourceManager.GetString("Tooltip_Select", resourceCulture); + } + } + /// /// Looks up a localized string similar to Sepia. /// diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.resx b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.resx index 49dc1c8..6d66aae 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.resx +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.resx @@ -562,7 +562,7 @@ Only Odd Pages - Oritation + Orientation Page Range @@ -603,4 +603,7 @@ Fit to Printable Area + + Content Selection Tool + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.zh.resx b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.zh.resx index 59f3a72..d210143 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.zh.resx +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Common.zh.resx @@ -603,4 +603,7 @@ 适合可打印区域 + + 内容选择工具 + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Compress.Designer.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Compress.Designer.cs new file mode 100644 index 0000000..727eb46 --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Compress.Designer.cs @@ -0,0 +1,414 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ComPDFKit.Controls.Strings { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Compress { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Compress() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ComPDFKit.Controls.Strings.Compress", typeof(Compress).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Custom. + /// + internal static string Compress_Custom { + get { + return ResourceManager.GetString("Compress_Custom", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to High. + /// + internal static string Compress_High { + get { + return ResourceManager.GetString("Compress_High", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Low. + /// + internal static string Compress_Low { + get { + return ResourceManager.GetString("Compress_Low", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Medium. + /// + internal static string Compress_Medium { + get { + return ResourceManager.GetString("Compress_Medium", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The file size entered is incorrect, try again please. + /// + internal static string Compress_NumberErrorWarning { + get { + return ResourceManager.GetString("Compress_NumberErrorWarning", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Compress files succeeded!. + /// + internal static string Compress_OKWarning { + get { + return ResourceManager.GetString("Compress_OKWarning", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Compress Quality. + /// + internal static string Compress_OptimizationQuality { + get { + return ResourceManager.GetString("Compress_OptimizationQuality", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Are you sure to stop the compressing?. + /// + internal static string CompressInterruptWarning { + get { + return ResourceManager.GetString("CompressInterruptWarning", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Compress. + /// + internal static string CompressStr { + get { + return ResourceManager.GetString("CompressStr", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Undo. + /// + internal static string ContentSelection_CancelDo { + get { + return ResourceManager.GetString("ContentSelection_CancelDo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Exit. + /// + internal static string ContentSelection_Exit { + get { + return ResourceManager.GetString("ContentSelection_Exit", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Output. + /// + internal static string ContentSelection_Output { + get { + return ResourceManager.GetString("ContentSelection_Output", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Progress. + /// + internal static string Convert_Progress { + get { + return ResourceManager.GetString("Convert_Progress", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Select Area. + /// + internal static string Corp_Customize { + get { + return ResourceManager.GetString("Corp_Customize", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The page cannot be restored to original state after you have cropped it. Are you sure you want to crop the page?. + /// + internal static string Corp_Customize_PRM { + get { + return ResourceManager.GetString("Corp_Customize_PRM", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Location. + /// + internal static string FileInfo_Location { + get { + return ResourceManager.GetString("FileInfo_Location", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Size. + /// + internal static string FileInfo_Size { + get { + return ResourceManager.GetString("FileInfo_Size", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Add Files. + /// + internal static string Main_AddFile { + get { + return ResourceManager.GetString("Main_AddFile", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cancel. + /// + internal static string Main_Cancel { + get { + return ResourceManager.GetString("Main_Cancel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Completed. + /// + internal static string Main_CompletedState { + get { + return ResourceManager.GetString("Main_CompletedState", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Copy. + /// + internal static string Main_Copy { + get { + return ResourceManager.GetString("Main_Copy", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Crop. + /// + internal static string Main_Crop { + get { + return ResourceManager.GetString("Main_Crop", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delete. + /// + internal static string Main_Delete { + get { + return ResourceManager.GetString("Main_Delete", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Failed. + /// + internal static string Main_FailedState { + get { + return ResourceManager.GetString("Main_FailedState", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to File Name. + /// + internal static string Main_FileName { + get { + return ResourceManager.GetString("Main_FileName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hint. + /// + internal static string Main_HintWarningTitle { + get { + return ResourceManager.GetString("Main_HintWarningTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Interrupt. + /// + internal static string Main_Interrupt { + get { + return ResourceManager.GetString("Main_Interrupt", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to About Us. + /// + internal static string Main_MenuHelp_About { + get { + return ResourceManager.GetString("Main_MenuHelp_About", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No. + /// + internal static string Main_No { + get { + return ResourceManager.GetString("Main_No", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No file selected. + /// + internal static string Main_NoSelectedFilesWarning { + get { + return ResourceManager.GetString("Main_NoSelectedFilesWarning", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to OK. + /// + internal static string Main_Ok { + get { + return ResourceManager.GetString("Main_Ok", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The file cannot be opened because the file format or file extension is invalid. Please make sure the file is not damaged and the file extension matches the file format.. + /// + internal static string Main_OpenFileFailedWarning { + get { + return ResourceManager.GetString("Main_OpenFileFailedWarning", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Please select a folder. + /// + internal static string Main_OpenFolderNoteWarning { + get { + return ResourceManager.GetString("Main_OpenFolderNoteWarning", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Print. + /// + internal static string Main_Print { + get { + return ResourceManager.GetString("Main_Print", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Remove All Files. + /// + internal static string Main_RemoveAll { + get { + return ResourceManager.GetString("Main_RemoveAll", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Yes. + /// + internal static string Main_Yes { + get { + return ResourceManager.GetString("Main_Yes", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move Down. + /// + internal static string Merge_MoveDown { + get { + return ResourceManager.GetString("Merge_MoveDown", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move Up. + /// + internal static string Merge_MoveUp { + get { + return ResourceManager.GetString("Merge_MoveUp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} file(s) in total. + /// + internal static string Merge_TotalPage { + get { + return ResourceManager.GetString("Merge_TotalPage", resourceCulture); + } + } + } +} diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Compress.resx b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Compress.resx new file mode 100644 index 0000000..f669be1 --- /dev/null +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Compress.resx @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Are you sure to stop the compressing? + + + Compress + + + Custom + + + High + + + Low + + + Medium + + + The file size entered is incorrect, try again please + + + Compress files succeeded! + + + Compress Quality + + + Undo + + + Exit + + + Output + + + Progress + + + Select Area + + + The page cannot be restored to original state after you have cropped it. Are you sure you want to crop the page? + + + Location + + + Size + + + Add Files + + + Cancel + + + Completed + + + Copy + + + Crop + + + Delete + + + Failed + + + File Name + + + Hint + + + Interrupt + + + About Us + + + No + + + No file selected + + + OK + + + The file cannot be opened because the file format or file extension is invalid. Please make sure the file is not damaged and the file extension matches the file format. + + + Please select a folder + + + Print + + + Remove All Files + + + Yes + + + Move Down + + + Move Up + + + {0} file(s) in total + + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Resources.resx b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Compress.zh.resx similarity index 54% rename from ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Resources.resx rename to ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Compress.zh.resx index af7dbeb..8a0b08c 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Resources.resx +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/Compress.zh.resx @@ -1,4 +1,4 @@ - + + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,126 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 确定要中断压缩吗? + + + 压缩 + + + 自定义 + + + + + + + + + 标准 + + + 输入的文件大小错误,请重试 + + + 压缩文件成功! + + + 压缩质量 + + + 撤销 + + + 退出 + + + 导出 + + + 进度 + + + 自定义裁剪区域 + + + 裁剪后的页面无法恢复到原始状态,是否继续裁剪? + + + 位置 + + + 大小 + + + 添加文档 + + + 取消 + + + 完成 + + + 复制 + + + 裁剪 + + + 删除 + + + 失败 + + + 文件名 + + + 提示 + + + 中断 + + + 关于 + + + + + + 没有选择文件 + + + 确认 + + + 无法打开文件,因为文件格式或文件扩展名无效。请确定文件未损坏,并且文件扩展名与文件的格式匹配。 + + + 请选择文件夹 + + + 打印 + + + 移除全部文件 + + + + + + 下移 + + + 上移 + + + 共{0}个文件 + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.Designer.cs b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.Designer.cs index ccdaa12..b371a88 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.Designer.cs +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.Designer.cs @@ -582,6 +582,15 @@ internal static string Option_Hidden { } } + /// + /// Looks up a localized string similar to Multi Select. + /// + internal static string Option_MultiSelect { + get { + return ResourceManager.GetString("Option_MultiSelect", resourceCulture); + } + } + /// /// Looks up a localized string similar to Visible but doesn't print. /// @@ -600,6 +609,15 @@ internal static string Option_Print { } } + /// + /// Looks up a localized string similar to Show Border. + /// + internal static string Option_ShowBorder { + get { + return ResourceManager.GetString("Option_ShowBorder", resourceCulture); + } + } + /// /// Looks up a localized string similar to Visible. /// @@ -735,6 +753,15 @@ internal static string Property_LineColor { } } + /// + /// Looks up a localized string similar to Line and Border Shape. + /// + internal static string Property_LineShape { + get { + return ResourceManager.GetString("Property_LineShape", resourceCulture); + } + } + /// /// Looks up a localized string similar to Line and Border Style. /// @@ -1248,6 +1275,15 @@ internal static string Title_Circle { } } + /// + /// Looks up a localized string similar to Cloud. + /// + internal static string Title_Cloud { + get { + return ResourceManager.GetString("Title_Cloud", resourceCulture); + } + } + /// /// Looks up a localized string similar to Combo Button. /// @@ -1347,6 +1383,15 @@ internal static string Title_Note { } } + /// + /// Looks up a localized string similar to Path Properties. + /// + internal static string Title_PathProperty { + get { + return ResourceManager.GetString("Title_PathProperty", resourceCulture); + } + } + /// /// Looks up a localized string similar to Preferences. /// diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.resx b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.resx index 90725e5..63bfd4d 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.resx +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.resx @@ -594,4 +594,19 @@ Show Caption + + Cloud + + + Line and Border Shape + + + Multi Select + + + Show Border + + + Path Properties + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.zh.resx b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.zh.resx index 69e68ec..2fb4a41 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.zh.resx +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/Strings/PropertyPanel.zh.resx @@ -157,7 +157,7 @@ 线宽 - 线型 + 线条类型 线 @@ -594,4 +594,19 @@ 文字展示 + + 云朵线 + + + 线条形状 + + + 多选 + + + 显示边框 + + + 路径属性 + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Compdfkit.Controls/packages.config b/ComPDFKit for Windows/Examples/Compdfkit.Controls/packages.config index 96aa395..4608a39 100644 --- a/ComPDFKit for Windows/Examples/Compdfkit.Controls/packages.config +++ b/ComPDFKit for Windows/Examples/Compdfkit.Controls/packages.config @@ -1,6 +1,8 @@  - + + + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/ContentEditor/ContentEditor.csproj b/ComPDFKit for Windows/Examples/ContentEditor/ContentEditor.csproj index afe0731..25be126 100644 --- a/ComPDFKit for Windows/Examples/ContentEditor/ContentEditor.csproj +++ b/ComPDFKit for Windows/Examples/ContentEditor/ContentEditor.csproj @@ -41,11 +41,11 @@ ComPDFKit_Logo.ico - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll ..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll @@ -135,11 +135,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/ContentEditor/MainWindow.xaml.cs b/ComPDFKit for Windows/Examples/ContentEditor/MainWindow.xaml.cs index d74bd6e..ea62368 100644 --- a/ComPDFKit for Windows/Examples/ContentEditor/MainWindow.xaml.cs +++ b/ComPDFKit for Windows/Examples/ContentEditor/MainWindow.xaml.cs @@ -89,6 +89,7 @@ public string AppInfo get { return Assembly.GetExecutingAssembly().GetName().Name + " " + string.Join(".", Assembly.GetExecutingAssembly().GetName().Version.ToString().Split('.').Take(3)); } } #endregion + public MainWindow() { InitializeComponent(); @@ -267,7 +268,6 @@ private void OpenFile_Click(object sender, RoutedEventArgs e) private void LeftToolPanelButton_Click(object sender, RoutedEventArgs e) { panelState.IsLeftPanelExpand = (sender as ToggleButton).IsChecked == true; - contentEditControl.PdfViewControl.GetCPDFViewer().GoToPage(pageIndex: 1, new Point(100, 100)); } private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) diff --git a/ComPDFKit for Windows/Examples/ContentEditor/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/ContentEditor/Properties/AssemblyInfo.cs index 7e90e6e..95f0a93 100644 --- a/ComPDFKit for Windows/Examples/ContentEditor/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/ContentEditor/Properties/AssemblyInfo.cs @@ -22,5 +22,5 @@ ResourceDictionaryLocation.SourceAssembly )] -[assembly: AssemblyVersion("2.1.3.0")] -[assembly: AssemblyFileVersion("2.1.3.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/ContentEditor/packages.config b/ComPDFKit for Windows/Examples/ContentEditor/packages.config index 5f51c51..ee67883 100644 --- a/ComPDFKit for Windows/Examples/ContentEditor/packages.config +++ b/ComPDFKit for Windows/Examples/ContentEditor/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/DigitalSignature/DigitalSignature.csproj b/ComPDFKit for Windows/Examples/DigitalSignature/DigitalSignature.csproj index 5d3199e..0af881c 100644 --- a/ComPDFKit for Windows/Examples/DigitalSignature/DigitalSignature.csproj +++ b/ComPDFKit for Windows/Examples/DigitalSignature/DigitalSignature.csproj @@ -57,11 +57,11 @@ ComPDFKit_Logo.ico - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll ..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll @@ -169,11 +169,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/DigitalSignature/DigitalSignature.csproj.user b/ComPDFKit for Windows/Examples/DigitalSignature/DigitalSignature.csproj.user deleted file mode 100644 index 8fbe371..0000000 --- a/ComPDFKit for Windows/Examples/DigitalSignature/DigitalSignature.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - true - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/DigitalSignature/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/DigitalSignature/Properties/AssemblyInfo.cs index f557468..ec3bc50 100644 --- a/ComPDFKit for Windows/Examples/DigitalSignature/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/DigitalSignature/Properties/AssemblyInfo.cs @@ -20,5 +20,5 @@ ResourceDictionaryLocation.SourceAssembly )] -[assembly: AssemblyVersion("2.1.3.0")] -[assembly: AssemblyFileVersion("2.1.3.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/DigitalSignature/packages.config b/ComPDFKit for Windows/Examples/DigitalSignature/packages.config index 5f51c51..ee67883 100644 --- a/ComPDFKit for Windows/Examples/DigitalSignature/packages.config +++ b/ComPDFKit for Windows/Examples/DigitalSignature/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/DocsEditor/DocsEditor.csproj b/ComPDFKit for Windows/Examples/DocsEditor/DocsEditor.csproj index 18a2c3a..3d32350 100644 --- a/ComPDFKit for Windows/Examples/DocsEditor/DocsEditor.csproj +++ b/ComPDFKit for Windows/Examples/DocsEditor/DocsEditor.csproj @@ -42,11 +42,11 @@ ComPDFKit_Logo.ico - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll ..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll @@ -104,10 +104,6 @@ ResXFileCodeGenerator Resources.Designer.cs - - PDF32000_2008.pdf - PreserveNewest - SettingsSingleFileGenerator @@ -141,11 +137,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/DocsEditor/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/DocsEditor/Properties/AssemblyInfo.cs index 174c618..3bafb93 100644 --- a/ComPDFKit for Windows/Examples/DocsEditor/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/DocsEditor/Properties/AssemblyInfo.cs @@ -20,5 +20,5 @@ ResourceDictionaryLocation.SourceAssembly )] -[assembly: AssemblyVersion("2.1.3.0")] -[assembly: AssemblyFileVersion("2.1.3.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/DocsEditor/packages.config b/ComPDFKit for Windows/Examples/DocsEditor/packages.config index 5f51c51..ee67883 100644 --- a/ComPDFKit for Windows/Examples/DocsEditor/packages.config +++ b/ComPDFKit for Windows/Examples/DocsEditor/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Forms/Forms.csproj b/ComPDFKit for Windows/Examples/Forms/Forms.csproj index 8fd6ec4..2f33701 100644 --- a/ComPDFKit for Windows/Examples/Forms/Forms.csproj +++ b/ComPDFKit for Windows/Examples/Forms/Forms.csproj @@ -41,11 +41,11 @@ ComPDFKit_Logo.ico - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll ..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll @@ -116,10 +116,6 @@ ComPDFKit_Forms_Sample_File.pdf PreserveNewest - - PDF32000_2008.pdf - Always - @@ -129,11 +125,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Forms/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Forms/Properties/AssemblyInfo.cs index 09e7186..8fdfe22 100644 --- a/ComPDFKit for Windows/Examples/Forms/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Forms/Properties/AssemblyInfo.cs @@ -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")] \ No newline at end of file +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Forms/packages.config b/ComPDFKit for Windows/Examples/Forms/packages.config index 5f51c51..ee67883 100644 --- a/ComPDFKit for Windows/Examples/Forms/packages.config +++ b/ComPDFKit for Windows/Examples/Forms/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Measure/Measure.csproj b/ComPDFKit for Windows/Examples/Measure/Measure.csproj index 3a18f18..64350fb 100644 --- a/ComPDFKit for Windows/Examples/Measure/Measure.csproj +++ b/ComPDFKit for Windows/Examples/Measure/Measure.csproj @@ -57,11 +57,11 @@ ComPDFKit_Logo.ico - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll ..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll @@ -163,11 +163,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Measure/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Measure/Properties/AssemblyInfo.cs index d4ff5fd..be720c2 100644 --- a/ComPDFKit for Windows/Examples/Measure/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Measure/Properties/AssemblyInfo.cs @@ -20,5 +20,5 @@ ResourceDictionaryLocation.SourceAssembly )] -[assembly: AssemblyVersion("2.1.3.0")] -[assembly: AssemblyFileVersion("2.1.3.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Measure/packages.config b/ComPDFKit for Windows/Examples/Measure/packages.config index 5f51c51..ee67883 100644 --- a/ComPDFKit for Windows/Examples/Measure/packages.config +++ b/ComPDFKit for Windows/Examples/Measure/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/PDFATest/App.config b/ComPDFKit for Windows/Examples/PDFATest/App.config deleted file mode 100644 index 731f6de..0000000 --- a/ComPDFKit for Windows/Examples/PDFATest/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/PDFATest/PDFATest.cs b/ComPDFKit for Windows/Examples/PDFATest/PDFATest.cs deleted file mode 100644 index 2fa13da..0000000 --- a/ComPDFKit for Windows/Examples/PDFATest/PDFATest.cs +++ /dev/null @@ -1,45 +0,0 @@ -using ComPDFKit.PDFDocument; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace PDFATest -{ - internal class PDFATest - { - private static string outputPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))) + "\\Output\\PDFA"; - public static bool CovertToPDFA(CPDFDocument document) - { - string convertToPDFAPath = outputPath + "\\ConvertToPDFATest.pdf"; - document.WritePDFAToFilePath(CPDFType.CPDFTypePDFA1a, convertToPDFAPath); - return true; - } - - public static bool CovertToPDFA1b(CPDFDocument document) - { - string convertToPDFA1bPath = outputPath + "\\ConvertToPDFA1bTest.pdf"; - document.WritePDFAToFilePath(CPDFType.CPDFTypePDFA1a, convertToPDFA1bPath); - return false; - } - - static void Main(string[] args) - { - Console.WriteLine("Running PDFA test sample…\r\n"); - - SDKLicenseHelper.LicenseVerify(); - - CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf"); - - if (!Directory.Exists(outputPath)) - { - Directory.CreateDirectory(outputPath); - } - - CovertToPDFA(document); - CovertToPDFA1b(document); - } - } -} diff --git a/ComPDFKit for Windows/Examples/PDFATest/PDFATest.csproj b/ComPDFKit for Windows/Examples/PDFATest/PDFATest.csproj deleted file mode 100644 index cd2563f..0000000 --- a/ComPDFKit for Windows/Examples/PDFATest/PDFATest.csproj +++ /dev/null @@ -1,82 +0,0 @@ - - - - - Debug - AnyCPU - {A104D585-61BB-4CAB-A968-876CCC8FA858} - Exe - PDFATest - Viewer_ComPDFKit - v4.6.1 - 512 - true - true - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\ComPDFKit.NetFramework.1.9.0\lib\ComPDFKit.Desk.dll - - - ..\packages\ComPDFKit.NetFramework.1.9.0\lib\ComPDFKit.Viewer.dll - - - - - - - - - - - - - LicenseKey.cs - - - - - - - CommonFivePage.pdf - PreserveNewest - - - - - - - license_key_windows.xml - PreserveNewest - - - - - - - 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}. - - - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/PDFATest/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/PDFATest/Properties/AssemblyInfo.cs deleted file mode 100644 index 03e1b25..0000000 --- a/ComPDFKit for Windows/Examples/PDFATest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PDFATest")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PDFATest")] -[assembly: AssemblyCopyright("Copyright © 2023")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a104d585-61bb-4cab-a968-876ccc8fa858")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// 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("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ComPDFKit for Windows/Examples/PDFATest/packages.config b/ComPDFKit for Windows/Examples/PDFATest/packages.config deleted file mode 100644 index e07de23..0000000 --- a/ComPDFKit for Windows/Examples/PDFATest/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/PDFViewer/App.config b/ComPDFKit for Windows/Examples/PDFViewer/App.config index 53e3f1e..65aad24 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/App.config +++ b/ComPDFKit for Windows/Examples/PDFViewer/App.config @@ -44,6 +44,9 @@ + + True + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/PDFViewer/App.xaml.cs b/ComPDFKit for Windows/Examples/PDFViewer/App.xaml.cs index eb0aec3..a1a18a4 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/App.xaml.cs +++ b/ComPDFKit for Windows/Examples/PDFViewer/App.xaml.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; -using System.IO; +using System.IO; using System.Reflection; -using System.Resources; +using System.Resources; using System.Threading; -using System.Threading.Tasks; using System.Windows; using System.Windows.Data; -using System.Windows.Threading; -using System.Xml; using ComPDFKit.NativeMethod; -using ComPDFKit.PDFDocument; using ComPDFKit.Controls.Helper; using PDFViewer.Properties; @@ -39,7 +34,7 @@ public static bool LicenseVerify() return false; } - LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(SDKLicenseHelper.ParseLicenseXML(), false); + LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(SDKLicenseHelper.ParseLicenseXML()); return (verifyResult == LicenseErrorCode.E_LICENSE_SUCCESS); } @@ -118,5 +113,4 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu throw new NotSupportedException(); } } - } diff --git a/ComPDFKit for Windows/Examples/PDFViewer/MainPage.xaml b/ComPDFKit for Windows/Examples/PDFViewer/MainPage.xaml index 32daf78..b24463d 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/MainPage.xaml +++ b/ComPDFKit for Windows/Examples/PDFViewer/MainPage.xaml @@ -148,6 +148,19 @@ + + + + + M10.75 6.75H6.25V11.25H10.75V6.75ZM23.75 6.75H19.25V11.25H23.75V6.75ZM10.75 18.75H6.25V23.25H10.75V18.75ZM23.75 18.75H19.25V23.25H23.75V18.75ZM14 9.75V8.25H12V9.75H14ZM18 9.75V8.25H16V9.75H18ZM9.25 14H7.75V12H9.25V14ZM9.25 18H7.75V16H9.25V18ZM20.75 14H22.25V12H20.75V14ZM20.75 18H22.25V16H20.75V18ZM14 20.25V21.75H12V20.25H14ZM18 20.25V21.75H16V20.25H18Z + + + + + + + + diff --git a/ComPDFKit for Windows/Examples/PDFViewer/MainPage.xaml.cs b/ComPDFKit for Windows/Examples/PDFViewer/MainPage.xaml.cs index 050ab39..b9a6b88 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/MainPage.xaml.cs +++ b/ComPDFKit for Windows/Examples/PDFViewer/MainPage.xaml.cs @@ -20,13 +20,14 @@ using System.Windows.Controls.Primitives; using System.Windows.Input; using ComPDFKit.Controls.PDFControlUI; +using ComPDFKit.Controls.Snapshot; +using System.Windows.Media; namespace PDFViewer { public partial class MainPage : UserControl, INotifyPropertyChanged { #region Properties - private string currentMode = "Viewer"; private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 }; @@ -181,15 +182,9 @@ private void LoadDocument() CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfviewer.GetZoom() * 100))); botaBarControl.AddBOTAContent(new[] { BOTATools.Thumbnail, BOTATools.Outline, BOTATools.Bookmark, BOTATools.Annotation, BOTATools.Search }); - botaBarControl.ViewCertificateEvent -= digitalSignatureControl.ViewCertificateEvent; - botaBarControl.ViewCertificateEvent += digitalSignatureControl.ViewCertificateEvent; - botaBarControl.ViewSignatureEvent -= digitalSignatureControl.ViewSignatureEvent; - botaBarControl.ViewSignatureEvent += digitalSignatureControl.ViewSignatureEvent; - botaBarControl.DeleteSignatureEvent -= BotaBarControl_DeleteSignatureEvent; - botaBarControl.DeleteSignatureEvent += BotaBarControl_DeleteSignatureEvent; botaBarControl.SelectBotaTool(BOTATools.Thumbnail); ViewSettingBtn.IsChecked = false; - botaBarControl.InitWithPDFViewer(viewControl); + botaBarControl.InitWithPDFViewer(viewControl); botaBarControl.SelectBotaTool(BOTATools.Thumbnail); displaySettingsControl.InitWithPDFViewer(viewControl); LoadCustomControl(); @@ -208,12 +203,6 @@ private void LoadDocument() } } - private void BotaBarControl_DeleteSignatureEvent(object sender, EventArgs e) - { - viewControl.PDFViewTool.IsDocumentModified = true; - DigitalSignatureControl_OnSignatureStatusChanged(sender, e); - } - private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEventObject e) { if (e.annotType == C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET) @@ -501,6 +490,15 @@ private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs return; } + if((string)item.Tag == "Viewer" || (string)item.Tag == "Annotation") + { + SnapshotButton.Visibility = Visibility.Visible; + } + else + { + SnapshotButton.Visibility = Visibility.Collapsed; + } + ClearPanelState(); if (ViewSettingBtn != null) ViewSettingBtn.IsChecked = false; @@ -576,13 +574,12 @@ private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs else if (item.Tag as string == "Annotation") { annotationControl.SetToolBarContainerVisibility(Visibility.Visible); - PDFGrid.Child = annotationControl; - - viewControl.SetToolType(ToolType.Pan); annotationControl.PDFViewControl = viewControl; annotationControl.InitWithPDFViewer(viewControl); if (annotationControl.PDFViewControl != null) { + PDFGrid.Child = annotationControl; + viewControl.SetToolType(ToolType.Pan); annotationControl.OnCanSaveChanged -= ControlOnCanSaveChanged; annotationControl.OnCanSaveChanged += ControlOnCanSaveChanged; @@ -678,8 +675,11 @@ private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs measureControl.OnAnnotEditHandler += PdfFormControlRefreshAnnotList; } } + currentMode = item.Tag as string; RightToolPanelButtonIsChecked = false; + SnapshotButton.IsChecked = false; + viewControl.FocusPDFViewTool.RemovePageSelectdUserControl(); } /// @@ -824,10 +824,70 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } + private void SnapShotButton_Click(object sender, RoutedEventArgs e) + { + if((sender as ToggleButton).IsChecked == true) + { + SnapshotEditToolArgs snapshotArgs = new SnapshotEditToolArgs(); + SnapshotMenu snapMenu = new SnapshotMenu(); + snapshotArgs.ControlPointColor = Colors.White; + snapshotArgs.BgColor = Color.FromArgb(0x99, 0x00, 0x00, 0x00); + snapshotArgs.LineColor = Color.FromArgb(0xFF, 0x47, 0x7E, 0xDE); + snapshotArgs.ToolPanel = snapMenu; + snapshotArgs.Viewer = viewControl; + snapMenu.SnapToolArgs = snapshotArgs; + snapMenu.PdfViewer = viewControl; + snapMenu.SnapToolEvent += SnapMenu_SnapToolEvent; + + viewControl.PDFToolManager.SetToolType(ToolType.SelectedPage); + viewControl.FocusPDFViewTool.SetPageSelectdUserControl(snapshotArgs.ToolPanel); + } + else + { + if ((ModeComboBox.SelectedItem as ComboBoxItem).Tag.ToString() == "Viewer") + { + viewControl.PDFToolManager.SetToolType(ToolType.Viewer); + } + else if ((ModeComboBox.SelectedItem as ComboBoxItem).Tag.ToString() == "Annotation") + { + viewControl.PDFToolManager.SetToolType(ToolType.Pan); + } + + viewControl.FocusPDFViewTool.RemovePageSelectdUserControl(); + } + } + + private void SnapMenu_SnapToolEvent(object sender, KeyValuePair e) + { + switch (e.Key) + { + case "CloseSnap": + { + if ((ModeComboBox.SelectedItem as ComboBoxItem).Tag.ToString() == "Viewer") + { + viewControl.PDFToolManager.SetToolType(ToolType.Viewer); + } + else if ((ModeComboBox.SelectedItem as ComboBoxItem).Tag.ToString() == "Annotation") + { + viewControl.PDFToolManager.SetToolType(ToolType.Pan); + } + + SnapshotButton.IsChecked = false; + viewControl.FocusPDFViewTool.RemovePageSelectdUserControl(); + } + break; + + case "Save": + CanSave = true; + break; + + default: + break; + } + } #endregion #region Open and Save file - private void SaveFileBtn_Click(object sender, RoutedEventArgs e) { SaveFile(); @@ -848,8 +908,8 @@ private void OpenFile(string filePath = "") { filePath = ComPDFKit.Controls.Helper.CommonHelper.GetExistedPathOrEmpty(); } - string oldFilePath = pdfDoc.FilePath; + string oldFilePath = pdfDoc.FilePath; if (!string.IsNullOrEmpty(filePath) && regularViewerControl.PdfViewControl != null) { if (oldFilePath.ToLower() == filePath.ToLower()) @@ -862,6 +922,21 @@ private void OpenFile(string filePath = "") return; } + if (CanSave) + { + string fileName = pdfDoc.FileName; + var message = fileName + " " + LanguageHelper.CommonManager.GetString("Warn_NotSave"); + var result = MessageBox.Show(message, LanguageHelper.CommonManager.GetString("Caption_Warning"), MessageBoxButton.YesNoCancel, MessageBoxImage.Question); + if (result == MessageBoxResult.Yes) + { + SaveFile(); + } + else if (result == MessageBoxResult.Cancel) + { + return; + } + } + passwordViewer = new PDFViewControl(); passwordViewer.InitDocument(filePath); CPDFViewer tempViewer = passwordViewer.PDFViewTool?.GetCPDFViewer(); diff --git a/ComPDFKit for Windows/Examples/PDFViewer/MainWindow.xaml.cs b/ComPDFKit for Windows/Examples/PDFViewer/MainWindow.xaml.cs index 1e3905e..a8cdd55 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/MainWindow.xaml.cs +++ b/ComPDFKit for Windows/Examples/PDFViewer/MainWindow.xaml.cs @@ -157,7 +157,6 @@ private void OpenFileEventHandler(object sender, OpenFileEventArgs args) tabItem.Tag = "Blank Page.pdf"; TabControl.Items.Add(tabItem); - viewPage.CanSave = true; } else diff --git a/ComPDFKit for Windows/Examples/PDFViewer/PDFViewer.csproj b/ComPDFKit for Windows/Examples/PDFViewer/PDFViewer.csproj index e46b47b..6251bd2 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/PDFViewer.csproj +++ b/ComPDFKit for Windows/Examples/PDFViewer/PDFViewer.csproj @@ -14,23 +14,9 @@ 4 true true + 7 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true AnyCPU @@ -93,34 +79,19 @@ 7 prompt - - 5B24765358669E0556E7C1FE9547CE97480FCD65 - - - PDFViewer_TemporaryKey.pfx - - - false - - - false - - - LocalIntranet - - - Properties\app.manifest - - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll .\Dragablz.dll + + ..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll + @@ -194,12 +165,13 @@ ResXFileCodeGenerator SettingDialog.Designer.cs + Designer SettingDialog.resx + Designer - SettingsSingleFileGenerator Settings.Designer.cs @@ -209,10 +181,10 @@ - + license_key_windows.xml PreserveNewest - + TestFile\PDF32000_2008.pdf PreserveNewest @@ -248,9 +220,9 @@ PreserveNewest - + PreserveNewest - + @@ -263,27 +235,12 @@ ComPDFKit.Tool - - - - - False - Microsoft .NET Framework 4.6.1 %28x86 和 x64%29 - true - - - False - .NET Framework 3.5 SP1 - false - - - - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/PDFViewer/PDFViewer.csproj.user b/ComPDFKit for Windows/Examples/PDFViewer/PDFViewer.csproj.user index f923c44..ff18737 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/PDFViewer.csproj.user +++ b/ComPDFKit for Windows/Examples/PDFViewer/PDFViewer.csproj.user @@ -1,15 +1,9 @@  - - true - Project - - - ProjectFiles - publish\|ftp://124.223.39.47:21/compdfkit/|ftp://124.223.39.47:21/var/www/compdfkit/|ftp://124.223.39.47/var/www/compdfkit/|ftp://124.223.39.47/ - http://124.223.39.47/|http://124.223.39.47:21/var/www/compdfkit/|http://124.223.39.47:8088/|http://124.223.39.47:8088/var/www/compdfkit/|http://localhost:54496/ + publish\ + @@ -17,7 +11,10 @@ zh-CN false - - false + + false + + + true \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/PDFViewer/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/PDFViewer/Properties/AssemblyInfo.cs index c5ba3bd..7f04775 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/PDFViewer/Properties/AssemblyInfo.cs @@ -24,5 +24,5 @@ ResourceDictionaryLocation.SourceAssembly )] -[assembly: AssemblyVersion("2.1.3.0")] -[assembly: AssemblyFileVersion("2.1.3.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/PDFViewer/Properties/Settings.settings b/ComPDFKit for Windows/Examples/PDFViewer/Properties/Settings.settings index c0e8a78..ea8abd7 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/Properties/Settings.settings +++ b/ComPDFKit for Windows/Examples/PDFViewer/Properties/Settings.settings @@ -33,7 +33,7 @@ - False + True \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/PDFViewer/Properties/app.manifest b/ComPDFKit for Windows/Examples/PDFViewer/Properties/app.manifest deleted file mode 100644 index c7d2b13..0000000 --- a/ComPDFKit for Windows/Examples/PDFViewer/Properties/app.manifest +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/PDFViewer/Strings/SettingDialog.resx b/ComPDFKit for Windows/Examples/PDFViewer/Strings/SettingDialog.resx index fa398e9..99cfc3f 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/Strings/SettingDialog.resx +++ b/ComPDFKit for Windows/Examples/PDFViewer/Strings/SettingDialog.resx @@ -157,7 +157,7 @@ Technical Support - @ 2014-2023 PDF Technologies, Inc. All Rights Reserved. + @ 2014-2024 PDF Technologies, Inc. All Rights Reserved. Privacy Policy diff --git a/ComPDFKit for Windows/Examples/PDFViewer/Strings/SettingDialog.zh.resx b/ComPDFKit for Windows/Examples/PDFViewer/Strings/SettingDialog.zh.resx index 4227daa..aee1002 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/Strings/SettingDialog.zh.resx +++ b/ComPDFKit for Windows/Examples/PDFViewer/Strings/SettingDialog.zh.resx @@ -157,7 +157,7 @@ 技术支持 - @ 2014-2023 PDF Technologies, Inc. All Rights Reserved. + @ 2014-2024 PDF Technologies, Inc. All Rights Reserved. 隐私协议 diff --git a/ComPDFKit for Windows/Examples/PDFViewer/packages.config b/ComPDFKit for Windows/Examples/PDFViewer/packages.config index 5afbd7a..ee67883 100644 --- a/ComPDFKit for Windows/Examples/PDFViewer/packages.config +++ b/ComPDFKit for Windows/Examples/PDFViewer/packages.config @@ -1,4 +1,5 @@  - + + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/AnnotationImportExportTest.csproj b/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/AnnotationImportExportTest.csproj index 501507e..4c9d248 100644 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/AnnotationImportExportTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/AnnotationImportExportTest.csproj @@ -41,6 +41,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -65,17 +66,17 @@ - true + false ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -129,11 +130,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/Properties/AssemblyInfo.cs index 0dd6869..c50f584 100644 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/VB/AnnotationImportExportTest.vbproj b/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/VB/AnnotationImportExportTest.vbproj index d711927..9c224dc 100644 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/VB/AnnotationImportExportTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/VB/AnnotationImportExportTest.vbproj @@ -52,11 +52,11 @@ On - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -140,11 +140,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/AnnotationImportExportTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/AnnotationTest.cs b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/AnnotationTest.cs index d568f0c..978507a 100644 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/AnnotationTest.cs +++ b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/AnnotationTest.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; -using System.Drawing.Printing; using System.IO; using System.Runtime.InteropServices; @@ -32,7 +31,7 @@ static void Main(string[] args) #endregion #region Sample 1: Create annotations - + if (CreateAnnots(document)) { Console.WriteLine("Create annots done."); @@ -47,7 +46,7 @@ static void Main(string[] args) if (DeleteAnnotations(annotsDocument)) { Console.WriteLine("Create annots done."); - } + } Console.WriteLine("--------------------"); @@ -92,7 +91,7 @@ static private void CreateFreehandAnnotation(CPDFDocument document) ink.SetTransparency(128); List> points = new List>(); ink.SetInkPath(points); - ink.SetThickness(8); + ink.SetThickness(8); points.Clear(); points.Add(new List() { @@ -100,7 +99,7 @@ static private void CreateFreehandAnnotation(CPDFDocument document) new CPoint(100,10), }); ink.SetInkPath(points); - ink.SetRect(new CRect(10, 10, 200, 200)); + ink.SetRect(new CRect(10, 200, 200, 20)); ink.UpdateAp(); } @@ -110,7 +109,7 @@ static private void CreateFreehandAnnotation(CPDFDocument document) /// Include: /// Square, Circle, Line /// - /// + /// 7 static private void CreateShapeAnnotation(CPDFDocument document) { CPDFPage page = document.PageAtIndex(0); @@ -118,24 +117,30 @@ static private void CreateShapeAnnotation(CPDFDocument document) byte[] lineColor = { 255, 0, 0 }; byte[] bgColor = { 0, 255, 0 }; + CPDFBorderEffector borderEffect = new CPDFBorderEffector( C_BORDER_TYPE.C_BORDER_TYPE_Cloud, C_BORDER_INTENSITY.C_INTENSITY_TWO); + // Square CPDFSquareAnnotation square = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE) as CPDFSquareAnnotation; - square.SetRect(new CRect(10, 250, 200, 200)); + square.SetSourceRect(new CRect(10, 250, 200, 200)); square.SetLineColor(lineColor); square.SetBgColor(bgColor); square.SetTransparency(120); square.SetLineWidth(1); - square.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, dashArray); + square.SetBorderWidth(1); + square.SetAnnotBorderEffector(borderEffect); + square.AnnotationRotator.SetRotation(45); square.UpdateAp(); // Circle CPDFCircleAnnotation circle = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE) as CPDFCircleAnnotation; - circle.SetRect(new CRect(10, 300, 110, 410)); + circle.SetRect(new CRect(10, 410, 110, 300)); circle.SetLineColor(lineColor); circle.SetBgColor(bgColor); circle.SetTransparency(120); circle.SetLineWidth(1); circle.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, dashArray); + circle.SetAnnotBorderEffect(borderEffect); + square.SetBorderWidth(1); circle.UpdateAp(); // Line @@ -160,7 +165,7 @@ static private void CreateNoteAnnotation(CPDFDocument document) textAnnotation.SetColor(new byte[] { 255, 0, 0 }); textAnnotation.SetTransparency(255); textAnnotation.SetContent("ComPDFKit"); - textAnnotation.SetRect(new CRect(300, 600, 350, 650)); + textAnnotation.SetRect(new CRect(300, 650, 350, 600)); textAnnotation.UpdateAp(); } @@ -172,8 +177,8 @@ static private void CreateSoundAnnotation(CPDFDocument document) { CPDFPage page = document.PageAtIndex(0); CPDFSoundAnnotation sound = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_SOUND) as CPDFSoundAnnotation; - sound.SetRect(new CRect(400, 700, 450, 750)); - sound.SetSoundPath("","Bird.wav"); + sound.SetRect(new CRect(400, 750, 450, 700)); + sound.SetSoundPath("", "Bird.wav"); sound.UpdateAp(); } @@ -184,7 +189,7 @@ static private void CreateSoundAnnotation(CPDFDocument document) static private void CreateMarkupAnnotation(CPDFDocument document) { List cRectList = new List(); - CRect rect = new CRect(300, 240, 400, 300); + CRect rect = new CRect(300, 300, 400, 240); cRectList.Add(rect); byte[] color = { 255, 0, 0 }; @@ -228,9 +233,7 @@ static private void CreateMarkupAnnotation(CPDFDocument document) public static byte[] BitmapToByteArray(Bitmap bitmap) { - BitmapData bmpdata = null; - try { bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat); @@ -257,31 +260,34 @@ public static byte[] BitmapToByteArray(Bitmap bitmap) static private void CreateStampAnnotation(CPDFDocument document) { CPDFPage page = document.PageAtIndex(0); - // Standard CPDFStampAnnotation standard = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP) as CPDFStampAnnotation; standard.SetStandardStamp("Approved"); - standard.SetRect(new CRect(300, 100, 450, 160)); + + standard.SetSourceRect(new CRect(100, 150, 250, 100)); + standard.AnnotationRotator.SetRotation(45); + standard.UpdateAp(); // Text CPDFStampAnnotation text = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP) as CPDFStampAnnotation; text.SetTextStamp("test", "detail text", C_TEXTSTAMP_SHAPE.TEXTSTAMP_LEFT_TRIANGLE, C_TEXTSTAMP_COLOR.TEXTSTAMP_RED); - text.SetRect(new CRect(300, 220, 450, 300)); + text.SetRect(new CRect(300, 300, 450, 220)); text.UpdateAp(); // Image Bitmap bitmap = new Bitmap("logo.png"); CPDFStampAnnotation image = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP) as CPDFStampAnnotation; image.SetImageStamp(BitmapToByteArray(bitmap), bitmap.Width, bitmap.Height); - image.SetRect(new CRect(300, 320, 380, 400)); - image.SetTransparency(255); + image.SetRect(new CRect(300, 400, 380, 320)); + image.SetTransparency(255); + standard.AnnotationRotator.SetRotation(45); image.UpdateAp(); } private static void CreateLinkAnnotation(CPDFDocument document) { - CPDFPage page = document.PageAtIndex(0); + CPDFPage page = document.PageAtIndex(0); CPDFDestination dest = new CPDFDestination(); dest.PageIndex = 1; CPDFLinkAnnotation link = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_LINK) as CPDFLinkAnnotation; @@ -322,7 +328,7 @@ static private bool CreateAnnots(CPDFDocument document) /// /// static private bool DeleteAnnotations(CPDFDocument document) - { + { CPDFPage page = document.PageAtIndex(0); List annotList = page.GetAnnotations(); @@ -331,7 +337,7 @@ static private bool DeleteAnnotations(CPDFDocument document) return false; } - string path = Path.Combine(outputPath , "DeleteAnnotsTest.pdf"); + string path = Path.Combine(outputPath, "DeleteAnnotsTest.pdf"); if (!document.WriteToFilePath(path)) { return false; diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/AnnotationTest.csproj b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/AnnotationTest.csproj index ab639cf..09acf7c 100644 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/AnnotationTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/AnnotationTest.csproj @@ -54,11 +54,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -119,11 +119,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/AnnotationTest.csproj.user b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/AnnotationTest.csproj.user deleted file mode 100644 index 6cbe588..0000000 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/AnnotationTest.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - ProjectFiles - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/Properties/AssemblyInfo.cs index c444d0a..79f66bd 100644 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/SoundAnnot.png b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/SoundAnnot.png deleted file mode 100644 index 8b19c74..0000000 Binary files a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/SoundAnnot.png and /dev/null differ diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/VB/AnnotationTest.vbproj b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/VB/AnnotationTest.vbproj index 1a53321..ac6853c 100644 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/VB/AnnotationTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/VB/AnnotationTest.vbproj @@ -52,11 +52,11 @@ On - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -153,11 +153,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/AnnotationTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/AnnotationTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/BackgroundTest.csproj b/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/BackgroundTest.csproj index f2ae527..b0d2867 100644 --- a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/BackgroundTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/BackgroundTest.csproj @@ -58,11 +58,11 @@ - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -121,11 +121,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/BackgroundTest.csproj.user b/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/BackgroundTest.csproj.user deleted file mode 100644 index 6cbe588..0000000 --- a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/BackgroundTest.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - ProjectFiles - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/Properties/AssemblyInfo.cs index f4a6b7f..9855031 100644 --- a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/BackgroundTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/VB/BackgroundTest.vbproj b/ComPDFKit for Windows/Examples/Samples/BackgroundTest/VB/BackgroundTest.vbproj index 1c01f33..b6e92e6 100644 --- a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/VB/BackgroundTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/BackgroundTest/VB/BackgroundTest.vbproj @@ -52,11 +52,11 @@ On - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -145,11 +145,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/BackgroundTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/BackgroundTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/BackgroundTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/BatesTest.csproj b/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/BatesTest.csproj index d46a93b..ee3f3f9 100644 --- a/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/BatesTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/BatesTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -76,11 +76,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/Properties/AssemblyInfo.cs index fe89d7e..ab4c7f9 100644 --- a/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/BatesTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BatesTest/VB/BatesTest.vbproj b/ComPDFKit for Windows/Examples/Samples/BatesTest/VB/BatesTest.vbproj index d7b54e3..dcf89d3 100644 --- a/ComPDFKit for Windows/Examples/Samples/BatesTest/VB/BatesTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/BatesTest/VB/BatesTest.vbproj @@ -52,11 +52,11 @@ On - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -135,11 +135,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BatesTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/BatesTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/BatesTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/BatesTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/BookmarkTest.csproj b/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/BookmarkTest.csproj index b86f74e..e84bd1f 100644 --- a/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/BookmarkTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/BookmarkTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -80,11 +80,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/Properties/AssemblyInfo.cs index d0d60fa..ec4e68b 100644 --- a/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/BookmarkTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BookmarkTest/VB/BookmarkTest.vbproj b/ComPDFKit for Windows/Examples/Samples/BookmarkTest/VB/BookmarkTest.vbproj index cec2aec..8838f7d 100644 --- a/ComPDFKit for Windows/Examples/Samples/BookmarkTest/VB/BookmarkTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/BookmarkTest/VB/BookmarkTest.vbproj @@ -52,11 +52,11 @@ On - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -135,11 +135,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/BookmarkTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/BookmarkTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/BookmarkTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/BookmarkTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/DigitalSignatureTest.cs b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/DigitalSignatureTest.cs index a7f2cdd..05124fa 100644 --- a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/DigitalSignatureTest.cs +++ b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/DigitalSignatureTest.cs @@ -1,20 +1,18 @@ using ComPDFKit.DigitalSign; using ComPDFKit.Import; -using ComPDFKit.PDFAnnotation; using ComPDFKit.PDFAnnotation.Form; using ComPDFKit.PDFDocument; using ComPDFKit.PDFPage; using System; using System.Collections.Generic; -using System.Drawing; using System.IO; -using System.Xml.Linq; +using System.Windows.Media; +using System.Windows.Media.Imaging; namespace DigitalSignatureTest { internal class DigitalSignatureTest { - static private string parentPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))); static private string outputPath = Path.Combine(parentPath, "Output", "CS"); @@ -111,6 +109,37 @@ private static void GenerateCertificate() Console.WriteLine("--------------------"); } + private static void ImagePathToByte(string imagePath, ref byte[] imageData, ref int imageWidth, ref int imageHeight) + { + if (!File.Exists(imagePath)) + return; + + imagePath = Path.GetFullPath(imagePath); + BitmapFrame frame = null; + BitmapDecoder decoder = BitmapDecoder.Create(new Uri(imagePath), BitmapCreateOptions.None, BitmapCacheOption.Default); + if (decoder != null && decoder.Frames.Count > 0) + { + frame = decoder.Frames[0]; + } + if (frame != null) + { + imageData = new byte[frame.PixelWidth * frame.PixelHeight * 4]; + if (frame.Format != PixelFormats.Bgra32) + { + FormatConvertedBitmap covert = new FormatConvertedBitmap(frame, PixelFormats.Bgra32, frame.Palette, 0); + covert.CopyPixels(imageData, frame.PixelWidth * 4, 0); + } + else + { + frame.CopyPixels(imageData, frame.PixelWidth * 4, 0); + } + + imageWidth = frame.PixelWidth; + imageHeight = frame.PixelHeight; + } + } + + /// /// /// Adding a signature is divided into two steps: @@ -148,7 +177,6 @@ private static void CreateDigitalSignature(CPDFDocument document, string certifi signatureField.SetWidgetBgRGBColor(new byte[] { 150, 180, 210 }); signatureField.UpdateAp(); - string name = GetGrantorFromDictionary(certificate.SubjectDict) + "\n"; string date = DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss"); string reason = "I am the owner of the document."; @@ -165,11 +193,34 @@ private static void CreateDigitalSignature(CPDFDocument document, string certifi "DN: " + DN + "\n", IsContentAlignLeft = false, IsDrawLogo = true, - LogoBitmap = new Bitmap("Logo.png"), TextColor = new float[] { 0, 0, 0 }, ContentColor = new float[] { 0, 0, 0 } }; - string filePath = outputPath + "\\" + document.FileName + "_Signed.pdf"; + + //using (var image = new MagickImage("Logo.png")) + //{ + // byte[] byteArray = image.ToByteArray(MagickFormat.Bgra); + // signatureConfig.LogoData = byteArray; + // signatureConfig.LogoHeight = (int)image.Height; + // signatureConfig.LogoWidth = (int)image.Width; + //} + + byte[] imageData = null; + int imageWidth = 0; + int imageHeight = 0; + ImagePathToByte("Logo.png", ref imageData, ref imageWidth, ref imageHeight); + if (imageData != null && imageWidth > 0 && imageHeight > 0) + { + signatureConfig.LogoData = imageData; + signatureConfig.LogoWidth = imageWidth; + signatureConfig.LogoHeight = imageHeight; + } + else + { + signatureConfig.IsDrawLogo = false; + } + + string filePath = Path.Combine(outputPath, document.FileName + "_Signed.pdf"); signatureField.UpdataApWithSignature(signatureConfig); if (document.WriteSignatureToFilePath(signatureField, filePath, diff --git a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/DigitalSignatureTest.csproj b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/DigitalSignatureTest.csproj index 061f588..948b871 100644 --- a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/DigitalSignatureTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/DigitalSignatureTest.csproj @@ -39,14 +39,13 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll - True + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll - True + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll + @@ -56,6 +55,7 @@ + @@ -92,13 +92,11 @@ - + 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}. - - + - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/Properties/AssemblyInfo.cs index b44364d..c6e4350 100644 --- a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/Properties/AssemblyInfo.cs @@ -15,5 +15,5 @@ [assembly: Guid("7372311c-7a31-4d97-a2c0-fc005fc345c1")] -[assembly: AssemblyVersion("2.1.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vb b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vb index 5210935..289952c 100644 --- a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vb +++ b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vb @@ -146,7 +146,7 @@ Module DigitalSignatureTest "Location: " & location & Environment.NewLine & "DN: " & DN & Environment.NewLine, .IsContentAlignLeft = False, - .IsDrawLogo = True, + .IsDrawLogo = False, .LogoData = File.ReadAllBytes("logo.png"), .TextColor = New Single() {0, 0, 0}, .ContentColor = New Single() {0, 0, 0} diff --git a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vbproj b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vbproj index 4020752..0faf24c 100644 --- a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vbproj @@ -52,11 +52,11 @@ On - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -143,11 +143,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vbproj.user b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vbproj.user deleted file mode 100644 index 6cbe588..0000000 --- a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vbproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - ProjectFiles - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/DigitalSignatureTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/DocumentCompareTest.csproj b/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/DocumentCompareTest.csproj index 3ba05f5..a5904ed 100644 --- a/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/DocumentCompareTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/DocumentCompareTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -91,11 +91,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/Properties/AssemblyInfo.cs index 79e3118..f8fc02b 100644 --- a/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/VB/DocumentCompareTest.vbproj b/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/VB/DocumentCompareTest.vbproj index 0ce41ec..cf8c30a 100644 --- a/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/VB/DocumentCompareTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/VB/DocumentCompareTest.vbproj @@ -53,11 +53,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -149,11 +149,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/DocumentCompareTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/DocumentInfoTest.csproj b/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/DocumentInfoTest.csproj index 7f539b8..5108880 100644 --- a/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/DocumentInfoTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/DocumentInfoTest.csproj @@ -53,11 +53,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -103,11 +103,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/Properties/AssemblyInfo.cs index 34b0d1c..95b655e 100644 --- a/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/VB/DocumentInfoTest.vbproj b/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/VB/DocumentInfoTest.vbproj index faabd73..fcbe3ea 100644 --- a/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/VB/DocumentInfoTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/VB/DocumentInfoTest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -136,11 +136,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/DocumentInfoTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/EncryptTest.csproj b/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/EncryptTest.csproj index 5cab0f9..02d7085 100644 --- a/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/EncryptTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/EncryptTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -80,11 +80,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/Properties/AssemblyInfo.cs index 120ae5e..8eed0c3 100644 --- a/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/EncryptTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/EncryptTest/VB/EncryptTest.vbproj b/ComPDFKit for Windows/Examples/Samples/EncryptTest/VB/EncryptTest.vbproj index 187ff01..413f7c9 100644 --- a/ComPDFKit for Windows/Examples/Samples/EncryptTest/VB/EncryptTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/EncryptTest/VB/EncryptTest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -140,11 +140,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/EncryptTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/EncryptTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/EncryptTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/EncryptTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/FlattenTest.csproj b/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/FlattenTest.csproj index e491519..50246e3 100644 --- a/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/FlattenTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/FlattenTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -76,11 +76,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/Properties/AssemblyInfo.cs index bc3d55b..6a8d7e2 100644 --- a/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/FlattenTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/FlattenTest/VB/FlattenTest.vbproj b/ComPDFKit for Windows/Examples/Samples/FlattenTest/VB/FlattenTest.vbproj index 2fa8b5c..d5575c0 100644 --- a/ComPDFKit for Windows/Examples/Samples/FlattenTest/VB/FlattenTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/FlattenTest/VB/FlattenTest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -135,11 +135,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/FlattenTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/FlattenTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/FlattenTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/FlattenTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/HeaderFooterTest.csproj b/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/HeaderFooterTest.csproj index 690b531..d5d59b3 100644 --- a/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/HeaderFooterTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/HeaderFooterTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -73,11 +73,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/Properties/AssemblyInfo.cs index eedaa7e..2adf7c1 100644 --- a/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/VB/HeaderFooterTest.vbproj b/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/VB/HeaderFooterTest.vbproj index 2525425..0356644 100644 --- a/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/VB/HeaderFooterTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/VB/HeaderFooterTest.vbproj @@ -52,11 +52,11 @@ On - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -133,11 +133,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/HeaderFooterTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/ImageExtractTest.csproj b/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/ImageExtractTest.csproj index c81f245..d8481b0 100644 --- a/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/ImageExtractTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/ImageExtractTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -79,11 +79,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/Properties/AssemblyInfo.cs index f98eebe..a729d94 100644 --- a/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/VB/ImageExtractTest.vbproj b/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/VB/ImageExtractTest.vbproj index a339864..7c42ebf 100644 --- a/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/VB/ImageExtractTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/VB/ImageExtractTest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -136,11 +136,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/ImageExtractTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/InteractiveFormsTest.csproj b/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/InteractiveFormsTest.csproj index be70785..a1c0499 100644 --- a/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/InteractiveFormsTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/InteractiveFormsTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -77,11 +77,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/Properties/AssemblyInfo.cs index ee9ef02..06fa2a4 100644 --- a/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/VB/InteractiveFormsTest.vbproj b/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/VB/InteractiveFormsTest.vbproj index aeae865..99ef0fd 100644 --- a/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/VB/InteractiveFormsTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/VB/InteractiveFormsTest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -135,11 +135,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/InteractiveFormsTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/LicenseKey.cs b/ComPDFKit for Windows/Examples/Samples/LicenseKey.cs index f6aefc8..ee25884 100644 --- a/ComPDFKit for Windows/Examples/Samples/LicenseKey.cs +++ b/ComPDFKit for Windows/Examples/Samples/LicenseKey.cs @@ -8,7 +8,7 @@ public static bool LicenseVerify() if (!LoadNativeLibrary()) return false; - string license = "vRK+dzgqDsImQkoKZb2i2WhhdsKYquZ5JJUUuOF6q4xySFETAYvInXOu/f3JAvR9X14z/s4W20EE9WSKsbEum6IvdY8uLoNFy6YM7SyvNC0zVPs5T7GnEBaTQ+qVgnGeV88LA7nbZjPGfQmC75jFLlItpetrbbp75d7LQs6ftq/I8akPBz4Kxc3SSow2MFj5GzH6VbCFYSlUKw/TwA4adwM8uk2g6Kh86i23vTzGejQ4FtQ6stKHXn4HllO0bXpWnFihljcZ3R8PR31pFNwT8UUw4h9NVdFcZxpnGRDbwx9QP9WyHpHZLwbeO48ufCgFCVysJEk1riNSTGTAaAP3FUtTVN6c+2dRhnnKQ9BD2+ZXPq1h0mtlp1NQ+RMIko/jptqMsDODbroq9eCcyCqv15famjsc5QhApxJ66Uir6JIEWg+1gHSh2bjFiiXJAZ6NYxZRbQCMGNWAvkvPL3VOmCcPKDpJojB4dAuUzkjcfNP3FtGWASLlf1sxBLPPUH3/SUjuKo61mV+inIkdPNQcpTuQO57aUzB8KSNTD9t5EApfDx1B3KqboczEI8JHpWmS+IJqLCfsdlZLlGqIVobinsWoWlrK+RCjMLVb1nG6cwgJkaUZSOX6lhqKCVjsk/y/UkMufir2Jr3VOcSskcB2q89CFCFifHHHnhIhHClAv/cmsbjAv8udd4vC2c8/IMyeZDTKE61QPTGv5Web7Veww7UvwzOJJzdEyurazXA+8W54OEFOcXWYSdIgqS/vfVtnuO1kXkGQlSX1V0ead/9e5cgbJBA0v6oCmcgFsdJ19cJWN2eb8XRaylJBvRjCLTfxyhbz5ot00OuvKj41xr9kzFxfdbfnnZIUvdt0DhdKOcq/XESwVIL+pht7hkwzW7dk3HovfUURbW/42AUBTS3P/UNn7rp3eHOhZnTYo6erdzuLfnoMUa8M8nhOhIEkkRTxyCgKfwd4akkqZVJx9r83Hlf9ceP1IoDYgrXYwpetLJ8="; + string license = "24ywO5QOL/6xA78UdefdSqyCN2DAK0GO3ctq7PFduZ7jNyK2r8ru+OkzxO/pRmyc/SdRk4qZpjcTuzVWqlvm9mYZYcz8fc0CCKLl7jziHKTdiudWddyaWwABRMRrw2IxMCT+UrngegMZ7KVzurK76fsaX0ULRsCR41Bd0UoPaybvGBeuVs3I6XTP5E5Hu0fpCo+oUwVV6xNJyIkK/B7oazkC0pjJFMnoNZ8fKI3M+P0jza6dpM6wQkM+b9GqGKu0XjKBE+d5OJgXD4oRIXKAYT86jmtum1ZcLYItWK9ChIO9TQJYuvtcIDCSnrNuA0YQegnfoY/q5b+rn7PQDV5di0tTVN6c+2dRhnnKQ9BD2+ZXPq1h0mtlp1NQ+RMIko/jptqMsDODbroq9eCcyCqv15famjsc5QhApxJ66Uir6JIEWg+1gHSh2bjFiiXJAZ6NYxZRbQCMGNWAvkvPL3VOmCcPKDpJojB4dAuUzkjcfNP3FtGWASLlf1sxBLPPUH3/SUjuKo61mV+inIkdPNQcpTuQO57aUzB8KSNTD9t5EApfDx1B3KqboczEI8JHpWmS+IJqLCfsdlZLlGqIVobinsWoWlrK+RCjMLVb1nG6cwjM5Mqll1bnX2z0pJMoAOF3kWgbT7lJD0GQGywLcuHOOrC478hvP2cDIaltVnym8VrDlbODXEho1HLWbJp0z6qlTJ6nD4pqlkYW0VU+Uu1LE2VCymCuLT01rJlnne9TsMGmX5tTLvKy9ITFm7uwkVffejxBTHIGmDrTVqlc7ABbYzXhlraeCUwg0QL0p8RvjNrLZiQUN8OqBJvMBbPRBvWxV0Fn6PIJWs5RPb0ewCk388ll85WKAtCYrFc+McXDZMpeW3W15O6SZ7ytdH0UNznOvCBEtlaG/qQYCIY/Mi23F98HL3lGbW1p+twFA05ez45CEe7JdAVzpWUI2KWlr3c5V7JB9xcxW0WhhJkt8nd55b6LfhfPoH5/z+YfXo5CvTFi9iZhMizKIZvrFgGf7a/v+u16tzCiO1ZkOjwxr2Hr5w=="; LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(license, false); return (verifyResult == LicenseErrorCode.E_LICENSE_SUCCESS); } diff --git a/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/OutlineTest.csproj b/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/OutlineTest.csproj index 256ec7b..96b74f9 100644 --- a/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/OutlineTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/OutlineTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -76,11 +76,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/Properties/AssemblyInfo.cs index 6735de5..38173f3 100644 --- a/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/OutlineTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/OutlineTest/VB/OutlineTest.vbproj b/ComPDFKit for Windows/Examples/Samples/OutlineTest/VB/OutlineTest.vbproj index 432c24e..dad6af6 100644 --- a/ComPDFKit for Windows/Examples/Samples/OutlineTest/VB/OutlineTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/OutlineTest/VB/OutlineTest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -135,11 +135,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/OutlineTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/OutlineTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/OutlineTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/OutlineTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/PDFA/sRGB2014.icc b/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/PDFA/sRGB2014.icc deleted file mode 100644 index 49afbfe..0000000 Binary files a/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/PDFA/sRGB2014.icc and /dev/null differ diff --git a/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/PDFATest.csproj b/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/PDFATest.csproj index 9e54caa..250e522 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/PDFATest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/PDFATest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -76,11 +76,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/PDFATest.csproj.user b/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/PDFATest.csproj.user deleted file mode 100644 index 6cbe588..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/PDFATest.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - ProjectFiles - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/Properties/AssemblyInfo.cs index 37d218a..d7a30e1 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/PDFATest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFATest/VB/PDFATest.vbproj b/ComPDFKit for Windows/Examples/Samples/PDFATest/VB/PDFATest.vbproj index c422964..a7dd970 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFATest/VB/PDFATest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/PDFATest/VB/PDFATest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -135,11 +135,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFATest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/PDFATest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFATest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/PDFATest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/PDFPageTest.csproj b/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/PDFPageTest.csproj index d7ea8bf..77f9dd2 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/PDFPageTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/PDFPageTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -80,11 +80,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/Properties/AssemblyInfo.cs index 5c0d288..3ade2cd 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/PDFPageTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFPageTest/VB/PDFPageTest.vbproj b/ComPDFKit for Windows/Examples/Samples/PDFPageTest/VB/PDFPageTest.vbproj index 835c978..b8e52f4 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFPageTest/VB/PDFPageTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/PDFPageTest/VB/PDFPageTest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -139,11 +139,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFPageTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/PDFPageTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFPageTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/PDFPageTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/PDFRedactTest.csproj b/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/PDFRedactTest.csproj index 78ae576..2d41f65 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/PDFRedactTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/PDFRedactTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -75,11 +75,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/Properties/AssemblyInfo.cs index cf2bea0..42a0d6c 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/VB/PDFRedactTest.vbproj b/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/VB/PDFRedactTest.vbproj index 9658c70..6d5d962 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/VB/PDFRedactTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/VB/PDFRedactTest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -136,11 +136,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/PDFRedactTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/App.config b/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/App.config deleted file mode 100644 index 731f6de..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/ComPDFKit_Logo.ico b/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/ComPDFKit_Logo.ico deleted file mode 100644 index f5af1a4..0000000 Binary files a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/ComPDFKit_Logo.ico and /dev/null differ diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/PDFToImage.cs b/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/PDFToImage.cs deleted file mode 100644 index 080ca0f..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/PDFToImage.cs +++ /dev/null @@ -1,79 +0,0 @@ -using ComPDFKit.PDFDocument; -using ComPDFKit.PDFPage; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; - -using ComPDFKit.Import; -using ImageMagick; - -namespace PDFToImageTest -{ - internal class PDFToImage - { - private static string parentPath = - Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))); - private static string outputPath = parentPath + @"\Output\CS"; - static void Main(string[] args) - { - Console.WriteLine("Running PDFToImage test sample…" + Environment.NewLine); - - SDKLicenseHelper.LicenseVerify(); - CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf"); - - if (!Directory.Exists(outputPath)) - { - Directory.CreateDirectory(outputPath); - } - - PDFPageToImage(document); - PDFToImage2(document); - Console.WriteLine("--------------------"); - Console.WriteLine("Done!"); - Console.WriteLine("--------------------"); - - Console.ReadLine(); - } - - private static void PDFToImage2(CPDFDocument document) - { - document.PdfToImage("1", outputPath); - } - - /// - /// Convert PDF to image - /// - static private bool PDFPageToImage(CPDFDocument document) - { - for (int i = 0; i < document.PageCount; i++) - { - CPDFPage pdfPage = document.PageAtIndex(i, true); - CSize cSize = document.GetPageSize(0); - System.Drawing.Size pageSize = new System.Drawing.Size((int)cSize.width, (int)cSize.height); - CRect pageRect = new CRect(0, (int)(pageSize.Height / 72.0 * 96), (int)(pageSize.Width / 72.0 * 96), 0); - byte[] bmpData = new byte[(int)(pageRect.width() * pageRect.height() * (96 / 72.0) * (96 / 72.0) * 4)]; - pdfPage.RenderPageBitmapWithMatrix((float)(96 / 72.0), pageRect, 0xFFFFFFFF, bmpData, 0, true); - var path = Path.Combine(outputPath, "PDFToImageTest" + i + ".png"); - - var settings = new MagickReadSettings() - { - Format = MagickFormat.Bgra, - Width = (int)pageRect.width(), - Height = (int)pageRect.height() - }; - using (var image = new MagickImage(bmpData,settings)) - { - image.Format = MagickFormat.Png; - image.Write(path); - } - Console.WriteLine("Png image saved in {0}", path); - } - return false; - } - } -} diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/PDFToImageTest.csproj b/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/PDFToImageTest.csproj deleted file mode 100644 index a410dfa..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/PDFToImageTest.csproj +++ /dev/null @@ -1,100 +0,0 @@ - - - - - Debug - AnyCPU - {82A11207-3CA9-47D2-9F1C-94FE057DABFE} - Exe - PDFToImage - Samples_ComPDFKit - v4.6.1 - 512 - true - true - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - ComPDFKit_Logo.ico - - - - ..\..\..\packages\ComPDFKit.NetFramework.2.0.0\lib\ComPDFKit.NET.dll - - - ..\..\..\packages\ComPDFKit.NetFramework.2.0.0\lib\ComPDFKit.Viewer.dll - - - ..\..\..\packages\Magick.NET-Q8-AnyCPU.13.8.0\lib\netstandard20\Magick.NET-Q8-AnyCPU.dll - - - ..\..\..\packages\Magick.NET.Core.13.8.0\lib\netstandard20\Magick.NET.Core.dll - - - - ..\..\..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll - - - - - - - - - - - - - - - LicenseKey.cs - - - - - - - CommonFivePage.pdf - PreserveNewest - - - - - - - license_key_windows.xml - PreserveNewest - - - - - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/Properties/AssemblyInfo.cs deleted file mode 100644 index 5041946..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PDFToImage")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("PDF Technologies, Inc.")] -[assembly: AssemblyProduct("PDFToImage")] -[assembly: AssemblyCopyright("Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("82a11207-3ca9-47d2-9f1c-94fe057dabfe")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// 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.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/packages.config deleted file mode 100644 index f4bdf90..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/CS/packages.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/App.config b/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/App.config deleted file mode 100644 index 731f6de..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/ComPDFKit_Logo.ico b/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/ComPDFKit_Logo.ico deleted file mode 100644 index f5af1a4..0000000 Binary files a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/ComPDFKit_Logo.ico and /dev/null differ diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Application.Designer.vb b/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Application.Designer.vb deleted file mode 100644 index 88dd01c..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Application.Designer.vb +++ /dev/null @@ -1,13 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Application.myapp b/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Application.myapp deleted file mode 100644 index e62f1a5..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - false - false - 0 - true - 0 - 2 - true - diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/AssemblyInfo.vb b/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/AssemblyInfo.vb deleted file mode 100644 index f3e8d96..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/AssemblyInfo.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports System -Imports System.Reflection -Imports System.Runtime.InteropServices - -' 有关程序集的一般信息由以下 -' 控制。更改这些特性值可修改 -' 与程序集关联的信息。 - -'查看程序集特性的值 - - - - - - - - - - -'如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID - - -' 程序集的版本信息由下列四个值组成: -' -' 主版本 -' 次版本 -' 生成号 -' 修订号 -' -'可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 -'通过使用 "*",如下所示: -' - - - diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Resources.Designer.vb b/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Resources.Designer.vb deleted file mode 100644 index d8c06dc..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Resources.Designer.vb +++ /dev/null @@ -1,62 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My.Resources - - 'This class was auto-generated by the StronglyTypedResourceBuilder - 'class via a tool like ResGen or Visual Studio. - 'To add or remove a member, edit your .ResX file then rerun ResGen - 'with the /str option, or rebuild your VS project. - ''' - ''' A strongly-typed resource class, for looking up localized strings, etc. - ''' - _ - Friend Module Resources - - Private resourceMan As Global.System.Resources.ResourceManager - - Private resourceCulture As Global.System.Globalization.CultureInfo - - ''' - ''' Returns the cached ResourceManager instance used by this class. - ''' - _ - Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager - Get - If Object.ReferenceEquals(resourceMan, Nothing) Then - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("VB.Resources", GetType(Resources).Assembly) - resourceMan = temp - End If - Return resourceMan - End Get - End Property - - ''' - ''' Overrides the current thread's CurrentUICulture property for all - ''' resource lookups using this strongly typed resource class. - ''' - _ - Friend Property Culture() As Global.System.Globalization.CultureInfo - Get - Return resourceCulture - End Get - Set(ByVal value As Global.System.Globalization.CultureInfo) - resourceCulture = value - End Set - End Property - End Module -End Namespace diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Settings.Designer.vb b/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Settings.Designer.vb deleted file mode 100644 index 2c92437..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Settings.Designer.vb +++ /dev/null @@ -1,73 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - _ - Partial Friend NotInheritable Class MySettings - Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) - -#Region "My.Settings Auto-Save Functionality" -#If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean - - Private Shared addedHandlerLockObject As New Object - - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub -#End If -#End Region - - Public Shared ReadOnly Property [Default]() As MySettings - Get - -#If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If -#End If - Return defaultInstance - End Get - End Property - End Class -End Namespace - -Namespace My - - _ - Friend Module MySettingsProperty - - _ - Friend ReadOnly Property Settings() As Global.VB.My.MySettings - Get - Return Global.VB.My.MySettings.Default - End Get - End Property - End Module -End Namespace diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Settings.settings b/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Settings.settings deleted file mode 100644 index 85b890b..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/My Project/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/PDFToImageTest.vb b/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/PDFToImageTest.vb deleted file mode 100644 index b4b21dc..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/PDFToImageTest.vb +++ /dev/null @@ -1,64 +0,0 @@ -Imports ComPDFKit.PDFDocument -Imports ComPDFKit.PDFPage -Imports System -Imports System.Drawing -Imports System.Drawing.Imaging -Imports System.IO -Imports System.Windows -Imports System.Windows.Media -Imports System.Windows.Media.Imaging -Imports ComPDFKit.Import - -Module PDFToImageTest - Private parentPath As String = - Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()))) - Private outputPath As String = Path.Combine(parentPath, "Output", "VB") - - Sub Main(args As String()) - Console.WriteLine("Running PDFToImage test sample..." & vbCrLf) - - SDKLicenseHelper.LicenseVerify() - Dim document As CPDFDocument = CPDFDocument.InitWithFilePath("CommonFivePage.pdf") - - If Not Directory.Exists(outputPath) Then - Directory.CreateDirectory(outputPath) - End If - - PDFPageToImage(document) - - Console.WriteLine("--------------------") - Console.WriteLine("Done!") - Console.WriteLine("--------------------") - - Console.ReadLine() - End Sub - - Private Sub SaveWriteableBitmapAsPng(writeableBitmap As WriteableBitmap, fileName As String) - Using stream As New FileStream(fileName, FileMode.Create) - Dim encoder As New PngBitmapEncoder() - encoder.Frames.Add(BitmapFrame.Create(writeableBitmap)) - encoder.Save(stream) - End Using - End Sub - - ' Convert PDF to image - Private Function PDFPageToImage(document As CPDFDocument) As Boolean - For i As Integer = 0 To document.PageCount - 1 - Dim pdfPage As CPDFPage = document.PageAtIndex(i, True) - Dim cSize As CSize = document.GetPageSize(0) - Dim pageSize As Windows.Size = New Windows.Size(cSize.Width, cSize.Height) - Dim pageRect As New CRect(0, CInt(pageSize.Height / 72.0 * 96), CInt(pageSize.Width / 72.0 * 96), 0) - Dim bmpData As Byte() = New Byte(CInt(pageRect.Width * pageRect.Height * (96 / 72.0) * (96 / 72.0) * 4) - 1) {} - pdfPage.RenderPageBitmapWithMatrix(CSng(96 / 72.0), pageRect, Convert.ToUInt32(&HFFFFFFF), bmpData, 0, True) - - Dim writeableBitmap As New WriteableBitmap(CInt(pageRect.Width), CInt(pageRect.Height), 96, 96, PixelFormats.Bgra32, Nothing) - writeableBitmap.WritePixels(New Int32Rect(0, 0, CInt(pageRect.Width), CInt(pageRect.Height)), bmpData, writeableBitmap.BackBufferStride, 0) - Dim filePath As String = Path.Combine(outputPath, "PDFToImageTest" & i & ".png") - SaveWriteableBitmapAsPng(writeableBitmap, filePath) - Console.WriteLine("Png image saved in " & filePath) - - Next - - Return False - End Function -End Module diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/PDFToImageTest.vbproj b/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/PDFToImageTest.vbproj deleted file mode 100644 index 92851b8..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/PDFToImageTest.vbproj +++ /dev/null @@ -1,148 +0,0 @@ - - - - - Debug - AnyCPU - {6D1DE0A5-8E7D-403E-8470-F72BB06FD35A} - Exe - VB.PDFToImageTest - VB - Samples_ComPDFKit - 512 - Console - v4.6.1 - true - true - - - - - AnyCPU - true - full - true - true - bin\Debug\ - Samples_ComPDFKit.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - false - - - AnyCPU - pdbonly - false - true - true - bin\Release\ - Samples_ComPDFKit.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - false - - - On - - - Binary - - - Off - - - On - - - ComPDFKit_Logo.ico - - - - ..\..\..\packages\ComPDFKit.NetFramework.2.0.0\lib\ComPDFKit.NET.dll - - - ..\..\..\packages\ComPDFKit.NetFramework.2.0.0\lib\ComPDFKit.Viewer.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - LicenseKey.vb - - - - - True - Application.myapp - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - VbMyResourcesResXFileCodeGenerator - Resources.Designer.vb - My.Resources - Designer - - - - - CommonFivePage.pdf - PreserveNewest - - - MyApplicationCodeGenerator - Application.Designer.vb - - - SettingsSingleFileGenerator - My - Settings.Designer.vb - - - - - - - license_key_windows.xml - PreserveNewest - - - - - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/packages.config deleted file mode 100644 index ce405bb..0000000 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImage/VB/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/PDFToImageTest.csproj b/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/PDFToImageTest.csproj index 247a0cb..ea370b3 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/PDFToImageTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/PDFToImageTest.csproj @@ -38,11 +38,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -78,11 +78,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/Properties/AssemblyInfo.cs index c1d7617..3e9eec1 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/packages.config b/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/CS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/VB/PDFToImageTest.vbproj b/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/VB/PDFToImageTest.vbproj index 0ebc9be..677a628 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/VB/PDFToImageTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/VB/PDFToImageTest.vbproj @@ -53,11 +53,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -136,11 +136,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/PDFToImageTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/Samples.sln b/ComPDFKit for Windows/Examples/Samples/Samples.sln new file mode 100644 index 0000000..a7b1fa9 --- /dev/null +++ b/ComPDFKit for Windows/Examples/Samples/Samples.sln @@ -0,0 +1,222 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreamLoadTest", "StreamLoadTest\StreamLoadTest.csproj", "{6B69302E-4F3E-480D-8CC0-52933C448C1C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UrlLoadTest", "UrlLoadTest\UrlLoadTest.csproj", "{23A30C13-8349-4A04-864F-8AB3C3164F7C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AnnotationImportExportTest", "AnnotationImportExportTest", "{7935FACE-83C9-4099-8C89-2D3A12C85E61}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnnotationImportExportTest", "AnnotationImportExportTest\CS\AnnotationImportExportTest.csproj", "{21F300DE-B152-42D4-BDEF-05875C046714}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AnnotationTest", "AnnotationTest", "{57EEE718-C2CE-4337-8D33-6AA00B2AAD81}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnnotationTest", "AnnotationTest\CS\AnnotationTest.csproj", "{36E5B53A-9256-488C-9E88-5E1968CA249E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BackgroundTest", "BackgroundTest", "{1B582A82-6BCD-403A-BCE5-29722C8285F0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BackgroundTest", "BackgroundTest\CS\BackgroundTest.csproj", "{9CA98D01-B356-482D-B288-4AE4FF0854A4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BatesTest", "BatesTest", "{AFE277E5-5E9D-4482-9EF9-709B28C9DD96}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BatesTest", "BatesTest\CS\BatesTest.csproj", "{729EE3AE-4E89-4E8D-A6E1-C7441DCDC51E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BookmarkTest", "BookmarkTest", "{909A8AE0-84CD-46D3-9CDD-B3F094047907}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookmarkTest", "BookmarkTest\CS\BookmarkTest.csproj", "{AE0521DF-A80D-4C29-B417-EF3A049CED61}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DigitalSignatureTest", "DigitalSignatureTest", "{AEA0FEB3-48A8-4696-9392-52060C8062F1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DigitalSignatureTest", "DigitalSignatureTest\CS\DigitalSignatureTest.csproj", "{1525FEED-BE9C-49D1-9183-E19FA2A76370}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DocumentCompareTest", "DocumentCompareTest", "{F33A2CEF-902F-436A-8E53-A427FCD9817B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocumentCompareTest", "DocumentCompareTest\CS\DocumentCompareTest.csproj", "{D49A54DE-672B-40D7-9B87-D6EF6EE2B572}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DocumentInfoTest", "DocumentInfoTest", "{72C08C43-1003-4D3A-9142-66DFCD3E6240}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocumentInfoTest", "DocumentInfoTest\CS\DocumentInfoTest.csproj", "{B0B190B1-C6AA-42CF-9469-4B90B0E8F051}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EncryptTest", "EncryptTest", "{D61292B1-346D-4D74-8504-0B0EA6A5C705}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EncryptTest", "EncryptTest\CS\EncryptTest.csproj", "{0DE54A16-41C8-4F66-9C2C-35F667458758}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FlattenTest", "FlattenTest", "{47A8B95B-93EA-4044-A66C-A95B3FA1FB04}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlattenTest", "FlattenTest\CS\FlattenTest.csproj", "{BEF003F3-8DFB-4180-B613-4B9EB27DD11B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HeaderFooterTest", "HeaderFooterTest", "{57EAD572-83C0-4158-90A6-D70791D9671D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HeaderFooterTest", "HeaderFooterTest\CS\HeaderFooterTest.csproj", "{F401B69A-AB3C-4D62-9F45-422D53664002}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ImageExtractTest", "ImageExtractTest", "{D660CFB9-FCC4-4B3B-B32A-244418FA3DF2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageExtractTest", "ImageExtractTest\CS\ImageExtractTest.csproj", "{88D6E10A-B2A0-4435-8157-F6AD8CA68982}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InteractiveFormsTest", "InteractiveFormsTest", "{700FDFD3-E5A0-422A-957C-A54F3956422C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteractiveFormsTest", "InteractiveFormsTest\CS\InteractiveFormsTest.csproj", "{6DC2304D-BEF8-4656-A206-352631E15E2B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OutlineTest", "OutlineTest", "{B4147B9B-DD1D-41D3-A9C5-E92D4E5C7DE0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OutlineTest", "OutlineTest\CS\OutlineTest.csproj", "{CC528195-2250-4447-8531-0D064837D2F3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PDFATest", "PDFATest", "{C316DB2C-7BBA-4F10-810E-0E7C5F125B1F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PDFATest", "PDFATest\CS\PDFATest.csproj", "{2FAD93CA-08E7-4229-99FB-11041E721B2E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PDFPageTest", "PDFPageTest", "{4D7A6B15-7E58-4A41-8A46-1A57FE011DF6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PDFPageTest", "PDFPageTest\CS\PDFPageTest.csproj", "{87723C16-7B73-4946-A00D-233BAFCC139C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PDFRedactTest", "PDFRedactTest", "{3B419B87-9F2C-44AE-80C9-02CF0884D061}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PDFRedactTest", "PDFRedactTest\CS\PDFRedactTest.csproj", "{E3B417B9-7548-40D4-9AB7-2FF4348CB53B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PDFToImageTest", "PDFToImageTest", "{6BD31062-1023-4BE0-9484-D8D42A197F2A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PDFToImageTest", "PDFToImageTest\CS\PDFToImageTest.csproj", "{5E4BABC0-23D6-4B73-8B89-19AD495B5906}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TextExtractTest", "TextExtractTest", "{1F47644D-B4AE-456B-9696-B1E68AA94EFB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TextExtractTest", "TextExtractTest\CS\TextExtractTest.csproj", "{8AB627CE-5E76-4DF0-817A-F4F521CF1824}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TextSearchTest", "TextSearchTest", "{57841B05-182A-47DC-95E5-8DD92473E38C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TextSearchTest", "TextSearchTest\CS\TextSearchTest.csproj", "{39FF28AE-3F41-464B-8CB7-26DA832471DC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WatermarkTest", "WatermarkTest", "{032D18EC-1177-4C8E-883F-28D38D52028D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WatermarkTest", "WatermarkTest\CS\WatermarkTest.csproj", "{97FCD03D-1BB0-46A8-A8E2-F521376DD5BC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6B69302E-4F3E-480D-8CC0-52933C448C1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B69302E-4F3E-480D-8CC0-52933C448C1C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B69302E-4F3E-480D-8CC0-52933C448C1C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B69302E-4F3E-480D-8CC0-52933C448C1C}.Release|Any CPU.Build.0 = Release|Any CPU + {23A30C13-8349-4A04-864F-8AB3C3164F7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23A30C13-8349-4A04-864F-8AB3C3164F7C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23A30C13-8349-4A04-864F-8AB3C3164F7C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23A30C13-8349-4A04-864F-8AB3C3164F7C}.Release|Any CPU.Build.0 = Release|Any CPU + {21F300DE-B152-42D4-BDEF-05875C046714}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {21F300DE-B152-42D4-BDEF-05875C046714}.Debug|Any CPU.Build.0 = Debug|Any CPU + {21F300DE-B152-42D4-BDEF-05875C046714}.Release|Any CPU.ActiveCfg = Release|Any CPU + {21F300DE-B152-42D4-BDEF-05875C046714}.Release|Any CPU.Build.0 = Release|Any CPU + {36E5B53A-9256-488C-9E88-5E1968CA249E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {36E5B53A-9256-488C-9E88-5E1968CA249E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {36E5B53A-9256-488C-9E88-5E1968CA249E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {36E5B53A-9256-488C-9E88-5E1968CA249E}.Release|Any CPU.Build.0 = Release|Any CPU + {9CA98D01-B356-482D-B288-4AE4FF0854A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9CA98D01-B356-482D-B288-4AE4FF0854A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9CA98D01-B356-482D-B288-4AE4FF0854A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9CA98D01-B356-482D-B288-4AE4FF0854A4}.Release|Any CPU.Build.0 = Release|Any CPU + {729EE3AE-4E89-4E8D-A6E1-C7441DCDC51E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {729EE3AE-4E89-4E8D-A6E1-C7441DCDC51E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {729EE3AE-4E89-4E8D-A6E1-C7441DCDC51E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {729EE3AE-4E89-4E8D-A6E1-C7441DCDC51E}.Release|Any CPU.Build.0 = Release|Any CPU + {AE0521DF-A80D-4C29-B417-EF3A049CED61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE0521DF-A80D-4C29-B417-EF3A049CED61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE0521DF-A80D-4C29-B417-EF3A049CED61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE0521DF-A80D-4C29-B417-EF3A049CED61}.Release|Any CPU.Build.0 = Release|Any CPU + {1525FEED-BE9C-49D1-9183-E19FA2A76370}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1525FEED-BE9C-49D1-9183-E19FA2A76370}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1525FEED-BE9C-49D1-9183-E19FA2A76370}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1525FEED-BE9C-49D1-9183-E19FA2A76370}.Release|Any CPU.Build.0 = Release|Any CPU + {D49A54DE-672B-40D7-9B87-D6EF6EE2B572}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D49A54DE-672B-40D7-9B87-D6EF6EE2B572}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D49A54DE-672B-40D7-9B87-D6EF6EE2B572}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D49A54DE-672B-40D7-9B87-D6EF6EE2B572}.Release|Any CPU.Build.0 = Release|Any CPU + {B0B190B1-C6AA-42CF-9469-4B90B0E8F051}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0B190B1-C6AA-42CF-9469-4B90B0E8F051}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0B190B1-C6AA-42CF-9469-4B90B0E8F051}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0B190B1-C6AA-42CF-9469-4B90B0E8F051}.Release|Any CPU.Build.0 = Release|Any CPU + {0DE54A16-41C8-4F66-9C2C-35F667458758}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0DE54A16-41C8-4F66-9C2C-35F667458758}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0DE54A16-41C8-4F66-9C2C-35F667458758}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0DE54A16-41C8-4F66-9C2C-35F667458758}.Release|Any CPU.Build.0 = Release|Any CPU + {BEF003F3-8DFB-4180-B613-4B9EB27DD11B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BEF003F3-8DFB-4180-B613-4B9EB27DD11B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BEF003F3-8DFB-4180-B613-4B9EB27DD11B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BEF003F3-8DFB-4180-B613-4B9EB27DD11B}.Release|Any CPU.Build.0 = Release|Any CPU + {F401B69A-AB3C-4D62-9F45-422D53664002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F401B69A-AB3C-4D62-9F45-422D53664002}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F401B69A-AB3C-4D62-9F45-422D53664002}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F401B69A-AB3C-4D62-9F45-422D53664002}.Release|Any CPU.Build.0 = Release|Any CPU + {88D6E10A-B2A0-4435-8157-F6AD8CA68982}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {88D6E10A-B2A0-4435-8157-F6AD8CA68982}.Debug|Any CPU.Build.0 = Debug|Any CPU + {88D6E10A-B2A0-4435-8157-F6AD8CA68982}.Release|Any CPU.ActiveCfg = Release|Any CPU + {88D6E10A-B2A0-4435-8157-F6AD8CA68982}.Release|Any CPU.Build.0 = Release|Any CPU + {6DC2304D-BEF8-4656-A206-352631E15E2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6DC2304D-BEF8-4656-A206-352631E15E2B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6DC2304D-BEF8-4656-A206-352631E15E2B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6DC2304D-BEF8-4656-A206-352631E15E2B}.Release|Any CPU.Build.0 = Release|Any CPU + {CC528195-2250-4447-8531-0D064837D2F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC528195-2250-4447-8531-0D064837D2F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC528195-2250-4447-8531-0D064837D2F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC528195-2250-4447-8531-0D064837D2F3}.Release|Any CPU.Build.0 = Release|Any CPU + {2FAD93CA-08E7-4229-99FB-11041E721B2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2FAD93CA-08E7-4229-99FB-11041E721B2E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2FAD93CA-08E7-4229-99FB-11041E721B2E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2FAD93CA-08E7-4229-99FB-11041E721B2E}.Release|Any CPU.Build.0 = Release|Any CPU + {87723C16-7B73-4946-A00D-233BAFCC139C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {87723C16-7B73-4946-A00D-233BAFCC139C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {87723C16-7B73-4946-A00D-233BAFCC139C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {87723C16-7B73-4946-A00D-233BAFCC139C}.Release|Any CPU.Build.0 = Release|Any CPU + {E3B417B9-7548-40D4-9AB7-2FF4348CB53B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E3B417B9-7548-40D4-9AB7-2FF4348CB53B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E3B417B9-7548-40D4-9AB7-2FF4348CB53B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E3B417B9-7548-40D4-9AB7-2FF4348CB53B}.Release|Any CPU.Build.0 = Release|Any CPU + {5E4BABC0-23D6-4B73-8B89-19AD495B5906}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5E4BABC0-23D6-4B73-8B89-19AD495B5906}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5E4BABC0-23D6-4B73-8B89-19AD495B5906}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5E4BABC0-23D6-4B73-8B89-19AD495B5906}.Release|Any CPU.Build.0 = Release|Any CPU + {8AB627CE-5E76-4DF0-817A-F4F521CF1824}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8AB627CE-5E76-4DF0-817A-F4F521CF1824}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8AB627CE-5E76-4DF0-817A-F4F521CF1824}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8AB627CE-5E76-4DF0-817A-F4F521CF1824}.Release|Any CPU.Build.0 = Release|Any CPU + {39FF28AE-3F41-464B-8CB7-26DA832471DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39FF28AE-3F41-464B-8CB7-26DA832471DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39FF28AE-3F41-464B-8CB7-26DA832471DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39FF28AE-3F41-464B-8CB7-26DA832471DC}.Release|Any CPU.Build.0 = Release|Any CPU + {97FCD03D-1BB0-46A8-A8E2-F521376DD5BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97FCD03D-1BB0-46A8-A8E2-F521376DD5BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97FCD03D-1BB0-46A8-A8E2-F521376DD5BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97FCD03D-1BB0-46A8-A8E2-F521376DD5BC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {21F300DE-B152-42D4-BDEF-05875C046714} = {7935FACE-83C9-4099-8C89-2D3A12C85E61} + {36E5B53A-9256-488C-9E88-5E1968CA249E} = {57EEE718-C2CE-4337-8D33-6AA00B2AAD81} + {9CA98D01-B356-482D-B288-4AE4FF0854A4} = {1B582A82-6BCD-403A-BCE5-29722C8285F0} + {729EE3AE-4E89-4E8D-A6E1-C7441DCDC51E} = {AFE277E5-5E9D-4482-9EF9-709B28C9DD96} + {AE0521DF-A80D-4C29-B417-EF3A049CED61} = {909A8AE0-84CD-46D3-9CDD-B3F094047907} + {1525FEED-BE9C-49D1-9183-E19FA2A76370} = {AEA0FEB3-48A8-4696-9392-52060C8062F1} + {D49A54DE-672B-40D7-9B87-D6EF6EE2B572} = {F33A2CEF-902F-436A-8E53-A427FCD9817B} + {B0B190B1-C6AA-42CF-9469-4B90B0E8F051} = {72C08C43-1003-4D3A-9142-66DFCD3E6240} + {0DE54A16-41C8-4F66-9C2C-35F667458758} = {D61292B1-346D-4D74-8504-0B0EA6A5C705} + {BEF003F3-8DFB-4180-B613-4B9EB27DD11B} = {47A8B95B-93EA-4044-A66C-A95B3FA1FB04} + {F401B69A-AB3C-4D62-9F45-422D53664002} = {57EAD572-83C0-4158-90A6-D70791D9671D} + {88D6E10A-B2A0-4435-8157-F6AD8CA68982} = {D660CFB9-FCC4-4B3B-B32A-244418FA3DF2} + {6DC2304D-BEF8-4656-A206-352631E15E2B} = {700FDFD3-E5A0-422A-957C-A54F3956422C} + {CC528195-2250-4447-8531-0D064837D2F3} = {B4147B9B-DD1D-41D3-A9C5-E92D4E5C7DE0} + {2FAD93CA-08E7-4229-99FB-11041E721B2E} = {C316DB2C-7BBA-4F10-810E-0E7C5F125B1F} + {87723C16-7B73-4946-A00D-233BAFCC139C} = {4D7A6B15-7E58-4A41-8A46-1A57FE011DF6} + {E3B417B9-7548-40D4-9AB7-2FF4348CB53B} = {3B419B87-9F2C-44AE-80C9-02CF0884D061} + {5E4BABC0-23D6-4B73-8B89-19AD495B5906} = {6BD31062-1023-4BE0-9484-D8D42A197F2A} + {8AB627CE-5E76-4DF0-817A-F4F521CF1824} = {1F47644D-B4AE-456B-9696-B1E68AA94EFB} + {39FF28AE-3F41-464B-8CB7-26DA832471DC} = {57841B05-182A-47DC-95E5-8DD92473E38C} + {97FCD03D-1BB0-46A8-A8E2-F521376DD5BC} = {032D18EC-1177-4C8E-883F-28D38D52028D} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {49193E22-E916-4F51-9350-BA2DB5786CE1} + EndGlobalSection +EndGlobal diff --git a/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/Properties/AssemblyInfo.cs index 3c8aed8..4411916 100644 --- a/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/Properties/AssemblyInfo.cs @@ -32,5 +32,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.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/StreamLoadTest.csproj b/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/StreamLoadTest.csproj index 5490504..b6c7cd6 100644 --- a/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/StreamLoadTest.csproj +++ b/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/StreamLoadTest.csproj @@ -35,11 +35,11 @@ 4 - - ..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -68,11 +68,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/packages.config b/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/StreamLoadTest/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/TextExtractTest/VB/TextExtractTest.vbproj b/ComPDFKit for Windows/Examples/Samples/TextExtractTest/VB/TextExtractTest.vbproj index b333814..f122c5c 100644 --- a/ComPDFKit for Windows/Examples/Samples/TextExtractTest/VB/TextExtractTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/TextExtractTest/VB/TextExtractTest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -135,11 +135,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/TextExtractTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/TextExtractTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/TextExtractTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/TextExtractTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/TextSearchTest/VB/TextSearchTest.vbproj b/ComPDFKit for Windows/Examples/Samples/TextSearchTest/VB/TextSearchTest.vbproj index 19bd049..b85c02f 100644 --- a/ComPDFKit for Windows/Examples/Samples/TextSearchTest/VB/TextSearchTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/TextSearchTest/VB/TextSearchTest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -137,11 +137,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/TextSearchTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/TextSearchTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/TextSearchTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/TextSearchTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/WatermarkTest/VB/WatermarkTest.vbproj b/ComPDFKit for Windows/Examples/Samples/WatermarkTest/VB/WatermarkTest.vbproj index 36bf937..7b8d67e 100644 --- a/ComPDFKit for Windows/Examples/Samples/WatermarkTest/VB/WatermarkTest.vbproj +++ b/ComPDFKit for Windows/Examples/Samples/WatermarkTest/VB/WatermarkTest.vbproj @@ -55,11 +55,11 @@ ComPDFKit_Logo.ico - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\..\..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\..\..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll @@ -144,11 +144,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/WatermarkTest/VB/packages.config b/ComPDFKit for Windows/Examples/Samples/WatermarkTest/VB/packages.config index 5afbd7a..aea2557 100644 --- a/ComPDFKit for Windows/Examples/Samples/WatermarkTest/VB/packages.config +++ b/ComPDFKit for Windows/Examples/Samples/WatermarkTest/VB/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Samples/license_key_windows.txt b/ComPDFKit for Windows/Examples/Samples/license_key_windows.txt index ad0d167..319c48b 100644 --- a/ComPDFKit for Windows/Examples/Samples/license_key_windows.txt +++ b/ComPDFKit for Windows/Examples/Samples/license_key_windows.txt @@ -1,8 +1,8 @@ [ComPDFKit License] Products=ComPDFKIT OrgName=ComPDFKit -StartDate=20231101000000 -ExpireDate=20241101000000 +StartDate=20241001000000 +ExpireDate=20251001000000 Platforms=Windows SN=E9CD809B-4317-F61E-201F-E64C78C3A749 -Sign=vRK+dzgqDsImQkoKZb2i2WhhdsKYquZ5JJUUuOF6q4xySFETAYvInXOu/f3JAvR9X14z/s4W20EE9WSKsbEum6IvdY8uLoNFy6YM7SyvNC0zVPs5T7GnEBaTQ+qVgnGeV88LA7nbZjPGfQmC75jFLlItpetrbbp75d7LQs6ftq/I8akPBz4Kxc3SSow2MFj5GzH6VbCFYSlUKw/TwA4adwM8uk2g6Kh86i23vTzGejQ4FtQ6stKHXn4HllO0bXpWnFihljcZ3R8PR31pFNwT8UUw4h9NVdFcZxpnGRDbwx9QP9WyHpHZLwbeO48ufCgFCVysJEk1riNSTGTAaAP3FUtTVN6c+2dRhnnKQ9BD2+ZXPq1h0mtlp1NQ+RMIko/jptqMsDODbroq9eCcyCqv15famjsc5QhApxJ66Uir6JIEWg+1gHSh2bjFiiXJAZ6NYxZRbQCMGNWAvkvPL3VOmCcPKDpJojB4dAuUzkjcfNP3FtGWASLlf1sxBLPPUH3/SUjuKo61mV+inIkdPNQcpTuQO57aUzB8KSNTD9t5EApfDx1B3KqboczEI8JHpWmS+IJqLCfsdlZLlGqIVobinsWoWlrK+RCjMLVb1nG6cwgJkaUZSOX6lhqKCVjsk/y/UkMufir2Jr3VOcSskcB2q89CFCFifHHHnhIhHClAv/cmsbjAv8udd4vC2c8/IMyeZDTKE61QPTGv5Web7Veww7UvwzOJJzdEyurazXA+8W54OEFOcXWYSdIgqS/vfVtnuO1kXkGQlSX1V0ead/9e5cgbJBA0v6oCmcgFsdJ19cJWN2eb8XRaylJBvRjCLTfxyhbz5ot00OuvKj41xr9kzFxfdbfnnZIUvdt0DhdKOcq/XESwVIL+pht7hkwzW7dk3HovfUURbW/42AUBTS3P/UNn7rp3eHOhZnTYo6erdzuLfnoMUa8M8nhOhIEkkRTxyCgKfwd4akkqZVJx9r83Hlf9ceP1IoDYgrXYwpetLJ8= \ No newline at end of file +Sign=24ywO5QOL/6xA78UdefdSqyCN2DAK0GO3ctq7PFduZ7jNyK2r8ru+OkzxO/pRmyc/SdRk4qZpjcTuzVWqlvm9mYZYcz8fc0CCKLl7jziHKTdiudWddyaWwABRMRrw2IxMCT+UrngegMZ7KVzurK76fsaX0ULRsCR41Bd0UoPaybvGBeuVs3I6XTP5E5Hu0fpCo+oUwVV6xNJyIkK/B7oazkC0pjJFMnoNZ8fKI3M+P0jza6dpM6wQkM+b9GqGKu0XjKBE+d5OJgXD4oRIXKAYT86jmtum1ZcLYItWK9ChIO9TQJYuvtcIDCSnrNuA0YQegnfoY/q5b+rn7PQDV5di0tTVN6c+2dRhnnKQ9BD2+ZXPq1h0mtlp1NQ+RMIko/jptqMsDODbroq9eCcyCqv15famjsc5QhApxJ66Uir6JIEWg+1gHSh2bjFiiXJAZ6NYxZRbQCMGNWAvkvPL3VOmCcPKDpJojB4dAuUzkjcfNP3FtGWASLlf1sxBLPPUH3/SUjuKo61mV+inIkdPNQcpTuQO57aUzB8KSNTD9t5EApfDx1B3KqboczEI8JHpWmS+IJqLCfsdlZLlGqIVobinsWoWlrK+RCjMLVb1nG6cwjM5Mqll1bnX2z0pJMoAOF3kWgbT7lJD0GQGywLcuHOOrC478hvP2cDIaltVnym8VrDlbODXEho1HLWbJp0z6qlTJ6nD4pqlkYW0VU+Uu1LE2VCymCuLT01rJlnne9TsMGmX5tTLvKy9ITFm7uwkVffejxBTHIGmDrTVqlc7ABbYzXhlraeCUwg0QL0p8RvjNrLZiQUN8OqBJvMBbPRBvWxV0Fn6PIJWs5RPb0ewCk388ll85WKAtCYrFc+McXDZMpeW3W15O6SZ7ytdH0UNznOvCBEtlaG/qQYCIY/Mi23F98HL3lGbW1p+twFA05ez45CEe7JdAVzpWUI2KWlr3c5V7JB9xcxW0WhhJkt8nd55b6LfhfPoH5/z+YfXo5CvTFi9iZhMizKIZvrFgGf7a/v+u16tzCiO1ZkOjwxr2Hr5w== \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/TestFile/Certificate.pfx b/ComPDFKit for Windows/Examples/TestFile/Certificate.pfx deleted file mode 100644 index fcdaf10..0000000 Binary files a/ComPDFKit for Windows/Examples/TestFile/Certificate.pfx and /dev/null differ diff --git a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Annotations_Sample_File.pdf b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Annotations_Sample_File.pdf index 860cb1a..83269d3 100644 Binary files a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Annotations_Sample_File.pdf and b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Annotations_Sample_File.pdf differ diff --git a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Forms_Sample_File.pdf b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Forms_Sample_File.pdf index 62f6f4d..e33b2ee 100644 Binary files a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Forms_Sample_File.pdf and b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Forms_Sample_File.pdf differ diff --git a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Measurement_Sample_File.pdf b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Measurement_Sample_File.pdf index 49efd59..261eadd 100644 Binary files a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Measurement_Sample_File.pdf and b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Measurement_Sample_File.pdf differ diff --git a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Sample_File_Windows.pdf b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Sample_File_Windows.pdf index 578235d..c7e8ae7 100644 Binary files a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Sample_File_Windows.pdf and b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Sample_File_Windows.pdf differ diff --git a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Signatures_Sample_File.pdf b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Signatures_Sample_File.pdf index 26fc221..0f4ae96 100644 Binary files a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Signatures_Sample_File.pdf and b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Signatures_Sample_File.pdf differ diff --git a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Watermark_Sample_File.pdf b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Watermark_Sample_File.pdf index 92fe874..9c4ec44 100644 Binary files a/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Watermark_Sample_File.pdf and b/ComPDFKit for Windows/Examples/TestFile/ComPDFKit_Watermark_Sample_File.pdf differ diff --git a/ComPDFKit for Windows/Examples/Viewer/.vs/Viewer.csproj.dtbcache.json b/ComPDFKit for Windows/Examples/Viewer/.vs/Viewer.csproj.dtbcache.json deleted file mode 100644 index e2112a8..0000000 --- a/ComPDFKit for Windows/Examples/Viewer/.vs/Viewer.csproj.dtbcache.json +++ /dev/null @@ -1 +0,0 @@ -{"RootPath":"C:\\Users\\tjz19\\Documents\\WXWork\\1688857377300814\\Cache\\File\\2024-05\\ComPDFKit 2.0.0 for Windows\\Examples\\Viewer","ProjectFileName":"Viewer.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"App.xaml.cs"},{"SourceFile":"MainWindow.xaml.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Properties\\Resources.Designer.cs"},{"SourceFile":"Properties\\Settings.Designer.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs"},{"SourceFile":"C:\\Users\\tjz19\\Documents\\WXWork\\1688857377300814\\Cache\\File\\2024-05\\ComPDFKit 2.0.0 for Windows\\Examples\\Viewer\\obj\\Debug\\MainWindow.g.cs"},{"SourceFile":"C:\\Users\\tjz19\\Documents\\WXWork\\1688857377300814\\Cache\\File\\2024-05\\ComPDFKit 2.0.0 for Windows\\Examples\\Viewer\\obj\\Debug\\App.g.cs"},{"SourceFile":"C:\\Users\\tjz19\\Documents\\WXWork\\1688857377300814\\Cache\\File\\2024-05\\ComPDFKit 2.0.0 for Windows\\Examples\\Viewer\\obj\\Debug\\Viewer_ComPDFKit_Content.g.cs"}],"References":[{"Reference":"C:\\Users\\tjz19\\Documents\\WXWork\\1688857377300814\\Cache\\File\\2024-05\\ComPDFKit 2.0.0 for Windows\\Examples\\Compdfkit.Controls\\bin\\Debug\\ComPDFKit.Controls.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":true,"ProjectPath":""},{"Reference":"C:\\Users\\tjz19\\Documents\\WXWork\\1688857377300814\\Cache\\File\\2024-05\\ComPDFKit 2.0.0 for Windows\\lib\\ComPDFKit.NET.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Users\\tjz19\\Documents\\WXWork\\1688857377300814\\Cache\\File\\2024-05\\ComPDFKit 2.0.0 for Windows\\Examples\\ComPDFKit.Tool\\bin\\Debug\\ComPDFKit.Tool.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":true,"ProjectPath":""},{"Reference":"C:\\Users\\tjz19\\Documents\\WXWork\\1688857377300814\\Cache\\File\\2024-05\\ComPDFKit 2.0.0 for Windows\\lib\\ComPDFKit.Viewer.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\PresentationCore.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Users\\tjz19\\Documents\\WXWork\\1688857377300814\\Cache\\File\\2024-05\\ComPDFKit 2.0.0 for Windows\\Examples\\packages\\PresentationFramework.Aero2.1.0.1\\lib\\PresentationFramework.Aero2.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\PresentationFramework.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Drawing.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Windows.Forms.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Xaml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\WindowsBase.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Users\\tjz19\\Documents\\WXWork\\1688857377300814\\Cache\\File\\2024-05\\ComPDFKit 2.0.0 for Windows\\Examples\\Viewer\\bin\\Debug\\Viewer_ComPDFKit.exe","OutputItemRelativePath":"Viewer_ComPDFKit.exe"},{"OutputItemFullPath":"C:\\Users\\tjz19\\Documents\\WXWork\\1688857377300814\\Cache\\File\\2024-05\\ComPDFKit 2.0.0 for Windows\\Examples\\Viewer\\bin\\Debug\\Viewer_ComPDFKit.pdb","OutputItemRelativePath":"Viewer_ComPDFKit.pdb"}],"CopyToOutputEntries":[]} \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Viewer/MainWindow.xaml.cs b/ComPDFKit for Windows/Examples/Viewer/MainWindow.xaml.cs index 5a13423..3f3a6f0 100644 --- a/ComPDFKit for Windows/Examples/Viewer/MainWindow.xaml.cs +++ b/ComPDFKit for Windows/Examples/Viewer/MainWindow.xaml.cs @@ -408,11 +408,10 @@ private void ExtractImage_Click(object sender, RoutedEventArgs e) } } - if (image == null) + if(image == null) { return; } - CPDFPage page = pdfViewControl.PDFToolManager.GetDocument().PageAtIndex(image.PageIndex); string savePath = Path.Combine(folderDialog.SelectedPath, Guid.NewGuid() + ".jpg"); string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".jpg"); @@ -442,7 +441,6 @@ private void CopyImage_Click(object sender, RoutedEventArgs e) { return; } - CPDFPage page = pdfViewControl.PDFToolManager.GetDocument().PageAtIndex(image.PageIndex); string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".jpg"); page.GetImgSelection().GetImgBitmap(image.ImageIndex, tempPath); @@ -455,7 +453,7 @@ private void CopyImage_Click(object sender, RoutedEventArgs e) imageData = new BitmapImage(); imageData.BeginInit(); imageData.StreamSource = ms; - + imageData.CacheOption = BitmapCacheOption.OnLoad; imageData.EndInit(); imageData.Freeze(); @@ -464,7 +462,7 @@ private void CopyImage_Click(object sender, RoutedEventArgs e) File.Delete(tempPath); } } - + private void CreateImageContextMenu(object sender, ref ContextMenu menu) { if (menu == null) diff --git a/ComPDFKit for Windows/Examples/Viewer/Properties/AssemblyInfo.cs b/ComPDFKit for Windows/Examples/Viewer/Properties/AssemblyInfo.cs index a1cc29d..6f9d241 100644 --- a/ComPDFKit for Windows/Examples/Viewer/Properties/AssemblyInfo.cs +++ b/ComPDFKit for Windows/Examples/Viewer/Properties/AssemblyInfo.cs @@ -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")] diff --git a/ComPDFKit for Windows/Examples/Viewer/Viewer.csproj b/ComPDFKit for Windows/Examples/Viewer/Viewer.csproj index 8ebf7a1..cb462cc 100644 --- a/ComPDFKit for Windows/Examples/Viewer/Viewer.csproj +++ b/ComPDFKit for Windows/Examples/Viewer/Viewer.csproj @@ -41,11 +41,11 @@ ComPDFKit_Logo.ico - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.NET.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.NET.dll - - ..\packages\ComPDFKit.NetFramework.2.1.3\lib\ComPDFKit.Viewer.dll + + ..\packages\ComPDFKit.NetFramework.2.2.0\lib\ComPDFKit.Viewer.dll ..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll @@ -103,9 +103,6 @@ ResXFileCodeGenerator Resources.Designer.cs - - PreserveNewest - SettingsSingleFileGenerator @@ -139,11 +136,11 @@ - + 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}. - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Examples/Viewer/developer_guide_windows.pdf b/ComPDFKit for Windows/Examples/Viewer/developer_guide_windows.pdf deleted file mode 100644 index 45c46a0..0000000 Binary files a/ComPDFKit for Windows/Examples/Viewer/developer_guide_windows.pdf and /dev/null differ diff --git a/ComPDFKit for Windows/Examples/Viewer/packages.config b/ComPDFKit for Windows/Examples/Viewer/packages.config index 5f51c51..ee67883 100644 --- a/ComPDFKit for Windows/Examples/Viewer/packages.config +++ b/ComPDFKit for Windows/Examples/Viewer/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/ComPDFKit for Windows/Nuget/ComPDFKit.NetFramework.2.1.3.nupkg b/ComPDFKit for Windows/Nuget/ComPDFKit.NetFramework.2.2.0.nupkg similarity index 54% rename from ComPDFKit for Windows/Nuget/ComPDFKit.NetFramework.2.1.3.nupkg rename to ComPDFKit for Windows/Nuget/ComPDFKit.NetFramework.2.2.0.nupkg index e1d6c87..4644667 100644 Binary files a/ComPDFKit for Windows/Nuget/ComPDFKit.NetFramework.2.1.3.nupkg and b/ComPDFKit for Windows/Nuget/ComPDFKit.NetFramework.2.2.0.nupkg differ diff --git a/ComPDFKit for Windows/api_reference_windows.chm b/ComPDFKit for Windows/api_reference_windows.chm index f64cef6..7f8d310 100644 Binary files a/ComPDFKit for Windows/api_reference_windows.chm and b/ComPDFKit for Windows/api_reference_windows.chm differ diff --git a/ComPDFKit for Windows/develop_guide_windows.pdf b/ComPDFKit for Windows/develop_guide_windows.pdf index 578235d..c7e8ae7 100644 Binary files a/ComPDFKit for Windows/develop_guide_windows.pdf and b/ComPDFKit for Windows/develop_guide_windows.pdf differ diff --git a/ComPDFKit for Windows/lib/ComPDFKit.NET.dll b/ComPDFKit for Windows/lib/ComPDFKit.NET.dll index a10341a..e34c1dd 100644 Binary files a/ComPDFKit for Windows/lib/ComPDFKit.NET.dll and b/ComPDFKit for Windows/lib/ComPDFKit.NET.dll differ diff --git a/ComPDFKit for Windows/lib/ComPDFKit.Viewer.dll b/ComPDFKit for Windows/lib/ComPDFKit.Viewer.dll index a8748fa..c225b0f 100644 Binary files a/ComPDFKit for Windows/lib/ComPDFKit.Viewer.dll and b/ComPDFKit for Windows/lib/ComPDFKit.Viewer.dll differ diff --git a/ComPDFKit for Windows/lib/x64/ComPDFKitNative.dll b/ComPDFKit for Windows/lib/x64/ComPDFKitNative.dll index 997fbd2..5c0d742 100644 Binary files a/ComPDFKit for Windows/lib/x64/ComPDFKitNative.dll and b/ComPDFKit for Windows/lib/x64/ComPDFKitNative.dll differ diff --git a/ComPDFKit for Windows/lib/x86/ComPDFKitNative.dll b/ComPDFKit for Windows/lib/x86/ComPDFKitNative.dll index 4fef39c..0a3aa2a 100644 Binary files a/ComPDFKit for Windows/lib/x86/ComPDFKitNative.dll and b/ComPDFKit for Windows/lib/x86/ComPDFKitNative.dll differ diff --git a/ComPDFKit for Windows/release_notes.txt b/ComPDFKit for Windows/release_notes.txt index d61e570..5fdb934 100644 --- a/ComPDFKit for Windows/release_notes.txt +++ b/ComPDFKit for Windows/release_notes.txt @@ -1,4 +1,17 @@ -*** Release Date: Aug 6, 2024*** +*** Release Date: Dec 12, 2024 *** +Version 2.2.0 +- New Features +1. Added support for strikethrough and underline text formatting. +2. Added editing support for path element types. +3. Added rotation functionality for image, signature, and stamp annotations. +4. Added cloud border styles for polygonal annotations. +5. Added document compression functionality. +6. Added snapshot functionality. + +- Issues Addressed +1. Fixed an issue where the content editing hierarchy was out of order. + +*** Release Date: Aug 6, 2024 *** Version 2.1.0 - New Features 1. Added annotation reply functionality. @@ -6,7 +19,6 @@ Version 2.1.0 3. Optimized UX for content editing. 4. Added font subsetting. - *** Release Date: Mar, 27, 2024 *** Version 2.0.0 - New Features