|
@@ -3,7 +3,11 @@ using ComPDFKit.Tool;
|
|
|
using Compdfkit_Tools.Common;
|
|
|
using Compdfkit_Tools.Data;
|
|
|
using Compdfkit_Tools.PDFControl;
|
|
|
+using ComPDFKitViewer;
|
|
|
+using ComPDFKitViewer.Annot;
|
|
|
using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.IO.Ports;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Media;
|
|
@@ -38,8 +42,48 @@ namespace Compdfkit_Tools.PDFControlUI
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- annotParam.UpdateAttrib(AnnotAttrib.Color, ((SolidColorBrush)BorderColorPickerControl.Brush).Color);
|
|
|
- annotParam.UpdateAnnot();
|
|
|
+ SolidColorBrush borderBrush=BorderColorPickerControl.Brush as SolidColorBrush;
|
|
|
+ if(annotCore!=null && annotCore.IsValid() && borderBrush!=null)
|
|
|
+ {
|
|
|
+ if(annotCore.Type==C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE)
|
|
|
+ {
|
|
|
+ CPDFSquareAnnotation squareAnnot = annotCore as CPDFSquareAnnotation;
|
|
|
+ squareAnnot?.SetLineColor(new byte[3]
|
|
|
+ {
|
|
|
+ borderBrush.Color.R,
|
|
|
+ borderBrush.Color.G,
|
|
|
+ borderBrush.Color.B
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if(annotCore.Type==C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE)
|
|
|
+ {
|
|
|
+ CPDFCircleAnnotation circleAnnot= annotCore as CPDFCircleAnnotation;
|
|
|
+ circleAnnot?.SetLineColor(new byte[3]
|
|
|
+ {
|
|
|
+ borderBrush.Color.R,
|
|
|
+ borderBrush.Color.G,
|
|
|
+ borderBrush.Color.B
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if(annotCore.Type==C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
|
|
|
+ {
|
|
|
+ CPDFLineAnnotation lineAnnot = annotCore as CPDFLineAnnotation;
|
|
|
+ lineAnnot?.SetLineColor(new byte[3]
|
|
|
+ {
|
|
|
+ borderBrush.Color.R,
|
|
|
+ borderBrush.Color.G,
|
|
|
+ borderBrush.Color.B
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (viewControl != null && viewControl.PDFViewTool != null)
|
|
|
+ {
|
|
|
+ CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ pdfViewer?.UpDataAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
CPDFAnnotationPreviewerControl.DrawShapePreview(GetShapeData());
|
|
|
}
|
|
@@ -52,8 +96,48 @@ namespace Compdfkit_Tools.PDFControlUI
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- annotParam.UpdateAttrib(AnnotAttrib.FillColor, ((SolidColorBrush)FillColorPickerControl.Brush).Color);
|
|
|
- annotParam.UpdateAnnot();
|
|
|
+ SolidColorBrush fillBrush = FillColorPickerControl.Brush as SolidColorBrush;
|
|
|
+ if (annotCore != null && annotCore.IsValid() && fillBrush != null)
|
|
|
+ {
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE)
|
|
|
+ {
|
|
|
+ CPDFSquareAnnotation squareAnnot = annotCore as CPDFSquareAnnotation;
|
|
|
+ squareAnnot?.SetBgColor(new byte[3]
|
|
|
+ {
|
|
|
+ fillBrush.Color.R,
|
|
|
+ fillBrush.Color.G,
|
|
|
+ fillBrush.Color.B
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE)
|
|
|
+ {
|
|
|
+ CPDFCircleAnnotation circleAnnot = annotCore as CPDFCircleAnnotation;
|
|
|
+ circleAnnot?.SetBgColor(new byte[3]
|
|
|
+ {
|
|
|
+ fillBrush.Color.R,
|
|
|
+ fillBrush.Color.G,
|
|
|
+ fillBrush.Color.B
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
|
|
|
+ {
|
|
|
+ CPDFLineAnnotation lineAnnot = annotCore as CPDFLineAnnotation;
|
|
|
+ lineAnnot?.SetBgColor(new byte[3]
|
|
|
+ {
|
|
|
+ fillBrush.Color.R,
|
|
|
+ fillBrush.Color.G,
|
|
|
+ fillBrush.Color.B
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (viewControl != null && viewControl.PDFViewTool != null)
|
|
|
+ {
|
|
|
+ CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ pdfViewer?.UpDataAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
CPDFAnnotationPreviewerControl.DrawShapePreview(GetShapeData());
|
|
|
}
|
|
@@ -66,8 +150,33 @@ namespace Compdfkit_Tools.PDFControlUI
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- annotParam.UpdateAttrib(AnnotAttrib.Thickness, CPDFThicknessControl.Thickness);
|
|
|
- annotParam.UpdateAnnot();
|
|
|
+
|
|
|
+ if (annotCore != null && annotCore.IsValid())
|
|
|
+ {
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE)
|
|
|
+ {
|
|
|
+ CPDFSquareAnnotation squareAnnot = annotCore as CPDFSquareAnnotation;
|
|
|
+ squareAnnot?.SetBorderWidth(CPDFThicknessControl.Thickness);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE)
|
|
|
+ {
|
|
|
+ CPDFCircleAnnotation circleAnnot = annotCore as CPDFCircleAnnotation;
|
|
|
+ circleAnnot?.SetBorderWidth(CPDFThicknessControl.Thickness);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
|
|
|
+ {
|
|
|
+ CPDFLineAnnotation lineAnnot = annotCore as CPDFLineAnnotation;
|
|
|
+ lineAnnot?.SetBorderWidth(CPDFThicknessControl.Thickness);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (viewControl != null && viewControl.PDFViewTool != null)
|
|
|
+ {
|
|
|
+ CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ pdfViewer?.UpDataAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
CPDFAnnotationPreviewerControl.DrawShapePreview(GetShapeData());
|
|
|
}
|
|
@@ -80,8 +189,37 @@ namespace Compdfkit_Tools.PDFControlUI
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- annotParam.UpdateAttrib(AnnotAttrib.Transparency, CPDFOpacityControl.OpacityValue / 100.0);
|
|
|
- annotParam.UpdateAnnot();
|
|
|
+ double opacity = CPDFOpacityControl.OpacityValue / 100.0;
|
|
|
+ if (opacity > 0 && opacity <= 1)
|
|
|
+ {
|
|
|
+ opacity = opacity * 255;
|
|
|
+ }
|
|
|
+ if (annotCore != null && annotCore.IsValid())
|
|
|
+ {
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE)
|
|
|
+ {
|
|
|
+ CPDFSquareAnnotation squareAnnot = annotCore as CPDFSquareAnnotation;
|
|
|
+ squareAnnot?.SetTransparency((byte)opacity);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE)
|
|
|
+ {
|
|
|
+ CPDFCircleAnnotation circleAnnot = annotCore as CPDFCircleAnnotation;
|
|
|
+ circleAnnot?.SetTransparency((byte)opacity);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
|
|
|
+ {
|
|
|
+ CPDFLineAnnotation lineAnnot = annotCore as CPDFLineAnnotation;
|
|
|
+ lineAnnot?.SetTransparency((byte)opacity);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (viewControl != null && viewControl.PDFViewTool != null)
|
|
|
+ {
|
|
|
+ CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ pdfViewer?.UpDataAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
CPDFAnnotationPreviewerControl.DrawShapePreview(GetShapeData());
|
|
|
}
|
|
@@ -94,8 +232,53 @@ namespace Compdfkit_Tools.PDFControlUI
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- annotParam.UpdateAttrib(AnnotAttrib.LineStyle, CPDFLineStyleControl.DashStyle);
|
|
|
- annotParam.UpdateAnnot();
|
|
|
+ if (annotCore != null && annotCore.IsValid())
|
|
|
+ {
|
|
|
+ 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<float> floatArray = new List<float>();
|
|
|
+ foreach (double num in CPDFLineStyleControl.DashStyle.Dashes)
|
|
|
+ {
|
|
|
+ floatArray.Add((float)num);
|
|
|
+ }
|
|
|
+ dashArray = floatArray.ToArray();
|
|
|
+ borderStyle = C_BORDER_STYLE.BS_DASHDED;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dashArray != null)
|
|
|
+ {
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE)
|
|
|
+ {
|
|
|
+ CPDFSquareAnnotation squareAnnot = annotCore as CPDFSquareAnnotation;
|
|
|
+ squareAnnot?.SetBorderStyle(borderStyle, dashArray);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE)
|
|
|
+ {
|
|
|
+ CPDFCircleAnnotation circleAnnot = annotCore as CPDFCircleAnnotation;
|
|
|
+ circleAnnot?.SetBorderStyle(borderStyle, dashArray);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (annotCore.Type == C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
|
|
|
+ {
|
|
|
+ CPDFLineAnnotation lineAnnot = annotCore as CPDFLineAnnotation;
|
|
|
+ lineAnnot?.SetBorderStyle(borderStyle, dashArray);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (viewControl != null && viewControl.PDFViewTool != null)
|
|
|
+ {
|
|
|
+ CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ pdfViewer?.UpDataAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
CPDFAnnotationPreviewerControl.DrawShapePreview(GetShapeData());
|
|
|
}
|
|
@@ -108,9 +291,22 @@ namespace Compdfkit_Tools.PDFControlUI
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- annotParam.UpdateAttrib(AnnotAttrib.LineStart, CPDFArrowControl.LineType.HeadLineType);
|
|
|
- annotParam.UpdateAttrib(AnnotAttrib.LineEnd, CPDFArrowControl.LineType.TailLineType);
|
|
|
- annotParam.UpdateAnnot();
|
|
|
+ if (annotCore != null && annotCore.IsValid())
|
|
|
+ {
|
|
|
+ if(annotCore.Type==C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
|
|
|
+ {
|
|
|
+ CPDFLineAnnotation lineAnnot= annotCore as CPDFLineAnnotation;
|
|
|
+ if(lineAnnot!=null)
|
|
|
+ {
|
|
|
+ lineAnnot.SetLineType(CPDFArrowControl.LineType.HeadLineType, CPDFArrowControl.LineType.TailLineType);
|
|
|
+ if (viewControl != null && viewControl.PDFViewTool != null)
|
|
|
+ {
|
|
|
+ CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ pdfViewer?.UpDataAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
CPDFAnnotationPreviewerControl.DrawShapePreview(GetShapeData());
|
|
|
}
|
|
@@ -123,8 +319,16 @@ namespace Compdfkit_Tools.PDFControlUI
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- annotParam.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
|
|
|
- annotParam.UpdateAnnot();
|
|
|
+ if (annotCore != null && annotCore.IsValid())
|
|
|
+ {
|
|
|
+ annotCore.SetContent(NoteTextBox.Text);
|
|
|
+
|
|
|
+ if (viewControl != null && viewControl.PDFViewTool != null)
|
|
|
+ {
|
|
|
+ CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ pdfViewer?.UpDataAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -164,38 +368,101 @@ namespace Compdfkit_Tools.PDFControlUI
|
|
|
this.annotCore = null;
|
|
|
this.viewControl = null;
|
|
|
|
|
|
- BorderColorPickerControl.Brush = new SolidColorBrush((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
|
|
|
-
|
|
|
- CPDFOpacityControl.OpacityValue = (int)((double)annotAttribEvent.Attribs[AnnotAttrib.Transparency] * 100);
|
|
|
- CPDFThicknessControl.Thickness = Convert.ToInt16(annotAttribEvent.Attribs[AnnotAttrib.Thickness]);
|
|
|
- NoteTextBox.Text = (string)annotAttribEvent.Attribs[AnnotAttrib.NoteText];
|
|
|
- if(annotAttribEvent.Attribs!=null && annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.Color))
|
|
|
+ if(param != null)
|
|
|
{
|
|
|
- BorderColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
|
|
|
- }
|
|
|
-
|
|
|
- if (annotAttribEvent.Attribs != null && annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.FillColor))
|
|
|
- {
|
|
|
- FillColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.FillColor]);
|
|
|
- }
|
|
|
+ if(param is SquareParam)
|
|
|
+ {
|
|
|
+ SquareParam squareParam= (SquareParam)param;
|
|
|
+ BorderColorPickerControl.Brush = new SolidColorBrush(Color.FromRgb(
|
|
|
+ squareParam.LineColor[0],
|
|
|
+ squareParam.LineColor[1],
|
|
|
+ squareParam.LineColor[2]));
|
|
|
+ CPDFThicknessControl.Thickness = (int)squareParam.LineWidth;
|
|
|
+ BorderColorPickerControl.SetCheckedForColor(Color.FromRgb(
|
|
|
+ squareParam.LineColor[0],
|
|
|
+ squareParam.LineColor[1],
|
|
|
+ squareParam.LineColor[2]));
|
|
|
+ FillColorPickerControl.SetCheckedForColor(Color.FromRgb(
|
|
|
+ squareParam.BgColor[0],
|
|
|
+ squareParam.BgColor[1],
|
|
|
+ squareParam.BgColor[2]));
|
|
|
+ if (squareParam.BorderStyle == C_BORDER_STYLE.BS_SOLID)
|
|
|
+ {
|
|
|
+ CPDFLineStyleControl.DashStyle = DashStyles.Solid;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CPDFLineStyleControl.DashStyle = DashStyles.Dash;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- CPDFLineStyleControl.DashStyle = (DashStyle)(annotAttribEvent.Attribs[AnnotAttrib.LineStyle]);
|
|
|
+ if(param is CircleParam)
|
|
|
+ {
|
|
|
+ CircleParam circleParam= (CircleParam)param;
|
|
|
+ BorderColorPickerControl.Brush = new SolidColorBrush(Color.FromRgb(
|
|
|
+ circleParam.LineColor[0],
|
|
|
+ circleParam.LineColor[1],
|
|
|
+ circleParam.LineColor[2]));
|
|
|
+ CPDFThicknessControl.Thickness = (int)circleParam.LineWidth;
|
|
|
+ BorderColorPickerControl.SetCheckedForColor(Color.FromRgb(
|
|
|
+ circleParam.LineColor[0],
|
|
|
+ circleParam.LineColor[1],
|
|
|
+ circleParam.LineColor[2]));
|
|
|
+ FillColorPickerControl.SetCheckedForColor(Color.FromRgb(
|
|
|
+ circleParam.BgColor[0],
|
|
|
+ circleParam.BgColor[1],
|
|
|
+ circleParam.BgColor[2]));
|
|
|
+ if (circleParam.BorderStyle == C_BORDER_STYLE.BS_SOLID)
|
|
|
+ {
|
|
|
+ CPDFLineStyleControl.DashStyle = DashStyles.Solid;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CPDFLineStyleControl.DashStyle = DashStyles.Dash;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (annotAttribEvent.GetAnnotTypes() == AnnotArgsType.AnnotSquare ||
|
|
|
- annotAttribEvent.GetAnnotTypes() == AnnotArgsType.AnnotCircle)
|
|
|
- {
|
|
|
- FillColorPickerControl.Brush = new SolidColorBrush((Color)annotAttribEvent.Attribs[AnnotAttrib.FillColor]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- LineType lineType = new LineType()
|
|
|
+ if(param is LineParam)
|
|
|
{
|
|
|
- HeadLineType = (C_LINE_TYPE)annotAttribEvent.Attribs[AnnotAttrib.LineStart],
|
|
|
- TailLineType = (C_LINE_TYPE)annotAttribEvent.Attribs[AnnotAttrib.LineEnd]
|
|
|
- };
|
|
|
- CPDFArrowControl.LineType = lineType;
|
|
|
+ LineParam lineParam= (LineParam)param;
|
|
|
+ BorderColorPickerControl.Brush = new SolidColorBrush(Color.FromRgb(
|
|
|
+ lineParam.LineColor[0],
|
|
|
+ lineParam.LineColor[1],
|
|
|
+ lineParam.LineColor[2]));
|
|
|
+ CPDFThicknessControl.Thickness = (int)lineParam.LineWidth;
|
|
|
+ BorderColorPickerControl.SetCheckedForColor(Color.FromRgb(
|
|
|
+ lineParam.LineColor[0],
|
|
|
+ lineParam.LineColor[1],
|
|
|
+ lineParam.LineColor[2]));
|
|
|
+ FillColorPickerControl.SetCheckedForColor(Color.FromRgb(
|
|
|
+ lineParam.BgColor[0],
|
|
|
+ lineParam.BgColor[1],
|
|
|
+ lineParam.BgColor[2]));
|
|
|
+
|
|
|
+ if(lineParam.BorderStyle==C_BORDER_STYLE.BS_SOLID)
|
|
|
+ {
|
|
|
+ CPDFLineStyleControl.DashStyle = DashStyles.Solid;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CPDFLineStyleControl.DashStyle = DashStyles.Dash;
|
|
|
+ }
|
|
|
+
|
|
|
+ LineType lineType = new LineType()
|
|
|
+ {
|
|
|
+ HeadLineType = lineParam.HeadLineType,
|
|
|
+ TailLineType = lineParam.TailLineType
|
|
|
+ };
|
|
|
+ CPDFArrowControl.LineType = lineType;
|
|
|
+ }
|
|
|
+
|
|
|
+ CPDFOpacityControl.OpacityValue = (int)(param.Transparency/255 * 100);
|
|
|
+ NoteTextBox.Text = param.Content;
|
|
|
}
|
|
|
- this.annotParam = annotAttribEvent;
|
|
|
+
|
|
|
+ this.annotParam = param;
|
|
|
+ this.annotCore = annot;
|
|
|
+ this.viewControl = view;
|
|
|
CPDFAnnotationPreviewerControl.DrawShapePreview(GetShapeData());
|
|
|
}
|
|
|
|