KMBatchOperateRightViewController.swift 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // KMBatchOperateRightViewController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by kdanmobile on 2023/10/26.
  6. //
  7. import Cocoa
  8. class KMBatchOperateRightViewController: NSViewController{
  9. lazy var compressViewController: KMBatchOperateCompressViewController? = {
  10. let vc = KMBatchOperateCompressViewController(files: self.files)
  11. vc.operateType = .Compress
  12. return vc
  13. }()
  14. lazy var convertViewController: KMBatchOperateConvertViewController? = {
  15. let vc = KMBatchOperateConvertViewController(files: self.files)
  16. vc.operateType = .Convert
  17. return vc
  18. }()
  19. lazy var addPasswordViewController: KMBatchOperateAddPasswordViewController? = {
  20. let vc = KMBatchOperateAddPasswordViewController(files: self.files)
  21. vc.operateType = .AddPassword
  22. return vc
  23. }()
  24. lazy var removePasswordViewController: KMBatchOperateRemovePasswordViewController? = {
  25. let vc = KMBatchOperateRemovePasswordViewController(files: self.files)
  26. vc.operateType = .RemovePassword
  27. return vc
  28. }()
  29. lazy var imageToPDFViewController: KMBatchOperateImageToPDFViewController? = {
  30. let vc = KMBatchOperateImageToPDFViewController(files: self.files)
  31. vc.operateType = .CreatePDF
  32. return vc
  33. }()
  34. var _currentType: KMBatchOperationType?
  35. var currentType: KMBatchOperationType?{
  36. get{
  37. return _currentType
  38. }
  39. set{
  40. if _currentType != newValue{
  41. _currentType = newValue
  42. for i in 0..<self.view.subviews.count {
  43. let v = self.view.subviews[i]
  44. v.removeFromSuperview()
  45. }
  46. if newValue == .Convert {
  47. self.view.addSubview(self.convertViewController!.view)
  48. self.convertViewController?.view.mas_makeConstraints({ make in
  49. make?.edges.equalTo()(self.view)
  50. })
  51. } else if _currentType == .AddHeaderFooter {
  52. } else if _currentType == .RemoveHeaderFooter {
  53. } else if _currentType == .AddBates {
  54. } else if _currentType == .RemoveBates {
  55. } else if _currentType == .AddPassword {
  56. self.view.addSubview(self.addPasswordViewController!.view)
  57. self.addPasswordViewController?.view.mas_makeConstraints({ make in
  58. make?.edges.equalTo()(self.view)
  59. })
  60. } else if _currentType == .RemovePassword {
  61. self.view.addSubview(self.removePasswordViewController!.view)
  62. self.removePasswordViewController?.view.mas_makeConstraints({ make in
  63. make?.edges.equalTo()(self.view)
  64. })
  65. } else if _currentType == .Compress {
  66. self.view.addSubview(self.compressViewController!.view)
  67. self.compressViewController?.view.mas_makeConstraints({ make in
  68. make?.edges.equalTo()(self.view)
  69. })
  70. } else if _currentType == .CreatePDF {
  71. self.view.addSubview(self.imageToPDFViewController!.view)
  72. self.imageToPDFViewController?.view.mas_makeConstraints({ make in
  73. make?.edges.equalTo()(self.view)
  74. })
  75. }
  76. }
  77. }
  78. }
  79. var files: [KMBatchOperateFile] = []
  80. override func viewDidLoad() {
  81. super.viewDidLoad()
  82. }
  83. func switchToOperateType(operateType: KMBatchOperationType, files: [KMBatchOperateFile]) {
  84. self.files = files
  85. self.imageToPDFViewController?.files = self.files
  86. self.currentType = operateType
  87. }
  88. func switchToOperateType(operateType: KMBatchOperationType) {
  89. self.currentType = operateType
  90. }
  91. func switchToConvertType(_ convertType: KMConvertWithPDFType) {
  92. if self.currentType == .Convert {
  93. self.convertViewController?.switchToConvertType(convertType)
  94. }
  95. }
  96. func watermarkInterfaceSelectWatermark(_ watermark: KMWatermarkModel) {
  97. if self.currentType == .AddWatermark {
  98. }
  99. }
  100. func backgroundInterfaceSelectBackground(_ background: KMBackgroundModel) {
  101. if self.currentType == .AddBackground {
  102. }
  103. }
  104. func headerFooterInterfaceSelectHeaderFooter(_ headerFooter: KMHeaderFooterModel) {
  105. if self.currentType == .AddHeaderFooter {
  106. }
  107. }
  108. func batesInterfaceSelectBates(_ headerFooter: KMHeaderFooterModel) {
  109. if self.currentType == .AddBates {
  110. }
  111. }
  112. }