.../Source/Utilities/CutBoxImageRef.swift
Line | Count | Source (jump to first uncovered line) |
1 | | // |
2 | | // CutBoxImageRef.swift |
3 | | // CutBox |
4 | | // |
5 | | // Created by jason on 13/9/23. |
6 | | // Copyright © 2023 ocodo. All rights reserved. |
7 | | // |
8 | | |
9 | | import Cocoa |
10 | | |
11 | | enum CutBoxImageRef: String { |
12 | | case magnitude |
13 | | case historyClockFaceWhite |
14 | | case star |
15 | | case page |
16 | | case statusIcon |
17 | | |
18 | 333 | func image(_ dashed: Bool = false, with withExtension: String = ".png" ) -> NSImage { |
19 | 333 | return get(self.rawValue, dashed: dashed, withExtension: withExtension) |
20 | 333 | } |
21 | | |
22 | 333 | private func get(_ named: String, dashed: Bool, withExtension: String) -> NSImage { |
23 | 333 | var imageName = named |
24 | 333 | if dashed { |
25 | 98 | imageName = imageName.dashed |
26 | 333 | } |
27 | 333 | |
28 | 333 | if let image = NSImage(named: "\(imageName)\(withExtension)") { |
29 | 0 | return image |
30 | 333 | } else { |
31 | 333 | return NSImage.fake |
32 | 333 | } |
33 | 0 | } |
34 | | } |