// // CardVC.swift // PDF Reader Pro Edition // // Created by Niehaoyu on 2024/9/14. // import Cocoa import KMComponentLibrary class CardVC: NSViewController { //PDFTool @IBOutlet weak var cardPDFTool: ComponentCardPDFTool! @IBOutlet weak var pdftoolCollaspseBtn: NSButton! @IBOutlet weak var pdfToolHeightConst: NSLayoutConstraint! //File @IBOutlet weak var cardFile: ComponentCardFile! @IBOutlet weak var fileFolderBtn: NSButton! @IBOutlet weak var fileHeightConst: NSLayoutConstraint! //Watermark @IBOutlet weak var cardWatermark: ComponentCardWatermark! //Header @IBOutlet weak var cardHeaderFooter: ComponentCardHeader! @IBOutlet weak var position00Btn: NSButton! @IBOutlet weak var position01Btn: NSButton! @IBOutlet weak var position10Btn: NSButton! @IBOutlet weak var position11Btn: NSButton! @IBOutlet weak var position20Btn: NSButton! @IBOutlet weak var position21Btn: NSButton! @IBOutlet weak var cardHeaderConst: NSLayoutConstraint! //Stamp @IBOutlet weak var cardStamp: ComponentCardStamp! override func viewDidLoad() { super.viewDidLoad() // Do view setup here. self.position00Btn.state = .on self.reloadData() } func reloadData() { //Tool let pdftoolProperty: ComponentCardPDFToolProperty = ComponentCardPDFToolProperty(collapse: self.pdftoolCollaspseBtn.state == .on, state: .normal, icon: ComponentLibrary.shared.image(forResource: "test"), text: "Example", subText: "content content content content content content content content") self.cardPDFTool.properties = pdftoolProperty self.pdfToolHeightConst.constant = self.cardPDFTool.properties.collapse == true ? 60 : 88 //File let fileProperty: ComponentCardFileProperty = ComponentCardFileProperty(folder: self.fileFolderBtn.state == .on, state: .normal, icon: NSImage(named: "ic_propertybar_file_pdf"), text: "Sample text") self.cardFile.properties = fileProperty self.fileHeightConst.constant = self.fileFolderBtn.state == .on ? 182 : 224 //Watermark let watermarkProperty: ComponentCardWMProperty = ComponentCardWMProperty(state: .normal, icon: NSImage(named: "ic_propertybar_file_pdf"), text: "Watermark") self.cardWatermark.properties = watermarkProperty //HeaderFooter var headeritems: [CardHeaderItemInfo] = [] if self.position00Btn.state == .on { let property = ComponentCPositionProperty(rowCount: 2, columnCount: 3, dash: true, isDisable: true, selRow: 0, selColumn: 0) let itemInfo = CardHeaderItemInfo(property: property, text: "Text-Text") headeritems.append(itemInfo) } if self.position01Btn.state == .on { let property = ComponentCPositionProperty(rowCount: 2, columnCount: 3, dash: true, isDisable: true, selRow: 0, selColumn: 1) let itemInfo = CardHeaderItemInfo(property: property, text: "Text-Text") headeritems.append(itemInfo) } if self.position10Btn.state == .on { let property = ComponentCPositionProperty(rowCount: 2, columnCount: 3, dash: true, isDisable: true, selRow: 1, selColumn: 0) let itemInfo = CardHeaderItemInfo(property: property, text: "Text-Text") headeritems.append(itemInfo) } if self.position11Btn.state == .on { let property = ComponentCPositionProperty(rowCount: 2, columnCount: 3, dash: true, isDisable: true, selRow: 1, selColumn: 1) let itemInfo = CardHeaderItemInfo(property: property, text: "Text-Text") headeritems.append(itemInfo) } if self.position20Btn.state == .on { let property = ComponentCPositionProperty(rowCount: 2, columnCount: 3, dash: true, isDisable: true, selRow: 0, selColumn: 2) let itemInfo = CardHeaderItemInfo(property: property, text: "Text-Text") headeritems.append(itemInfo) } if self.position21Btn.state == .on { let property = ComponentCPositionProperty(rowCount: 2, columnCount: 3, dash: true, isDisable: true, selRow: 1, selColumn: 2) let itemInfo = CardHeaderItemInfo(property: property, text: "Text-Text") headeritems.append(itemInfo) } let headerProperty: ComponentCardHeaderProperty = ComponentCardHeaderProperty(state: .normal, text: "Header Footer", items: headeritems) self.cardHeaderFooter.properties = headerProperty self.cardHeaderConst.constant = self.cardHeaderFooter.properties.propertyInfo.viewHeight //Stamp let stampProperty = ComponentCardStampProperty(state: .normal, icon: NSImage(named: "ic_propertybar_file_pdf")) self.cardStamp.properties = stampProperty } @IBAction func clickAction(_ sender: Any) { self.reloadData() } }