123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using compdfkit_tools.Data;
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer.PdfViewer;
- 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>
- /// CPDFMarkupUI.xaml 的交互逻辑
- /// </summary>
- public partial class CPDFMarkupUI : UserControl
- {
- private AnnotationType currentAnnotationType;
- public event EventHandler<CPDFAnnotationData> PropertyChanged;
- public CPDFMarkupUI()
- {
- InitializeComponent();
- ColorPickerControl.ColorChanged += ColorPickerControl_ColorChanged;
- CPDFOpacityControl.OpacityChanged += CPDFOpacityControl_OpacityChanged;
- }
- private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
- {
- PropertyChanged?.Invoke(this, GetMarkupData());
- }
- private void ColorPickerControl_ColorChanged(object sender, EventArgs e)
- {
- PropertyChanged?.Invoke(this, GetMarkupData());
- }
- private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
- {
- PropertyChanged?.Invoke(this, GetMarkupData());
- }
- public CPDFMarkupData GetMarkupData()
- {
- CPDFMarkupData pdfMarkupData = new CPDFMarkupData();
- pdfMarkupData.AnnotationType = currentAnnotationType;
- pdfMarkupData.Color = ((SolidColorBrush)ColorPickerControl.Brush).Color;
- pdfMarkupData.Opacity = CPDFOpacityControl.OpacityValue / 100.0;
- pdfMarkupData.Note = NoteTextBox.Text;
- return pdfMarkupData;
- }
- public void InitWithAnnotationType(AnnotationType annotationType)
- {
- switch (annotationType)
- {
- case AnnotationType.Highlight:
- TitleTextBlock.Text = "Highlight";
- break;
- case AnnotationType.Underline:
- TitleTextBlock.Text = "Underline";
- break;
- case AnnotationType.Strikeout:
- TitleTextBlock.Text = "Strikeout";
- break;
- case AnnotationType.Squiggly:
- TitleTextBlock.Text = "Squiggly";
- break;
- default:
- throw new ArgumentException("Not Excepted Argument");
- }
- currentAnnotationType = annotationType;
- }
- }
- }
|