KMRectangleController.swift 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. //
  2. // KMRectangleController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2024/11/26.
  6. //
  7. import Cocoa
  8. import KMComponentLibrary
  9. class KMRectangleController: NSViewController {
  10. //Color
  11. @IBOutlet var colorBGView: NSView!
  12. @IBOutlet var colorLabel: NSTextField!
  13. @IBOutlet var colorGroup: ComponentCColorGroup!
  14. @IBOutlet var colorSlider: ComponentSlider!
  15. @IBOutlet var colorOpacitySelect: ComponentSelect!
  16. @IBOutlet var fillColorGroup: ComponentCColorGroup!
  17. //Line
  18. @IBOutlet var lineBGView: NSView!
  19. @IBOutlet var lineLabel: NSTextField!
  20. @IBOutlet var lineTypeSelector: ComponentCSelectorGroup!
  21. @IBOutlet var lineWidthSlider: ComponentSlider!
  22. @IBOutlet var lineWidthSelect: ComponentSelect!
  23. @IBOutlet var linedashInfoView: NSView!
  24. @IBOutlet var lineDashSlider: ComponentSlider!
  25. @IBOutlet var lineDashSelect: ComponentSelect!
  26. private let solidProperty = ComponentCSelectorProperty.init(size: .s, state: .normal, text: "", iconImage: NSImage(named: "lineStyle_solid"))
  27. private let dashProperty = ComponentCSelectorProperty.init(size: .s, state: .normal, text: "", iconImage: NSImage(named: "lineStyle_dash"))
  28. private var annotations: [CPDFAnnotation] = [] //CPDFCircleAnnotation, CPDFSquareAnnotation
  29. var pdfView: CPDFListView?
  30. //MARK: - func
  31. override func viewDidAppear() {
  32. super.viewDidAppear()
  33. colorSlider.reloadData()
  34. lineWidthSlider.reloadData()
  35. lineDashSlider.reloadData()
  36. }
  37. override func viewDidLoad() {
  38. super.viewDidLoad()
  39. // Do view setup here.
  40. setupProperty()
  41. }
  42. func setupProperty() {
  43. //Color
  44. colorLabel.stringValue = KMLocalizedString("Color")
  45. colorLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
  46. colorLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
  47. if true {
  48. let colorAProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMPDFWatermarkData.watermarkDefaultColors()[0])
  49. let colorBProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMPDFWatermarkData.watermarkDefaultColors()[1])
  50. let colorCProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMPDFWatermarkData.watermarkDefaultColors()[2])
  51. let colorDProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMPDFWatermarkData.watermarkDefaultColors()[3])
  52. let colorEProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: true, color: KMPDFWatermarkData.watermarkDefaultColors()[4])
  53. colorGroup.setUpWithColorPropertys([colorAProperty, colorBProperty, colorCProperty, colorDProperty], customItemProperty: colorEProperty)
  54. colorGroup.delegate = self
  55. }
  56. if true {
  57. let colorAProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMPDFWatermarkData.watermarkDefaultColors()[0])
  58. let colorBProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMPDFWatermarkData.watermarkDefaultColors()[1])
  59. let colorCProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMPDFWatermarkData.watermarkDefaultColors()[2])
  60. let colorDProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMPDFWatermarkData.watermarkDefaultColors()[3])
  61. let colorEProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: true, color: KMPDFWatermarkData.watermarkDefaultColors()[4])
  62. fillColorGroup.setUpWithColorPropertys([colorAProperty, colorBProperty, colorCProperty, colorDProperty], customItemProperty: colorEProperty)
  63. fillColorGroup.delegate = self
  64. }
  65. colorSlider.properties = ComponentSliderProperty(size: .m, percent: 1)
  66. colorSlider.delegate = self
  67. colorOpacitySelect.properties = ComponentSelectProperties(size: .s,
  68. state: .normal,
  69. creatable: true,
  70. text: "100%",
  71. textUnit: "%",
  72. regexString: "0123456789%")
  73. if true {
  74. var opacityItems: [ComponentMenuitemProperty] = []
  75. for string in ["25%", "50%", "75%", "100%"] {
  76. let item = ComponentMenuitemProperty(type: .normal, text: string)
  77. opacityItems.append(item)
  78. }
  79. colorOpacitySelect.updateMenuItemsArr(opacityItems)
  80. }
  81. colorOpacitySelect.delegate = self
  82. //Line
  83. lineLabel.stringValue = KMLocalizedString("Line")
  84. lineLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
  85. lineLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
  86. lineTypeSelector.updateItemProperty([solidProperty, dashProperty])
  87. lineTypeSelector.delegate = self
  88. lineWidthSlider.properties = ComponentSliderProperty(size: .m, percent: 1)
  89. lineWidthSlider.delegate = self
  90. lineWidthSelect.properties = ComponentSelectProperties(size: .s,
  91. state: .normal,
  92. creatable: true,
  93. text: "2",
  94. textUnit: " pt",
  95. regexString: "0123456789 pt")
  96. if true {
  97. var opacityItems: [ComponentMenuitemProperty] = []
  98. for string in ["1 pt", "3 pt", "6 pt", "9 pt", "12 pt", "15 pt", "18 pt"] {
  99. let item = ComponentMenuitemProperty(type: .normal, text: string)
  100. opacityItems.append(item)
  101. }
  102. lineWidthSelect.updateMenuItemsArr(opacityItems)
  103. }
  104. lineWidthSelect.delegate = self
  105. lineDashSlider.properties = ComponentSliderProperty(size: .m, percent: 1)
  106. lineDashSlider.delegate = self
  107. lineDashSelect.properties = ComponentSelectProperties(size: .s,
  108. state: .normal,
  109. creatable: true,
  110. text: "2",
  111. textUnit: " pt",
  112. regexString: "0123456789 pt")
  113. if true {
  114. var opacityItems: [ComponentMenuitemProperty] = []
  115. for string in ["1 pt", "3 pt", "6 pt", "9 pt", "12 pt", "15 pt", "18 pt"] {
  116. let item = ComponentMenuitemProperty(type: .normal, text: string)
  117. opacityItems.append(item)
  118. }
  119. lineDashSelect.updateMenuItemsArr(opacityItems)
  120. }
  121. lineDashSelect.delegate = self
  122. }
  123. func reloadData() {
  124. guard let pdfView = self.pdfView else {
  125. return
  126. }
  127. self.annotations.removeAll()
  128. let allAnnotations: [CPDFAnnotation] = pdfView.activeAnnotations as? [CPDFAnnotation] ?? []
  129. for annotation in allAnnotations {
  130. if annotation is CPDFCircleAnnotation {
  131. annotations.append((annotation as! CPDFCircleAnnotation))
  132. } else if annotation is CPDFSquareAnnotation {
  133. annotations.append((annotation as! CPDFSquareAnnotation))
  134. }
  135. }
  136. if annotations.count == 0 {
  137. return
  138. }
  139. guard let firstAnnotation = annotations.first else {
  140. return
  141. }
  142. if annotations.count == 1 {
  143. colorGroup.currentColor = firstAnnotation.color
  144. colorGroup.refreshUI()
  145. if firstAnnotation is CPDFCircleAnnotation {
  146. fillColorGroup.currentColor = (firstAnnotation as! CPDFCircleAnnotation).interiorColor
  147. } else if firstAnnotation is CPDFSquareAnnotation {
  148. fillColorGroup.currentColor = (firstAnnotation as! CPDFSquareAnnotation).interiorColor
  149. }
  150. fillColorGroup.refreshUI()
  151. let opacity = firstAnnotation.opacity
  152. colorSlider.properties.percent = opacity
  153. colorSlider.reloadData()
  154. colorOpacitySelect.properties.text = String(format: "%.0f%@", opacity*100, "%")
  155. colorOpacitySelect.reloadData()
  156. let border: CPDFBorder = firstAnnotation.border
  157. dashProperty.state = .normal
  158. solidProperty.state = .normal
  159. if border.style == .dashed {
  160. dashProperty.state = .pressed
  161. } else if border.style == .solid {
  162. solidProperty.state = .pressed
  163. }
  164. lineTypeSelector.reloadData()
  165. let percent = (border.lineWidth - 1)/17
  166. lineWidthSlider.properties.percent = percent
  167. lineWidthSlider.reloadData()
  168. lineWidthSelect.properties.text = String(format: "%.0f%@", border.lineWidth, " pt")
  169. lineWidthSelect.reloadData()
  170. linedashInfoView.isHidden = true
  171. if border.style == .dashed {
  172. linedashInfoView.isHidden = false
  173. var dash = 1.0
  174. for dashPattern in border.dashPattern {
  175. if let value = dashPattern as? CGFloat {
  176. dash = value
  177. break
  178. }
  179. }
  180. let percent: CGFloat = (CGFloat(dash) - 1)/17
  181. lineDashSlider.properties.percent = percent
  182. lineDashSlider.reloadData()
  183. lineDashSelect.properties.text = String(format: "%.0f%@", CGFloat(dash), " pt")
  184. lineDashSelect.reloadData()
  185. }
  186. } else {
  187. // if true {
  188. // var multiColor: Bool = false
  189. // for annotationA in annotations {
  190. // for annotationB in annotations {
  191. // if annotationA != annotationB {
  192. // if annotationA.color != annotationB.color {
  193. // multiColor = true
  194. // break
  195. // }
  196. // }
  197. // }
  198. // if multiColor == true {
  199. // break
  200. // }
  201. // }
  202. // if multiColor == true {
  203. // colorGroup.currentColor = NSColor.clear
  204. // } else {
  205. // colorGroup.currentColor = firstAnnotation.color
  206. // }
  207. // colorGroup.refreshUI()
  208. // }
  209. //
  210. // if true {
  211. // var multiOpacity: Bool = false
  212. // for annotationA in annotations {
  213. // for annotationB in annotations {
  214. // if annotationA != annotationB {
  215. // if annotationA.opacity != annotationB.opacity {
  216. // multiOpacity = true
  217. // break
  218. // }
  219. // }
  220. // }
  221. // if multiOpacity == true {
  222. // break
  223. // }
  224. // }
  225. //
  226. // if multiOpacity {
  227. // colorSlider.properties.percent = 0
  228. // colorSlider.reloadData()
  229. //
  230. // colorOpacitySelect.resetText("-")
  231. // } else {
  232. // let opacity = firstAnnotation.opacity
  233. //
  234. // colorSlider.properties.percent = opacity
  235. // colorSlider.reloadData()
  236. //
  237. // colorOpacitySelect.properties.text = String(format: "%.0f%@", opacity*100, "%")
  238. // colorOpacitySelect.reloadData()
  239. // }
  240. // }
  241. //
  242. // if true {
  243. // var multiStyle: Bool = false
  244. // for annotationA in annotations {
  245. // for annotationB in annotations {
  246. // if annotationA != annotationB {
  247. // if annotationA.borderStyle() != annotationB.borderStyle() {
  248. // multiStyle = true
  249. // break
  250. // }
  251. // }
  252. // }
  253. // if multiStyle == true {
  254. // break
  255. // }
  256. // }
  257. //
  258. // linedashInfoView.isHidden = true
  259. // if multiStyle {
  260. // dashProperty.state = .normal
  261. // solidProperty.state = .normal
  262. //
  263. // lineTypeSelector.reloadData()
  264. // } else {
  265. // let style = firstAnnotation.border.style
  266. // dashProperty.state = .normal
  267. // solidProperty.state = .normal
  268. // if style == .dashed {
  269. // dashProperty.state = .pressed
  270. // } else if style == .solid {
  271. // solidProperty.state = .pressed
  272. // }
  273. // lineTypeSelector.reloadData()
  274. //
  275. // if style == .dashed {
  276. // linedashInfoView.isHidden = false
  277. // }
  278. // }
  279. // }
  280. //
  281. // if true {
  282. // var multiLineWidth: Bool = false
  283. // for annotationA in annotations {
  284. // for annotationB in annotations {
  285. // if annotationA != annotationB {
  286. // if annotationA.borderStyle() != annotationB.borderStyle() {
  287. // multiLineWidth = true
  288. // break
  289. // }
  290. // }
  291. // }
  292. // if multiLineWidth == true {
  293. // break
  294. // }
  295. // }
  296. // if multiLineWidth {
  297. // lineWidthSlider.properties.percent = 0
  298. // lineWidthSlider.reloadData()
  299. //
  300. // lineWidthSelect.resetText("-")
  301. // } else {
  302. // let border: CPDFBorder = firstAnnotation.border
  303. //
  304. // let percent = (border.lineWidth - 1)/17
  305. // lineWidthSlider.properties.percent = percent
  306. // lineWidthSlider.reloadData()
  307. //
  308. // lineWidthSelect.properties.text = String(format: "%.0f%@", border.lineWidth, " pt")
  309. // lineWidthSelect.reloadData()
  310. // }
  311. // }
  312. //
  313. // if true {
  314. // var multiLineDash: Bool = false
  315. // for annotationA in annotations {
  316. // var dashA = 1.0
  317. // for dashPattern in annotationA.border.dashPattern {
  318. // if let value = dashPattern as? CGFloat {
  319. // dashA = value
  320. // break
  321. // }
  322. // }
  323. // for annotationB in annotations {
  324. // if annotationA != annotationB {
  325. // var dashB = 1.0
  326. // for dashPattern in annotationB.border.dashPattern {
  327. // if let value = dashPattern as? CGFloat {
  328. // dashB = value
  329. // break
  330. // }
  331. // }
  332. // if dashA != dashB {
  333. // multiLineDash = true
  334. // break
  335. // }
  336. // }
  337. // }
  338. // if multiLineDash == true {
  339. // break
  340. // }
  341. // }
  342. // if multiLineDash {
  343. // lineDashSlider.properties.percent = 0
  344. // lineDashSlider.reloadData()
  345. //
  346. // lineDashSelect.resetText("-")
  347. // } else {
  348. // var dashA = 1.0
  349. // for dashPattern in firstAnnotation.border.dashPattern {
  350. // if let value = dashPattern as? CGFloat {
  351. // dashA = value
  352. // break
  353. // }
  354. // }
  355. //
  356. // let percent = (dashA - 1)/17
  357. // lineDashSlider.properties.percent = percent
  358. // lineDashSlider.reloadData()
  359. //
  360. // lineDashSelect.properties.text = String(format: "%.0f%@", dashA, " pt")
  361. // lineDashSelect.reloadData()
  362. // }
  363. // }
  364. }
  365. }
  366. //MARK: - Mouse
  367. override func mouseDown(with event: NSEvent) {
  368. super.mouseDown(with: event)
  369. view.window?.makeFirstResponder(nil)
  370. }
  371. }
  372. //MARK: - ComponentCColorDelegate
  373. extension KMRectangleController: ComponentCColorDelegate {
  374. func componentCColorDidChooseColor(_ view: NSView, _ color: NSColor?) {
  375. if view == colorGroup {
  376. for annotation in self.annotations {
  377. if annotation is CPDFCircleAnnotation {
  378. (annotation as! CPDFCircleAnnotation).updateColor(color, withPDFView: pdfView)
  379. } else if annotation is CPDFSquareAnnotation {
  380. (annotation as! CPDFSquareAnnotation).updateColor(color, withPDFView: pdfView)
  381. }
  382. }
  383. } else if view == fillColorGroup {
  384. for annotation in self.annotations {
  385. if annotation is CPDFCircleAnnotation {
  386. (annotation as! CPDFCircleAnnotation).updateInteriorColor(color, withPDFView: pdfView)
  387. } else if annotation is CPDFSquareAnnotation {
  388. (annotation as! CPDFSquareAnnotation).updateInteriorColor(color, withPDFView: pdfView)
  389. }
  390. }
  391. }
  392. reloadData()
  393. }
  394. }
  395. //MARK: - ComponentSliderDelegate
  396. extension KMRectangleController: ComponentSliderDelegate {
  397. func componentSliderDidUpdate(_ view: ComponentSlider) {
  398. if view == colorSlider {
  399. let percent = view.properties.percent
  400. for annotation in self.annotations {
  401. if annotation is CPDFCircleAnnotation {
  402. (annotation as! CPDFCircleAnnotation).updateOpacity(percent, withPDFView: pdfView)
  403. } else if annotation is CPDFSquareAnnotation {
  404. (annotation as! CPDFSquareAnnotation).updateOpacity(percent, withPDFView: pdfView)
  405. }
  406. }
  407. } else if view == lineWidthSlider {
  408. let percent = view.properties.percent * 17 + 1
  409. for annotation in self.annotations {
  410. if annotation is CPDFCircleAnnotation {
  411. (annotation as! CPDFCircleAnnotation).updateLineWidth(percent, withPDFView: pdfView)
  412. } else if annotation is CPDFSquareAnnotation {
  413. (annotation as! CPDFSquareAnnotation).updateLineWidth(percent, withPDFView: pdfView)
  414. }
  415. }
  416. } else if view == lineDashSlider {
  417. let percent = view.properties.percent * 17 + 1
  418. for annotation in self.annotations {
  419. if annotation is CPDFCircleAnnotation {
  420. (annotation as! CPDFCircleAnnotation).updateDashPattern(percent, withPDFView: pdfView)
  421. } else if annotation is CPDFSquareAnnotation {
  422. (annotation as! CPDFSquareAnnotation).updateDashPattern(percent, withPDFView: pdfView)
  423. }
  424. }
  425. }
  426. reloadData()
  427. }
  428. }
  429. //MARK: - ComponentSelectDelegate
  430. extension KMRectangleController: ComponentSelectDelegate {
  431. func componentSelectTextDidEndEditing(_ view: ComponentSelect, removeUnit text: String?) {
  432. if let result = text {
  433. if view == colorOpacitySelect {
  434. let opacity = max(0, min(1, result.stringToCGFloat()/100))
  435. for annotation in self.annotations {
  436. if annotation is CPDFCircleAnnotation {
  437. (annotation as! CPDFCircleAnnotation).updateOpacity(opacity, withPDFView: pdfView)
  438. } else if annotation is CPDFSquareAnnotation {
  439. (annotation as! CPDFSquareAnnotation).updateOpacity(opacity, withPDFView: pdfView)
  440. }
  441. }
  442. } else if view == lineWidthSelect {
  443. var value = result.stringToCGFloat()
  444. if value > 18 {
  445. value = 18
  446. } else if value < 1 {
  447. value = 1
  448. }
  449. for annotation in self.annotations {
  450. if annotation is CPDFCircleAnnotation {
  451. (annotation as! CPDFCircleAnnotation).updateLineWidth(value, withPDFView: pdfView)
  452. } else if annotation is CPDFSquareAnnotation {
  453. (annotation as! CPDFSquareAnnotation).updateLineWidth(value, withPDFView: pdfView)
  454. }
  455. }
  456. } else if view == lineDashSelect {
  457. var value = result.stringToCGFloat()
  458. if value > 18 {
  459. value = 18
  460. } else if value < 1 {
  461. value = 1
  462. }
  463. for annotation in self.annotations {
  464. if annotation is CPDFCircleAnnotation {
  465. (annotation as! CPDFCircleAnnotation).updateDashPattern(value, withPDFView: pdfView)
  466. } else if annotation is CPDFSquareAnnotation {
  467. (annotation as! CPDFSquareAnnotation).updateDashPattern(value, withPDFView: pdfView)
  468. }
  469. }
  470. }
  471. reloadData()
  472. }
  473. }
  474. func componentSelectDidSelect(view: ComponentSelect?, menuItemProperty: ComponentMenuitemProperty?) {
  475. if var result = menuItemProperty?.text {
  476. if let textUnit = view?.properties.textUnit {
  477. result = result.stringByDeleteCharString(textUnit)
  478. }
  479. if view == colorOpacitySelect {
  480. let opacity = max(0, min(1, result.stringToCGFloat()/100))
  481. for annotation in self.annotations {
  482. if annotation is CPDFCircleAnnotation {
  483. (annotation as! CPDFCircleAnnotation).updateOpacity(opacity, withPDFView: pdfView)
  484. } else if annotation is CPDFSquareAnnotation {
  485. (annotation as! CPDFSquareAnnotation).updateOpacity(opacity, withPDFView: pdfView)
  486. }
  487. }
  488. } else if view == lineWidthSelect {
  489. var value = result.stringToCGFloat()
  490. if value > 18 {
  491. value = 18
  492. } else if value < 1 {
  493. value = 1
  494. }
  495. for annotation in self.annotations {
  496. if annotation is CPDFCircleAnnotation {
  497. (annotation as! CPDFCircleAnnotation).updateLineWidth(value, withPDFView: pdfView)
  498. } else if annotation is CPDFSquareAnnotation {
  499. (annotation as! CPDFSquareAnnotation).updateLineWidth(value, withPDFView: pdfView)
  500. }
  501. }
  502. } else if view == lineDashSelect {
  503. var value = result.stringToCGFloat()
  504. if value > 18 {
  505. value = 18
  506. } else if value < 1 {
  507. value = 1
  508. }
  509. for annotation in self.annotations {
  510. if annotation is CPDFCircleAnnotation {
  511. (annotation as! CPDFCircleAnnotation).updateDashPattern(value, withPDFView: pdfView)
  512. } else if annotation is CPDFSquareAnnotation {
  513. (annotation as! CPDFSquareAnnotation).updateDashPattern(value, withPDFView: pdfView)
  514. }
  515. }
  516. }
  517. reloadData()
  518. }
  519. }
  520. }
  521. //MARK: - ComponentCSelectorGroupDelegate
  522. extension KMRectangleController: ComponentCSelectorGroupDelegate {
  523. func componentCSelectorGroupDidChoose(_ view: ComponentCSelectorGroup, _ item: ComponentCSelectorItem) {
  524. if item.properties == solidProperty {
  525. for annotation in self.annotations {
  526. if annotation is CPDFCircleAnnotation {
  527. (annotation as! CPDFCircleAnnotation).updateStyle(.solid, withPDFView: pdfView)
  528. } else if annotation is CPDFSquareAnnotation {
  529. (annotation as! CPDFSquareAnnotation).updateStyle(.solid, withPDFView: pdfView)
  530. }
  531. }
  532. } else if item.properties == dashProperty {
  533. for annotation in self.annotations {
  534. if annotation is CPDFCircleAnnotation {
  535. (annotation as! CPDFCircleAnnotation).updateStyle(.dashed, withPDFView: pdfView)
  536. } else if annotation is CPDFSquareAnnotation {
  537. (annotation as! CPDFSquareAnnotation).updateStyle(.dashed, withPDFView: pdfView)
  538. }
  539. }
  540. }
  541. reloadData()
  542. }
  543. }