using ComPDFKit.PDFAnnotation; using ComPDFKit.PDFAnnotation.Form; using ComPDFKit.PDFDocument; using ComPDFKit.Tool; using ComPDFKit.Tool.Help; using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace Compdfkit_Tools.PDFControl { public partial class CheckBoxProperty : UserControl { private CheckBoxParam widgetParam = null; private CPDFCheckBoxWidget cPDFAnnotation = null; private PDFViewControl pdfViewerControl = null; private CPDFDocument cPDFDocument = null; bool IsLoadedData = false; public CheckBoxProperty() { InitializeComponent(); } #region Loaded public void SetProperty(AnnotParam annotParam, CPDFAnnotation annotation, CPDFDocument doc, PDFViewControl cPDFViewer) { widgetParam = (CheckBoxParam)annotParam; cPDFAnnotation = (CPDFCheckBoxWidget)annotation; pdfViewerControl = cPDFViewer; cPDFDocument = doc; } private void UserControl_Loaded(object sender, RoutedEventArgs e) { FieldNameText.Text = widgetParam.FieldName; FormFieldCombox.SelectedIndex = (int)ParamConverter.ConverterWidgetFormFlags(widgetParam.Flags, widgetParam.IsHidden); BorderColorPickerControl.SetCheckedForColor(ParamConverter.ConverterByteForColor(widgetParam.LineColor)); BackgroundColorPickerControl.SetCheckedForColor(ParamConverter.ConverterByteForColor(widgetParam.BgColor)); CheckButtonStyleCombox.SelectedIndex = (int)widgetParam.CheckStyle; chkSelected.IsChecked = widgetParam.IsChecked; IsLoadedData = true; } private void UserControl_Unloaded(object sender, RoutedEventArgs e) { IsLoadedData = false; } #endregion private void FieldNameText_TextChanged(object sender, TextChangedEventArgs e) { if (IsLoadedData) { cPDFAnnotation.SetFieldName((sender as TextBox).Text); pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame(); } } private void FormFieldCombox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (IsLoadedData) { cPDFAnnotation.SetFlags( ParamConverter.GetFormFlags((ParamConverter.FormField)(sender as ComboBox).SelectedIndex, cPDFAnnotation)); pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame(); } } private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e) { if (IsLoadedData) { byte[] Color = new byte[3]; Color[0] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.R; Color[1] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.G; Color[2] = ((SolidColorBrush)BorderColorPickerControl.Brush).Color.B; cPDFAnnotation.SetWidgetBorderRGBColor(Color); pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame(); } } private void BackgroundColorPickerControl_ColorChanged(object sender, EventArgs e) { if (IsLoadedData) { byte[] Color = new byte[3]; Color[0] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.R; Color[1] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.G; Color[2] = ((SolidColorBrush)BackgroundColorPickerControl.Brush).Color.B; cPDFAnnotation.SetWidgetBgRGBColor(Color); pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame(); } } private void CheckButtonStyleCombox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (IsLoadedData) { cPDFAnnotation.SetWidgetCheckStyle((C_CHECK_STYLE)(sender as ComboBox).SelectedIndex); pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame(); } } private void chkSelected_Checked(object sender, RoutedEventArgs e) { if (IsLoadedData) { cPDFAnnotation.SetChecked(true); pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame(); } } private void chkSelected_Unchecked(object sender, RoutedEventArgs e) { if (IsLoadedData) { cPDFAnnotation.SetChecked(false); pdfViewerControl.PDFViewTool.GetCPDFViewer().UpDateAnnotFrame(); } } } }