|
@@ -18,6 +18,9 @@ using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using System.Windows.Navigation;
|
|
|
using System.Windows.Shapes;
|
|
|
+using Compdfkit_Tools.PDFControl;
|
|
|
+using ComPDFKit.Tool;
|
|
|
+using CFontNameHelper = ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
|
|
|
|
|
|
namespace Compdfkit_Tools.Measure.Property
|
|
|
{
|
|
@@ -34,6 +37,12 @@ namespace Compdfkit_Tools.Measure.Property
|
|
|
|
|
|
bool IsLoadedData = false;
|
|
|
|
|
|
+ private LineMeasureParam lineMeasureParam;
|
|
|
+
|
|
|
+ public CPDFLineAnnotation Annotation{ get; set; }
|
|
|
+
|
|
|
+ public PDFViewControl ViewControl{ get; set; }
|
|
|
+
|
|
|
public StraightnessProperty()
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -41,12 +50,20 @@ namespace Compdfkit_Tools.Measure.Property
|
|
|
|
|
|
private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
|
|
{
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
|
|
|
- //LineEvent?.UpdateAnnot();
|
|
|
+ if (IsLoadedData)
|
|
|
+ {
|
|
|
+ if (Annotation != null && ViewControl != null)
|
|
|
+ {
|
|
|
+ Annotation.SetContent(NoteTextBox.Text);
|
|
|
+ Annotation.UpdateAp();
|
|
|
+ ViewControl?.UpdateAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void FontStyleCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
+ if (!IsLoadedData) return;
|
|
|
int selectIndex = Math.Max(0, FontStyleCombox.SelectedIndex);
|
|
|
bool isBold = false;
|
|
|
bool isItalic = false;
|
|
@@ -72,162 +89,143 @@ namespace Compdfkit_Tools.Measure.Property
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.IsBold, isBold);
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.IsItalic, isItalic);
|
|
|
- //LineEvent?.UpdateAnnot();
|
|
|
+ if(Annotation != null)
|
|
|
+ {
|
|
|
+ CTextAttribute textAttribute = Annotation.GetTextAttribute();
|
|
|
+ var fontType = CFontNameHelper.GetFontType((FontCombox.SelectedItem as ComboBoxItem).Content.ToString());
|
|
|
+ var newName = CFontNameHelper.ObtainFontName(fontType, isBold, isItalic);
|
|
|
+ textAttribute.FontName = newName;
|
|
|
+ Annotation.SetTextAttribute(textAttribute);
|
|
|
+ Annotation.UpdateAp();
|
|
|
+ ViewControl?.UpdateAnnotFrame();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void FontSizeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
if (IsLoadedData)
|
|
|
{
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.FontSize, (sender as ComboBox).SelectedItem);
|
|
|
- //LineEvent?.UpdateAnnot();
|
|
|
+ if (FontSizeComboBox.SelectedItem != null)
|
|
|
+ {
|
|
|
+ if (Annotation != null && ViewControl != null)
|
|
|
+ {
|
|
|
+ CTextAttribute textAttribute = Annotation.GetTextAttribute();
|
|
|
+ textAttribute.FontSize = (float)Convert.ToDouble(FontSizeComboBox.SelectedItem);
|
|
|
+ Annotation.SetTextAttribute(textAttribute);
|
|
|
+ Annotation.UpdateAp();
|
|
|
+ ViewControl?.UpdateAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void FontCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
- ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
|
|
|
- if (selectItem != null && selectItem.Content != null)
|
|
|
+ if (IsLoadedData)
|
|
|
{
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.FontName, selectItem.Content.ToString());
|
|
|
- //LineEvent?.UpdateAnnot();
|
|
|
+ if (Annotation != null && ViewControl != null)
|
|
|
+ {
|
|
|
+ ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
|
|
|
+ if (selectItem != null && selectItem.Content != null)
|
|
|
+ {
|
|
|
+ CTextAttribute textAttr = Annotation.GetTextAttribute();
|
|
|
+ bool isBold = CFontNameHelper.IsBold(textAttr.FontName);
|
|
|
+ bool isItalic = CFontNameHelper.IsItalic(textAttr.FontName);
|
|
|
+ var fontType = CFontNameHelper.GetFontType(selectItem.Content.ToString());
|
|
|
+ textAttr.FontName = CFontNameHelper.ObtainFontName(fontType, isBold, isItalic);
|
|
|
+ Annotation.SetTextAttribute(textAttr);
|
|
|
+ Annotation.UpdateAp();
|
|
|
+ ViewControl.UpdateAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
- SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
|
|
|
- if (checkBrush != null)
|
|
|
+ if (IsLoadedData)
|
|
|
{
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.Color, checkBrush.Color);
|
|
|
- //LineEvent?.UpdateAnnot();
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.Transparency, CPDFOpacityControl.OpacityValue/100D);
|
|
|
- //LineEvent?.UpdateAnnot();
|
|
|
+ if (IsLoadedData)
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ Annotation.UpdateAp();
|
|
|
+ ViewControl.UpdateAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //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:
|
|
|
- // FontColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
|
|
|
- // break;
|
|
|
- // case AnnotAttrib.FontName:
|
|
|
- // {
|
|
|
- // string fontName= (string)annotEvent.Attribs[AnnotAttrib.FontName];
|
|
|
- // if (fontName.Contains("Courier"))
|
|
|
- // {
|
|
|
- // FontCombox.SelectedIndex = 1;
|
|
|
- // }
|
|
|
- // else if (fontName == "Arial" || fontName.Contains("Helvetica"))
|
|
|
- // {
|
|
|
- // 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;
|
|
|
- // case AnnotAttrib.NoteText:
|
|
|
- // NoteTextBox.Text= annotEvent.Attribs[attrib].ToString();
|
|
|
- // 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 SetAnnotArgsData(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 SetAnnotParam(LineMeasureParam param, CPDFAnnotation annot, PDFViewControl viewControl)
|
|
|
+ {
|
|
|
+ Annotation = annot as CPDFLineAnnotation;
|
|
|
+ ViewControl = viewControl;
|
|
|
+ lineMeasureParam = param;
|
|
|
+ if (param == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Color lineColor = Color.FromRgb(param.LineColor[0], param.LineColor[1], param.LineColor[2]);
|
|
|
+ BorderColorPickerControl.SetCheckedForColor(lineColor);
|
|
|
+ CPDFThicknessControl.Thickness = (int)param.LineWidth;
|
|
|
+ if (lineMeasureParam.BorderStyle == C_BORDER_STYLE.BS_SOLID)
|
|
|
+ {
|
|
|
+ CPDFLineStyleControl.DashStyle = DashStyles.Solid;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CPDFLineStyleControl.DashStyle = DashStyles.Dash;
|
|
|
+ }
|
|
|
+ LineType lineType = new LineType()
|
|
|
+ {
|
|
|
+ HeadLineType = param.HeadLineType,
|
|
|
+ TailLineType = param.TailLineType
|
|
|
+ };
|
|
|
+ CPDFArrowControl.LineType = lineType;
|
|
|
+ double opacity = param.Transparency / 255.0 * 100.0;
|
|
|
+ CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity);
|
|
|
+ NoteTextBox.Text = param.Content;
|
|
|
+ SetFontSize(param.FontSize);
|
|
|
+ SetFontStyle(param.IsBold,param.IsItalic);
|
|
|
+ SetFontName(param.FontName);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetFontName(string fontName)
|
|
|
+ {
|
|
|
+ foreach (ComboBoxItem item in FontCombox.Items)
|
|
|
+ {
|
|
|
+ if (item.Content.ToString() == fontName)
|
|
|
+ {
|
|
|
+ FontCombox.SelectedItem = item;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public void SetFontStyle(bool isBold, bool isItalic)
|
|
|
{
|
|
@@ -263,30 +261,76 @@ namespace Compdfkit_Tools.Measure.Property
|
|
|
|
|
|
private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.Thickness, CPDFThicknessControl.Thickness);
|
|
|
- //LineEvent?.UpdateAnnot();
|
|
|
+ if (IsLoadedData)
|
|
|
+ {
|
|
|
+ if (Annotation != null && ViewControl != null)
|
|
|
+ {
|
|
|
+ Annotation.SetLineWidth(CPDFThicknessControl.Thickness);
|
|
|
+ Annotation.UpdateAp();
|
|
|
+ ViewControl.UpdateAnnotFrame();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.LineStyle, CPDFLineStyleControl.DashStyle);
|
|
|
- //LineEvent?.UpdateAnnot();
|
|
|
+ if (!IsLoadedData) return;
|
|
|
+ if (Annotation != null && ViewControl != 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<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;
|
|
|
+ }
|
|
|
+ Annotation.SetBorderStyle(borderStyle, dashArray);
|
|
|
+ Annotation.UpdateAp();
|
|
|
+ ViewControl.UpdateAnnotFrame();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void CPDFArrowControl_ArrowChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.LineStart, CPDFArrowControl.LineType.HeadLineType);
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.LineEnd, CPDFArrowControl.LineType.TailLineType);
|
|
|
- //LineEvent?.UpdateAnnot();
|
|
|
+ if (!IsLoadedData) return;
|
|
|
+ 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();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void FontColorPickerControl_ColorChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
+ if (!IsLoadedData) return;
|
|
|
SolidColorBrush checkBrush = FontColorPickerControl.GetBrush() as SolidColorBrush;
|
|
|
- if (checkBrush != null)
|
|
|
+ if (checkBrush != null && Annotation != null && ViewControl != null)
|
|
|
{
|
|
|
- //LineEvent?.UpdateAttrib(AnnotAttrib.FontColor, checkBrush.Color);
|
|
|
- //LineEvent?.UpdateAnnot();
|
|
|
+ byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
|
|
|
+ if (Annotation != null)
|
|
|
+ {
|
|
|
+ CTextAttribute textAttribute = Annotation.GetTextAttribute();
|
|
|
+ textAttribute.FontColor = color;
|
|
|
+ Annotation.SetTextAttribute(textAttribute);
|
|
|
+ Annotation.UpdateAp();
|
|
|
+ ViewControl.UpdateAnnotFrame();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|