KMEditBackgroundController.swift 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // KMEditBackgroundController.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2022/12/24.
  6. //
  7. import Cocoa
  8. class KMEditBackgroundController: KMWatermarkAdjectivePropertyBaseController {
  9. var firstController = KMBackgroundPropertyInfoController(nibName: "KMBackgroundPropertyInfoController", bundle: nil)
  10. var secondController = KMBackgroundFilePropertyInfoController(nibName: "KMBackgroundFilePropertyInfoController", bundle: nil)
  11. var isEdited: Bool = false
  12. private var myEditModel: KMBackgroundModel!
  13. var editModel: KMBackgroundModel {
  14. get {
  15. return myEditModel
  16. }
  17. set {
  18. myEditModel = newValue
  19. self.firstController.model = newValue
  20. self.secondController.model = newValue
  21. }
  22. }
  23. override func viewWillAppear() {
  24. super.viewWillAppear()
  25. if (self.editModel.type == .color) {
  26. self.selectTabIndex(index: 0)
  27. } else if (self.editModel.type == .file) {
  28. self.selectTabIndex(index: 1)
  29. self.secondController.outsideBox.isHidden = false
  30. self.secondController.positionBox.isHidden = false
  31. self.secondController.pageRangeBox.isHidden = false
  32. self.secondController.fileInfoView.tipLabel.stringValue = self.editModel.imagePath.lastPathComponent
  33. }
  34. }
  35. override func viewDidLoad() {
  36. super.viewDidLoad()
  37. self.backButtton.title = NSLocalizedString("", comment: "")
  38. self.showBack(show: true)
  39. self.titleLabel.stringValue = NSLocalizedString("Edit Background", comment: "")
  40. self.addButton.attributedTitle = NSAttributedString(string: NSLocalizedString("恢复", comment: ""), attributes: [NSAttributedString.Key.foregroundColor : NSColor(red: 24.0/255.0, green: 160.0/255.0, blue: 251.0/255.0, alpha: 1.0),NSAttributedString.Key.font : NSFont.systemFont(ofSize: 12), NSAttributedString.Key.underlineStyle : true])
  41. self.segementControl.items = [NSLocalizedString("Color", comment: ""),NSLocalizedString("File", comment: "")]
  42. self.segementControl.itemClick = { [weak self] (index: Int) in
  43. self!.tabView.selectTabViewItem(at: index)
  44. }
  45. let item = NSTabViewItem(identifier: "tabID")
  46. item.label = "tab1";
  47. item.viewController = self.firstController
  48. let item2 = NSTabViewItem(identifier: "tabID2")
  49. item2.label = "tab2";
  50. item2.viewController = self.secondController
  51. self.tabView.addTabViewItem(item)
  52. self.tabView.addTabViewItem(item2)
  53. self.firstController.delegate = self
  54. self.secondController.delegate = self
  55. childViewController.append(self.firstController)
  56. childViewController.append(self.secondController)
  57. self.segementControl.isHidden = true
  58. self.segementControlHeightConst.constant = 0
  59. }
  60. override func resume() {
  61. if (self.flagModel == nil) {
  62. return
  63. }
  64. if (childViewController.count <= 0) {
  65. return
  66. }
  67. if (self.segementControl.selectItemIndex == 0) {
  68. firstController.model = self.flagModel?.copy() as! KMBackgroundModel
  69. } else if (self.segementControl.selectItemIndex == 1) {
  70. }
  71. }
  72. }
  73. extension KMEditBackgroundController: KMBackgroundPropertyInfoDelegate {
  74. func propertyInfoDidChange(model: KMBackgroundModel) {
  75. self.myEditModel = model
  76. self.isEdited = true
  77. }
  78. }