|
@@ -85,7 +85,12 @@ class KMNoteTypeImageView: NSImageView {
|
|
|
}
|
|
|
|
|
|
if type == SKNNoteString {
|
|
|
- image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsNote)
|
|
|
+ image = NSImage(named: "markup_note_base")
|
|
|
+ let upImage = NSImage(named: "markup_note_Cover")
|
|
|
+
|
|
|
+ if let img = NSImage.combineImages(images: [image?.filled(with: color), upImage]) {
|
|
|
+ image = img
|
|
|
+ }
|
|
|
} else if type == SKNFreeTextString {
|
|
|
image = NSImage(named: KMImageNameUXIconSidebarAnnotationText)
|
|
|
} else if type == SKNCircleString {
|
|
@@ -119,62 +124,25 @@ class KMNoteTypeImageView: NSImageView {
|
|
|
}
|
|
|
image?.unlockFocus()
|
|
|
} else if type == SKNHighlightString {
|
|
|
- if let baseImage = NSImage(named: highlight) {
|
|
|
- var size = NSMakeSize(20, 20)
|
|
|
- image = NSImage(size: size)
|
|
|
- image?.lockFocus()
|
|
|
- if let context = NSGraphicsContext.current?.cgContext {
|
|
|
- let newColor = color.usingColorSpaceName(NSColorSpaceName.calibratedRGB)
|
|
|
- let newUnderlineColor = NSColor(red: newColor!.redComponent, green: newColor!.greenComponent, blue: newColor!.blueComponent, alpha: newColor?.alphaComponent ?? 0.7)
|
|
|
- newUnderlineColor.setFill()
|
|
|
- context.setStrokeColor(NSColor.clear.cgColor)
|
|
|
- let fw = image!.size.width
|
|
|
- let fh = image!.size.height
|
|
|
- context.move(to: CGPoint(x: 0, y: fh - 4))
|
|
|
- context.addArc(tangent1End: CGPoint(x: 0, y: 0), tangent2End: CGPoint(x: 4, y: 0), radius: 2)
|
|
|
- context.addArc(tangent1End: CGPoint(x: fw, y: 0), tangent2End: CGPoint(x: fw, y: 4), radius: 2)
|
|
|
- context.addArc(tangent1End: CGPoint(x: fw, y: fh), tangent2End: CGPoint(x: fw - 4, y: fh), radius: 2)
|
|
|
- context.addArc(tangent1End: CGPoint(x: 0, y: fh), tangent2End: CGPoint(x: 0, y: fh - 4), radius: 2)
|
|
|
- context.drawPath(using: .fillStroke)
|
|
|
- baseImage.draw(in: CGRect(x: 0, y: 0, width: image!.size.width, height: image!.size.height))
|
|
|
- }
|
|
|
- image?.unlockFocus()
|
|
|
+ image = NSImage(named: "markup_highlight_base")
|
|
|
+ let upImage = NSImage(named: "markup_highlight_Cover")
|
|
|
+
|
|
|
+ if let img = NSImage.combineImages(images: [image?.filled(with: color), upImage]) {
|
|
|
+ image = img
|
|
|
}
|
|
|
} else if type == SKNUnderlineString {
|
|
|
- if let baseImage = NSImage(named: underline) {
|
|
|
- var size = NSMakeSize(20, 20)
|
|
|
- image = NSImage(size: size)
|
|
|
- image?.lockFocus()
|
|
|
- if let context = NSGraphicsContext.current?.cgContext {
|
|
|
- context.beginPath()
|
|
|
- context.move(to: CGPoint(x: 0, y: 1))
|
|
|
- context.addLine(to: CGPoint(x: image!.size.width, y: 1))
|
|
|
- let newColor = color.usingColorSpaceName(NSColorSpaceName.calibratedRGB)
|
|
|
- let newUnderlineColor = NSColor(red: newColor!.redComponent, green: newColor!.greenComponent, blue: newColor!.blueComponent, alpha: 1)
|
|
|
- newUnderlineColor.setStroke()
|
|
|
- context.setLineWidth(2)
|
|
|
- context.strokePath()
|
|
|
- baseImage.draw(in: CGRect(x: 0, y: 0, width: image!.size.width, height: image!.size.height))
|
|
|
- }
|
|
|
- image?.unlockFocus()
|
|
|
+ image = NSImage(named: "markup_underline_Cover")
|
|
|
+ let upImage = NSImage(named: "markup_underline_base")
|
|
|
+
|
|
|
+ if let img = NSImage.combineImages(images: [(image?.filled(with: color))!, upImage!]) {
|
|
|
+ return img
|
|
|
}
|
|
|
} else if type == SKNStrikeOutString {
|
|
|
- if let strikeImage = NSImage(named: highlight) {
|
|
|
- var size = NSMakeSize(20, 20)
|
|
|
- image = NSImage(size: size)
|
|
|
- image?.lockFocus()
|
|
|
- if let context = NSGraphicsContext.current?.cgContext {
|
|
|
- context.beginPath()
|
|
|
- context.move(to: CGPoint(x: 0, y: size.height / 2 ))
|
|
|
- context.addLine(to: CGPoint(x: size.width, y: size.height / 2 ))
|
|
|
- let newColor = color.usingColorSpaceName(NSColorSpaceName.calibratedRGB)
|
|
|
- let strikenColor = NSColor(red: newColor!.redComponent, green: newColor!.greenComponent, blue: newColor!.blueComponent, alpha: 1)
|
|
|
- strikenColor.setStroke()
|
|
|
- context.setLineWidth(2)
|
|
|
- context.strokePath()
|
|
|
- strikeImage.draw(in: CGRect(x: 0, y: 0, width: image!.size.width, height: image!.size.height))
|
|
|
- }
|
|
|
- image?.unlockFocus()
|
|
|
+ image = NSImage(named: "markup_strikethrough_Cover")
|
|
|
+ let upImage = NSImage(named: "markup_strikethrough_base")
|
|
|
+
|
|
|
+ if let img = NSImage.combineImages(images: [(image?.filled(with: color))!, upImage!]) {
|
|
|
+ image = img
|
|
|
}
|
|
|
} else if type == SKNLine_NoneString {
|
|
|
image = NSImage(size: CGSize(width: 16, height: 16))
|
|
@@ -209,25 +177,11 @@ class KMNoteTypeImageView: NSImageView {
|
|
|
}
|
|
|
image?.unlockFocus()
|
|
|
} else if type == SKNInkString {
|
|
|
- if let baseImage = NSImage(named: inkIcon)?.copy() as? NSImage {
|
|
|
- // baseImage.size.offset(x: 1.5, y: 1.5)
|
|
|
- var size = NSMakeSize(20, 20)
|
|
|
- image = NSImage(size: size)
|
|
|
- image?.lockFocus()
|
|
|
- let ref3 = NSGraphicsContext.current?.cgContext
|
|
|
- KMContextSaveGState(ref3)
|
|
|
- KMContextBeginPath(ref3)
|
|
|
- KMContextMoveToPoint(ref3, 2, 3)
|
|
|
- KMContextAddCurveToPoint(ref3, image!.size.width/2, -5, 3 * image!.size.width/4, 3 * image!.size.width/4, image!.size.width, 4)
|
|
|
- KMContextSetLineWidth(ref3, 1);
|
|
|
- if let newColor = color.usingColorSpaceName(.calibratedRGB) {
|
|
|
- let newInkColor = NSColor(red: newColor.redComponent, green: newColor.greenComponent, blue: newColor.blueComponent, alpha: 1)
|
|
|
- newInkColor.set()
|
|
|
- }
|
|
|
- KMContextStrokePath(ref3);
|
|
|
- KMContextRestoreGState(ref3);
|
|
|
- baseImage.draw(in: CGRect(x: 0, y: 0, width: image!.size.width, height: image!.size.height))
|
|
|
- image?.unlockFocus()
|
|
|
+ image = NSImage(named: "markup_pen_Cover")
|
|
|
+ let upImage = NSImage(named: "markup_pen_base")
|
|
|
+
|
|
|
+ if let img = NSImage.combineImages(images: [(image?.filled(with: color))!, upImage!]) {
|
|
|
+ image = img
|
|
|
}
|
|
|
} else if type == SKNStampString {
|
|
|
image = NSImage(named: KMImageNameUXIconSidebarAnnotationStamp)?.copy() as? NSImage
|
|
@@ -236,69 +190,35 @@ class KMNoteTypeImageView: NSImageView {
|
|
|
} else if type == SKNStamp_ImageString {
|
|
|
image = NSImage(named: "KMImageNameAnnotationImage")?.copy() as? NSImage
|
|
|
} else if type == SKNSignFalseString {
|
|
|
- image = NSImage(named: "KMImageNameToolbarForx")?.copy() as? NSImage
|
|
|
+ image = NSImage(named: "fill_tick")
|
|
|
} else if type == SKNSignTureString {
|
|
|
- image = NSImage(named: "KMImageNameToolbarTick")?.copy() as? NSImage
|
|
|
+ image = NSImage(named: "fill_fork")
|
|
|
} else if type == SKNSignCircleString {
|
|
|
- image = NSImage(named: "KMImageNameToolbarRoundedrec")?.copy() as? NSImage
|
|
|
+ image = NSImage(named: "fill_rectangle")
|
|
|
} else if type == SKNSignLineString {
|
|
|
- image = NSImage(named: "KMImageNameToolbarSignLine")?.copy() as? NSImage
|
|
|
+ image = NSImage(named: "fill_line")
|
|
|
} else if type == SKNSignDotString {
|
|
|
- image = NSImage(named: "KMImageNameToolbarPoint")?.copy() as? NSImage
|
|
|
+ image = NSImage(named: "fill_dot")
|
|
|
} else if type == SKNRedactString {
|
|
|
image = NSImage(named: "KMImageNameUXIconSubtoolbarRedactPoint")?.copy() as? NSImage
|
|
|
} else if type == SKNSignatureString {
|
|
|
- image = NSImage(named: "KMImageNameSidetabbarSignatureNor")?.copy() as? NSImage
|
|
|
+ image = NSImage(named: "markup_sign")
|
|
|
} else if type == "Ink_Table" {
|
|
|
image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsTable)?.copy() as? NSImage
|
|
|
} else if type == SKMeasurePolygonString {
|
|
|
- image = NSImage(named: "KMImageNameListPolygon")?.copy() as? NSImage
|
|
|
+ image = NSImage(named: "KMNImageNameFilterMeasure")?.copy() as? NSImage
|
|
|
} else if type == SKMeasureMultilinesString {
|
|
|
- image = NSImage(named: "KMImageNameListPolyline")?.copy() as? NSImage
|
|
|
+ image = NSImage(named: "KMNImageNameFilterMeasure")?.copy() as? NSImage
|
|
|
} else if type == SKMeasureLineString {
|
|
|
- image = NSImage(named: "KMImageNameUXIconMeasureNor")?.copy() as? NSImage
|
|
|
+ image = NSImage(named: "KMNImageNameFilterMeasure")?.copy() as? NSImage
|
|
|
} else if type == SKMeasureRectangleString {
|
|
|
image = NSImage(named: "KMImageNameListMeasureSquare")?.copy() as? NSImage
|
|
|
} else if type == "Squiggly" {
|
|
|
- if let baseImage = NSImage(named: underline)?.copy() as? NSImage {
|
|
|
- // baseImage.size.offset(x: 1.5, y: 1.5)
|
|
|
- var size = NSMakeSize(20, 20)
|
|
|
- image = NSImage(size: size)
|
|
|
- image?.lockFocus()
|
|
|
- let ref3 = NSGraphicsContext.current?.cgContext
|
|
|
- KMContextSaveGState(ref3)
|
|
|
- KMContextBeginPath(ref3)
|
|
|
-
|
|
|
- let length = 24.0
|
|
|
- let stepLength = 6.0
|
|
|
- var count = Int(round(length / CGFloat(stepLength)))
|
|
|
-
|
|
|
- if count == 0 {
|
|
|
- count = 1
|
|
|
- }
|
|
|
- KMContextSetLineWidth(ref3, 2);
|
|
|
- if let newColor = color.usingColorSpaceName(.calibratedRGB) {
|
|
|
- let newInkColor = NSColor(red: newColor.redComponent, green: newColor.greenComponent, blue: newColor.blueComponent, alpha: 1)
|
|
|
- newInkColor.set()
|
|
|
- }
|
|
|
- var initX = 0.0
|
|
|
- for i in 0..<count {
|
|
|
- let s = CGPoint(x: initX, y: 2)
|
|
|
- let e = CGPoint(x: initX + stepLength, y: 2)
|
|
|
- let cp1 = CGPoint(x: initX + CGFloat(stepLength) / 2, y: 2 + 4)
|
|
|
- let cp2 = CGPoint(x: initX + CGFloat(stepLength) - CGFloat(stepLength) / 2, y: 0)
|
|
|
-
|
|
|
- ref3?.move(to: s)
|
|
|
- ref3?.addCurve(to: e, control1: cp1, control2: cp2)
|
|
|
- ref3?.strokePath()
|
|
|
-
|
|
|
- initX += CGFloat(stepLength)
|
|
|
- }
|
|
|
-
|
|
|
- KMContextStrokePath(ref3);
|
|
|
- KMContextRestoreGState(ref3);
|
|
|
- baseImage.draw(in: CGRect(x: 0, y: 0, width: image!.size.width, height: image!.size.height))
|
|
|
- image?.unlockFocus()
|
|
|
+ image = NSImage(named: "markup_wavyline_Cover")
|
|
|
+ let upImage = NSImage(named: "markup_wavyline_base")
|
|
|
+
|
|
|
+ if let img = NSImage.combineImages(images: [(image?.filled(with: CPDFMarkupAnnotation.defaultColor(.squiggly)))!, upImage!]) {
|
|
|
+ image = img
|
|
|
}
|
|
|
} else if type == "eraser" {
|
|
|
image = NSImage(named: "KMImageNameEraserIcon")?.copy() as? NSImage
|
|
@@ -324,8 +244,6 @@ class KMNoteTypeImageView: NSImageView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
func KMPDFAnnotationNoteType(_ anno: CPDFAnnotation?) -> String {
|
|
|
guard let inAnno = anno else {
|
|
|
return ""
|