123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- //
- // DSignatureCreateViewController.swift
- // PDF Reader Pro Edition
- //
- // Created by Niehaoyu on 2023/9/28.
- //
- import Cocoa
- class DSignatureCreateViewController: NSViewController {
-
- @IBOutlet weak var configureLabel: NSTextField!
- @IBOutlet weak var selectLabel: NSTextField!
-
- @IBOutlet weak var fileBox: NSBox!
- @IBOutlet weak var fileLabel: NSTextField!
- @IBOutlet weak var fileSubLabel: NSTextField!
- @IBOutlet weak var createFileButton: NSButton!
-
- @IBOutlet weak var createButton: NSButton!
- @IBOutlet weak var creatBox: NSBox!
- @IBOutlet weak var creatLabel: NSTextField!
- @IBOutlet weak var creatSubLabel: NSTextField!
-
- @IBOutlet weak var promptBox: NSBox!
- @IBOutlet var promptTextView: NSTextView!
- @IBOutlet weak var previousStepButton: NSButton!
- @IBOutlet weak var continueButton: NSButton!
-
- var isCreatDS: Bool = false
- var _type: CDSignatureCreatType = .createNone
-
- var actionBlock: ((_ createVC:DSignatureCreateViewController, _ actionType:DSignatureActionType, _ createType: CDSignatureCreatType)->Void)?
-
-
- override func viewWillAppear() {
- super.viewWillAppear()
-
- if self.isCreatDS {
- self.previousStepButton.isHidden = true
- }
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- self.localizedLanguage()
-
- self.configureLabel.textColor = NSColor.labelColor
- self.selectLabel.textColor = NSColor.labelColor
- self.fileLabel.textColor = NSColor.labelColor
- self.creatLabel.textColor = NSColor.labelColor
-
- self.fileSubLabel.textColor = NSColor.labelColor
- self.creatSubLabel.textColor = NSColor.labelColor
- self.promptTextView.textColor = NSColor.labelColor
-
- self.fileBox.borderColor = NSColor(red: 165.0/255.0, green: 167.0/255.0, blue: 179.0/255.0, alpha: 1.0)
- self.creatBox.borderColor = NSColor(red: 165.0/255.0, green: 167.0/255.0, blue: 179.0/255.0, alpha: 1.0)
-
- self.type = .fromFile
-
- }
-
- //MARK: Setter
- var type: CDSignatureCreatType {
- set {
- _type = newValue;
-
- if _type == .signCreate {
- self.createButton.state = .on
- self.createFileButton.state = .off
- } else if _type == .fromFile {
- self.createButton.state = .off
- self.createFileButton.state = .on
- }
- }
-
- get {
- return _type;
- }
- }
-
- func localizedLanguage() {
-
- self.configureLabel.stringValue = NSLocalizedString("Configure a Digital ID for Signing", comment: "")
- self.selectLabel.stringValue = NSLocalizedString("Select the type of Digital ID:", comment: "")
- self.fileLabel.stringValue = NSLocalizedString("Use a Digital ID from a File", comment: "")
- self.fileSubLabel.stringValue = NSLocalizedString("Import an existing digital ID that you have obtained as a file", comment: "")
- self.creatLabel.stringValue = NSLocalizedString("Create a New Digital ID", comment: "")
- self.creatSubLabel.stringValue = NSLocalizedString("Create your self-signed digital ID", comment: "")
-
- self.promptTextView.string = String(format:"%@\n\n%@",NSLocalizedString("A digital ID is required to create a digital signature.The most secure digital ID are issued by trusted Certificate authorities and are based on secure devices like smart card or token. Some are based on files.", comment: ""),NSLocalizedString("You can also create a new digital ID, but they provide a low level of identity assurance.", comment: ""))
- self.previousStepButton.title = NSLocalizedString("Previous Step", comment: "")
- self.continueButton.title = NSLocalizedString("Continue", comment: "")
- }
-
- //MARK: IBAction
-
- @IBAction func closeAction(_ sender: Any) {
- guard let callBack = self.actionBlock else {
- return
- }
- callBack(self, .cancel, self.type)
- }
-
- @IBAction func previousAction(_ sender: Any) {
- guard let callBack = self.actionBlock else {
- return
- }
- callBack(self, .previousStep, self.type)
- }
-
- @IBAction func continueAction(_ sender: Any) {
- guard let callBack = self.actionBlock else {
- return
- }
- callBack(self, .confirm, self.type)
- }
-
- @IBAction func buttonItemClick_CreatType(_ sender: Any) {
- let button: NSButton = sender as! NSButton
- if button.tag == 0 {
- self.type = .fromFile
- } else if button.tag == 1 {
- self.type = .signCreate
- }
- }
-
-
- }
|