KMConvertCSVSettingView.swift 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. // tableSheetComboBox.removeAllItems()
  19. // tableSheetComboBox.addItems(withObjectValues: ["支持一个表格提取到单独的工作表","支持按页面提取表格到单独的工作表","支持将所有表格提取到一个工作表"])
  20. // tableSheetComboBox.selectItem(at: 0)
  21. // tableSheetComboBox.delegate = self
  22. }
  23. override func initSubViews() {
  24. super.initSubViews()
  25. self.oneFileForPageComboBox.title = NSLocalizedString("Excel Worksheet Settings", comment: "")
  26. self.oneFileForPageComboBox.font = .SFProTextSemiboldFont(12)
  27. self.oneFileForPageComboBox.setTitleColor(color: NSColor.km_init(hex: "#616469"))
  28. self.onlyGetTableVC = KMDesignButton.init(withType: .CheckBox)
  29. self.onlyGetTableBox.contentView = self.onlyGetTableVC!.view
  30. self.onlyGetTableVC?.target = self
  31. self.onlyGetTableVC?.action = #selector(self.radioAction(sender:))
  32. self.onlyGetTableVC?.checkbox_radio()
  33. self.tipView?.km_add_left_constraint(constant: 8)
  34. self.tipView?.km_add_top_constraint(equalTo: self.pageRangeBox, attribute: .bottom, constant: -5)
  35. self.tipView?.km_add_right_constraint()
  36. self.tipView?.km_add_height_constraint(constant: 16+20+16)
  37. }
  38. override func initDefaultVlaue() {
  39. super.initDefaultVlaue()
  40. self.onlyGetTableBox.fillColor = .clear
  41. self.onlyGetTableVC?.stringValue = NSLocalizedString("Only Table", comment: "")
  42. self.onlyGetTableVC?.checkbox_radio()
  43. }
  44. override func viewDidMoveToWindow() {
  45. super.viewDidMoveToWindow()
  46. if (self.pageRangeItemView == nil) {
  47. self.pageRangeItemView = KMConvertPageRangeSettingItemView.createFromNib()
  48. self.pageRangeBox.contentView = self.pageRangeItemView
  49. // self.tipView?.km_add_left_constraint(constant: 8)
  50. // self.tipView?.km_add_top_constraint(equalTo: self.pageRangeBox, attribute: .bottom, constant: -5)
  51. // self.tipView?.km_add_right_constraint()
  52. // self.tipView?.km_add_height_constraint(constant: 16+20+16)
  53. }
  54. }
  55. @objc func radioAction(sender: NSButton) {
  56. for radio in [self.onlyGetTableVC] {
  57. if ((radio?.button.isEqual(to: sender))!) {
  58. if radio?.state == .Checked {
  59. radio?.state = .Norm
  60. } else {
  61. radio?.state = .Checked
  62. }
  63. }
  64. }
  65. // if let state = self.onlyGetTableVC?.state, state == .Checked {
  66. // self.tableSheetComboBox.isEnabled = true
  67. // } else {
  68. // self.tableSheetComboBox.isEnabled = false
  69. // }
  70. if let state = self.onlyGetTableVC?.state, state == .Checked {
  71. self.selectedSettingIndex = 1
  72. } else {
  73. self.selectedSettingIndex = 0
  74. }
  75. }
  76. }
  77. //extension KMConvertCSVSettingView: NSComboBoxDelegate {
  78. // func comboBoxSelectionDidChange(_ notification: Notification) {
  79. // if (tableSheetComboBox.isEqual(to: notification.object)) {
  80. // if tableSheetComboBox.indexOfSelectedItem < 0 {
  81. // selectedTableFormatIndex = 0
  82. // return
  83. // }
  84. //
  85. // selectedTableFormatIndex = tableSheetComboBox.indexOfSelectedItem
  86. // }
  87. // }
  88. //}