KMWatermarkAdjectiveBaseModel.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // KMWatermarkAdjectiveBaseModel.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2022/12/27.
  6. //
  7. import Cocoa
  8. /// 关联指
  9. enum KMWatermarkAdjectiveText {
  10. case font(name: String, size: CGFloat)
  11. case color(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)
  12. }
  13. @objcMembers class KMWatermarkAdjectiveBaseModel: KMBatchSettingItemViewModel {
  14. var textFont: KMWatermarkAdjectiveText!
  15. var textColor: KMWatermarkAdjectiveText!
  16. var id: String = ""
  17. var pageRangeType: Int = 0
  18. var pageRangeString: String = ""
  19. var pageCount: Int = 0
  20. public func getTextColor() -> NSColor {
  21. var color: NSColor!
  22. switch self.textColor {
  23. case .color(red: let red, green: let green, blue: let blue, alpha: let alpha):
  24. color = NSColor(red: red, green: green, blue: blue, alpha: alpha)
  25. default:
  26. break
  27. }
  28. if (color == nil) {
  29. color = NSColor.black
  30. }
  31. return color
  32. }
  33. public func getTextFont() -> NSFont {
  34. var fontSize = 0.0
  35. var fontName: String = ""
  36. switch self.textFont {
  37. case .font(name: let name, size: let size):
  38. fontName = name
  39. fontSize = size
  40. break
  41. default:
  42. break
  43. }
  44. return NSFont(name: fontName, size: fontSize)!
  45. }
  46. public func getTextFontName() -> String {
  47. var fontName: String = ""
  48. switch self.textFont {
  49. case .font(name: let name, size: _):
  50. fontName = name
  51. break
  52. default:
  53. break
  54. }
  55. return fontName
  56. }
  57. public func getTextFontSize() -> CGFloat {
  58. var fontSize = 0.0
  59. switch self.textFont {
  60. case .font(name: _, size: let size):
  61. fontSize = size
  62. break
  63. default:
  64. break
  65. }
  66. return fontSize
  67. }
  68. }