// // KMRedactPropertyWindowController.swift // PDF Reader Pro // // Created by tangchao on 2023/1/17. // import Cocoa class KMRedactPropertyWindowController: KMRedactBaseWindowController { var colorViewIndex: Int = 0 var outsideColor: NSColor { get { return NSColor.clear } } var fillColor: NSColor { get { return NSColor.clear } } var isOver: Bool { get { return false } } var overText: String { get { return "" } } var fontColor: NSColor { get { return NSColor.clear } } var aligement: NSTextAlignment = .left var font: NSFont = NSFont(name: "Helvetica", size: 0)! override func windowDidLoad() { super.windowDidLoad() self.setContentSize(NSSize(width: 444, height: 527)) self.topLineIsShow(false) self.titleLabel.stringValue = NSLocalizedString("Settings", comment: "") self.funcButton.title = NSLocalizedString("Apply", comment: "") self.funcButton.layer?.backgroundColor = NSColor.black.cgColor self.funcButton.attributedTitle = NSMutableAttributedString(string: self.funcButton.title, attributes: [NSAttributedString.Key.foregroundColor : NSColor.white]) let contentView = KMRedactPropertyContentView.createFromNib() contentView?.frame = self.contentBox.contentView!.bounds contentView?.autoresizingMask = [.width,.height] self.contentBox.contentView?.addSubview(contentView!) self.contentView = contentView contentView?.annotation = self.annotation contentView?.itemClick = { [weak self] index, value in if (index == 1) { /// 外观 self?.colorViewIndex = 1 self?.showColorPanel() return } else if (index == 2) { /// 填充 self?.colorViewIndex = 2 self?.showColorPanel() return } else if (index == 3) { /// 覆盖文本check } else if (index == 4) { /// 覆盖文本编辑 } else if (index == 5) { /// 字体类型 self?.font = NSFont(name: value as! String, size: (self?.font.pointSize)!)! } else if (index == 6) { /// 字体大小 self?.font = NSFont(name: (self?.font.fontName)!, size: CGFloat(value as! Int))! } else if (index == 7) { /// 字体相关 } else if (index == 8) { /// 字体颜色 self?.colorViewIndex = 3 self?.showColorPanel() return } else if (index == 9) { /// 字体aligement if (value as! Int == 0) { self?.aligement = .left } else if (value as! Int == 1) { self?.aligement = .center } else if (value as! Int == 2) { self?.aligement = .right } } } } // MARK: Private Methods @objc private func showColorPanel() { let panel = NSColorPanel.shared panel.setTarget(self) panel.setAction(#selector(colorPanelAction)) panel.orderFront(nil) } @objc private func colorPanelAction(sender: NSColorPanel) { } }