|
@@ -83,10 +83,10 @@ class KMPrintPosterView: KMBaseXibView {
|
|
|
|
|
|
unitComboBox.selectItem(at: 1)
|
|
|
|
|
|
- let paperArray = KMPageSizeTool.paperSize()
|
|
|
+ var paperArray = KMPrintPaperInfo.KMPaperType.allValues()
|
|
|
var tPaperArray = paperArray
|
|
|
- tPaperArray.append(NSLocalizedString("Custom", comment: ""))
|
|
|
-
|
|
|
+ tPaperArray.removeFirst()
|
|
|
+
|
|
|
splitSizeComboBox.addItems(withObjectValues: tPaperArray)
|
|
|
splitSizeComboBox.selectItem(at: 1)
|
|
|
splitSizeComboBox.isEditable = false
|
|
@@ -94,16 +94,13 @@ class KMPrintPosterView: KMBaseXibView {
|
|
|
pageHeightTextField.isEnabled = false
|
|
|
|
|
|
var tFileArray = paperArray
|
|
|
- tFileArray.insert(NSLocalizedString("Actual Size", comment: ""), at: 0)
|
|
|
- tFileArray.append(NSLocalizedString("Custom", comment: ""))
|
|
|
-
|
|
|
filePageSizeBox.addItems(withObjectValues: tFileArray)
|
|
|
filePageSizeBox.selectItem(at: 0)
|
|
|
filePageSizeBox.isEditable = false
|
|
|
paperWidthTextField.isEnabled = false
|
|
|
paperHeightTextField.isEnabled = false
|
|
|
|
|
|
- selectPerComboBox.addItems(withObjectValues: ["2", "4", "6", "9", "16", NSLocalizedString("Custom", comment: "")])
|
|
|
+ selectPerComboBox.addItems(withObjectValues: KMPrintPageOperation.PageOfPaper.PageType.allValues())
|
|
|
selectPerComboBox.selectItem(at: 5)
|
|
|
selectPerComboBox.isEditable = false
|
|
|
|
|
@@ -128,6 +125,7 @@ class KMPrintPosterView: KMBaseXibView {
|
|
|
overlapLabel.stringValue = NSLocalizedString("Overlap:", comment: "")
|
|
|
commentsFormsLabel.stringValue = NSLocalizedString("Comments & Forms:", comment: "")
|
|
|
|
|
|
+ pageRangeComboBox.removeAllItems()
|
|
|
pageRangeComboBox.addItems(withObjectValues: [
|
|
|
NSLocalizedString("All Pages", comment: ""),
|
|
|
NSLocalizedString("Odd Pages Only", comment: ""),
|
|
@@ -136,6 +134,7 @@ class KMPrintPosterView: KMBaseXibView {
|
|
|
])
|
|
|
pageRangeComboBox.placeholderString = NSLocalizedString("e.g. 1,3-5,10", comment: "")
|
|
|
|
|
|
+ commentsFormsComboBox.removeAllItems()
|
|
|
commentsFormsComboBox.addItems(withObjectValues: [
|
|
|
NSLocalizedString("Document", comment: ""),
|
|
|
NSLocalizedString("Document and Markups", comment: ""),
|
|
@@ -154,19 +153,18 @@ class KMPrintPosterView: KMBaseXibView {
|
|
|
tableView.tabViewItem(at: 0).label = NSLocalizedString("Tile", comment: "")
|
|
|
tableView.tabViewItem(at: 1).label = NSLocalizedString("Split", comment: "")
|
|
|
|
|
|
- let paperArray = KMPageSizeTool.paperSize()
|
|
|
+ var paperArray = KMPrintPaperInfo.KMPaperType.allValues() /*KMPageSizeTool.paperSize()*/
|
|
|
var tPaperArray = paperArray
|
|
|
- tPaperArray.append(NSLocalizedString("Custom", comment: ""))
|
|
|
-
|
|
|
+ tPaperArray.removeFirst()
|
|
|
+ splitSizeComboBox.removeAllItems()
|
|
|
splitSizeComboBox.addItems(withObjectValues: tPaperArray)
|
|
|
|
|
|
var tFileArray = paperArray
|
|
|
- tFileArray.insert(NSLocalizedString("Actual Size", comment: ""), at: 0)
|
|
|
- tFileArray.append(NSLocalizedString("Custom", comment: ""))
|
|
|
-
|
|
|
+ filePageSizeBox.removeAllItems()
|
|
|
filePageSizeBox.addItems(withObjectValues: tFileArray)
|
|
|
|
|
|
- selectPerComboBox.addItems(withObjectValues: ["2", "4", "6", "9", "16", NSLocalizedString("Custom", comment: "")])
|
|
|
+ selectPerComboBox.removeAllItems()
|
|
|
+ selectPerComboBox.addItems(withObjectValues: KMPrintPageOperation.PageOfPaper.PageType.allValues())
|
|
|
}
|
|
|
|
|
|
override func reloadData() {
|
|
@@ -175,6 +173,302 @@ class KMPrintPosterView: KMBaseXibView {
|
|
|
columnCountText.stringValue = "\(poster.pageOfPaper.point.x)"
|
|
|
lineCountText.stringValue = "\(poster.pageOfPaper.point.y)"
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //MARK: Action
|
|
|
+ @IBAction func buttonItemClickCutMarks(_ sender: NSButton) {
|
|
|
+ self.viewModel.posterCutMarkAction(isSelect: cutMarksButton.state == .on, completion: { success, model in
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func buttonItemClickLabels(_ sender: NSButton) {
|
|
|
+ self.viewModel.posterTagsAction(isSelect: cutMarksButton.state == .on, tags:[labelTextField.stringValue]) { success, model in
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func buttonItemClickOrientation(_ sender: NSButton) {
|
|
|
+ var direction: KMPrintPaperDirectionType = .vertical
|
|
|
+ if landscapeButton.state == .on {
|
|
|
+ direction = .horizontal
|
|
|
+ } else if portraitButton.state == .on {
|
|
|
+ direction = .vertical
|
|
|
+ }
|
|
|
+
|
|
|
+ self.viewModel.printDirectionAction(type: direction, completion: { success, model in
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @IBAction func comboBoxItemClickPageRange(_ sender: NSComboBox) {
|
|
|
+ var range: KMPrintPageRange = KMPrintPageRange()
|
|
|
+ if sender.indexOfSelectedItem == 0 ||
|
|
|
+ sender.indexOfSelectedItem == 1 ||
|
|
|
+ sender.indexOfSelectedItem == 2 {
|
|
|
+ window?.makeFirstResponder(self)
|
|
|
+ sender.isEditable = false
|
|
|
+
|
|
|
+ if sender.indexOfSelectedItem == 0 {
|
|
|
+ range.type = .allPage
|
|
|
+ } else if sender.indexOfSelectedItem == 1 {
|
|
|
+ range.type = .oddPage
|
|
|
+ } else if sender.indexOfSelectedItem == 2 {
|
|
|
+ range.type = .evenPage
|
|
|
+ }
|
|
|
+ } else if sender.indexOfSelectedItem == 3 {
|
|
|
+ sender.stringValue = ""
|
|
|
+ sender.isEditable = true
|
|
|
+ window?.makeFirstResponder(sender)
|
|
|
+
|
|
|
+ range.type = .custom
|
|
|
+ range.pageString = sender.stringValue
|
|
|
+ }
|
|
|
+ self.viewModel.pageRangeAction(range: range) { success, model in
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func comboBoxItemClickSplitSize(_ sender: NSComboBox) {
|
|
|
+ overlapTextField.stringValue = "0"
|
|
|
+ var customSize = CGSize(width: 595, height: 842)
|
|
|
+// self.PDFPrint.splitSize = CGSizeMake(tSize.width * 595.0/210, tSize.height * 842.0/297.0);
|
|
|
+ if splitSizeComboBox.indexOfSelectedItem == splitSizeComboBox.numberOfItems - 1 {
|
|
|
+ pageWidthTextField.isEnabled = true
|
|
|
+ pageHeightTextField.isEnabled = true
|
|
|
+ } else {
|
|
|
+ pageWidthTextField.isEnabled = false
|
|
|
+ pageHeightTextField.isEnabled = false
|
|
|
+ }
|
|
|
+
|
|
|
+ let type = KMPrintPaperInfo.KMPaperType(rawValue: sender.stringValue) ?? .A4
|
|
|
+ self.viewModel.printPaperTypeAction(type: type, customSize: customSize, completion: { success, model in
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func comboBoxItemClickFullPageSize(_ sender: NSComboBox) {
|
|
|
+ var customSize = CGSize(width: 595, height: 842)
|
|
|
+ if filePageSizeBox.indexOfSelectedItem == 0 {
|
|
|
+ paperWidthTextField.isEnabled = false
|
|
|
+ paperHeightTextField.isEnabled = false
|
|
|
+ } else if filePageSizeBox.indexOfSelectedItem == filePageSizeBox.numberOfItems - 1 {
|
|
|
+ paperWidthTextField.isEnabled = true
|
|
|
+ paperHeightTextField.isEnabled = true
|
|
|
+ } else {
|
|
|
+ paperWidthTextField.isEnabled = false
|
|
|
+ paperHeightTextField.isEnabled = false
|
|
|
+ }
|
|
|
+
|
|
|
+ overlapTextField.stringValue = "0"
|
|
|
+ let type = KMPrintPaperInfo.KMPaperType(rawValue: sender.stringValue) ?? .A4
|
|
|
+ self.viewModel.printPaperTypeAction(type: type, posterType: .breakUp, customSize: customSize, completion: { success, model in
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func buttonItemClickReversePage(_ sender: NSButton) {
|
|
|
+ self.viewModel.printReverseAction(isSelect: reverseButton.state == .on) { success, model in
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func comboBoxItemClickUnit(_ sender: Any) {
|
|
|
+ if unitComboBox.indexOfSelectedItem == 1 {
|
|
|
+ unitTLabel.stringValue = NSLocalizedString("mm", comment: "")
|
|
|
+ unitT1Label.stringValue = NSLocalizedString("mm", comment: "")
|
|
|
+ overlapUnit.stringValue = NSLocalizedString("mm", comment: "")
|
|
|
+ } else if unitComboBox.indexOfSelectedItem == 0 {
|
|
|
+ unitTLabel.stringValue = NSLocalizedString("cm", comment: "")
|
|
|
+ unitT1Label.stringValue = NSLocalizedString("cm", comment: "")
|
|
|
+ overlapUnit.stringValue = NSLocalizedString("cm", comment: "")
|
|
|
+ } else {
|
|
|
+ unitTLabel.stringValue = NSLocalizedString("cm", comment: "")
|
|
|
+ unitT1Label.stringValue = NSLocalizedString("cm", comment: "")
|
|
|
+ overlapUnit.stringValue = NSLocalizedString("in", comment: "")
|
|
|
+ }
|
|
|
+
|
|
|
+ overlapTextField.stringValue = "0"
|
|
|
+ self.viewModel.printOverlapChangeAction(value: overlapTextField.floatValue, completion: { success, model in
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func comboBoxItemClickCommentsForms(_ sender: NSComboBox) {
|
|
|
+ var type: KMPrintContentType = .document
|
|
|
+ if commentsFormsComboBox.indexOfSelectedItem == 0 {
|
|
|
+ type = .document
|
|
|
+ } else if commentsFormsComboBox.indexOfSelectedItem == 1 {
|
|
|
+ type = .documentAndMarkup
|
|
|
+ } else if commentsFormsComboBox.indexOfSelectedItem == 2 {
|
|
|
+ type = .documentAndStamp
|
|
|
+ }
|
|
|
+
|
|
|
+ self.viewModel.printContentAction(type: type, completion: { success, model in
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func comboBoxItemClickPagesPer(_ sender: NSComboBox) {
|
|
|
+ if selectPerComboBox.indexOfSelectedItem != 5 {
|
|
|
+ columnCountText.isEditable = false
|
|
|
+ lineCountText.isEditable = false
|
|
|
+ columnCountText.isSelectable = false
|
|
|
+ lineCountText.isSelectable = false
|
|
|
+ } else {
|
|
|
+ columnCountText.isEditable = true
|
|
|
+ lineCountText.isEditable = true
|
|
|
+ columnCountText.isSelectable = true
|
|
|
+ lineCountText.isSelectable = true
|
|
|
+ }
|
|
|
+
|
|
|
+ self.viewModel.printPagePerChangeAction(type: KMPrintPageOperation.PageOfPaper.PageType(rawValue: selectPerComboBox.stringValue) ?? .page, completion: { success, model in
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ func tabView(_ tabView: NSTabView, willSelect tabViewItem: NSTabViewItem?) {
|
|
|
+ overlapTextField.stringValue = "0"
|
|
|
+ self.viewModel.printOverlapChangeAction(value: overlapTextField.floatValue, completion: { success, model in
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ if let identifier = tabViewItem?.identifier as? String {
|
|
|
+ if identifier == "1" {
|
|
|
+ self.viewModel.posterTypeAction(type: .tile) { success, model in
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ self.viewModel.posterTypeAction(type: .breakUp) { success, model in
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func controlTextDidEndEditing(_ notification: Notification) {
|
|
|
+ guard let textField = notification.object as? NSTextField else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if textField == scaleTextField {
|
|
|
+ if scaleTextField.integerValue <= 0 {
|
|
|
+ scaleTextField.stringValue = "100"
|
|
|
+ }
|
|
|
+
|
|
|
+ self.viewModel.posterScaleAction(value: scaleTextField.floatValue / 100.0) { success, model in
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if textField == pageRangeComboBox {
|
|
|
+
|
|
|
+ let range = KMPrintPageRange(type: .custom, pageString: pageRangeComboBox.stringValue)
|
|
|
+ self.viewModel.pageRangeAction(range: range) { success, model in
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if textField == columnCountText {
|
|
|
+ if selectPerComboBox.indexOfSelectedItem != 5 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if columnCountText.integerValue < 1 {
|
|
|
+ columnCountText.stringValue = "1"
|
|
|
+ } else if columnCountText.integerValue > 99 {
|
|
|
+ columnCountText.stringValue = "99"
|
|
|
+ }
|
|
|
+
|
|
|
+ let point = CGPoint(x: columnCountText.integerValue, y: lineCountText.integerValue)
|
|
|
+ self.viewModel.printPagePerChangeAction(type: .custom, customPoint: point) { success, model in
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if textField == lineCountText {
|
|
|
+ if selectPerComboBox.indexOfSelectedItem != 5 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if lineCountText.integerValue < 1 {
|
|
|
+ lineCountText.stringValue = "1"
|
|
|
+ } else if lineCountText.integerValue > 99 {
|
|
|
+ lineCountText.stringValue = "99"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ let point = CGPoint(x: columnCountText.integerValue, y: lineCountText.integerValue)
|
|
|
+ self.viewModel.printPagePerChangeAction(type: .custom, customPoint: point) { success, model in
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if textField == pageWidthTextField || textField == paperWidthTextField {
|
|
|
+ overlapTextField.stringValue = "0"
|
|
|
+
|
|
|
+ var over = CGFloat((textField.stringValue as NSString).floatValue)
|
|
|
+ if unitComboBox.indexOfSelectedItem == 0 {
|
|
|
+ over *= 595.0 / 21
|
|
|
+ } else if unitComboBox.indexOfSelectedItem == 3 {
|
|
|
+ over *= 595.0 / 210 * 25.4
|
|
|
+ } else {
|
|
|
+ over *= 595.0 / 210
|
|
|
+ }
|
|
|
+ var size = self.viewModel.model.paper.info.size
|
|
|
+ size.width = over
|
|
|
+ self.viewModel.printPaperTypeAction(type: .custom, customSize: size, completion: { success, model in
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ } else if textField == pageHeightTextField || textField == paperHeightTextField {
|
|
|
+ overlapTextField.stringValue = "0"
|
|
|
+ self.viewModel.printOverlapChangeAction(value: overlapTextField.floatValue) { success, model in
|
|
|
+
|
|
|
+ }
|
|
|
+ var over = CGFloat((textField.stringValue as NSString).floatValue)
|
|
|
+ if unitComboBox.indexOfSelectedItem == 0 {
|
|
|
+ over *= 842.0 / 29.7
|
|
|
+ } else if unitComboBox.indexOfSelectedItem == 3 {
|
|
|
+ over *= 842.0 / 297 * 25.4
|
|
|
+ } else {
|
|
|
+ over *= 842.0 / 297
|
|
|
+ }
|
|
|
+ var size = self.viewModel.model.paper.info.size
|
|
|
+ size.width = over
|
|
|
+ self.viewModel.printPaperTypeAction(type: .custom, customSize: size, completion: { success, model in
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func controlTextDidChange(_ notification: Notification) {
|
|
|
+ guard let textField = notification.object as? NSTextField else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if textField == columnCountText || textField == lineCountText {
|
|
|
+ if let string = textField.formatter?.string(for: NSNumber(value: textField.stringValue.stringToCGFloat())) {
|
|
|
+ textField.stringValue = string
|
|
|
+ }
|
|
|
+ } else if textField == overlapTextField {
|
|
|
+ var maxOverlap: CGFloat
|
|
|
+ let size = self.viewModel.model.paper.info.size
|
|
|
+ maxOverlap = min(size.width, size.height)
|
|
|
+
|
|
|
+ var over = textField.stringValue.stringToCGFloat()
|
|
|
+ if unitComboBox.indexOfSelectedItem == 0 {
|
|
|
+ over *= 28.4
|
|
|
+ } else if unitComboBox.indexOfSelectedItem == 3 {
|
|
|
+ over *= 72.0
|
|
|
+ } else {
|
|
|
+ over *= 2.84 // 595/210
|
|
|
+ }
|
|
|
+
|
|
|
+ if over <= 0 || over > maxOverlap / 2 {
|
|
|
+ overlapTextField.stringValue = "0"
|
|
|
+ over = 0
|
|
|
+ }
|
|
|
+
|
|
|
+ self.viewModel.printOverlapChangeAction(value: Float(over)) { success, model in
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|