KMNAnnotationPopMode.swift 23 KB

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