// // KMWatermarkAdjectiveBaseModel.swift // PDF Master // // Created by tangchao on 2022/12/27. // import Cocoa /// 关联指 enum KMWatermarkAdjectiveText { case font(name: String, size: CGFloat) case color(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) } @objcMembers class KMWatermarkAdjectiveBaseModel: KMBatchSettingItemViewModel { var textFont: KMWatermarkAdjectiveText! var textColor: KMWatermarkAdjectiveText! var id: String = "" var pageRangeType: Int = 0 var pageRangeString: String = "" var pageCount: Int = 0 public func getTextColor() -> NSColor { var color: NSColor! switch self.textColor { case .color(red: let red, green: let green, blue: let blue, alpha: let alpha): color = NSColor(red: red, green: green, blue: blue, alpha: alpha) default: break } if (color == nil) { color = NSColor.black } return color } public func getTextFont() -> NSFont { var fontSize = 0.0 var fontName: String = "" switch self.textFont { case .font(name: let name, size: let size): fontName = name fontSize = size break default: break } return NSFont(name: fontName, size: fontSize)! } public func getTextFontName() -> String { var fontName: String = "" switch self.textFont { case .font(name: let name, size: _): fontName = name break default: break } return fontName } public func getTextFontSize() -> CGFloat { var fontSize = 0.0 switch self.textFont { case .font(name: _, size: let size): fontSize = size break default: break } return fontSize } }