KMBatchoperateConvertCollectionViewItem.swift 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // KMBatchoperateConvertCollectionViewItem.swift
  3. // Cisdem PDFMaster
  4. //
  5. // Created by kdanmobile on 2023/11/1.
  6. //
  7. import Cocoa
  8. class KMBatchoperateConvertCollectionViewItem: NSCollectionViewItem{
  9. var selectLayer: CALayer?
  10. @IBOutlet var advancedButton: NSButton!
  11. @IBOutlet var containerView: NSView!
  12. @IBOutlet var moreInfoTextField: NSTextField!
  13. @IBOutlet var icomIV: NSImageView!
  14. @IBOutlet var nameTF: NSTextField!
  15. override func viewDidLoad() {
  16. super.viewDidLoad()
  17. self.nameTF!.font = NSFont.systemFont(ofSize: 12)
  18. nameTF!.textColor = KMAppearance.Layout.h1Color()
  19. moreInfoTextField.font = NSFont.boldSystemFont(ofSize: 9)
  20. moreInfoTextField.textColor = KMAppearance.Layout.mColor()
  21. view.wantsLayer = true
  22. selectLayer = CALayer()
  23. view.layer?.addSublayer(selectLayer!)
  24. selectLayer?.frame = CGRect(x: 0, y: 0, width: 64, height: 76)
  25. selectLayer!.backgroundColor = KMAppearance.Status.selColor().cgColor
  26. selectLayer?.cornerRadius = 6
  27. selectLayer!.isHidden = true
  28. moreInfoTextField.sizeToFit()
  29. containerView.wantsLayer = true
  30. containerView.layer?.cornerRadius = moreInfoTextField.bounds.height / 2
  31. }
  32. override var isSelected: Bool{
  33. get{
  34. return super.isSelected
  35. }
  36. set{
  37. super.isSelected = newValue
  38. self.selectLayer?.isHidden = !newValue
  39. }
  40. }
  41. @IBAction func buttonClicked_AdvancedClicked(_ sender: Any) {
  42. if !IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  43. KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
  44. }
  45. }
  46. func updateInterface(_ type: KMConvertWithPDFType) {
  47. var titleString: String? = nil
  48. var moreInfoString: String? = nil
  49. var image = NSImage(named: KMImageNameUXIconPropertybarFileWord)
  50. advancedButton.isHidden = true
  51. containerView.isHidden = true
  52. switch type {
  53. case .WordStandard:
  54. titleString = "Word"
  55. moreInfoString = NSLocalizedString("Standard", comment: "")
  56. containerView.isHidden = false
  57. moreInfoTextField.textColor = KMAppearance.Layout.h0Color()
  58. containerView.layer?.backgroundColor = KMAppearance.Else.textTagColor().cgColor
  59. case .WordAdvance:
  60. titleString = "Word"
  61. if !IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
  62. moreInfoString = NSLocalizedString("Advanced", comment: "")
  63. containerView.isHidden = false
  64. }
  65. moreInfoTextField.textColor = KMAppearance.Layout.w0Color()
  66. containerView.layer?.backgroundColor = KMAppearance.Interactive.a0Color().cgColor
  67. case .Excel:
  68. image = NSImage(named: KMImageNameUXIconPropertybarFileExcel)
  69. titleString = "Excel"
  70. case .PowerPoint:
  71. image = NSImage(named: KMImageNameUXIconPropertybarFilePPT)
  72. titleString = "PowerPoint"
  73. case .RTF:
  74. image = NSImage(named: KMImageNameUXIconPropertybarFileElse)
  75. titleString = "RTF"
  76. case .CSV:
  77. image = NSImage(named: KMImageNameUXIconPropertybarFileCSV)
  78. titleString = "CSV"
  79. case .HTML:
  80. image = NSImage(named: KMImageNameUXIconPropertybarFileHTML)
  81. titleString = "HTML"
  82. case .Text:
  83. image = NSImage(named: KMImageNameUXIconPropertybarFileTXT)
  84. titleString = "Text"
  85. case .JPEG:
  86. image = NSImage(named: KMImageNameUXIconPropertybarFileJPEG)
  87. titleString = "JPEG"
  88. case .JPG:
  89. image = NSImage(named: KMImageNameUXIconPropertybarFileJPG)
  90. titleString = "JPG"
  91. case .PNG:
  92. image = NSImage(named: KMImageNameUXIconPropertybarFilePNG)
  93. titleString = "PNG"
  94. case .GIF:
  95. image = NSImage(named: KMImageNameUXIconPropertybarFileGIF)
  96. titleString = "GIF"
  97. case .TIFF:
  98. image = NSImage(named: KMImageNameUXIconPropertybarFileTIFF)
  99. titleString = "TIFF"
  100. case .TGA:
  101. image = NSImage(named: KMImageNameUXIconPropertybarFileTGA)
  102. titleString = "TGA"
  103. case .BMP:
  104. image = NSImage(named: KMImageNameUXIconPropertybarFileBMP)
  105. titleString = "BMP"
  106. case .JPEG2000:
  107. image = NSImage(named: KMImageNameUXIconPropertybarFileJP2)
  108. titleString = "JPEG2000"
  109. }
  110. nameTF?.stringValue = titleString ?? ""
  111. moreInfoTextField.stringValue = moreInfoString ?? ""
  112. moreInfoTextField.toolTip = moreInfoString ?? ""
  113. icomIV?.image = image
  114. }
  115. }