|
@@ -1,5 +1,11 @@
|
|
|
-using System;
|
|
|
+using ComPDFKit.PDFAnnotation;
|
|
|
+using Compdfkit_Tools.Common;
|
|
|
+using Compdfkit_Tools.Data;
|
|
|
+using ComPDFKitViewer;
|
|
|
+using ComPDFKitViewer.AnnotEvent;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Diagnostics;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
@@ -20,6 +26,7 @@ namespace Compdfkit_Tools.Measure.Property
|
|
|
/// </summary>
|
|
|
public partial class MultilineProperty : UserControl
|
|
|
{
|
|
|
+ private AnnotAttribEvent LineEvent { get; set; }
|
|
|
public MultilineProperty()
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -27,22 +34,264 @@ namespace Compdfkit_Tools.Measure.Property
|
|
|
|
|
|
private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
|
|
{
|
|
|
-
|
|
|
+ LineEvent.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
|
|
|
+ LineEvent.UpdateAnnot();
|
|
|
}
|
|
|
|
|
|
private void FontStyleCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
+ int selectIndex = Math.Max(0, FontStyleCombox.SelectedIndex);
|
|
|
+ bool isBold = false;
|
|
|
+ bool isItalic = false;
|
|
|
|
|
|
+ switch (selectIndex)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ isBold = false;
|
|
|
+ isItalic = false;
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ isBold = true;
|
|
|
+ isItalic = false;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ isBold = false;
|
|
|
+ isItalic = true;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ isBold = true;
|
|
|
+ isItalic = true;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ LineEvent?.UpdateAttrib(AnnotAttrib.IsBold, isBold);
|
|
|
+ LineEvent?.UpdateAttrib(AnnotAttrib.IsItalic, isItalic);
|
|
|
+ LineEvent?.UpdateAnnot();
|
|
|
}
|
|
|
|
|
|
- private void FontSizeCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
+ private void FontSizeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
-
|
|
|
+ ComboBoxItem selectItem = FontSizeComboBox.SelectedItem as ComboBoxItem;
|
|
|
+ if (selectItem != null && selectItem.Content != null)
|
|
|
+ {
|
|
|
+ if (int.TryParse(selectItem.Content.ToString(), out int newFontSize))
|
|
|
+ {
|
|
|
+ FontSizeTextBox.Text = (newFontSize).ToString();
|
|
|
+ LineEvent?.UpdateAttrib(AnnotAttrib.FontSize, newFontSize);
|
|
|
+ LineEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void FontCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
+ ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
|
|
|
+ if (selectItem != null && selectItem.Content != null)
|
|
|
+ {
|
|
|
+ LineEvent?.UpdateAttrib(AnnotAttrib.FontName, selectItem.Content.ToString());
|
|
|
+ LineEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
|
|
|
+ if (checkBrush != null)
|
|
|
+ {
|
|
|
+ LineEvent?.UpdateAttrib(AnnotAttrib.Color, checkBrush.Color);
|
|
|
+ LineEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ LineEvent?.UpdateAttrib(AnnotAttrib.Transparency, CPDFOpacityControl.OpacityValue/100D*255D);
|
|
|
+ LineEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetAnnotEventData(AnnotAttribEvent annotEvent)
|
|
|
+ {
|
|
|
+ LineEvent = null;
|
|
|
+ if(annotEvent!=null)
|
|
|
+ {
|
|
|
+ foreach(AnnotAttrib attrib in annotEvent.Attribs.Keys)
|
|
|
+ {
|
|
|
+ switch(attrib)
|
|
|
+ {
|
|
|
+ case AnnotAttrib.Color:
|
|
|
+ BorderColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
|
|
|
+ break;
|
|
|
+ case AnnotAttrib.Transparency:
|
|
|
+ double transparennt= Convert.ToDouble(annotEvent.Attribs[attrib]);
|
|
|
+ if(transparennt>1)
|
|
|
+ {
|
|
|
+ transparennt =(transparennt / 255D);
|
|
|
+ }
|
|
|
+ CPDFOpacityControl.OpacityValue = (int)(transparennt*100);
|
|
|
+ break;
|
|
|
+ case AnnotAttrib.Thickness:
|
|
|
+ CPDFThicknessControl.Thickness = Convert.ToInt16(annotEvent.Attribs[attrib]);
|
|
|
+ break;
|
|
|
+ case AnnotAttrib.LineStyle:
|
|
|
+ CPDFLineStyleControl.DashStyle= (DashStyle)(annotEvent.Attribs[attrib]);
|
|
|
+ break;
|
|
|
+ case AnnotAttrib.FontColor:
|
|
|
+ FillColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
|
|
|
+ break;
|
|
|
+ case AnnotAttrib.FontName:
|
|
|
+ {
|
|
|
+ string fontName= (string)annotEvent.Attribs[AnnotAttrib.FontName];
|
|
|
+ if (fontName == "Courier New")
|
|
|
+ {
|
|
|
+ FontCombox.SelectedIndex = 1;
|
|
|
+ }
|
|
|
+ else if (fontName == "Arial")
|
|
|
+ {
|
|
|
+ FontCombox.SelectedIndex = 0;
|
|
|
|
|
|
+ }
|
|
|
+ else if (fontName.Contains("Times"))
|
|
|
+ {
|
|
|
+ FontCombox.SelectedIndex = 2;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FontCombox.SelectedIndex = -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case AnnotAttrib.FontSize:
|
|
|
+ SetFontSize(Convert.ToDouble(annotEvent.Attribs[attrib]));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ C_LINE_TYPE headLineType = C_LINE_TYPE.LINETYPE_NONE;
|
|
|
+ C_LINE_TYPE tailLineType = C_LINE_TYPE.LINETYPE_NONE;
|
|
|
+
|
|
|
+ if(annotEvent.Attribs.ContainsKey(AnnotAttrib.LineStart))
|
|
|
+ {
|
|
|
+ headLineType = (C_LINE_TYPE)annotEvent.Attribs[AnnotAttrib.LineStart];
|
|
|
+ }
|
|
|
+ if (annotEvent.Attribs.ContainsKey(AnnotAttrib.LineEnd))
|
|
|
+ {
|
|
|
+ tailLineType = (C_LINE_TYPE)annotEvent.Attribs[AnnotAttrib.LineEnd];
|
|
|
+ }
|
|
|
+ LineType lineType = new LineType()
|
|
|
+ {
|
|
|
+ HeadLineType = headLineType,
|
|
|
+ TailLineType = tailLineType
|
|
|
+ };
|
|
|
+ CPDFArrowControl.LineType = lineType;
|
|
|
+
|
|
|
+ bool isBold=false;
|
|
|
+ bool isItalic=false;
|
|
|
+ if (annotEvent.Attribs.ContainsKey(AnnotAttrib.IsBold))
|
|
|
+ {
|
|
|
+ isBold = (bool)annotEvent.Attribs[AnnotAttrib.IsBold];
|
|
|
+ }
|
|
|
+ if (annotEvent.Attribs.ContainsKey(AnnotAttrib.IsItalic))
|
|
|
+ {
|
|
|
+ isItalic = (bool)annotEvent.Attribs[AnnotAttrib.IsItalic];
|
|
|
+ }
|
|
|
+
|
|
|
+ SetFontStyle(isBold, isItalic);
|
|
|
+ }
|
|
|
+
|
|
|
+ LineEvent =annotEvent;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetAnnotEventData(LineMeasureArgs annotArgs)
|
|
|
+ {
|
|
|
+ Dictionary<AnnotAttrib, object> attribDict = new Dictionary<AnnotAttrib, object>();
|
|
|
+ attribDict[AnnotAttrib.Color] = annotArgs.LineColor;
|
|
|
+ attribDict[AnnotAttrib.Transparency] = annotArgs.Transparency;
|
|
|
+ attribDict[AnnotAttrib.Thickness] = annotArgs.LineWidth;
|
|
|
+ attribDict[AnnotAttrib.LineStyle] = annotArgs.LineDash;
|
|
|
+ attribDict[AnnotAttrib.LineStart] = annotArgs.HeadLineType;
|
|
|
+ attribDict[AnnotAttrib.LineEnd] = annotArgs.TailLineType;
|
|
|
+ attribDict[AnnotAttrib.FontColor] = annotArgs.FontColor;
|
|
|
+ attribDict[AnnotAttrib.FontName] = annotArgs.FontName;
|
|
|
+ attribDict[AnnotAttrib.IsBold] = annotArgs.IsBold;
|
|
|
+ attribDict[AnnotAttrib.IsItalic] = annotArgs.IsItalic;
|
|
|
+ attribDict[AnnotAttrib.FontSize] = annotArgs.FontSize;
|
|
|
+ attribDict[AnnotAttrib.NoteText] = annotArgs.Content;
|
|
|
+
|
|
|
+ AnnotAttribEvent annotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annotArgs, attribDict);
|
|
|
+ SetAnnotEventData(annotEvent);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetFontStyle(bool isBold, bool isItalic)
|
|
|
+ {
|
|
|
+ if (isBold == false && isItalic == false)
|
|
|
+ {
|
|
|
+ FontStyleCombox.SelectedIndex = 0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isBold && isItalic == false)
|
|
|
+ {
|
|
|
+ FontStyleCombox.SelectedIndex = 1;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isBold == false && isItalic)
|
|
|
+ {
|
|
|
+ FontStyleCombox.SelectedIndex = 2;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isBold && isItalic)
|
|
|
+ {
|
|
|
+ FontStyleCombox.SelectedIndex = 3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetFontSize(double newFontSize)
|
|
|
+ {
|
|
|
+ if (FontSizeTextBox != null)
|
|
|
+ {
|
|
|
+ if (newFontSize - (int)(newFontSize) > 0)
|
|
|
+ {
|
|
|
+ FontSizeTextBox.Text = ((int)newFontSize).ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FontSizeTextBox.Text = ((int)(newFontSize)).ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ LineEvent?.UpdateAttrib(AnnotAttrib.Thickness, CPDFThicknessControl.Thickness);
|
|
|
+ LineEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ LineEvent?.UpdateAttrib(AnnotAttrib.LineStyle, CPDFLineStyleControl.DashStyle);
|
|
|
+ LineEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CPDFArrowControl_ArrowChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ LineEvent?.UpdateAttrib(AnnotAttrib.LineStart, CPDFArrowControl.LineType.HeadLineType);
|
|
|
+ LineEvent?.UpdateAttrib(AnnotAttrib.LineEnd, CPDFArrowControl.LineType.TailLineType);
|
|
|
+ LineEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FillColorPickerControl_ColorChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
|
|
|
+ if (checkBrush != null)
|
|
|
+ {
|
|
|
+ LineEvent?.UpdateAttrib(AnnotAttrib.FontColor, checkBrush.Color);
|
|
|
+ LineEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|