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