// // KMPreferenceCommon.swift // PDF Reader Pro // // Created by tangchao on 2024/1/16. // import Foundation // general public let KMUserNameKey = "SKUserName" public let KMReopenLastOpenFilesKey = "SKReopenLastOpenFiles" public let KMOpenDocumentInTabKey = "KMOpenDocumentInTab" public let KMInitialWindowSizeOptionKey = "SKInitialWindowSizeOption" public let KMOpenContentsPaneOnlyForTOCKey = "SKOpenContentsPaneOnlyForTOC" public let KMRememberSnapshotsKey = "SKRememberSnapshots" public let KMDefaultPDFDisplaySettingsKey = "SKDefaultPDFDisplaySettings" public let KMDefaultFullScreenPDFDisplaySettingsKey = "SKDefaultFullScreenPDFDisplaySettings" public let KMAutoSaveSkimNotesKey = "SKAutoSaveSkimNotes" public let KMSnapshotsOnTopKey = "SKSnapshotsOnTop" public let KMSavePasswordOptionKey = "SKSavePasswordOption" // display public let KMThumbnailSizeKey = "SKThumbnailSize" public let KMSnapshotThumbnailSizeKey = "SKSnapshotThumbnailSize" public let KMTableFontSizeKey = "SKTableFontSize" public let KMGreekingThresholdKey = "SKGreekingThreshold" public let KMShouldAntiAliasKey = "SKShouldAntiAlias" public let KMBackgroundColorKey = "SKBackgroundColor" public let KMFullScreenBackgroundColorKey = "SKFullScreenBackgroundColor" public let KMReadingBarColorKey = "SKReadingBarColor" public let KMReadingBarInvertKey = "SKReadingBarInvert" // note public let KMFreeTextNoteColorKey = "SKFreeTextNoteColor" public let KMAnchoredNoteColorKey = "SKAnchoredNoteColor" public let KMLineNoteColorKey = "SKLineNoteColor" public let KMLineNoteInteriorColorKey = "SKLineNoteInteriorColor" public let KMCircleNoteColorKey = "SKCircleNoteColor" public let KMCircleNoteInteriorColorKey = "SKCircleNoteInteriorColor" public let KMSquareNoteInteriorColorKey = "SKSquareNoteInteriorColor" public let KMHighlightNoteColorKey = "SKHighlightNoteColor" public let KMUnderlineNoteColorKey = "SKUnderlineNoteColor" public let KMStrikeOutNoteColorKey = "SKStrikeOutNoteColor" // font public let KMFreeTextNoteFontNameKey = "SKFreeTextNoteFontName" public let KMFreeTextNoteFontSizeKey = "SKFreeTextNoteFontSize" public let KMFreeTextNoteAlignmentKey = "SKFreeTextNoteAlignment" public let KMAnchoredNoteFontNameKey = "SKAnchoredNoteFontName" public let KMAnchoredNoteFontSizeKey = "SKAnchoredNoteFontSize" // line style public let KMFreeTextNoteLineStyleKey = "SKFreeTextNoteLineStyle" public let KMFreeTextNoteLineWidthKey = "SKFreeTextNoteLineWidth" public let KMFreeTextNoteDashPatternKey = "SKFreeTextNoteDashPattern" public let KMCircleNoteLineStyleKey = "SKCircleNoteLineStyle" public let KMCircleNoteLineWidthKey = "SKCircleNoteLineWidth" public let KMCircleNoteDashPatternhKey = "SKCircleNoteDashPattern" public let KMSquareNoteLineStyleKey = "SKSquareNoteLineStyle" public let KMSquareNoteLineWidthKey = "SKSquareNoteLineWidth" public let KMSquareNoteDashPatternKey = "SKSquareNoteDashPattern" public let KMLineNoteLineStyleKey = "SKLineNoteLineStyle" public let KMLineNoteLineWidthKey = "SKLineNoteLineWidth" public let KMLineNoteDashPatternKey = "SKLineNoteDashPattern" public let KMLineNoteStartLineStyleKey = "SKLineNoteStartLineStyle" public let KMLineNoteEndLineStyleKey = "SKLineNoteEndLineStyle" public let KMInkNoteLineStyleKey = "SKInkNoteLineStyle" public let KMInkNoteLineWidthKey = "SKInkNoteLineWidth" public let KMInkNoteDashPatternKey = "SKInkNoteDashPattern" func KMPreferenceKeyToCKey(pKey: KMPreferenceKey) -> String? { // freeText if pKey == KMPreference.freeTextNoteLineWidthKey { return CFreeTextNoteLineWidthKey } else if pKey == KMPreference.freeTextNoteLineStyleKey { return CFreeTextNoteLineStyleKey } else if pKey == KMPreference.freeTextNoteDashPatternKey { return CFreeTextNoteDashPatternKey } // Line else if pKey == KMPreference.lineNoteLineWidthKey { return CLineNoteLineWidthKey } else if pKey == KMPreference.lineNoteLineStyleKey { return CLineNoteLineStyleKey } else if pKey == KMPreference.lineNoteDashPatternKey { return CLineNoteDashPatternKey } else if pKey == KMPreference.lineNoteStartLineStyleKey { return CLineNoteStartLineStyleKey } else if pKey == KMPreference.lineNoteEndLineStyleKey { return CLineNoteEndLineStyleKey } // freehand else if pKey == KMPreference.inkNoteLineWidthKey { return CInkNoteLineWidthKey } else if pKey == KMPreference.inkNoteLineStyleKey { return CInkNoteLineStyleKey } else if pKey == KMPreference.inkNoteDashPatternKey { return CInkNoteDashPatternKey } // circle else if pKey == KMPreference.circleNoteLineWidthKey { return CCircleNoteLineWidthKey } else if pKey == KMPreference.circleNoteLineStyleKey { return CCircleNoteLineStyleKey } else if pKey == KMPreference.circleNoteDashPatternKey { return CCircleNoteDashPatternKey } // rect else if pKey == KMPreference.squareNoteLineWidthKey { return CSquareNoteLineWidthKey } else if pKey == KMPreference.squareNoteLineStyleKey { return CSquareNoteLineStyleKey } else if pKey == KMPreference.squareNoteDashPatternKey { return CSquareNoteDashPatternKey } return nil } // MARK: - NSUserDefault key 与 偏好设置 key 相互转换 func KMPreferenceKeyToUDKey(pKey: KMPreferenceKey) -> String? { // general if pKey == KMPreference.generalAuthorNameKey { return KMUserNameKey } else if pKey == KMPreference.openLastUnclosedDocumentWhenAppStartKey { return KMReopenLastOpenFilesKey } else if pKey == KMPreference.openDocumentTypeKey { return KMOpenDocumentInTabKey } else if pKey == KMPreference.openFileTypeKey { return KMInitialWindowSizeOptionKey } else if pKey == KMPreference.showLeftSideBarKey { return KMOpenContentsPaneOnlyForTOCKey } else if pKey == KMPreference.rememberSnapshotKey { return KMRememberSnapshotsKey } else if pKey == KMPreference.autoSaveNoteBackupKey { return KMAutoSaveSkimNotesKey } else if pKey == KMPreference.keepSnapshotWindowToTopKey { return KMSnapshotsOnTopKey } else if pKey == KMPreference.savePasswordTypeKey { return KMSavePasswordOptionKey } // display else if pKey == KMPreference.thumbPageSizeKey { return KMThumbnailSizeKey } else if pKey == KMPreference.thumbSnapshotSizeKey { return KMSnapshotThumbnailSizeKey } else if pKey == KMPreference.outlineFontSizeKey { return KMTableFontSizeKey } else if pKey == KMPreference.greekThresholdKey { return KMGreekingThresholdKey } else if pKey == KMPreference.antiAliasTextKey { return KMShouldAntiAliasKey } else if pKey == KMPreference.displayBackgroundNormalColorKey { return KMBackgroundColorKey } else if pKey == KMPreference.displayBackgroundFullScreenColorKey { return KMFullScreenBackgroundColorKey } else if pKey == KMPreference.readBarColorKey { return KMReadingBarColorKey } else if pKey == KMPreference.invertBarKey { return KMReadingBarInvertKey } // note else if pKey == KMPreference.markupColorTextKey { return KMFreeTextNoteColorKey } else if pKey == KMPreference.markupColorNoteKey { return KMAnchoredNoteColorKey } else if pKey == KMPreference.markupColorLineKey { return KMLineNoteColorKey } // else if pKey == KMPreference.markup else if pKey == KMPreference.markupColorCircleBorderKey { return KMCircleNoteColorKey } else if pKey == KMPreference.markupColorCircleFillKey { return KMCircleNoteInteriorColorKey } else if pKey == KMPreference.markupColorRectangleBorderKey { } else if pKey == KMPreference.markupColorRectangleFillKey { return KMSquareNoteInteriorColorKey } else if pKey == KMPreference.markupColorHighlightKey { return KMHighlightNoteColorKey } else if pKey == KMPreference.markupColorUnderlineKey { return KMUnderlineNoteColorKey } else if pKey == KMPreference.markupColorStrikthroughKey { return KMStrikeOutNoteColorKey } else if pKey == KMPreference.markupColorPenKey { } // font else if pKey == KMPreference.markupFontTextStringKey { return KMFreeTextNoteFontNameKey } else if pKey == KMPreference.markupTextFontSizeKey { return KMFreeTextNoteFontSizeKey } else if pKey == KMPreference.markupFontTextAligmentKey { return KMFreeTextNoteAlignmentKey } else if pKey == KMPreference.markupFontNoteStringKey { return KMAnchoredNoteFontNameKey } else if pKey == KMPreference.markupNoteFontSizeKey { return KMAnchoredNoteFontSizeKey } // line style else if pKey == KMPreference.freeTextNoteLineStyleKey { return KMFreeTextNoteLineStyleKey } else if pKey == KMPreference.freeTextNoteLineWidthKey { return KMFreeTextNoteLineWidthKey } else if pKey == KMPreference.freeTextNoteDashPatternKey { return KMFreeTextNoteDashPatternKey } else if pKey == KMPreference.circleNoteLineStyleKey { return KMCircleNoteLineStyleKey } else if pKey == KMPreference.circleNoteLineWidthKey { return KMCircleNoteLineWidthKey } else if pKey == KMPreference.circleNoteDashPatternKey { return KMCircleNoteDashPatternhKey } else if pKey == KMPreference.squareNoteLineStyleKey { return KMSquareNoteLineStyleKey } else if pKey == KMPreference.squareNoteLineWidthKey { return KMSquareNoteLineWidthKey } else if pKey == KMPreference.squareNoteDashPatternKey { return KMSquareNoteDashPatternKey } else if pKey == KMPreference.lineNoteLineStyleKey { return KMLineNoteLineStyleKey } else if pKey == KMPreference.lineNoteLineWidthKey { return KMLineNoteLineWidthKey } else if pKey == KMPreference.lineNoteDashPatternKey { return KMLineNoteDashPatternKey } else if pKey == KMPreference.lineNoteStartLineStyleKey { return KMLineNoteStartLineStyleKey } else if pKey == KMPreference.lineNoteEndLineStyleKey { return KMLineNoteEndLineStyleKey } else if pKey == KMPreference.inkNoteLineStyleKey { return KMInkNoteLineStyleKey } else if pKey == KMPreference.inkNoteLineWidthKey { return KMInkNoteLineWidthKey } else if pKey == KMPreference.inkNoteDashPatternKey { return KMInkNoteDashPatternKey } return nil } //public let KMLineNoteInteriorColorKey = "SKLineNoteInteriorColor" func KMPreferenceKeyFromUDKey(udKey: String) -> KMPreferenceKey? { // general if udKey == KMUserNameKey { return KMPreference.generalAuthorNameKey } else if udKey == KMReopenLastOpenFilesKey { return KMPreference.openLastUnclosedDocumentWhenAppStartKey } else if udKey == KMOpenDocumentInTabKey { return KMPreference.openDocumentTypeKey } else if udKey == KMInitialWindowSizeOptionKey { return KMPreference.openFileTypeKey } else if udKey == KMOpenContentsPaneOnlyForTOCKey { return KMPreference.showLeftSideBarKey } else if udKey == KMRememberSnapshotsKey { return KMPreference.rememberSnapshotKey } else if udKey == KMAutoSaveSkimNotesKey { return KMPreference.autoSaveNoteBackupKey } else if udKey == KMSnapshotsOnTopKey { return KMPreference.keepSnapshotWindowToTopKey } else if udKey == KMSavePasswordOptionKey { return KMPreference.savePasswordTypeKey } // display else if udKey == KMThumbnailSizeKey { return KMPreference.thumbPageSizeKey } else if udKey == KMSnapshotThumbnailSizeKey { return KMPreference.thumbSnapshotSizeKey } else if udKey == KMTableFontSizeKey { return KMPreference.outlineFontSizeKey } else if udKey == KMGreekingThresholdKey { return KMPreference.greekThresholdKey } else if udKey == KMShouldAntiAliasKey { return KMPreference.antiAliasTextKey } else if udKey == KMBackgroundColorKey { return KMPreference.displayBackgroundNormalColorKey } else if udKey == KMFullScreenBackgroundColorKey { return KMPreference.displayBackgroundFullScreenColorKey } else if udKey == KMReadingBarColorKey { return KMPreference.readBarColorKey } else if udKey == KMReadingBarInvertKey { return KMPreference.invertBarKey } // note else if udKey == KMFreeTextNoteColorKey { return KMPreference.markupColorTextKey } else if udKey == KMAnchoredNoteColorKey { return KMPreference.markupColorNoteKey } else if udKey == KMLineNoteColorKey { return KMPreference.markupColorLineKey } else if udKey == KMCircleNoteColorKey { return KMPreference.markupColorCircleBorderKey } else if udKey == KMCircleNoteInteriorColorKey { return KMPreference.markupColorCircleFillKey } else if udKey == KMSquareNoteInteriorColorKey { return KMPreference.markupColorRectangleFillKey } else if udKey == KMHighlightNoteColorKey { return KMPreference.markupColorHighlightKey } else if udKey == KMUnderlineNoteColorKey { return KMPreference.markupColorUnderlineKey } else if udKey == KMStrikeOutNoteColorKey { return KMPreference.markupColorStrikthroughKey } // font else if udKey == KMFreeTextNoteFontNameKey { return KMPreference.markupFontTextStringKey } else if udKey == KMFreeTextNoteFontSizeKey { return KMPreference.markupTextFontSizeKey } else if udKey == KMFreeTextNoteAlignmentKey { return KMPreference.markupFontTextAligmentKey } else if udKey == KMAnchoredNoteFontNameKey { return KMPreference.markupFontNoteStringKey } else if udKey == KMAnchoredNoteFontSizeKey { return KMPreference.markupNoteFontSizeKey } // line style else if udKey == KMFreeTextNoteLineStyleKey { return KMPreference.freeTextNoteLineStyleKey } else if udKey == KMFreeTextNoteLineWidthKey { return KMPreference.freeTextNoteLineWidthKey } else if udKey == KMFreeTextNoteDashPatternKey { return KMPreference.freeTextNoteDashPatternKey } else if udKey == KMCircleNoteLineStyleKey { return KMPreference.circleNoteLineStyleKey } else if udKey == KMCircleNoteLineWidthKey { return KMPreference.circleNoteLineWidthKey } else if udKey == KMCircleNoteDashPatternhKey { return KMPreference.circleNoteDashPatternKey } else if udKey == KMSquareNoteLineStyleKey { return KMPreference.squareNoteLineStyleKey } else if udKey == KMSquareNoteLineWidthKey { return KMPreference.squareNoteLineWidthKey } else if udKey == KMSquareNoteDashPatternKey { return KMPreference.squareNoteDashPatternKey } else if udKey == KMLineNoteLineStyleKey { return KMPreference.lineNoteLineStyleKey } else if udKey == KMLineNoteLineWidthKey { return KMPreference.lineNoteLineWidthKey } else if udKey == KMLineNoteDashPatternKey { return KMPreference.lineNoteDashPatternKey } else if udKey == KMLineNoteStartLineStyleKey { return KMPreference.lineNoteStartLineStyleKey } else if udKey == KMLineNoteEndLineStyleKey { return KMPreference.lineNoteEndLineStyleKey } else if udKey == KMInkNoteLineStyleKey { return KMPreference.inkNoteLineStyleKey } else if udKey == KMInkNoteLineWidthKey { return KMPreference.inkNoteLineWidthKey } else if udKey == KMInkNoteDashPatternKey { return KMPreference.inkNoteDashPatternKey } return nil }