KMNAnnotationPopMode.swift 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. //
  2. // KMNAnnotationPopMode.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by 丁林圭 on 2024/12/1.
  6. //
  7. import Cocoa
  8. @objc public enum ListViewPopType: Int, CaseIterable{
  9. case generaAnnotation = 0
  10. case freeTextAnnotation
  11. case shapeAnnotation
  12. case linkAnnotation
  13. case formAnnotation
  14. case formRadioAnnotation
  15. case multpleAnnotation
  16. case popTypeNone
  17. }
  18. @objc public enum linkDetailType: Int, CaseIterable{
  19. case linkSetting
  20. case page
  21. case url
  22. case email
  23. }
  24. @objc public enum DetailPopType: Int, CaseIterable{
  25. case freeTextAlight = 0
  26. case contentEditAlight
  27. case freeTextDoubleAlight
  28. case doubleObjectAlight
  29. case freeTextMultpleAlight
  30. case multpleObjectAlight
  31. case detailNone
  32. }
  33. @objc public enum ObjectAlignType: Int, CaseIterable{
  34. case alightLeft = 0
  35. case alightRight
  36. case alightTop
  37. case alightVer
  38. case alightHor
  39. case alightBottom
  40. case averageVer
  41. case averageHor
  42. }
  43. @objc public enum ListViewDetailPopType: Int, CaseIterable{
  44. case textAlight = 0
  45. case alight
  46. }
  47. let changeValue:CGFloat = 1.0
  48. let maxLineValue:CGFloat = 18.0
  49. let minLineValue:CGFloat = 1.0
  50. class KMNAnnotationPopMode: NSObject {
  51. private(set) var annotation: CPDFAnnotation?
  52. private(set) var annotations: [CPDFAnnotation] = []
  53. private(set) var annotationType: CAnnotationType = CAnnotationType.unkown
  54. private(set) var popType: ListViewPopType = .popTypeNone
  55. init(pdfAnnotations: [CPDFAnnotation]) {
  56. super.init()
  57. if let firstAnnotation = pdfAnnotations.first {
  58. annotation = firstAnnotation
  59. }
  60. self.annotations = pdfAnnotations
  61. popType = self.annotationPopType()
  62. }
  63. private func annotationPopType()->ListViewPopType {
  64. let firstAnnotation:CPDFAnnotation = annotations.first ?? CPDFAnnotation.init()
  65. let type = annotationType(annotation: firstAnnotation)
  66. if annotations.count == 0 {
  67. return .popTypeNone
  68. } else if annotations.count == 1 {
  69. return type
  70. } else {
  71. var isSampleAnnotation = true
  72. for i in 1 ..< annotations.count {
  73. let annotation = annotations[i]
  74. if type != annotationType(annotation: annotation) {
  75. isSampleAnnotation = false
  76. break
  77. }
  78. }
  79. if(isSampleAnnotation) {
  80. return type
  81. } else {
  82. return .popTypeNone
  83. }
  84. }
  85. }
  86. public func annotationType(annotation:CPDFAnnotation)->ListViewPopType {
  87. if annotation.isKind(of: CPDFMarkupAnnotation.self) {
  88. return .generaAnnotation
  89. } else if annotation.isKind(of: CPDFFreeTextAnnotation.self) {
  90. return .freeTextAnnotation
  91. } else if (annotation.isKind(of: CPDFInkAnnotation.self) ||
  92. annotation.isKind(of: CPDFCircleAnnotation.self) ||
  93. annotation.isKind(of: CPDFSquareAnnotation.self) ||
  94. annotation.isKind(of: CPDFLineAnnotation.self) ||
  95. annotation.isKind(of: CPDFPolygonAnnotation.self) ||
  96. annotation.isKind(of: CPDFPolylineAnnotation.self) ||
  97. annotation.isKind(of: CSelfSignAnnotation.self)) {
  98. return .shapeAnnotation
  99. } else if annotation.isKind(of: CPDFLinkAnnotation.self) {
  100. if(annotations.count > 1) {
  101. return .multpleAnnotation
  102. } else {
  103. return .linkAnnotation
  104. }
  105. } else if annotation.isForm() {
  106. if(annotations.count > 1) {
  107. return .multpleAnnotation
  108. } else if(annotations.count == 1) {
  109. if(annotation.isKind(of: CPDFButtonWidgetAnnotation.self)) {
  110. let button = annotation as! CPDFButtonWidgetAnnotation
  111. if(button.controlType() == .radioButtonControl) {
  112. return .formRadioAnnotation
  113. }
  114. }
  115. return .formAnnotation
  116. }
  117. }
  118. return .popTypeNone
  119. }
  120. private func convertAnnotationType(firstAnnotation:CPDFAnnotation) -> CAnnotationType {
  121. var annotationType = CAnnotationType.unkown
  122. if firstAnnotation.isKind(of: CSelfSignAnnotationFreeText.self) {
  123. let freeText:CSelfSignAnnotationFreeText = firstAnnotation as! CSelfSignAnnotationFreeText
  124. annotationType = freeText.subType
  125. } else if firstAnnotation.isKind(of: CPDFPolygonAnnotation.self) {
  126. annotationType = CAnnotationType.measurePolyGon
  127. } else if firstAnnotation.isKind(of: CPDFPolylineAnnotation.self) {
  128. annotationType = CAnnotationType.measurePolyLine
  129. } else if firstAnnotation.isKind(of: CSelfSignAnnotation.self) {
  130. let selfSignAnnotation:CSelfSignAnnotation = firstAnnotation as! CSelfSignAnnotation
  131. annotationType = selfSignAnnotation.annotationType
  132. } else if firstAnnotation.isKind(of: CPDFFreeTextAnnotation.self) {
  133. annotationType = CAnnotationType.freeText
  134. } else if firstAnnotation.isKind(of: CPDFTextAnnotation.self) {
  135. annotationType = CAnnotationType.anchored
  136. } else if firstAnnotation.isKind(of: CPDFCircleAnnotation.self) {
  137. annotationType = CAnnotationType.circle
  138. } else if firstAnnotation.isKind(of: CPDFSquareAnnotation.self) {
  139. annotationType = CAnnotationType.square
  140. } else if firstAnnotation.isKind(of: CPDFMarkupAnnotation.self) {
  141. let markupAnnotation:CPDFMarkupAnnotation = firstAnnotation as! CPDFMarkupAnnotation
  142. let markupType = markupAnnotation.markupType()
  143. if markupType == .highlight {
  144. annotationType = CAnnotationType.highlight
  145. } else if(markupType == .strikeOut) {
  146. annotationType = CAnnotationType.strikeOut
  147. } else if(markupType == .underline) {
  148. annotationType = CAnnotationType.underline
  149. } else if(markupType == .squiggly) {
  150. annotationType = CAnnotationType.squiggly
  151. }
  152. } else if firstAnnotation.isKind(of: CPDFLineAnnotation.self) {
  153. let lineAnnotation:CPDFLineAnnotation = firstAnnotation as! CPDFLineAnnotation
  154. if lineAnnotation.isMeasure == true {
  155. annotationType = CAnnotationType.measureLine
  156. } else if lineAnnotation.isArrowLine() == true {
  157. annotationType = CAnnotationType.arrow
  158. } else {
  159. annotationType = CAnnotationType.line
  160. }
  161. } else if firstAnnotation.isKind(of: KMTableAnnotation.self) {
  162. annotationType = CAnnotationType.table
  163. } else if firstAnnotation.isKind(of: CPDFInkAnnotation.self) {
  164. annotationType = CAnnotationType.ink
  165. } else if firstAnnotation.isKind(of: CPDFLinkAnnotation.self) {
  166. annotationType = CAnnotationType.link
  167. } else if firstAnnotation.isKind(of: CPDFListSignatureAnnotation.self) {
  168. annotationType = CAnnotationType.signSignature
  169. } else if firstAnnotation.isKind(of: CPDFStampAnnotation.self) {
  170. annotationType = CAnnotationType.stamp
  171. } else if firstAnnotation.isKind(of: CPDFButtonWidgetAnnotation.self) {
  172. let buttonWidgetAnnotation:CPDFButtonWidgetAnnotation = firstAnnotation as! CPDFButtonWidgetAnnotation
  173. let controlType = buttonWidgetAnnotation.controlType()
  174. if controlType == .radioButtonControl {
  175. annotationType = CAnnotationType.radioButton
  176. } else if(controlType == .checkBoxControl) {
  177. annotationType = CAnnotationType.checkBox
  178. } else if(controlType == .pushButtonControl) {
  179. annotationType = CAnnotationType.actionButton
  180. }
  181. } else if firstAnnotation.isKind(of: CPDFTextWidgetAnnotation.self) {
  182. annotationType = CAnnotationType.textField
  183. } else if firstAnnotation.isKind(of: CPDFChoiceWidgetAnnotation.self) {
  184. annotationType = CAnnotationType.textField
  185. }
  186. else if firstAnnotation.isKind(of: CPDFChoiceWidgetAnnotation.self) {
  187. let choiceWidgetAnnotation:CPDFChoiceWidgetAnnotation = firstAnnotation as! CPDFChoiceWidgetAnnotation
  188. if(choiceWidgetAnnotation.isListChoice == true) {
  189. annotationType = CAnnotationType.listMenu
  190. } else {
  191. annotationType = CAnnotationType.comboBox
  192. }
  193. } else if firstAnnotation.isKind(of: CPDFSignatureWidgetAnnotation.self) {
  194. annotationType = CAnnotationType.signature
  195. }
  196. return annotationType
  197. }
  198. public func annotationColor()->NSColor? { //返回颜色是nil说明颜色不一样,返回透明则说明是没有颜色或者透明色
  199. var color:NSColor? = nil
  200. let isNotSameColor: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .color)
  201. if isNotSameColor == false {
  202. var anColor = annotation?.color
  203. if let selfAnnotation = annotation as? CSelfSignAnnotation {
  204. anColor = selfAnnotation.lineColor
  205. }
  206. color = (anColor != nil) ? anColor : .clear
  207. }
  208. return color
  209. }
  210. public func setAnnotationColor(annotationColor:NSColor?) {
  211. for i in 0 ..< annotations.count {
  212. let annotation = annotations[i]
  213. if annotation.isKind(of: CSelfSignAnnotation.self) == true {
  214. if let signAnnotation:CSelfSignAnnotation = annotation as? CSelfSignAnnotation {
  215. signAnnotation.lineColor = annotationColor
  216. }
  217. } else {
  218. annotation.color = annotationColor
  219. }
  220. let annotationType = convertAnnotationType(firstAnnotation: annotation)
  221. var keyValue = ""
  222. if annotationType == .highlight {
  223. keyValue = CHighlightNoteColorKey
  224. } else if annotationType == .underline {
  225. keyValue = CUnderlineNoteColorKey
  226. } else if annotationType == .strikeOut {
  227. keyValue = CStrikeOutNoteColorKey
  228. } else if annotationType == .squiggly {
  229. keyValue = CSquigglyNoteColorKey
  230. } else if annotationType == .circle {
  231. keyValue = CCircleNoteColorKey
  232. } else if annotationType == .square {
  233. keyValue = CSquareNoteColorKey
  234. } else if annotationType == .freeText ||
  235. annotationType == .signDate ||
  236. annotationType == .signText {
  237. keyValue = CFreeTextNoteBorderColorKey
  238. } else if annotationType == .line {
  239. keyValue = CLineNoteColorKey
  240. } else if annotationType == .arrow {
  241. keyValue = CArrowNoteColorKey
  242. } else if annotationType == .ink {
  243. keyValue = CInkNoteColorKey
  244. } else if annotationType == .signFalse {
  245. keyValue = CAnnotationSelfSignFalseColorKey
  246. } else if annotationType == .signTure {
  247. keyValue = CAnnotationSelfSignTureColorKey
  248. } else if annotationType == .signLine {
  249. keyValue = CAnnotationSelfSignLineColorKey
  250. } else if annotationType == .signDot {
  251. keyValue = CAnnotationSelfSignDotColorKey
  252. } else if annotationType == .redact {
  253. keyValue = CAnnotationRedactBorderColorKey
  254. }
  255. if keyValue.isEmpty == false {
  256. if annotationColor != nil {
  257. UserDefaults.standard.setPDFListViewColor(annotationColor!, forKey: keyValue)
  258. } else {
  259. UserDefaults.standard.removeObject(forKey: keyValue)
  260. }
  261. }
  262. }
  263. }
  264. public func annotationFontColor()->NSColor? { //不管相同还是不相同 pop框都是显示第一个颜色
  265. var fontColor:NSColor? = nil
  266. if annotation?.isKind(of: CPDFFreeTextAnnotation.self) == true {
  267. let freeTextAnnotation = annotation as! CPDFFreeTextAnnotation
  268. let anColor = freeTextAnnotation.fontColor
  269. fontColor = (anColor != nil) ? anColor : .clear
  270. }
  271. return fontColor
  272. }
  273. public func setAnnotationFontColor(annotationFontColor:NSColor?) {
  274. for i in 0 ..< annotations.count {
  275. let annotation = annotations[i]
  276. if annotation.isKind(of: CPDFFreeTextAnnotation.self) == true {
  277. let freeTextAnnotation = annotation as! CPDFFreeTextAnnotation
  278. freeTextAnnotation.fontColor = annotationFontColor
  279. let keyValue = CFreeTextNoteFontColorKey
  280. if annotationFontColor != nil {
  281. UserDefaults.standard.setPDFListViewColor(annotationFontColor!, forKey: keyValue)
  282. } else {
  283. UserDefaults.standard.removeObject(forKey: keyValue)
  284. }
  285. }
  286. }
  287. }
  288. public func annotationAlignment()->NSTextAlignment { //natural时说明不一致
  289. var textAlignment:NSTextAlignment = .natural
  290. if annotation?.isKind(of: CPDFFreeTextAnnotation.self) == true {
  291. let freeTextAnnotation = annotation as! CPDFFreeTextAnnotation
  292. let isNotSameColor: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .font_Alignment)
  293. if isNotSameColor == false {
  294. textAlignment = freeTextAnnotation.alignment
  295. }
  296. }
  297. return textAlignment
  298. }
  299. public func setAnnotationAlignment(annotationAlignment:NSTextAlignment) {
  300. for i in 0 ..< annotations.count {
  301. let annotation = annotations[i]
  302. if annotation.isKind(of: CPDFFreeTextAnnotation.self) == true {
  303. let freeTextAnnotation = annotation as! CPDFFreeTextAnnotation
  304. freeTextAnnotation.alignment = annotationAlignment
  305. let keyValue = CFreeTextNoteAlignmentKey
  306. UserDefaults.standard.set(annotationAlignment.rawValue, forKey: keyValue)
  307. }
  308. }
  309. }
  310. public func annotationFontName()->CPDFFont? { //返回字体是nil说明字体名不一样
  311. var cFont:CPDFFont? = nil
  312. if annotation?.isKind(of: CPDFFreeTextAnnotation.self) == true {
  313. let isNotSameName: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .font_Name)
  314. let isNotSameStyle: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .font_Style)
  315. if isNotSameName == false && isNotSameStyle == false {
  316. let freeTextAnnotation = annotation as! CPDFFreeTextAnnotation
  317. cFont = freeTextAnnotation.cFont
  318. }
  319. }
  320. return cFont
  321. }
  322. public func setAnnotationFont(font:CPDFFont) {
  323. for i in 0 ..< annotations.count {
  324. let annotation = annotations[i]
  325. if annotation.isKind(of: CPDFFreeTextAnnotation.self) == true {
  326. let freeTextAnnotation = annotation as! CPDFFreeTextAnnotation
  327. freeTextAnnotation.cFont = font
  328. let keyValue = CFreeTextNoteFontNameKey
  329. let appleFont:String = CPDFFont.convertAppleFont(font) ?? "Helvetica"
  330. UserDefaults.standard.set(appleFont, forKey: keyValue)
  331. }
  332. }
  333. }
  334. public func annotationFieldName()->String? { //pop只有一个的时候才会支持获取,不然是对齐
  335. var fieldName:String? = nil
  336. if annotations.count == 1 && annotation?.isForm() == true {
  337. if(annotation?.isKind(of: CPDFWidgetAnnotation.self) == true) {
  338. if let widgetAnnotation = annotation as? CPDFWidgetAnnotation {
  339. fieldName = widgetAnnotation.fieldName()
  340. }
  341. }
  342. }
  343. return fieldName
  344. }
  345. public func setannotationFieldName(fieldName:String) {
  346. for i in 0 ..< annotations.count {
  347. let annotation = annotations[i]
  348. if annotation.isKind(of: CPDFWidgetAnnotation.self) == true {
  349. if let widgetAnnotation = annotation as? CPDFWidgetAnnotation {
  350. widgetAnnotation.setFieldName(fieldName)
  351. }
  352. }
  353. }
  354. }
  355. public func annotationGropName()->String? { //pop只有一个的时候才会支持获取,不然是对齐
  356. var gropNameName:String? = nil
  357. if annotations.count == 1 && annotation?.isForm() == true {
  358. if(annotation?.isKind(of: CPDFButtonWidgetAnnotation.self) == true) {
  359. if let buttonWidgetAnnotation = annotation as? CPDFButtonWidgetAnnotation {
  360. if buttonWidgetAnnotation.controlType() == .radioButtonControl {
  361. gropNameName = buttonWidgetAnnotation.buttonWidgetStateString()
  362. }
  363. }
  364. }
  365. }
  366. return gropNameName
  367. }
  368. public func setannotationGropName(gropName:String) {
  369. for i in 0 ..< annotations.count {
  370. let annotation = annotations[i]
  371. if(annotation.isKind(of: CPDFButtonWidgetAnnotation.self) == true) {
  372. if let buttonWidgetAnnotation = annotation as? CPDFButtonWidgetAnnotation {
  373. buttonWidgetAnnotation.setButtonWidgetStateString(gropName)
  374. }
  375. }
  376. }
  377. }
  378. public func zoomOutFontSize()->Bool{ //悬浮菜单注释同一类型
  379. var isChange:Bool = false
  380. for i in 0 ..< annotations.count {
  381. let annotation = annotations[i]
  382. if annotation.isKind(of: CPDFFreeTextAnnotation.self) == true {
  383. let freeTextAnnotation = annotation as! CPDFFreeTextAnnotation
  384. var fontSize = freeTextAnnotation.fontSize
  385. if(fontSize > changeValue) {
  386. fontSize -= changeValue
  387. freeTextAnnotation.fontSize = fontSize
  388. let keyValue = CFreeTextNoteFontSizeKey
  389. UserDefaults.standard.set(fontSize, forKey: keyValue)
  390. isChange = true
  391. }
  392. }
  393. }
  394. return isChange
  395. }
  396. public func zoomInFontSize()->Bool{ //悬浮菜单注释同一类型
  397. for i in 0 ..< annotations.count {
  398. let annotation = annotations[i]
  399. if annotation.isKind(of: CPDFFreeTextAnnotation.self) == true {
  400. let freeTextAnnotation = annotation as! CPDFFreeTextAnnotation
  401. var fontSize = freeTextAnnotation.fontSize
  402. fontSize += changeValue
  403. freeTextAnnotation.fontSize = fontSize
  404. let keyValue = CFreeTextNoteFontSizeKey
  405. UserDefaults.standard.set(fontSize, forKey: keyValue)
  406. }
  407. }
  408. return true
  409. }
  410. public func zoomOutShapeWidth()->Bool{
  411. for i in 0 ..< annotations.count {
  412. let annotation = annotations[i]
  413. var shapeWidth = annotation.borderWidth
  414. if annotation.isKind(of: CSelfSignAnnotation.self) == true {
  415. if let signAnnotation:CSelfSignAnnotation = annotation as? CSelfSignAnnotation {
  416. shapeWidth = signAnnotation.lineAnnotationWidth
  417. }
  418. }
  419. if shapeWidth < minLineValue {
  420. break
  421. }
  422. if(shapeWidth > minLineValue) {
  423. shapeWidth -= changeValue
  424. if annotation.isKind(of: CSelfSignAnnotation.self) == true {
  425. if let signAnnotation:CSelfSignAnnotation = annotation as? CSelfSignAnnotation {
  426. signAnnotation.lineAnnotationWidth = shapeWidth
  427. }
  428. } else {
  429. annotation.borderWidth = shapeWidth
  430. }
  431. var keyValue = ""
  432. let annotationType = convertAnnotationType(firstAnnotation: annotation)
  433. if annotationType == .circle {
  434. keyValue = CCircleNoteLineWidthKey
  435. } else if annotationType == .square {
  436. keyValue = CSquareNoteLineWidthKey
  437. } else if annotationType == .line {
  438. keyValue = CLineNoteLineWidthKey
  439. } else if annotationType == .arrow {
  440. keyValue = CArrowNoteLineWidthKey
  441. } else if annotationType == .ink {
  442. keyValue = CInkNoteLineWidthKey
  443. } else if annotationType == .freeText {
  444. keyValue = CAnnotationTextWidgetLineWidthKey
  445. } else if annotationType == .signFalse {
  446. keyValue = CAnnotationSelfSignFalseLineWidthKey
  447. } else if annotationType == .signTure {
  448. keyValue = CAnnotationSelfSignTureLineWidthKey
  449. } else if annotationType == .signCircle {
  450. keyValue = CAnnotationSelfSignCircleLineWidthKey
  451. } else if annotationType == .signLine {
  452. keyValue = CAnnotationSelfSignLineLineWidthKey
  453. }
  454. if keyValue.isEmpty == false {
  455. UserDefaults.standard.set(shapeWidth, forKey: keyValue)
  456. }
  457. return true
  458. }
  459. }
  460. return false
  461. }
  462. public func zoomInShapeWidth()->Bool{
  463. for i in 0 ..< annotations.count {
  464. let annotation = annotations[i]
  465. var shapeWidth = annotation.borderWidth
  466. if annotation.isKind(of: CSelfSignAnnotation.self) == true {
  467. if let signAnnotation:CSelfSignAnnotation = annotation as? CSelfSignAnnotation {
  468. shapeWidth = signAnnotation.lineAnnotationWidth
  469. }
  470. }
  471. if shapeWidth > maxLineValue {
  472. break
  473. }
  474. shapeWidth += changeValue
  475. if shapeWidth > maxLineValue {
  476. shapeWidth = maxLineValue
  477. }
  478. if annotation.isKind(of: CSelfSignAnnotation.self) == true {
  479. if let signAnnotation:CSelfSignAnnotation = annotation as? CSelfSignAnnotation {
  480. signAnnotation.lineAnnotationWidth = shapeWidth
  481. }
  482. } else {
  483. annotation.borderWidth = shapeWidth
  484. }
  485. var keyValue = ""
  486. let annotationType = convertAnnotationType(firstAnnotation: annotation)
  487. if annotationType == .circle {
  488. keyValue = CCircleNoteLineWidthKey
  489. } else if annotationType == .square {
  490. keyValue = CSquareNoteLineWidthKey
  491. } else if annotationType == .line {
  492. keyValue = CLineNoteLineWidthKey
  493. } else if annotationType == .arrow {
  494. keyValue = CArrowNoteLineWidthKey
  495. } else if annotationType == .ink {
  496. keyValue = CInkNoteLineWidthKey
  497. } else if annotationType == .freeText {
  498. keyValue = CAnnotationTextWidgetLineWidthKey
  499. } else if annotationType == .signFalse {
  500. keyValue = CAnnotationSelfSignFalseLineWidthKey
  501. } else if annotationType == .signTure {
  502. keyValue = CAnnotationSelfSignTureLineWidthKey
  503. } else if annotationType == .signCircle {
  504. keyValue = CAnnotationSelfSignCircleLineWidthKey
  505. } else if annotationType == .signLine {
  506. keyValue = CAnnotationSelfSignLineLineWidthKey
  507. }
  508. if keyValue.isEmpty == false {
  509. UserDefaults.standard.set(shapeWidth, forKey: keyValue)
  510. }
  511. }
  512. return true
  513. }
  514. }