|
@@ -7,7 +7,7 @@
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
|
-typealias KMPrintViewModelCompletion = (_ success: Bool, _ model: KMPrintModel) -> Void
|
|
|
+typealias KMPrintViewModelCompletion = (_ success: Bool, _ model: KMPrintModel?) -> Void
|
|
|
|
|
|
class KMPrintViewModel: NSObject {
|
|
|
lazy var model: KMPrintModel = KMPrintModel()
|
|
@@ -55,6 +55,11 @@ extension KMPrintViewModel {
|
|
|
|
|
|
//页面范围
|
|
|
func pageRangeAction(range: KMPrintPageRange, completion: KMPrintViewModelCompletion) {
|
|
|
+ if range.type == model.page.range.type {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
model.page.range.type = range.type
|
|
|
model.page.range.pageString = range.pageString
|
|
|
|
|
@@ -63,6 +68,10 @@ extension KMPrintViewModel {
|
|
|
|
|
|
//打印方向
|
|
|
func printDirectionAction(type: KMPrintPaperDirectionType, completion: KMPrintViewModelCompletion) {
|
|
|
+ if type == model.paper.direction {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
model.paper.direction = type
|
|
|
|
|
|
completion(true, model)
|
|
@@ -70,6 +79,10 @@ extension KMPrintViewModel {
|
|
|
|
|
|
//打印内容
|
|
|
func printContentAction(type: KMPrintContentType, completion: KMPrintViewModelCompletion) {
|
|
|
+ if type == self.model.page.contentType {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
self.model.page.contentType = type
|
|
|
|
|
|
completion(true, model)
|
|
@@ -77,6 +90,10 @@ extension KMPrintViewModel {
|
|
|
|
|
|
//逆页面打印
|
|
|
func printReverseAction(isSelect: Bool, completion: KMPrintViewModelCompletion) {
|
|
|
+ if isSelect == self.model.page.range.reversePrintOrder {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
self.model.page.range.reversePrintOrder = isSelect
|
|
|
|
|
|
completion(true, model)
|
|
@@ -84,6 +101,10 @@ extension KMPrintViewModel {
|
|
|
|
|
|
//打印页面偏移
|
|
|
func printOverlapChangeAction(value: Float, completion: KMPrintViewModelCompletion) {
|
|
|
+ if value == self.model.page.operation.poster.overlap {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
self.model.page.operation.poster.overlap = value
|
|
|
|
|
|
completion(true, model)
|
|
@@ -91,6 +112,11 @@ extension KMPrintViewModel {
|
|
|
|
|
|
//单位
|
|
|
func printUnitChangeAction(unit: KMPrintPaperInfoUnit, completion: KMPrintViewModelCompletion) {
|
|
|
+ if unit == self.model.paper.info.unit {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
self.model.paper.info.unit = unit
|
|
|
|
|
|
completion(true, model)
|
|
@@ -105,6 +131,10 @@ extension KMPrintViewModel {
|
|
|
|
|
|
//纸张类型
|
|
|
func printPaperTypeAction(type: KMPrintPaperInfo.KMPaperType, posterType: KMPrintPageOperation.Poster.PosterType = .tile, customSize: CGSize = CGSizeZero, completion: KMPrintViewModelCompletion) {
|
|
|
+ if type == self.model.paper.info.type {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
self.model.page.operation.poster.overlap = 0
|
|
|
self.model.page.operation.poster.type = posterType
|
|
|
self.model.paper.info.type = type
|
|
@@ -120,8 +150,13 @@ extension KMPrintViewModel {
|
|
|
|
|
|
//页面
|
|
|
func printPagePerChangeAction(type: KMPrintPageOperation.PageOfPaper.PageType, customPoint: CGPoint = CGPoint(x: 2, y: 2), completion: KMPrintViewModelCompletion) {
|
|
|
- self.model.page.operation.pageOfPaper.type = type
|
|
|
+ if type == self.model.page.operation.pageOfPaper.type {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
self.model.page.operation.pageOfPaper.point = customPoint
|
|
|
+ self.model.page.operation.pageOfPaper.type = type
|
|
|
|
|
|
completion(true, model)
|
|
|
}
|
|
@@ -130,12 +165,20 @@ extension KMPrintViewModel {
|
|
|
//Poster
|
|
|
extension KMPrintViewModel {
|
|
|
func posterCutMarkAction(isSelect: Bool, completion: KMPrintViewModelCompletion) {
|
|
|
+ if isSelect == self.model.page.operation.poster.isCutMark {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
self.model.page.operation.poster.isCutMark = isSelect
|
|
|
|
|
|
completion(true, model)
|
|
|
}
|
|
|
|
|
|
func posterTagsAction(isSelect: Bool, tags: [String], completion: KMPrintViewModelCompletion) {
|
|
|
+ if isSelect == self.model.page.operation.poster.isTags {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
self.model.page.operation.poster.isTags = isSelect
|
|
|
self.model.page.operation.poster.tags = tags
|
|
|
|
|
@@ -143,13 +186,21 @@ extension KMPrintViewModel {
|
|
|
}
|
|
|
|
|
|
func posterTypeAction(type: KMPrintPageOperation.Poster.PosterType, completion: KMPrintViewModelCompletion) {
|
|
|
+ if type == self.model.page.operation.poster.type {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
self.model.page.operation.poster.type = type
|
|
|
|
|
|
completion(true, model)
|
|
|
}
|
|
|
|
|
|
- func posterScaleAction(value: Float, completion: KMPrintViewModelCompletion) {
|
|
|
- self.model.page.operation.poster.scale = CGFloat(value)
|
|
|
+ func posterScaleAction(value: CGFloat, completion: KMPrintViewModelCompletion) {
|
|
|
+ if value == self.model.page.operation.poster.scale {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ self.model.page.operation.poster.scale = value
|
|
|
|
|
|
completion(true, model)
|
|
|
}
|
|
@@ -158,6 +209,10 @@ extension KMPrintViewModel {
|
|
|
//Multipage
|
|
|
extension KMPrintViewModel {
|
|
|
func multipageBorderChangeAction(isBorder: Bool, completion: KMPrintViewModelCompletion) {
|
|
|
+ if isBorder == self.model.page.operation.multipage.isBorder {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
self.model.page.operation.multipage.isBorder = isBorder
|
|
|
|
|
|
completion(true, model)
|
|
@@ -176,18 +231,31 @@ extension KMPrintViewModel {
|
|
|
}
|
|
|
|
|
|
func multipagelineSpacingChangeAction(value: CGFloat, completion: KMPrintViewModelCompletion) {
|
|
|
+ if value == self.model.page.operation.multipage.lineSpacing {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
self.model.page.operation.multipage.lineSpacing = value
|
|
|
|
|
|
completion(true, model)
|
|
|
}
|
|
|
|
|
|
func multipagecolumnsSpacingChangeAction(value: CGFloat, completion: KMPrintViewModelCompletion) {
|
|
|
+ if value == self.model.page.operation.multipage.columnsSpacing {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
self.model.page.operation.multipage.columnsSpacing = value
|
|
|
|
|
|
completion(true, model)
|
|
|
}
|
|
|
|
|
|
func multipagePageOrderChangeAction(type: KMPrintPageOperation.Multipage.Order, completion: KMPrintViewModelCompletion) {
|
|
|
+ if type == self.model.page.operation.multipage.orderType {
|
|
|
+ completion(false, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
self.model.page.operation.multipage.orderType = type
|
|
|
|
|
|
completion(true, model)
|