123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- //
- // KMBatchOperateRightViewController.swift
- // PDF Reader Pro
- //
- // Created by kdanmobile on 2023/10/26.
- //
- import Cocoa
- class KMBatchOperateRightViewController: NSViewController{
- lazy var compressViewController: KMBatchOperateCompressViewController? = {
- let vc = KMBatchOperateCompressViewController(files: self.files)
- vc.operateType = .Compress
- return vc
- }()
- lazy var convertViewController: KMBatchOperateConvertViewController? = {
- let vc = KMBatchOperateConvertViewController(files: self.files)
- vc.operateType = .Convert
- return vc
- }()
- lazy var addWatermarkViewController: KMBatchOperateAddWatermarkViewController? = {
- let vc = KMBatchOperateAddWatermarkViewController(files: self.files)
- vc.operateType = .AddWatermark
- vc.isBatchOperation = true
- return vc
- }()
- lazy var removeWatermarkViewController: KMBatchOperateRemoveWatermarkViewController? = {
- let vc = KMBatchOperateRemoveWatermarkViewController(files: self.files)
- vc.operateType = .RemoveWatermark
- return vc
- }()
- lazy var addBackgroundViewController: KMBatchOperateAddWatermarkViewController? = {
- let vc = KMBatchOperateAddWatermarkViewController(files: self.files)
- vc.operateType = .AddBackground
- vc.isBatchOperation = true
- vc.isBackground = true
- return vc
- }()
- lazy var removeBackgroundViewController: KMBatchOperateRemoveWatermarkViewController? = {
- let vc = KMBatchOperateRemoveWatermarkViewController(files: self.files)
- vc.operateType = .RemoveBackground
- vc.isBackground = true
- return vc
- }()
- lazy var addHeaderFooterViewController: KMBatchOperateAddHeaderFooterViewController? = {
- let vc = KMBatchOperateAddHeaderFooterViewController(files: self.files)
- vc.operateType = .AddHeaderFooter
- vc.isBatchOperation = true
- return vc
- }()
- lazy var addBatesViewController: KMBatchOperateAddHeaderFooterViewController? = {
- let vc = KMBatchOperateAddHeaderFooterViewController(files: self.files)
- vc.operateType = .AddBates
- vc.isBates = true
- vc.isBatchOperation = true
- return vc
- }()
- lazy var removeHeaderFooterViewController: KMBatchOperateRemoveHeaderFooterViewController? = {
- let vc = KMBatchOperateRemoveHeaderFooterViewController(files: self.files)
- vc.operateType = .RemoveHeaderFooter
- vc.isBates = false
- return vc
- }()
- lazy var removeBatesViewController: KMBatchOperateRemoveHeaderFooterViewController? = {
- let vc = KMBatchOperateRemoveHeaderFooterViewController(files: self.files)
- vc.operateType = .RemoveBates
- vc.isBates = true
- return vc
- }()
- lazy var addPasswordViewController: KMBatchOperateAddPasswordViewController? = {
- let vc = KMBatchOperateAddPasswordViewController(files: self.files)
- vc.operateType = .AddPassword
- return vc
- }()
- lazy var removePasswordViewController: KMBatchOperateRemovePasswordViewController? = {
- let vc = KMBatchOperateRemovePasswordViewController(files: self.files)
- vc.operateType = .RemovePassword
- return vc
- }()
- lazy var imageToPDFViewController: KMBatchOperateImageToPDFViewController? = {
- let vc = KMBatchOperateImageToPDFViewController(files: self.files)
- vc.operateType = .CreatePDF
- return vc
- }()
-
- var _currentType: KMBatchOperationType?
- var currentType: KMBatchOperationType?{
- get{
- return _currentType
- }
- set{
- if _currentType != newValue{
- _currentType = newValue
- for i in 0..<self.view.subviews.count {
- let v = self.view.subviews[i]
- v.removeFromSuperview()
- }
- if newValue == .Convert {
- self.view.addSubview(self.convertViewController!.view)
- self.convertViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .AddWatermark {
- self.view.addSubview(self.addWatermarkViewController!.view)
- self.addWatermarkViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .RemoveWatermark {
- self.view.addSubview(self.removeWatermarkViewController!.view)
- self.removeWatermarkViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .AddBackground {
- self.view.addSubview(self.addBackgroundViewController!.view)
- self.addBackgroundViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .RemoveBackground {
- self.view.addSubview(self.removeBackgroundViewController!.view)
- self.removeBackgroundViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .AddHeaderFooter {
- self.view.addSubview(self.addHeaderFooterViewController!.view)
- self.addHeaderFooterViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .RemoveHeaderFooter {
- self.view.addSubview(self.removeHeaderFooterViewController!.view)
- self.removeHeaderFooterViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .AddBates {
- self.view.addSubview(self.addBatesViewController!.view)
- self.addBatesViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .RemoveBates {
- self.view.addSubview(self.removeBatesViewController!.view)
- self.removeBatesViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .AddPassword {
- self.view.addSubview(self.addPasswordViewController!.view)
- self.addPasswordViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .RemovePassword {
- self.view.addSubview(self.removePasswordViewController!.view)
- self.removePasswordViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .Compress {
- self.view.addSubview(self.compressViewController!.view)
- self.compressViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- } else if _currentType == .CreatePDF {
- self.view.addSubview(self.imageToPDFViewController!.view)
- self.imageToPDFViewController?.view.mas_makeConstraints({ make in
- make?.edges.equalTo()(self.view)
- })
- }
- }
- }
- }
- var files: [KMBatchOperateFile] = []
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- }
-
- func switchToOperateType(operateType: KMBatchOperationType, files: [KMBatchOperateFile]) {
- self.files = files
- self.imageToPDFViewController?.files = self.files
- self.currentType = operateType
- }
-
- func switchToOperateType(operateType: KMBatchOperationType) {
- self.currentType = operateType
- }
-
- func switchToConvertType(_ convertType: KMConvertWithPDFType) {
- if self.currentType == .Convert {
- self.convertViewController?.switchToConvertType(convertType)
- }
- }
-
- func watermarkInterfaceSelectWatermark(_ watermark: KMWatermarkModel) {
- if self.currentType == .AddWatermark {
- self.addWatermarkViewController?.watermarkInterfaceSelectWatermark(watermark)
- }
- }
-
- func backgroundInterfaceSelectBackground(_ background: KMBackgroundModel) {
- if self.currentType == .AddBackground {
- self.addBackgroundViewController?.backgroundInterfaceSelectBackGround(background)
- }
- }
-
- func headerFooterInterfaceSelectHeaderFooter(_ headerFooter: KMHeaderFooterObject) {
- if self.currentType == .AddHeaderFooter {
- self.addHeaderFooterViewController?.headerFooterInterfaceSelectHeaderFooter(headerFooter: headerFooter)
- }
- }
-
- func batesInterfaceSelectBates(_ headerFooter: KMHeaderFooterObject) {
- if self.currentType == .AddBates {
- self.addHeaderFooterViewController?.headerFooterInterfaceSelectHeaderFooter(headerFooter: headerFooter)
- }
- }
- }
|