12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using Compdfkit_Tools.Common;
- using Compdfkit_Tools.Data;
- using ComPDFKitViewer.AnnotEvent;
- 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 AnnotAttribEvent annotAttribEvent { get;private set; }
- public CPDFNoteUI()
- {
- InitializeComponent();
- ColorPickerControl.ColorChanged += ColorPickerControl_ColorChanged;
- CPDFAnnotationPreviewerControl.DrawNotePreview(GetNoteData());
- ColorPickerControl.SetCheckedForColor(GetNoteData().BorderColor);
- }
- private void ColorPickerControl_ColorChanged(object sender, EventArgs e)
- {
- if (annotAttribEvent == null)
- {
- PropertyChanged?.Invoke(this, GetNoteData());
- }
- else
- {
- annotAttribEvent.UpdateAttrib(AnnotAttrib.Color, ((SolidColorBrush)ColorPickerControl.Brush).Color);
- annotAttribEvent.UpdateAnnot();
- }
- CPDFAnnotationPreviewerControl.DrawNotePreview(GetNoteData());
- }
- private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
- {
- if (annotAttribEvent == null)
- {
- PropertyChanged?.Invoke(this, GetNoteData());
- }
- else
- {
- annotAttribEvent.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
- annotAttribEvent.UpdateAnnot();
- }
- }
- public void SetPresentAnnotAttrib(AnnotAttribEvent annotAttribEvent)
- {
- this.annotAttribEvent = null;
- NoteTextBox.Text = (string)annotAttribEvent.Attribs[AnnotAttrib.NoteText];
- this.annotAttribEvent = annotAttribEvent;
- if (annotAttribEvent.Attribs != null && annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.Color))
- {
- ColorPickerControl.Loaded += ColorPickerControl_Loaded;
- }
- }
- private void ColorPickerControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
- {
- ColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
- ColorPickerControl.Loaded -= ColorPickerControl_Loaded;
- }
- public CPDFNoteData GetNoteData()
- {
- CPDFNoteData pdfNoteData = new CPDFNoteData();
- pdfNoteData.AnnotationType = CPDFAnnotationType.Note;
- pdfNoteData.BorderColor = ((SolidColorBrush)ColorPickerControl.Brush).Color;
- pdfNoteData.Note = NoteTextBox.Text;
- return pdfNoteData;
- }
- }
- }
|