1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using compdfkit_tools.Common;
- using compdfkit_tools.Data;
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace compdfkit_tools.PDFControlUI
- {
- /// <summary>
- /// CPDFNoteUI.xaml 的交互逻辑
- /// </summary>
- 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());
- }
- 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;
- ColorPickerControl.Brush = new SolidColorBrush((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
- NoteTextBox.Text = (string)annotAttribEvent.Attribs[AnnotAttrib.NoteText];
- this.annotAttribEvent = annotAttribEvent;
- if (annotAttribEvent.Attribs != null && annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.Color))
- {
- ColorPickerControl.SetCheckedForColor((Color)annotAttribEvent.Attribs[AnnotAttrib.Color]);
- }
- }
- public CPDFNoteData GetNoteData()
- {
- CPDFNoteData pdfNoteData = new CPDFNoteData();
- pdfNoteData.AnnotationType = CPDFAnnotationType.Note;
- pdfNoteData.BorderColor = ((SolidColorBrush)ColorPickerControl.Brush).Color;
- pdfNoteData.Note = NoteTextBox.Text;
- return pdfNoteData;
- }
- }
- }
|