KMConvertCSVSettingView.swift 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // KMConvertCSVSettingView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2022/12/6.
  6. //
  7. import Cocoa
  8. class KMConvertCSVSettingView: KMConvertSettingView {
  9. @IBOutlet weak var oneFileForPageComboBox: NSButton!
  10. @IBOutlet weak var onlyGetTableBox: NSBox!
  11. @IBOutlet weak var tableSheetComboBox: NSComboBox!
  12. @IBOutlet weak var pageRangeBox: NSBox!
  13. var selectedSettingIndex: Int = 0
  14. var selectedTableFormatIndex: Int = 0
  15. var onlyGetTableVC: KMDesignButton?
  16. override func awakeFromNib() {
  17. super.awakeFromNib()
  18. }
  19. override func initSubViews() {
  20. super.initSubViews()
  21. self.oneFileForPageComboBox.title = NSLocalizedString("Excel Worksheet Settings", comment: "")
  22. self.oneFileForPageComboBox.font = .SFProTextSemiboldFont(12)
  23. self.oneFileForPageComboBox.setTitleColor(color: NSColor.km_init(hex: "#616469"))
  24. self.onlyGetTableVC = KMDesignButton.init(withType: .CheckBox)
  25. self.onlyGetTableBox.contentView = self.onlyGetTableVC!.view
  26. self.onlyGetTableVC?.target = self
  27. self.onlyGetTableVC?.action = #selector(self.radioAction(sender:))
  28. self.onlyGetTableVC?.checkbox_radio()
  29. self.tipView?.km_add_left_constraint(constant: 8)
  30. self.tipView?.km_add_top_constraint(equalTo: self.pageRangeBox, attribute: .bottom, constant: -5)
  31. self.tipView?.km_add_right_constraint()
  32. self.tipView?.km_add_height_constraint(constant: 16+20+16)
  33. }
  34. override func initDefaultVlaue() {
  35. super.initDefaultVlaue()
  36. self.onlyGetTableBox.fillColor = .clear
  37. self.onlyGetTableVC?.stringValue = NSLocalizedString("Only Table", comment: "")
  38. self.onlyGetTableVC?.checkbox_radio()
  39. }
  40. override func viewDidMoveToWindow() {
  41. super.viewDidMoveToWindow()
  42. if (self.pageRangeItemView == nil) {
  43. self.pageRangeItemView = KMConvertPageRangeSettingItemView.createFromNib()
  44. self.pageRangeBox.contentView = self.pageRangeItemView
  45. }
  46. }
  47. @objc func radioAction(sender: NSButton) {
  48. for radio in [self.onlyGetTableVC] {
  49. if ((radio?.button.isEqual(to: sender))!) {
  50. if radio?.state == .Checked {
  51. radio?.state = .Norm
  52. } else {
  53. radio?.state = .Checked
  54. }
  55. }
  56. }
  57. if let state = self.onlyGetTableVC?.state, state == .Checked {
  58. self.selectedSettingIndex = 1
  59. } else {
  60. self.selectedSettingIndex = 0
  61. }
  62. }
  63. }