1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //
- // KMEditBackgroundController.swift
- // PDF Master
- //
- // Created by tangchao on 2022/12/24.
- //
- import Cocoa
- class KMEditBackgroundController: KMWatermarkAdjectivePropertyBaseController {
-
- var firstController = KMBackgroundPropertyInfoController(nibName: "KMBackgroundPropertyInfoController", bundle: nil)
- var secondController = KMBackgroundFilePropertyInfoController(nibName: "KMBackgroundFilePropertyInfoController", bundle: nil)
-
- var isEdited: Bool = false
- private var myEditModel: KMBackgroundModel!
- var editModel: KMBackgroundModel {
- get {
- return myEditModel
- }
- set {
- myEditModel = newValue
- self.firstController.model = newValue
- self.secondController.model = newValue
- }
- }
-
- override func viewWillAppear() {
- super.viewWillAppear()
-
- if (self.editModel.type == .color) {
- self.selectTabIndex(index: 0)
- } else if (self.editModel.type == .file) {
- self.selectTabIndex(index: 1)
-
- self.secondController.outsideBox.isHidden = false
- self.secondController.positionBox.isHidden = false
- self.secondController.pageRangeBox.isHidden = false
-
- self.secondController.fileInfoView.tipLabel.stringValue = self.editModel.imagePath.lastPathComponent
- }
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- self.backButtton.title = NSLocalizedString("", comment: "")
- self.showBack(show: true)
- self.titleLabel.stringValue = NSLocalizedString("Edit Background", comment: "")
- 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])
- self.segementControl.items = [NSLocalizedString("Color", comment: ""),NSLocalizedString("File", comment: "")]
- self.segementControl.itemClick = { [weak self] (index: Int) in
- self!.tabView.selectTabViewItem(at: index)
- }
-
- let item = NSTabViewItem(identifier: "tabID")
- item.label = "tab1";
- item.viewController = self.firstController
- let item2 = NSTabViewItem(identifier: "tabID2")
- item2.label = "tab2";
- item2.viewController = self.secondController
-
- self.tabView.addTabViewItem(item)
- self.tabView.addTabViewItem(item2)
-
- self.firstController.delegate = self
- self.secondController.delegate = self
- childViewController.append(self.firstController)
- childViewController.append(self.secondController)
-
- self.segementControl.isHidden = true
- self.segementControlHeightConst.constant = 0
- }
-
- override func resume() {
- if (self.flagModel == nil) {
- return
- }
- if (childViewController.count <= 0) {
- return
- }
-
- if (self.segementControl.selectItemIndex == 0) {
- firstController.model = self.flagModel?.copy() as! KMBackgroundModel
- } else if (self.segementControl.selectItemIndex == 1) {
-
- }
- }
- }
- extension KMEditBackgroundController: KMBackgroundPropertyInfoDelegate {
- func propertyInfoDidChange(model: KMBackgroundModel) {
- self.myEditModel = model
- self.isEdited = true
- }
- }
|