CPDFUnderlineViewController.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // CPDFUnderlineViewController.m
  3. // ComPDFKit_Tools
  4. //
  5. // Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
  6. //
  7. // THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  8. // AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  9. // UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  10. // This notice may not be removed from this file.
  11. //
  12. #import "CPDFUnderlineViewController.h"
  13. #import "CPDFAnnotationBaseViewController_Header.h"
  14. @interface CPDFUnderlineViewController ()
  15. @end
  16. @implementation CPDFUnderlineViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. // Do any additional setup after loading the view.
  20. }
  21. - (void)commomInitTitle {
  22. self.titleLabel.text = NSLocalizedString(@"Underline", nil);
  23. self.sampleView.selecIndex = CPDFSamplesUnderline;
  24. self.colorView.selectedColor = self.annotStyle.color;
  25. }
  26. - (void)commomInitFromAnnotStyle {
  27. self.sampleView.color = self.annotStyle.color;
  28. self.sampleView.opcity = self.annotStyle.opacity;
  29. self.opacitySliderView.opacitySlider.value = self.annotStyle.opacity;
  30. self.opacitySliderView.startLabel.text = [NSString stringWithFormat:@"%d%%", (int)((self.opacitySliderView.opacitySlider.value/1)*100)];
  31. [self.sampleView setNeedsDisplay];
  32. }
  33. #pragma mark - CPDFColorSelectViewDelegate
  34. - (void)selectColorView:(CPDFColorSelectView *)select color:(UIColor *)color {
  35. self.sampleView.color = color;
  36. self.annotStyle.color = color;
  37. if (self.delegate && [self.delegate respondsToSelector:@selector(underlineViewController:annotStyle:)]) {
  38. [self.delegate underlineViewController:self annotStyle:self.annotStyle];
  39. }
  40. [self.sampleView setNeedsDisplay];
  41. }
  42. #pragma mark - CPDFColorPickerViewDelegate
  43. - (void)pickerView:(CPDFColorPickerView *)colorPickerView color:(UIColor *)color {
  44. self.sampleView.color = color;
  45. self.annotStyle.color = color;
  46. if (self.delegate && [self.delegate respondsToSelector:@selector(underlineViewController:annotStyle:)]) {
  47. [self.delegate underlineViewController:self annotStyle:self.annotStyle];
  48. }
  49. [self.sampleView setNeedsDisplay];
  50. CGFloat red, green, blue, alpha;
  51. [color getRed:&red green:&green blue:&blue alpha:&alpha];
  52. self.opacitySliderView.opacitySlider.value = alpha;
  53. self.opacitySliderView.startLabel.text = [NSString stringWithFormat:@"%d%%", (int)((self.opacitySliderView.opacitySlider.value/1)*100)];
  54. [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
  55. }
  56. #pragma mark - CPDFOpacitySliderViewDelegate
  57. - (void)opacitySliderView:(CPDFOpacitySliderView *)opacitySliderView opacity:(CGFloat)opacity {
  58. self.sampleView.opcity = opacity;
  59. self.annotStyle.opacity = opacity;
  60. if (self.delegate && [self.delegate respondsToSelector:@selector(underlineViewController:annotStyle:)]) {
  61. [self.delegate underlineViewController:self annotStyle:self.annotStyle];
  62. }
  63. [self.sampleView setNeedsDisplay];
  64. }
  65. #pragma mark - UIColorPickerViewControllerDelegate
  66. - (void)colorPickerViewControllerDidFinish:(UIColorPickerViewController *)viewController API_AVAILABLE(ios(14.0)) {
  67. self.sampleView.color = viewController.selectedColor;
  68. self.annotStyle.color = self.sampleView.color;
  69. if (self.delegate && [self.delegate respondsToSelector:@selector(underlineViewController:annotStyle:)]) {
  70. [self.delegate underlineViewController:self annotStyle:self.annotStyle];
  71. }
  72. [self.sampleView setNeedsDisplay];
  73. CGFloat red, green, blue, alpha;
  74. [viewController.selectedColor getRed:&red green:&green blue:&blue alpha:&alpha];
  75. self.opacitySliderView.opacitySlider.value = alpha;
  76. self.opacitySliderView.startLabel.text = [NSString stringWithFormat:@"%d%%", (int)((self.opacitySliderView.opacitySlider.value/1)*100)];
  77. }
  78. @end