|
@@ -0,0 +1,928 @@
|
|
|
+using ComPDFKit.Import;
|
|
|
+using ComPDFKit.PDFAnnotation;
|
|
|
+using ComPDFKit.PDFDocument;
|
|
|
+using ComPDFKit.PDFPage;
|
|
|
+using ComPDFKit.Tool.Help;
|
|
|
+using ComPDFKit.Tool.UndoManger;
|
|
|
+using ComPDFKitViewer;
|
|
|
+using ComPDFKitViewer.Annot;
|
|
|
+using ComPDFKitViewer.Helper;
|
|
|
+using ComPDFKitViewer.Layer;
|
|
|
+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.Input;
|
|
|
+using System.Windows.Media;
|
|
|
+
|
|
|
+namespace ComPDFKit.Tool.FillTool
|
|
|
+{
|
|
|
+ internal class FillCreateTool : BaseLayer
|
|
|
+ {
|
|
|
+ internal CPDFViewer PDFViewer { get; set; }
|
|
|
+ internal int PageIndex { get; set; } = -1;
|
|
|
+ internal Point MouseDownPos { get; set; } = new Point(-1, -1);
|
|
|
+ internal Point CurrentMousePos { get; set; } = new Point(-1, -1);
|
|
|
+ internal Rect PageBound { get; set; } = Rect.Empty;
|
|
|
+ internal FillItem FillParam { get; private set; }
|
|
|
+ internal bool IsMouseMoved { get; set; }
|
|
|
+ private Rect DrawBound { get; set; }
|
|
|
+ private double DPIScale { get; set; } = 96D / 72D;
|
|
|
+ public override void Draw()
|
|
|
+ {
|
|
|
+ if (FillParam == null || PDFViewer == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Point mousePos = Mouse.GetPosition(PDFViewer);
|
|
|
+ Rect viewRect = new Rect(0, 0, PDFViewer.ActualWidth, PDFViewer.ActualHeight);
|
|
|
+ if (viewRect.Contains(mousePos) == false && Mouse.LeftButton == MouseButtonState.Released)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CurrentMousePos.X == -1 || CurrentMousePos.Y == -1)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ DrawingContext drawDC = Open();
|
|
|
+ switch (FillParam.Type)
|
|
|
+ {
|
|
|
+ case FillType.Square:
|
|
|
+ DrawRect(drawDC);
|
|
|
+ break;
|
|
|
+ case FillType.Circle:
|
|
|
+ DrawCircle(drawDC);
|
|
|
+ break;
|
|
|
+ case FillType.Line:
|
|
|
+ DrawLine(drawDC);
|
|
|
+ break;
|
|
|
+ case FillType.Cross:
|
|
|
+ DrawCross(drawDC);
|
|
|
+ break;
|
|
|
+ case FillType.Check:
|
|
|
+ DrawCheck(drawDC);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ Present();
|
|
|
+ }
|
|
|
+
|
|
|
+ internal void SetFillParam(FillItem param)
|
|
|
+ {
|
|
|
+ FillParam = param;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DrawCircle(DrawingContext drawDC)
|
|
|
+ {
|
|
|
+ if (FillParam == null || FillParam.Param == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ CircleParam circleParam = FillParam.Param as CircleParam;
|
|
|
+ if (circleParam == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ double zoom = PDFViewer.GetZoom();
|
|
|
+ SolidColorBrush fillBrush = Brushes.Black;
|
|
|
+ if (circleParam.BgColor != null && circleParam.BgColor.Length == 3)
|
|
|
+ {
|
|
|
+ fillBrush = new SolidColorBrush(Color.FromRgb(circleParam.BgColor[0], circleParam.BgColor[1], circleParam.BgColor[2]));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (PageIndex >= 0 && Mouse.LeftButton == MouseButtonState.Pressed)
|
|
|
+ {
|
|
|
+ double xPos = Math.Max(PageBound.Left, CurrentMousePos.X);
|
|
|
+ xPos = Math.Min(xPos, PageBound.Right);
|
|
|
+ double yPos = Math.Max(PageBound.Top, CurrentMousePos.Y);
|
|
|
+ yPos = Math.Min(yPos, PageBound.Bottom);
|
|
|
+
|
|
|
+ double centerX = (MouseDownPos.X + xPos) / 2;
|
|
|
+ double centerY = (MouseDownPos.Y + yPos) / 2;
|
|
|
+ double radioX = Math.Abs((MouseDownPos.X - xPos) / 2);
|
|
|
+ double radioY = Math.Abs((MouseDownPos.Y - yPos) / 2);
|
|
|
+
|
|
|
+ if (FillParam.KeepRate)
|
|
|
+ {
|
|
|
+ double minRadio = Math.Min(radioX, radioY);
|
|
|
+ radioX = minRadio;
|
|
|
+ radioY = minRadio;
|
|
|
+ centerX = MouseDownPos.X + ((xPos - MouseDownPos.X) >= 0 ? 1 : -1) * radioX;
|
|
|
+ centerY = MouseDownPos.Y + ((yPos - MouseDownPos.Y) >= 0 ? 1 : -1) * radioX;
|
|
|
+ }
|
|
|
+ DrawBound = new Rect(centerX - radioX, centerY - radioY, radioX * 2, radioY * 2);
|
|
|
+ drawDC.DrawEllipse(fillBrush, null, new Point(centerX, centerY), radioX, radioY);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ DrawBound = new Rect(CurrentMousePos.X - FillParam.Width * zoom / 2, CurrentMousePos.Y - FillParam.Height * zoom / 2, FillParam.Width * zoom, FillParam.Height * zoom);
|
|
|
+ drawDC.DrawEllipse(fillBrush, null, CurrentMousePos, FillParam.Width * zoom/2, FillParam.Height * zoom/2);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DrawRect(DrawingContext drawDC)
|
|
|
+ {
|
|
|
+ if (FillParam == null || FillParam.Param == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ SquareParam squareParam = FillParam.Param as SquareParam;
|
|
|
+ if (squareParam == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ double zoom = PDFViewer.GetZoom();
|
|
|
+ SolidColorBrush lineBrush = Brushes.Black;
|
|
|
+ if (squareParam.LineColor != null && squareParam.LineColor.Length == 3)
|
|
|
+ {
|
|
|
+ lineBrush = new SolidColorBrush(Color.FromRgb(squareParam.LineColor[0], squareParam.LineColor[1], squareParam.LineColor[2]));
|
|
|
+ }
|
|
|
+
|
|
|
+ Pen borderPen = new Pen(lineBrush, squareParam.LineWidth * zoom * DPIScale);
|
|
|
+ int halfPenWidth = (int)Math.Ceiling(borderPen.Thickness / 2);
|
|
|
+
|
|
|
+ if (PageIndex >= 0 && Mouse.LeftButton == MouseButtonState.Pressed)
|
|
|
+ {
|
|
|
+ double xPos = Math.Max(PageBound.Left, CurrentMousePos.X);
|
|
|
+ xPos = Math.Min(xPos, PageBound.Right);
|
|
|
+ double yPos = Math.Max(PageBound.Top, CurrentMousePos.Y);
|
|
|
+ yPos = Math.Min(yPos, PageBound.Bottom);
|
|
|
+
|
|
|
+ double centerX = (MouseDownPos.X + xPos) / 2;
|
|
|
+ double centerY = (MouseDownPos.Y + yPos) / 2;
|
|
|
+ double radioX = Math.Abs((MouseDownPos.X - xPos) / 2);
|
|
|
+ double radioY = Math.Abs((MouseDownPos.Y - yPos) / 2);
|
|
|
+
|
|
|
+ if (FillParam.KeepRate)
|
|
|
+ {
|
|
|
+ double minRadio = Math.Min(radioX, radioY);
|
|
|
+ radioX = minRadio;
|
|
|
+ radioY = minRadio;
|
|
|
+ centerX = MouseDownPos.X + ((xPos - MouseDownPos.X) >= 0 ? 1 : -1) * radioX;
|
|
|
+ centerY = MouseDownPos.Y + ((yPos - MouseDownPos.Y) >= 0 ? 1 : -1) * radioY;
|
|
|
+ }
|
|
|
+ DrawBound = new Rect(centerX - radioX, centerY - radioY, radioX * 2, radioY * 2);
|
|
|
+ drawDC.DrawRectangle(null, borderPen, new Rect(DrawBound.Left + halfPenWidth, DrawBound.Top + halfPenWidth, DrawBound.Width - 2 * halfPenWidth, DrawBound.Height - 2 * halfPenWidth));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ DrawBound = new Rect(
|
|
|
+ CurrentMousePos.X - FillParam.Width / 2 * zoom,
|
|
|
+ CurrentMousePos.Y - FillParam.Height / 2 * zoom,
|
|
|
+ FillParam.Width * zoom, FillParam.Height * zoom);
|
|
|
+
|
|
|
+ drawDC.DrawRectangle(null, borderPen, new Rect(DrawBound.Left + halfPenWidth, DrawBound.Top + halfPenWidth, DrawBound.Width - 2 * halfPenWidth, DrawBound.Height - 2 * halfPenWidth));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DrawLine(DrawingContext drawDC)
|
|
|
+ {
|
|
|
+ if (FillParam == null || FillParam.Param == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ LineParam lineParam = FillParam.Param as LineParam;
|
|
|
+ if (lineParam == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ double zoom = PDFViewer.GetZoom();
|
|
|
+ SolidColorBrush lineBrush = Brushes.Black;
|
|
|
+ if (lineParam.LineColor != null && lineParam.LineColor.Length == 3)
|
|
|
+ {
|
|
|
+ lineBrush = new SolidColorBrush(Color.FromRgb(lineParam.LineColor[0], lineParam.LineColor[1], lineParam.LineColor[2]));
|
|
|
+ }
|
|
|
+
|
|
|
+ Pen borderPen = new Pen(lineBrush, lineParam.LineWidth * zoom);
|
|
|
+ if (PageIndex >= 0 && Mouse.LeftButton == MouseButtonState.Pressed)
|
|
|
+ {
|
|
|
+ double xPos = Math.Max(PageBound.Left, CurrentMousePos.X);
|
|
|
+ xPos = Math.Min(xPos, PageBound.Right);
|
|
|
+ DrawBound = new Rect(new Point(xPos, MouseDownPos.Y), MouseDownPos);
|
|
|
+ drawDC.DrawLine(borderPen, new Point(xPos, MouseDownPos.Y), MouseDownPos);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Point leftPos = new Point(
|
|
|
+ CurrentMousePos.X - FillParam.Width / 2 * zoom,
|
|
|
+ CurrentMousePos.Y);
|
|
|
+ Point rightPos = new Point(
|
|
|
+ CurrentMousePos.X + FillParam.Width / 2 * zoom,
|
|
|
+ CurrentMousePos.Y);
|
|
|
+ DrawBound = new Rect(leftPos, rightPos);
|
|
|
+ drawDC.DrawLine(borderPen, leftPos, rightPos);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void GetPointsBound(List<CPoint> checkList, out Rect checkBound)
|
|
|
+ {
|
|
|
+ checkBound = new Rect(0, 0, 0, 0);
|
|
|
+ if (checkList == null || checkList.Count == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int left = 0;
|
|
|
+ int top = 0;
|
|
|
+ int right = 0;
|
|
|
+ int bottom = 0;
|
|
|
+
|
|
|
+ foreach (CPoint point in checkList)
|
|
|
+ {
|
|
|
+ left = (int)Math.Min(left, point.x);
|
|
|
+ top = (int)Math.Min(t, point.y);
|
|
|
+ right = (int)Math.Max(right, point.x);
|
|
|
+ bottom = (int)Math.Max(bottom, point.y);
|
|
|
+ }
|
|
|
+
|
|
|
+ checkBound = new Rect(left, top, right - left, bottom - top);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DrawCheck(DrawingContext drawDC)
|
|
|
+ {
|
|
|
+ if (FillParam == null || FillParam.Param == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ InkParam inkParam = FillParam.Param as InkParam;
|
|
|
+ if (inkParam == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ double zoom = PDFViewer.GetZoom();
|
|
|
+ SolidColorBrush inkBrush = Brushes.Black;
|
|
|
+ if (inkParam.InkColor != null && inkParam.InkColor.Length == 3)
|
|
|
+ {
|
|
|
+ inkBrush = new SolidColorBrush(Color.FromRgb(inkParam.InkColor[0], inkParam.InkColor[1], inkParam.InkColor[2]));
|
|
|
+ }
|
|
|
+
|
|
|
+ Pen borderPen = new Pen(inkBrush, inkParam.Thickness * zoom);
|
|
|
+ borderPen.StartLineCap=PenLineCap.Round;
|
|
|
+ borderPen.EndLineCap=PenLineCap.Round;
|
|
|
+
|
|
|
+ if (inkParam.InkPath == null || inkParam.InkPath.Count == 0)
|
|
|
+ {
|
|
|
+ int width = Math.Max(0, FillParam.Width);
|
|
|
+ int height = Math.Max(0, FillParam.Height);
|
|
|
+ if (width == 0 || height == 0)
|
|
|
+ {
|
|
|
+ width = 30;
|
|
|
+ height = 30;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<List<CPoint>> defaultList = new List<List<CPoint>>();
|
|
|
+ List<CPoint> pointList = new List<CPoint>();
|
|
|
+ defaultList.Add(pointList);
|
|
|
+
|
|
|
+ pointList.Add(new CPoint(0, height * 2 / 3));
|
|
|
+ pointList.Add(new CPoint(width / 3, height));
|
|
|
+ pointList.Add(new CPoint(width, height / 3));
|
|
|
+
|
|
|
+ inkParam.InkPath = defaultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (inkParam.InkPath != null && inkParam.InkPath.Count > 0)
|
|
|
+ {
|
|
|
+ double minX = 0;
|
|
|
+ double minY = 0;
|
|
|
+ double maxX = 0;
|
|
|
+ double maxY = 0;
|
|
|
+
|
|
|
+ foreach (List<CPoint> loopItems in inkParam.InkPath)
|
|
|
+ {
|
|
|
+ GetPointsBound(loopItems, out Rect checkBound);
|
|
|
+ minX = Math.Min(minX, checkBound.X);
|
|
|
+ minY = Math.Min(minY, checkBound.Y);
|
|
|
+ maxX = Math.Max(maxX, checkBound.Right);
|
|
|
+ maxY = Math.Max(maxY, checkBound.Bottom);
|
|
|
+ }
|
|
|
+
|
|
|
+ Rect prevRect = new Rect(minX, minY, maxX - minX, maxY - minY);
|
|
|
+ if (prevRect.Width == 0 || prevRect.Height == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<List<Point>> drawPathList = new List<List<Point>>();
|
|
|
+ foreach (List<CPoint> loopItems in inkParam.InkPath)
|
|
|
+ {
|
|
|
+ List<Point> drawPath = new List<Point>();
|
|
|
+ foreach (CPoint item in loopItems)
|
|
|
+ {
|
|
|
+ drawPath.Add(new Point(item.x - minX, item.y - minY));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (drawPath.Count >= 2)
|
|
|
+ {
|
|
|
+ drawPathList.Add(drawPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ double offsetX = (maxX - minX) / 2;
|
|
|
+ double offsetY = (maxY - minY) / 2;
|
|
|
+ Point centerPoint = CurrentMousePos;
|
|
|
+ if (PageIndex >= 0 && Mouse.LeftButton == MouseButtonState.Pressed)
|
|
|
+ {
|
|
|
+ double xPos = Math.Max(PageBound.Left, CurrentMousePos.X);
|
|
|
+ xPos = Math.Min(xPos, PageBound.Right);
|
|
|
+ double yPos = Math.Max(PageBound.Top, CurrentMousePos.Y);
|
|
|
+ yPos = Math.Min(yPos, PageBound.Bottom);
|
|
|
+
|
|
|
+ if (FillParam.KeepRate)
|
|
|
+ {
|
|
|
+ if (GetRateMoveSize(prevRect, out Point ratePoint) == false)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ xPos = ratePoint.X;
|
|
|
+ yPos = ratePoint.Y;
|
|
|
+ }
|
|
|
+ Rect drawRect = new Rect(MouseDownPos, new Point(xPos, yPos));
|
|
|
+ if (drawRect.Width == 0 || drawRect.Height == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double rateX = drawRect.Width / prevRect.Width / zoom;
|
|
|
+ double rateY = drawRect.Height / prevRect.Height / zoom;
|
|
|
+
|
|
|
+ if (FillParam.KeepRate)
|
|
|
+ {
|
|
|
+ rateY = rateX * prevRect.Height / prevRect.Width;
|
|
|
+ }
|
|
|
+
|
|
|
+ offsetX = (offsetX * rateX);
|
|
|
+ offsetY = (offsetY * rateY);
|
|
|
+
|
|
|
+ List<List<Point>> rateList = new List<List<Point>>();
|
|
|
+ foreach (List<Point> loopItems in drawPathList)
|
|
|
+ {
|
|
|
+ List<Point> ratePath = new List<Point>();
|
|
|
+ foreach (Point item in loopItems)
|
|
|
+ {
|
|
|
+ ratePath.Add(new Point((item.X - minX) * rateX, (item.Y - minY) * rateY));
|
|
|
+ }
|
|
|
+
|
|
|
+ rateList.Add(ratePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ drawPathList = rateList;
|
|
|
+ centerPoint.X = (MouseDownPos.X + xPos) / 2;
|
|
|
+ centerPoint.Y = (MouseDownPos.Y + yPos) / 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ GeometryGroup drawGroup = new GeometryGroup();
|
|
|
+ foreach (List<Point> loopItems in drawPathList)
|
|
|
+ {
|
|
|
+ PathGeometry pathGeometry = new PathGeometry();
|
|
|
+ PathFigure path = new PathFigure();
|
|
|
+ path.IsClosed = false;
|
|
|
+ path.StartPoint = new Point((loopItems[0].X - offsetX) * zoom + centerPoint.X, (loopItems[0].Y - offsetY) * zoom + centerPoint.Y);
|
|
|
+ for (int i = 1; i < loopItems.Count; i++)
|
|
|
+ {
|
|
|
+ LineSegment segment = new LineSegment();
|
|
|
+ segment.IsSmoothJoin = true;
|
|
|
+ segment.Point = new Point((loopItems[i].X - offsetX) * zoom + centerPoint.X, (loopItems[i].Y - offsetY) * zoom + centerPoint.Y);
|
|
|
+ path.Segments.Add(segment);
|
|
|
+ }
|
|
|
+ pathGeometry.Figures.Add(path);
|
|
|
+
|
|
|
+ drawGroup.Children.Add(pathGeometry);
|
|
|
+ }
|
|
|
+ DrawBound = drawGroup.Bounds;
|
|
|
+ drawDC.DrawGeometry(null, borderPen, drawGroup);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DrawCross(DrawingContext drawDC)
|
|
|
+ {
|
|
|
+ if (FillParam == null || FillParam.Param == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ InkParam inkParam = FillParam.Param as InkParam;
|
|
|
+ if (inkParam == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ double zoom = PDFViewer.GetZoom();
|
|
|
+ SolidColorBrush inkBrush = Brushes.Black;
|
|
|
+ if (inkParam.InkColor != null && inkParam.InkColor.Length == 3)
|
|
|
+ {
|
|
|
+ inkBrush = new SolidColorBrush(Color.FromRgb(inkParam.InkColor[0], inkParam.InkColor[1], inkParam.InkColor[2]));
|
|
|
+ }
|
|
|
+
|
|
|
+ Pen borderPen = new Pen(inkBrush, inkParam.Thickness * zoom);
|
|
|
+ borderPen.StartLineCap = PenLineCap.Round;
|
|
|
+ borderPen.EndLineCap = PenLineCap.Round;
|
|
|
+
|
|
|
+ if (inkParam.InkPath == null || inkParam.InkPath.Count == 0)
|
|
|
+ {
|
|
|
+ int width = Math.Max(0, FillParam.Width);
|
|
|
+ int height = Math.Max(0, FillParam.Height);
|
|
|
+ if (width == 0 || height == 0)
|
|
|
+ {
|
|
|
+ width = 30;
|
|
|
+ height = 30;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<List<CPoint>> defaultList = new List<List<CPoint>>();
|
|
|
+ List<CPoint> pointList = new List<CPoint>();
|
|
|
+ defaultList.Add(pointList);
|
|
|
+
|
|
|
+ pointList.Add(new CPoint(0, 0));
|
|
|
+ pointList.Add(new CPoint(width / 2, height / 2));
|
|
|
+ pointList.Add(new CPoint(width, height));
|
|
|
+
|
|
|
+ pointList = new List<CPoint>();
|
|
|
+ defaultList.Add(pointList);
|
|
|
+
|
|
|
+ pointList.Add(new CPoint(0, height));
|
|
|
+ pointList.Add(new CPoint(width / 2, height / 2));
|
|
|
+ pointList.Add(new CPoint(width, 0));
|
|
|
+
|
|
|
+ inkParam.InkPath = defaultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (inkParam.InkPath != null && inkParam.InkPath.Count > 0)
|
|
|
+ {
|
|
|
+ double minX = 0;
|
|
|
+ double minY = 0;
|
|
|
+ double maxX = 0;
|
|
|
+ double maxY = 0;
|
|
|
+
|
|
|
+ foreach (List<CPoint> loopItems in inkParam.InkPath)
|
|
|
+ {
|
|
|
+ GetPointsBound(loopItems, out Rect checkBound);
|
|
|
+ minX = Math.Min(minX, checkBound.X);
|
|
|
+ minY = Math.Min(minY, checkBound.Y);
|
|
|
+ maxX = Math.Max(maxX, checkBound.Right);
|
|
|
+ maxY = Math.Max(maxY, checkBound.Bottom);
|
|
|
+ }
|
|
|
+
|
|
|
+ Rect prevRect = new Rect(minX, minY, maxX - minX, maxY - minY);
|
|
|
+ if (prevRect.Width == 0 || prevRect.Height == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<List<Point>> drawPathList = new List<List<Point>>();
|
|
|
+ foreach (List<CPoint> loopItems in inkParam.InkPath)
|
|
|
+ {
|
|
|
+ List<Point> drawPath = new List<Point>();
|
|
|
+ foreach (CPoint item in loopItems)
|
|
|
+ {
|
|
|
+ drawPath.Add(new Point(item.x - minX, item.y - minY));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (drawPath.Count >= 2)
|
|
|
+ {
|
|
|
+ drawPathList.Add(drawPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ double offsetX = (maxX - minX) / 2;
|
|
|
+ double offsetY = (maxY - minY) / 2;
|
|
|
+ Point centerPoint = CurrentMousePos;
|
|
|
+ if (PageIndex >= 0 && Mouse.LeftButton == MouseButtonState.Pressed)
|
|
|
+ {
|
|
|
+ double xPos = Math.Max(PageBound.Left, CurrentMousePos.X);
|
|
|
+ xPos = Math.Min(xPos, PageBound.Right);
|
|
|
+ double yPos = Math.Max(PageBound.Top, CurrentMousePos.Y);
|
|
|
+ yPos = Math.Min(yPos, PageBound.Bottom);
|
|
|
+
|
|
|
+ if (FillParam.KeepRate)
|
|
|
+ {
|
|
|
+ if(GetRateMoveSize(prevRect,out Point ratePoint)==false)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ xPos = ratePoint.X;
|
|
|
+ yPos = ratePoint.Y;
|
|
|
+ }
|
|
|
+ Rect drawRect = new Rect(MouseDownPos, new Point(xPos, yPos));
|
|
|
+ if (drawRect.Width == 0 || drawRect.Height == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double rateX = drawRect.Width / prevRect.Width / zoom;
|
|
|
+ double rateY = drawRect.Height / prevRect.Height / zoom;
|
|
|
+
|
|
|
+ if (FillParam.KeepRate)
|
|
|
+ {
|
|
|
+ rateY = rateX * prevRect.Height / prevRect.Width;
|
|
|
+ }
|
|
|
+
|
|
|
+ offsetX = (offsetX * rateX);
|
|
|
+ offsetY = (offsetY * rateY);
|
|
|
+
|
|
|
+ List<List<Point>> rateList = new List<List<Point>>();
|
|
|
+ foreach (List<Point> loopItems in drawPathList)
|
|
|
+ {
|
|
|
+ List<Point> ratePath = new List<Point>();
|
|
|
+ foreach (Point item in loopItems)
|
|
|
+ {
|
|
|
+ ratePath.Add(new Point((item.X - minX) * rateX, (item.Y - minY) * rateY));
|
|
|
+ }
|
|
|
+
|
|
|
+ rateList.Add(ratePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ drawPathList = rateList;
|
|
|
+ centerPoint.X = (MouseDownPos.X + xPos) / 2;
|
|
|
+ centerPoint.Y = (MouseDownPos.Y + yPos) / 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ GeometryGroup drawGroup = new GeometryGroup();
|
|
|
+ foreach (List<Point> loopItems in drawPathList)
|
|
|
+ {
|
|
|
+ PathGeometry pathGeometry = new PathGeometry();
|
|
|
+ PathFigure path = new PathFigure();
|
|
|
+ path.IsClosed = false;
|
|
|
+ path.StartPoint = new Point((loopItems[0].X - offsetX) * zoom + centerPoint.X, (loopItems[0].Y - offsetY) * zoom + centerPoint.Y);
|
|
|
+ for (int i = 1; i < loopItems.Count; i++)
|
|
|
+ {
|
|
|
+ LineSegment segment = new LineSegment();
|
|
|
+ segment.IsSmoothJoin=true;
|
|
|
+ segment.Point = new Point((loopItems[i].X - offsetX) * zoom + centerPoint.X, (loopItems[i].Y - offsetY) * zoom + centerPoint.Y);
|
|
|
+ path.Segments.Add(segment);
|
|
|
+ }
|
|
|
+ pathGeometry.Figures.Add(path);
|
|
|
+
|
|
|
+ drawGroup.Children.Add(pathGeometry);
|
|
|
+ }
|
|
|
+ DrawBound = drawGroup.Bounds;
|
|
|
+ drawDC.DrawGeometry(null, borderPen, drawGroup);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool GetRateMoveSize(Rect oldRect ,out Point ratePoint)
|
|
|
+ {
|
|
|
+ ratePoint=new Point(0,0);
|
|
|
+ double rateY = oldRect.Height / oldRect.Width;
|
|
|
+ double xPos = Math.Max(PageBound.Left, CurrentMousePos.X);
|
|
|
+ xPos = Math.Min(xPos, PageBound.Right);
|
|
|
+
|
|
|
+ double moveX = xPos - MouseDownPos.X;
|
|
|
+ double moveY = CurrentMousePos.Y - MouseDownPos.Y;
|
|
|
+ if (moveX == 0)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (moveY == 0)
|
|
|
+ {
|
|
|
+ moveY = 1;
|
|
|
+ }
|
|
|
+ double rateMoveY = Math.Abs(moveX * rateY);
|
|
|
+ double yPos = MouseDownPos.Y + rateMoveY * Math.Abs(moveY) / moveY;
|
|
|
+ if (yPos >= PageBound.Top && yPos <= PageBound.Bottom)
|
|
|
+ {
|
|
|
+ ratePoint= new Point(xPos, yPos);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(moveY>=0)
|
|
|
+ {
|
|
|
+ rateMoveY=PageBound.Bottom-MouseDownPos.Y;
|
|
|
+ yPos=PageBound.Bottom;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ rateMoveY=MouseDownPos.Y-PageBound.Top;
|
|
|
+ yPos=PageBound.Top;
|
|
|
+ }
|
|
|
+
|
|
|
+ double rateMoveX = rateMoveY / rateY;
|
|
|
+ xPos = MouseDownPos.X + rateMoveX * Math.Abs(moveX) / (moveX);
|
|
|
+ ratePoint = new Point(xPos, yPos);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ internal FillItem SaveFillItem()
|
|
|
+ {
|
|
|
+ if (FillParam == null || PageIndex < 0 || PDFViewer == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ switch (FillParam.Type)
|
|
|
+ {
|
|
|
+ case FillType.Square:
|
|
|
+ return SaveRect();
|
|
|
+ case FillType.Circle:
|
|
|
+ return SaveCircle();
|
|
|
+ case FillType.Line:
|
|
|
+ return SaveLine();
|
|
|
+ case FillType.Check:
|
|
|
+ return SaveCheck();
|
|
|
+ case FillType.Cross:
|
|
|
+ return SaveCross();
|
|
|
+ default:
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private FillItem SaveRect()
|
|
|
+ {
|
|
|
+ double zoom = PDFViewer.GetZoom();
|
|
|
+ CPDFDocument pdfDoc = PDFViewer.GetDocument();
|
|
|
+ if (zoom <= 0 || pdfDoc == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CPDFPage pdfPage = pdfDoc.PageAtIndex(PageIndex);
|
|
|
+ SquareParam param = FillParam.Param as SquareParam;
|
|
|
+ if (pdfPage == null || param == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Rect offsetRect = new Rect(DrawBound.X - PageBound.X, DrawBound.Y - PageBound.Y, DrawBound.Width, DrawBound.Height);
|
|
|
+ Rect standRect = new Rect(offsetRect.X / zoom, offsetRect.Y / zoom, offsetRect.Width / zoom, offsetRect.Height / zoom);
|
|
|
+ Rect pdfRect = new Rect(standRect.X / 96D * 72D, standRect.Y / 96D * 72D, standRect.Width / 96D * 72D, standRect.Height / 96D * 72D);
|
|
|
+
|
|
|
+ CPDFSquareAnnotation squareAnnot = (CPDFSquareAnnotation)pdfPage.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE);
|
|
|
+ squareAnnot.SetRect(new CRect((float)pdfRect.Left, (float)pdfRect.Bottom, (float)pdfRect.Right, (float)pdfRect.Top));
|
|
|
+ squareAnnot.SetLineWidth((float)param.LineWidth);
|
|
|
+ squareAnnot.SetLineColor(param.LineColor);
|
|
|
+ squareAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
|
|
|
+ if(string.IsNullOrEmpty(param.Author)==false)
|
|
|
+ {
|
|
|
+ squareAnnot.SetAuthor(param.Author);
|
|
|
+ }
|
|
|
+ squareAnnot.UpdateAp();
|
|
|
+
|
|
|
+ FillItem cloneItem = FillParam.Clone();
|
|
|
+ cloneItem.Param = ParamConverter.AnnotConverter(pdfDoc, squareAnnot);
|
|
|
+ cloneItem.HistoryItem = new SquareAnnotHistory();
|
|
|
+ cloneItem.HistoryItem.Action = HistoryAction.Add;
|
|
|
+ cloneItem.HistoryItem.CurrentParam = ParamConverter.AnnotConverter(pdfDoc, squareAnnot);
|
|
|
+ cloneItem.HistoryItem.PDFDoc = pdfDoc;
|
|
|
+ PDFViewer.UndoManager.AddHistory(cloneItem.HistoryItem);
|
|
|
+ return cloneItem;
|
|
|
+ }
|
|
|
+
|
|
|
+ private FillItem SaveCircle()
|
|
|
+ {
|
|
|
+ double zoom = PDFViewer.GetZoom();
|
|
|
+ CPDFDocument pdfDoc = PDFViewer.GetDocument();
|
|
|
+ if (zoom <= 0 || pdfDoc == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CPDFPage pdfPage = pdfDoc.PageAtIndex(PageIndex);
|
|
|
+ CircleParam param = FillParam.Param as CircleParam;
|
|
|
+ if (pdfPage == null || param == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Rect offsetRect = new Rect(DrawBound.X - PageBound.X, DrawBound.Y - PageBound.Y, DrawBound.Width, DrawBound.Height);
|
|
|
+ Rect standRect = new Rect(offsetRect.X / zoom, offsetRect.Y / zoom, offsetRect.Width / zoom, offsetRect.Height / zoom);
|
|
|
+ Rect pdfRect = new Rect(standRect.X / 96D * 72D, standRect.Y / 96D * 72D, standRect.Width / 96D * 72D, standRect.Height / 96D * 72D);
|
|
|
+
|
|
|
+ CPDFCircleAnnotation circleAnnot = (CPDFCircleAnnotation)pdfPage.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE);
|
|
|
+ circleAnnot.SetRect(new CRect((float)pdfRect.Left, (float)pdfRect.Bottom, (float)pdfRect.Right, (float)pdfRect.Top));
|
|
|
+ if (param.HasBgColor)
|
|
|
+ {
|
|
|
+ circleAnnot.SetBgColor(param.BgColor);
|
|
|
+ circleAnnot.SetLineColor(param.BgColor);
|
|
|
+ }
|
|
|
+
|
|
|
+ circleAnnot.SetLineWidth(0);
|
|
|
+ circleAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
|
|
|
+ if (string.IsNullOrEmpty(param.Author) == false)
|
|
|
+ {
|
|
|
+ circleAnnot.SetAuthor(param.Author);
|
|
|
+ }
|
|
|
+ circleAnnot.UpdateAp();
|
|
|
+
|
|
|
+ FillItem cloneItem = FillParam.Clone();
|
|
|
+ cloneItem.Param = ParamConverter.AnnotConverter(pdfDoc, circleAnnot);
|
|
|
+ cloneItem.HistoryItem = new CircleAnnotHistory();
|
|
|
+ cloneItem.HistoryItem.Action = HistoryAction.Add;
|
|
|
+ cloneItem.HistoryItem.CurrentParam = ParamConverter.AnnotConverter(pdfDoc, circleAnnot);
|
|
|
+ cloneItem.HistoryItem.PDFDoc = pdfDoc;
|
|
|
+ PDFViewer.UndoManager.AddHistory(cloneItem.HistoryItem);
|
|
|
+ return cloneItem;
|
|
|
+ }
|
|
|
+
|
|
|
+ private FillItem SaveLine()
|
|
|
+ {
|
|
|
+ double zoom = PDFViewer.GetZoom();
|
|
|
+ CPDFDocument pdfDoc = PDFViewer.GetDocument();
|
|
|
+ if (zoom <= 0 || pdfDoc == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CPDFPage pdfPage = pdfDoc.PageAtIndex(PageIndex);
|
|
|
+ LineParam param = FillParam.Param as LineParam;
|
|
|
+ if (pdfPage == null || param == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Rect offsetRect = new Rect(DrawBound.X - PageBound.X, DrawBound.Y - PageBound.Y, DrawBound.Width, DrawBound.Height);
|
|
|
+ Rect standRect = new Rect(offsetRect.X / zoom, offsetRect.Y / zoom, offsetRect.Width / zoom, offsetRect.Height / zoom);
|
|
|
+ Rect pdfRect = new Rect(standRect.X / 96D * 72D, standRect.Y / 96D * 72D, standRect.Width / 96D * 72D, standRect.Height / 96D * 72D);
|
|
|
+
|
|
|
+ CPDFLineAnnotation lineAnnot = (CPDFLineAnnotation)pdfPage.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_LINE);
|
|
|
+ lineAnnot.SetRect(new CRect((float)pdfRect.Left, (float)pdfRect.Bottom, (float)pdfRect.Right, (float)pdfRect.Top));
|
|
|
+ lineAnnot.SetLinePoints(new CPoint((float)pdfRect.Left,(float)(pdfRect.Top+pdfRect.Height/2)),new CPoint((float)pdfRect.Right,(float)(pdfRect.Top+pdfRect.Height/2)));
|
|
|
+ lineAnnot.SetLineWidth((float)param.LineWidth);
|
|
|
+ lineAnnot.SetLineColor(param.LineColor);
|
|
|
+ lineAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
|
|
|
+ if (string.IsNullOrEmpty(param.Author) == false)
|
|
|
+ {
|
|
|
+ lineAnnot.SetAuthor(param.Author);
|
|
|
+ }
|
|
|
+ lineAnnot.UpdateAp();
|
|
|
+
|
|
|
+ FillItem cloneItem = FillParam.Clone();
|
|
|
+ cloneItem.Param = ParamConverter.AnnotConverter(pdfDoc, lineAnnot);
|
|
|
+ cloneItem.HistoryItem = new LineAnnotHistory();
|
|
|
+ cloneItem.HistoryItem.Action = HistoryAction.Add;
|
|
|
+ cloneItem.HistoryItem.CurrentParam = ParamConverter.AnnotConverter(pdfDoc, lineAnnot);
|
|
|
+ cloneItem.HistoryItem.PDFDoc = pdfDoc;
|
|
|
+ PDFViewer.UndoManager.AddHistory(cloneItem.HistoryItem);
|
|
|
+ return cloneItem;
|
|
|
+ }
|
|
|
+
|
|
|
+ private FillItem SaveCheck()
|
|
|
+ {
|
|
|
+ double zoom = PDFViewer.GetZoom();
|
|
|
+ CPDFDocument pdfDoc = PDFViewer.GetDocument();
|
|
|
+ if (zoom <= 0 || pdfDoc == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CPDFPage pdfPage = pdfDoc.PageAtIndex(PageIndex);
|
|
|
+ InkParam param = FillParam.Param as InkParam;
|
|
|
+ if (pdfPage == null || param == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(param==null || param.InkPath==null || param.InkPath.Count==0)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<List<CPoint>> rawPointList = new List<List<CPoint>>();
|
|
|
+ Rect offsetRect = new Rect(DrawBound.X - PageBound.X, DrawBound.Y - PageBound.Y, DrawBound.Width, DrawBound.Height);
|
|
|
+ Rect standRect = new Rect(offsetRect.X / zoom, offsetRect.Y / zoom, offsetRect.Width / zoom, offsetRect.Height / zoom);
|
|
|
+ Rect pdfRect = new Rect(standRect.X / 96D * 72D, standRect.Y / 96D * 72D, standRect.Width / 96D * 72D, standRect.Height / 96D * 72D);
|
|
|
+
|
|
|
+ foreach (List<CPoint> segmentList in param.InkPath)
|
|
|
+ {
|
|
|
+ List<CPoint> pointList = new List<CPoint>();
|
|
|
+ foreach (CPoint point in segmentList)
|
|
|
+ {
|
|
|
+ pointList.Add(new CPoint(point.x/96F*72F+(float)pdfRect.Left,point.y/96F*72F+(float)pdfRect.Top));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pointList.Count > 0)
|
|
|
+ {
|
|
|
+ rawPointList.Add(pointList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CPDFInkAnnotation inkAnnot = (CPDFInkAnnotation)pdfPage.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_INK);
|
|
|
+ inkAnnot.SetInkPath(rawPointList);
|
|
|
+ inkAnnot.SetRect(new CRect((float)pdfRect.Left, (float)pdfRect.Bottom, (float)pdfRect.Right, (float)pdfRect.Top));
|
|
|
+ inkAnnot.SetInkColor(param.InkColor);
|
|
|
+ inkAnnot.SetThickness((float)param.Thickness);
|
|
|
+ inkAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
|
|
|
+ if (string.IsNullOrEmpty(param.Author) == false)
|
|
|
+ {
|
|
|
+ inkAnnot.SetAuthor(param.Author);
|
|
|
+ }
|
|
|
+ inkAnnot.UpdateAp();
|
|
|
+
|
|
|
+ FillItem cloneItem = FillParam.Clone();
|
|
|
+ cloneItem.Param = ParamConverter.AnnotConverter(pdfDoc, inkAnnot);
|
|
|
+ cloneItem.HistoryItem = new InkAnnotHistory();
|
|
|
+ cloneItem.HistoryItem.Action = HistoryAction.Add;
|
|
|
+ cloneItem.HistoryItem.CurrentParam = ParamConverter.AnnotConverter(pdfDoc, inkAnnot);
|
|
|
+ cloneItem.HistoryItem.PDFDoc = pdfDoc;
|
|
|
+ PDFViewer.UndoManager.AddHistory(cloneItem.HistoryItem);
|
|
|
+ return cloneItem;
|
|
|
+ }
|
|
|
+
|
|
|
+ private FillItem SaveCross()
|
|
|
+ {
|
|
|
+ double zoom = PDFViewer.GetZoom();
|
|
|
+ CPDFDocument pdfDoc = PDFViewer.GetDocument();
|
|
|
+ if (zoom <= 0 || pdfDoc == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CPDFPage pdfPage = pdfDoc.PageAtIndex(PageIndex);
|
|
|
+ InkParam param = FillParam.Param as InkParam;
|
|
|
+ if (pdfPage == null || param == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param == null || param.InkPath == null || param.InkPath.Count == 0)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<List<CPoint>> rawPointList = new List<List<CPoint>>();
|
|
|
+ Rect offsetRect = new Rect(DrawBound.X - PageBound.X, DrawBound.Y - PageBound.Y, DrawBound.Width, DrawBound.Height);
|
|
|
+ Rect standRect = new Rect(offsetRect.X / zoom, offsetRect.Y / zoom, offsetRect.Width / zoom, offsetRect.Height / zoom);
|
|
|
+ Rect pdfRect = new Rect(standRect.X / 96D * 72D, standRect.Y / 96D * 72D, standRect.Width / 96D * 72D, standRect.Height / 96D * 72D);
|
|
|
+
|
|
|
+ foreach (List<CPoint> segmentList in param.InkPath)
|
|
|
+ {
|
|
|
+ List<CPoint> pointList = new List<CPoint>();
|
|
|
+ foreach (CPoint point in segmentList)
|
|
|
+ {
|
|
|
+ pointList.Add(new CPoint(point.x / 96F * 72F + (float)pdfRect.Left, point.y / 96F * 72F + (float)pdfRect.Top));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pointList.Count > 0)
|
|
|
+ {
|
|
|
+ rawPointList.Add(pointList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CPDFInkAnnotation inkAnnot = (CPDFInkAnnotation)pdfPage.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_INK);
|
|
|
+ inkAnnot.SetInkPath(rawPointList);
|
|
|
+ inkAnnot.SetRect(new CRect((float)pdfRect.Left, (float)pdfRect.Bottom, (float)pdfRect.Right, (float)pdfRect.Top));
|
|
|
+ inkAnnot.SetInkColor(param.InkColor);
|
|
|
+ inkAnnot.SetThickness((float)param.Thickness);
|
|
|
+ inkAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
|
|
|
+ if (string.IsNullOrEmpty(param.Author) == false)
|
|
|
+ {
|
|
|
+ inkAnnot.SetAuthor(param.Author);
|
|
|
+ }
|
|
|
+ inkAnnot.UpdateAp();
|
|
|
+
|
|
|
+ FillItem cloneItem = FillParam.Clone();
|
|
|
+ cloneItem.Param = ParamConverter.AnnotConverter(pdfDoc, inkAnnot);
|
|
|
+ cloneItem.HistoryItem = new InkAnnotHistory();
|
|
|
+ cloneItem.HistoryItem.Action = HistoryAction.Add;
|
|
|
+ cloneItem.HistoryItem.CurrentParam = ParamConverter.AnnotConverter(pdfDoc, inkAnnot);
|
|
|
+ cloneItem.HistoryItem.PDFDoc = pdfDoc;
|
|
|
+ PDFViewer.UndoManager.AddHistory(cloneItem.HistoryItem);
|
|
|
+ return cloneItem;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|