|
@@ -24,47 +24,125 @@ namespace compdfkit_tools.PDFControlUI
|
|
|
{
|
|
|
private AnnotationType currentAnnotationType;
|
|
|
|
|
|
+ public event EventHandler<CPDFAnnotationData> PropertyChanged;
|
|
|
+
|
|
|
public CPDFShapeUI()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
+ BorderColorPickerControl.ColorChanged += BorderColorPickerControl_ColorChanged;
|
|
|
+ CPDFOpacityControl.OpacityChanged += CPDFOpacityControl_OpacityChanged;
|
|
|
+ CPDFThicknessControl.ThicknessChanged += CPDFThicknessControl_ThicknessChanged;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ PropertyChanged?.Invoke(this, GetShapeData());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ PropertyChanged?.Invoke(this, GetShapeData());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ PropertyChanged?.Invoke(this, GetShapeData());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FillColorPickerControl_ColorChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ PropertyChanged?.Invoke(this, GetShapeData());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CPDFArrowControl_ArrowChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ PropertyChanged?.Invoke(PropertyChanged, GetShapeData());
|
|
|
}
|
|
|
|
|
|
- public CPDFShapeData GetShapeData()
|
|
|
+ public DashStyle CalculateDashStyle(CPDFDash pdfDash, int Thickness )
|
|
|
{
|
|
|
- CPDFShapeData pdfShapeData = new CPDFShapeData();
|
|
|
+ DashStyle dashStyle = new DashStyle();
|
|
|
+ if (pdfDash.IsSolid)
|
|
|
+ {
|
|
|
+ dashStyle = DashStyles.Solid;
|
|
|
+ return dashStyle;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dashStyle.Dashes.Add(pdfDash.DashSpacing / Thickness);
|
|
|
+ dashStyle.Dashes.Add(pdfDash.DashSpacing / Thickness);
|
|
|
+ return dashStyle;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- return pdfShapeData;
|
|
|
+ public CPDFAnnotationData GetShapeData()
|
|
|
+ {
|
|
|
+ if (currentAnnotationType == AnnotationType.Circle || currentAnnotationType == AnnotationType.Square)
|
|
|
+ {
|
|
|
+ CPDFShapeData pdfShapeData = new CPDFShapeData();
|
|
|
+ pdfShapeData.AnnotationType = currentAnnotationType;
|
|
|
+ pdfShapeData.BorderColor = ((SolidColorBrush)BorderColorPickerControl.Brush).Color;
|
|
|
+ pdfShapeData.FillColor = ((SolidColorBrush)FillColorPickerControl.Brush).Color;
|
|
|
+ pdfShapeData.Opacity = CPDFOpacityControl.OpacityValue / 100.0;
|
|
|
+ pdfShapeData.Thickness = CPDFThicknessControl.Thickness;
|
|
|
+ pdfShapeData.DashStyle = CalculateDashStyle(CPDFLineStyleControl.CPDFDash, CPDFThicknessControl.Thickness);
|
|
|
+ pdfShapeData.LineType = CPDFArrowControl.LineType;
|
|
|
+ pdfShapeData.Note = NoteTextBox.Text;
|
|
|
+ return pdfShapeData;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CPDFLineShapeData pdfLineShapeData = new CPDFLineShapeData();
|
|
|
+ pdfLineShapeData.AnnotationType = currentAnnotationType;
|
|
|
+ pdfLineShapeData.BorderColor = ((SolidColorBrush)BorderColorPickerControl.Brush).Color;
|
|
|
+ pdfLineShapeData.Opacity = CPDFOpacityControl.OpacityValue / 100.0;
|
|
|
+ pdfLineShapeData.LineType = CPDFArrowControl.LineType;
|
|
|
+ pdfLineShapeData.Thickness = CPDFThicknessControl.Thickness;
|
|
|
+ pdfLineShapeData.DashStyle = CalculateDashStyle(CPDFLineStyleControl.CPDFDash, CPDFThicknessControl.Thickness);
|
|
|
+ pdfLineShapeData.Note = NoteTextBox.Text;
|
|
|
+ return pdfLineShapeData;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public void SetUIWhenRectAndRound()
|
|
|
+ public void InitWhenRectAndRound()
|
|
|
{
|
|
|
+ FillColorStackPanel.Visibility = Visibility.Visible;
|
|
|
+ ArrowStackPanel.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
+ FillColorPickerControl.ColorChanged += FillColorPickerControl_ColorChanged;
|
|
|
+ CPDFArrowControl.ArrowChanged -= CPDFArrowControl_ArrowChanged;
|
|
|
}
|
|
|
|
|
|
- public void SetUIWhenArrowAndLine()
|
|
|
+ public void InitWhenArrowAndLine()
|
|
|
{
|
|
|
+ FillColorStackPanel.Visibility = Visibility.Collapsed;
|
|
|
+ ArrowStackPanel.Visibility = Visibility.Visible;
|
|
|
|
|
|
+ CPDFArrowControl.ArrowChanged += CPDFArrowControl_ArrowChanged;
|
|
|
+ FillColorPickerControl.ColorChanged -= FillColorPickerControl_ColorChanged;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public void InitWithAnnotationType(AnnotationType annotationType)
|
|
|
{
|
|
|
switch (annotationType)
|
|
|
{
|
|
|
case AnnotationType.Square:
|
|
|
TitleTextBlock.Text = "Square";
|
|
|
- SetUIWhenRectAndRound();
|
|
|
+ InitWhenRectAndRound();
|
|
|
break;
|
|
|
case AnnotationType.Circle:
|
|
|
TitleTextBlock.Text = "Circle";
|
|
|
- SetUIWhenRectAndRound();
|
|
|
+ InitWhenRectAndRound();
|
|
|
break;
|
|
|
case AnnotationType.Arrow:
|
|
|
TitleTextBlock.Text = "Arrow";
|
|
|
- SetUIWhenArrowAndLine();
|
|
|
+ InitWhenArrowAndLine();
|
|
|
break;
|
|
|
case AnnotationType.Line:
|
|
|
TitleTextBlock.Text = "Line";
|
|
|
- SetUIWhenArrowAndLine();
|
|
|
+ InitWhenArrowAndLine();
|
|
|
break;
|
|
|
default:
|
|
|
throw new ArgumentException("Not Excepted Argument");
|