123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using ComPDFKit.PDFAnnotation;
- using ComPDFKit.Tool;
- using Compdfkit_Tools.Common;
- using Compdfkit_Tools.Data;
- using Compdfkit_Tools.PDFControl;
- using ComPDFKitViewer;
- using System;
- using System.Windows.Controls;
- using System.Windows.Media;
- namespace Compdfkit_Tools.PDFControlUI
- {
- public partial class CPDFNoteUI : UserControl
- {
- public event EventHandler<CPDFAnnotationData> PropertyChanged;
- internal StickyNoteParam stickyParam { get;private set; }
- private CPDFTextAnnotation textAnnot;
- private PDFViewControl viewControl;
- public CPDFNoteUI()
- {
- InitializeComponent();
- ColorPickerControl.ColorChanged += ColorPickerControl_ColorChanged;
- CPDFAnnotationPreviewerControl.DrawNotePreview(GetNoteData());
- }
- private void ColorPickerControl_ColorChanged(object sender, EventArgs e)
- {
- if (stickyParam == null)
- {
- PropertyChanged?.Invoke(this, GetNoteData());
- }
- else
- {
- SolidColorBrush colorBrush= ColorPickerControl.Brush as SolidColorBrush;
- if (textAnnot!=null && textAnnot.IsValid() && colorBrush!=null)
- {
- textAnnot.SetColor(new byte[3]
- {
- colorBrush.Color.R,
- colorBrush.Color.G,
- colorBrush.Color.B
- });
- if (viewControl != null && viewControl.PDFViewTool != null)
- {
- CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
- pdfViewer?.UpDateAnnotFrame();
- }
- }
- }
- CPDFAnnotationPreviewerControl.DrawNotePreview(GetNoteData());
- }
- private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
- {
- if (stickyParam == null)
- {
- PropertyChanged?.Invoke(this, GetNoteData());
- }
- else
- {
- if (textAnnot != null && textAnnot.IsValid())
- {
- textAnnot.SetContent(NoteTextBox.Text);
- if (viewControl != null && viewControl.PDFViewTool != null)
- {
- CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
- pdfViewer?.UpDateAnnotFrame();
- }
- }
- }
- }
- public void SetPresentAnnotAttrib(StickyNoteParam param,CPDFTextAnnotation annot,PDFViewControl view)
- {
- this.stickyParam = null;
- this.viewControl = null;
- this.textAnnot = null;
- if(param != null)
- {
- ColorPickerControl.Brush = new SolidColorBrush(Color.FromRgb(
- param.StickyNoteColor[0],
- param.StickyNoteColor[1],
- param.StickyNoteColor[2]));
- NoteTextBox.Text = param.Content;
- ColorPickerControl.SetCheckedForColor(Color.FromRgb(
- param.StickyNoteColor[0],
- param.StickyNoteColor[1],
- param.StickyNoteColor[2]));
- }
-
- this.stickyParam = param;
- this.textAnnot=annot;
- this.viewControl = view;
- }
- public CPDFNoteData GetNoteData()
- {
- CPDFNoteData pdfNoteData = new CPDFNoteData();
- pdfNoteData.AnnotationType = CPDFAnnotationType.Note;
- pdfNoteData.BorderColor = ((SolidColorBrush)ColorPickerControl.Brush).Color;
- pdfNoteData.Note = NoteTextBox.Text;
- return pdfNoteData;
- }
- }
- }
|