KMCreateBackgroundController.swift 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // KMCreateBackgroundController.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2022/12/23.
  6. //
  7. import Cocoa
  8. class KMCreateBackgroundController: KMWatermarkAdjectivePropertyBaseController {
  9. override func viewDidLoad() {
  10. super.viewDidLoad()
  11. // Do view setup here.
  12. self.backButtton.title = NSLocalizedString("", comment: "")
  13. self.showBack(show: true)
  14. self.titleLabel.stringValue = NSLocalizedString("Add Background", comment: "")
  15. 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])
  16. self.segementControl.items = [NSLocalizedString("Color", comment: ""),NSLocalizedString("File", comment: "")]
  17. self.segementControl.itemClick = {
  18. [self] (index: Int) in
  19. self.tabView.selectTabViewItem(at: index)
  20. }
  21. let item = NSTabViewItem(identifier: "tabID")
  22. item.label = "tab1";
  23. let controller = KMBackgroundPropertyInfoController(nibName: "KMBackgroundPropertyInfoController", bundle: nil)
  24. item.viewController = controller
  25. controller.model = KMBackgroundModel()
  26. controller.delegate = self
  27. let item2 = NSTabViewItem(identifier: "tabID2")
  28. item2.label = "tab2";
  29. let controller2 = KMBackgroundFilePropertyInfoController(nibName: "KMBackgroundFilePropertyInfoController", bundle: nil)
  30. item2.viewController = controller2
  31. controller2.model = KMBackgroundModel()
  32. controller2.model.type = .file
  33. controller2.delegate = self
  34. self.tabView.addTabViewItem(item)
  35. self.tabView.addTabViewItem(item2)
  36. childViewController.append(controller)
  37. childViewController.append(controller2)
  38. }
  39. func fetchTemplate() -> AnyObject {
  40. if (self.tabView.indexOfTabViewItem(self.tabView.selectedTabViewItem!) == 0) {
  41. let currentController: KMBackgroundPropertyInfoController = self.tabView.selectedTabViewItem?.viewController as! KMBackgroundPropertyInfoController
  42. return currentController.model
  43. } else {
  44. let currentController: KMBackgroundFilePropertyInfoController = self.tabView.selectedTabViewItem?.viewController as! KMBackgroundFilePropertyInfoController
  45. return currentController.model
  46. }
  47. }
  48. }
  49. extension KMCreateBackgroundController: KMBackgroundPropertyInfoDelegate {
  50. func propertyInfoDidChange(model: KMBackgroundModel) {
  51. if (self.delegate == nil) {
  52. return
  53. }
  54. self.delegate?.propertyInfoDidChange(model: model)
  55. }
  56. }