CPDFStrikeoutViewController.m 3.8 KB

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