KMPDFToolbarManager.swift 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. //
  2. // KMPDFToolbarManager.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2024/10/22.
  6. //
  7. import Foundation
  8. import KMComponentLibrary
  9. //注释等颜色发生变化时调用
  10. let toolbarImageColorChangedNotificationName = NSNotification.Name("ToolbarImageColorChangedNotificationName")
  11. class KMPDFToolbarManager: NSObject {
  12. var pdfViewManager: KMPDFViewManager?
  13. let dividerProperty = ComponentDividerProperty(type: .vertical, dash: false)
  14. //MARK: -View
  15. var viewProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, identifier: KMPDFToolbar_ViewDisplay_Identifier)
  16. //MARK: -页面编辑
  17. var pageProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, identifier: KMPDFToolbar_PageEdit_Identifier)
  18. var page_pageInfo_Property: ComponentSelectProperties = ComponentSelectProperties(size: .xs, state: .normal, isDisabled: false, isError: false, leftIcon: false, placeholder: KMLocalizedString("Select Page"), errorText: nil, creatable: true, text: "")
  19. var page_page_oddPage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Odd Pages Only"), identifier: KMPDFToolbar_PageEdit_page_oddPage_Identifier)
  20. var page_page_EvenPage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Even Pages Only"), identifier: KMPDFToolbar_PageEdit_page_EvenPage_Identifier)
  21. var page_page_PortraitPage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Portrait pages"), identifier: KMPDFToolbar_PageEdit_page_PortraitPage_Identifier)
  22. var page_page_LandscapePage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Landscape pages"), identifier: KMPDFToolbar_PageEdit_page_LandscapePage_Identifier)
  23. var page_page_AllPage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("All Pages"), identifier: KMPDFToolbar_PageEdit_page_AllPage_Identifier)
  24. var page_page_CustomPage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Custom"), identifier: KMPDFToolbar_PageEdit_page_CustomPage_Identifier)
  25. var page_Insert_Property: ComponentDropdownToolProperty = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Insert"), leftIcon: NSImage(named: "pageEdit_insert"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  26. var page_Insert_File_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Insert File"), identifier: KMPDFToolbar_PageEdit_InsertFile_Identifier)
  27. var page_Insert_Blank_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Insert Blank File"), identifier: KMPDFToolbar_PageEdit_InsertBlank_Identifier)
  28. var page_Insert_Clip_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("From Clipboard"), identifier: KMPDFToolbar_PageEdit_InsertClip_Identifier)
  29. var page_Insert_Scanner_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("From Scanner"), identifier: KMPDFToolbar_PageEdit_InsertScanner_Identifier)
  30. var page_Extract_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Extract"), icon: NSImage(named: "pageEdit_extract"), keepPressState: false, identifier: KMPDFToolbar_PageEdit_Extract_Identifier)
  31. var page_Replace_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Replace"), icon: NSImage(named: "pageEdit_replace"), keepPressState: false, identifier: KMPDFToolbar_PageEdit_Replace_Identifier)
  32. var page_Split_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Split"),icon: NSImage(named: "pageEdit_split"), keepPressState: false, identifier: KMPDFToolbar_PageEdit_Split_Identifier)
  33. var page_Reverse_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Reverse"), icon: NSImage(named: "pageEdit_reverse"), keepPressState: false, identifier: KMPDFToolbar_PageEdit_Reverse_Identifier)
  34. var page_LeftRotate_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "pageEdit_rotateRight"), keepPressState: false,identifier: KMPDFToolbar_PageEdit_LeftRotate_Identifier)
  35. var page_RightRotate_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "pageEdit_rotateLeft"), keepPressState: false,identifier: KMPDFToolbar_PageEdit_RightRotate_Identifier)
  36. var page_Delete_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "pageEdit_delete"), keepPressState: false,identifier: KMPDFToolbar_PageEdit_Delete_Identifier)
  37. var page_Reduce_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "pageEdit_zoomout"), keepPressState: false,identifier: KMPDFToolbar_PageEdit_Reduce_Identifier)
  38. var page_Increase_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "pageEdit_zoomin"),keepPressState: false, identifier: KMPDFToolbar_PageEdit_Increase_Identifier)
  39. //MARK: -ToosView
  40. var toolsProperty: ComponentDropdownToolProperty = ComponentDropdownToolProperty(state: .normal, leftIcon: NSImage(named: "toolbar_Tools_select"), showDropdown: true)
  41. var tools_selectProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "toolbar_Tools_select"), keyEquivalent: KMLocalizedString("⇧1"), text: KMLocalizedString("Select"), identifier: KMPDFToolbar_View_Select_Identifier)
  42. var tools_scrollProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "toolbar_Tools_scroll"), keyEquivalent: KMLocalizedString("⇧2"), text: KMLocalizedString("Scroll"), identifier: KMPDFToolbar_View_Scroll_Identifier)
  43. var tools_contentProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "toolbar_Tools_content"), keyEquivalent: KMLocalizedString("⇧3"), text: KMLocalizedString("Content Selection"), identifier: KMPDFToolbar_View_ContentSelection_Identifier)
  44. var tools_magnifyProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "toolbar_Tools_magnify"), keyEquivalent: KMLocalizedString("⇧4"), text: KMLocalizedString("Magnify"), identifier: KMPDFToolbar_View_Magnify_Identifier)
  45. var tools_areaProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "toolbar_Tools_zoom"), keyEquivalent: KMLocalizedString("⇧5"), text: KMLocalizedString("Area Zoom"), identifier: KMPDFToolbar_View_AreaZoom_Identifier)
  46. //MARK: -缩放比例
  47. var selectZoomProperty: ComponentSelectZoomProperty = ComponentSelectZoomProperty(state: .normal, isDisabled: false, text: "100%", leftIcon_nor: NSImage(named: "toolbar_minus"), leftIcon_dis: NSImage(named: "toolbar_minus_dis"), dropdownIcon: NSImage(named: "toolbar_zoom_dropdown"), rightIcon_nor: NSImage(named: "toolbar_plus"), rightIcon_dis: NSImage(named: "toolbar_plus_dis"))
  48. //MARK: -工具栏
  49. let markupMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Markup"), identifier: KMPDFToolbar_Markup_Identifier)
  50. let editMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Edit"), identifier: KMPDFToolbar_Edit_Identifier)
  51. let formMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Form"), identifier: KMPDFToolbar_Form_Identifier)
  52. let fillMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Fill"), identifier: KMPDFToolbar_Fill_Identifier)
  53. let convertMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Convert"), identifier: KMPDFToolbar_Convert_Identifier)
  54. let protectMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Protect"), identifier: KMPDFToolbar_Protect_Identifier)
  55. let toolsMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Tools"), identifier: KMPDFToolbar_Tools_Identifier)
  56. //MARK: -右侧模块
  57. var undoProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_undo"), keepPressState: false, identifier: KMPDFToolbar_undo_Identifier)
  58. var redoProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_redo"), keepPressState: false,identifier: KMPDFToolbar_redo_Identifier)
  59. var saveProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_save"), keepPressState: false,identifier: KMPDFToolbar_save_Identifier)
  60. var batchProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_batch"), keepPressState: false,identifier: KMPDFToolbar_batch_Identifier)
  61. var ttsProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_TTS"), keepPressState: false,identifier: KMPDFToolbar_tts_Identifier)
  62. var pptProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_ppt"), keepPressState: false,identifier: KMPDFToolbar_ppt_Identifier)
  63. var printProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_print"), keepPressState: false, identifier: KMPDFToolbar_print_Identifier)
  64. var fileInfo_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_fileInfo"), keepPressState: false, identifier: KMPDFToolbar_fileInfo_Identifier)
  65. var shareProperty: ComponentDropdownToolProperty = ComponentDropdownToolProperty(state: .normal, leftIcon: NSImage(named: "toolbar_share"), identifier: KMPDFToolbar_share_Identifier)
  66. var share_PDF_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("PDF"), identifier: KMPDFToolbar_share_PDF_Identifier)
  67. var share_Flatted_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Flattened Copy"), identifier: KMPDFToolbar_share_Flattened_Identifier)
  68. var share_Original_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Original PDF"), identifier: KMPDFToolbar_share_Original_Identifier)
  69. var rightViewProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_rightView"), identifier: KMPDFToolbar_rightView_Identifier)
  70. //MARK: -Markup
  71. let highlightProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkup_HighlightImage(), identifier: KMPDFToolbar_highlight_Identifier)
  72. let UnderlineProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkupUnderlineImage(), identifier: KMPDFToolbar_underline_Identifier)
  73. let wavelineProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkupwavylineImage(), identifier: KMPDFToolbar_waveline_Identifier)
  74. let strikethroughProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkupStrikethroughImage(), identifier: KMPDFToolbar_strikethrough_Identifier)
  75. let textProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_text"), identifier: KMPDFToolbar_text_Identifier)
  76. let noteProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkupNoteImage(), identifier: KMPDFToolbar_note_Identifier)
  77. let penProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkupPenImage(), identifier: KMPDFToolbar_pen_Identifier)
  78. let eraserProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_erase"), identifier: KMPDFToolbar_eraser_Identifier)
  79. let rectangleProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_rectangle"), identifier: KMPDFToolbar_rectangle_Identifier)
  80. let circleProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_oval"), identifier: KMPDFToolbar_circle_Identifier)
  81. let arrowProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_arrow"), identifier: KMPDFToolbar_arrow_Identifier)
  82. let lineProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_line"), identifier: KMPDFToolbar_line_Identifier)
  83. let measureProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_measure"), identifier: KMPDFToolbar_measure_Identifier)
  84. let stampProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_stamp"), identifier: KMPDFToolbar_stamp_Identifier)
  85. let signProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_sign"), identifier: KMPDFToolbar_sign_Identifier)
  86. let eyeProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_show"), identifier: KMPDFToolbar_eye_Identifier)
  87. //MARK: -Edit
  88. let edit_text_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Text"), icon: NSImage(named: "markup_text"), identifier: KMPDFToolbar_edit_text_Identifier)
  89. let edit_image_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Image"), icon: NSImage(named: "edit_image"), identifier: KMPDFToolbar_edit_image_Identifier)
  90. let edit_link_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Link"), icon: NSImage(named: "edit_link"), identifier: KMPDFToolbar_edit_link_Identifier)
  91. let edit_crop_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Crop"), icon: NSImage(named: "edit_crop"), identifier: KMPDFToolbar_edit_crop_Identifier)
  92. let edit_watermark_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Watermark"), leftIcon: NSImage(named: "edit_watermark"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"), identifier: "")
  93. var edit_watermark_add_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Add Watermark"), identifier: KMPDFToolbar_edit_addWatermark_Identifier)
  94. var edit_watermark_remove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Remove Watermark"), identifier: KMPDFToolbar_edit_removeWatermark_Identifier)
  95. var edit_watermark_batchAdd_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Add Watermarks"), identifier: KMPDFToolbar_edit_batch_AddWatermark_Identifier)
  96. var edit_watermark_batchRemove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Remove Watermarks"), identifier: KMPDFToolbar_edit_batchRemoveWatermark_Identifier)
  97. let edit_background_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Background"), leftIcon: NSImage(named: "edit_background"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"), identifier: "")
  98. var edit_bg_add_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Add Background"), identifier: KMPDFToolbar_edit_addBG_Identifier)
  99. var edit_bg_remove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Remove Background"), identifier: KMPDFToolbar_edit_removeBG_Identifier)
  100. var edit_bg_batchAdd_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Add Background"), identifier: KMPDFToolbar_edit_batch_AddBG_Identifier)
  101. var edit_bg_batchRemove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Remove Background"), identifier: KMPDFToolbar_edit_batchRemoveBG_Identifier)
  102. let edit_headerfooter_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Header & Footer"), leftIcon: NSImage(named: "edit_headerfooter"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"), identifier: "")
  103. var edit_hf_add_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Add Header & Footer"), identifier: KMPDFToolbar_edit_addHF_Identifier)
  104. var edit_hf_remove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Remove Header & Footer"), identifier: KMPDFToolbar_edit_removeHF_Identifier)
  105. var edit_hf_batchAdd_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Add Header & Footer"), identifier: KMPDFToolbar_edit_batch_AddHF_Identifier)
  106. var edit_hf_batchRemove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Remove Header & Footer"), identifier: KMPDFToolbar_edit_batchRemoveHF_Identifier)
  107. let edit_bates_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Bates Numbers"), leftIcon: NSImage(named: "edit_bates"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"), identifier: "")
  108. var edit_bates_add_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Add Bates Numbers"), identifier: KMPDFToolbar_edit_addBates_Identifier)
  109. var edit_bates_remove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Remove Bates Numbers"), identifier: KMPDFToolbar_edit_removeBates_Identifier)
  110. var edit_bates_batchAdd_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Add Bates Numbers"), identifier: KMPDFToolbar_edit_batch_AddBates_Identifier)
  111. var edit_bates_batchRemove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Remove Bates Numbers"), identifier: KMPDFToolbar_edit_batchRemoveBates_Identifier)
  112. //MARK: -Form
  113. let form_text_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Text Field"), icon: NSImage(named: "form_text"), identifier: KMPDFToolbar_form_text_Identifier)
  114. let form_checkbox_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Check Box"), icon: NSImage(named: "form_checkbox"), identifier: KMPDFToolbar_form_checkbox_Identifier)
  115. let form_radio_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Radio"), icon: NSImage(named: "form_radio"), identifier: KMPDFToolbar_form_radio_Identifier)
  116. let form_list_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("List"), icon: NSImage(named: "form_listbox"), identifier: KMPDFToolbar_form_list_Identifier)
  117. let form_dropdown_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Dropdown"), icon: NSImage(named: "form_dropdown"), identifier: KMPDFToolbar_form_dropdown_Identifier)
  118. let form_OK_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Button"), icon: NSImage(named: "form_OK"), identifier: KMPDFToolbar_form_OK_Identifier)
  119. let form_digitalSign_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Digital Signature"), icon: NSImage(named: "form_digitalSign"), identifier: KMPDFToolbar_form_digitalSign_Identifier)
  120. let form_alignment_Property = ComponentDropdownToolProperty(state: .normal, text: nil, leftIcon: NSImage(named: "form_alignment"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  121. let form_more_Property = ComponentDropdownToolProperty(state: .normal, text: nil, leftIcon: NSImage(named: "form_more"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  122. var form_alignment_left_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "alignLeft"), text: KMLocalizedString("Align Left"), identifier: KMPDFToolbar_form_Align_Left_Identifier)
  123. var form_alignment_Hori_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "alignXCenter"), text: KMLocalizedString("Align Horizontally"), identifier: KMPDFToolbar_form_Align_Hori_Identifier)
  124. var form_alignment_Right_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "alignRight"), text: KMLocalizedString("Align Right"), identifier: KMPDFToolbar_form_Align_Right_Identifier)
  125. var form_alignment_Top_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "alignTop"), text: KMLocalizedString("Align Top"), identifier: KMPDFToolbar_form_Align_Top_Identifier)
  126. var form_alignment_Vert_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "alignYCenter"), text: KMLocalizedString("Align Vertically"), identifier: KMPDFToolbar_form_Align_Vert_Identifier)
  127. var form_alignment_Bottom_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "alignBottom"), text: KMLocalizedString("Align Bottom"), identifier: KMPDFToolbar_form_Align_Bottom_Identifier)
  128. var form_alignment_Distribute_Vert_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "alignHorizonal"), text: KMLocalizedString("Distribute Vertically"), identifier: KMPDFToolbar_form_Distribute_Vert_Identifier)
  129. var form_alignment_Distribute_Hori_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(lefticon: NSImage(named: "alignAverageVertical"), text: KMLocalizedString("Distribute Horizontally"), identifier: KMPDFToolbar_form_Distribute_Hori_Identifier)
  130. var form_Highlight_Fields_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(righticon: NSImage(named: "tick_Green"), text: KMLocalizedString("Highlight Existing Fields"), identifier: KMPDFToolbar_form_HighlightFields_Identifier)
  131. var form_ShowName_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(righticon: NSImage(named: "tick_Green"), text: KMLocalizedString("Show Name"), identifier: KMPDFToolbar_form_ShowName_Identifier)
  132. var form_ClearForm_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Clear Form"), identifier: KMPDFToolbar_form_ClearForm_Identifier)
  133. //MARK: -Fill
  134. let fill_tick_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_tick"), identifier: KMPDFToolbar_fill_tick_Identifier)
  135. let fill_fork_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_fork"), identifier: KMPDFToolbar_fill_fork_Identifier)
  136. let fill_rectangle_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_rectangle"), identifier: KMPDFToolbar_fill_rectangle_Identifier)
  137. let fill_line_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_line"), identifier: KMPDFToolbar_fill_line_Identifier)
  138. let fill_dot_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_dot"), identifier: KMPDFToolbar_fill_dot_Identifier)
  139. let fill_date_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_date"), identifier: KMPDFToolbar_fill_date_Identifier)
  140. let fill_sign_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_sign"), identifier: KMPDFToolbar_fill_sign_Identifier)
  141. //MARK: -Convert
  142. let convert_word_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("To Word"), icon: NSImage(named: "convert_word"), keepPressState: false,identifier: KMPDFToolbar_convert_word_Identifier)
  143. let convert_excel_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("To Excel"), icon: NSImage(named: "convert_excel"), keepPressState: false,identifier: KMPDFToolbar_convert_excel_Identifier)
  144. let convert_ppt_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("To PPT"), icon: NSImage(named: "convert_ppt"), keepPressState: false,identifier: KMPDFToolbar_convert_ppt_Identifier)
  145. let convert_image_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("To Image"), icon: NSImage(named: "convert_image"), keepPressState: false,identifier: KMPDFToolbar_convert_image_Identifier)
  146. let convert_others_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("To Others"), leftIcon: NSImage(named: "form_more"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  147. let convert_imageToPDF_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Image to PDF"), icon: NSImage(named: "convert_imageToPdf"), keepPressState: false,identifier: KMPDFToolbar_convert_imageToPDF_Identifier)
  148. let convert_ocr_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("OCR"), icon: NSImage(named: "convert_ocr"), identifier: KMPDFToolbar_convert_ocr_Identifier)
  149. var convert_RTF_property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "convert_rtf"), keyEquivalent: nil, text: KMLocalizedString("To RTF"), identifier: KMPDFToolbar_convert_RTF_Identifier)
  150. var convert_CSV_property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "convert_csv"), keyEquivalent: nil, text: KMLocalizedString("To CSV"), identifier: KMPDFToolbar_convert_CSV_Identifier)
  151. var convert_HTML_property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "convert_html"), keyEquivalent: nil, text: KMLocalizedString("To HTML"), identifier: KMPDFToolbar_convert_HTML_Identifier)
  152. var convert_Text_property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "convert_text"), keyEquivalent: nil, text: KMLocalizedString("To Text"), identifier: KMPDFToolbar_convert_Text_Identifier)
  153. var convert_Json_property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "convert_Json"), keyEquivalent: nil, text: KMLocalizedString("To Json"), identifier: KMPDFToolbar_convert_Json_Identifier)
  154. //MARK: -Protect
  155. let protect_redact_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Redact"), icon: NSImage(named: "protect_redact"), identifier: KMPDFToolbar_protect_redact_Identifier)
  156. let protect_security_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Security"), icon: NSImage(named: "protect_security"), identifier: KMPDFToolbar_protect_security_Identifier)
  157. let protect_removeSecurity_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Remove Security"), icon: NSImage(named: "protect_security"), identifier: KMPDFToolbar_protect_removeSecurity_Identifier)
  158. let protect_digitalSign_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Digital Signature"), icon: NSImage(named: "form_digitalSign"), identifier: KMPDFToolbar_protect_digitalSign_Identifier)
  159. //MARK: -Tools
  160. let tools_OCR_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("OCR"), icon: NSImage(named: "tools_OCR"), identifier: KMPDFToolbar_tools_OCR_Identifier)
  161. let tools_merge_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Merge"), icon: NSImage(named: "tools_merge"), identifier: KMPDFToolbar_tools_merge_Identifier)
  162. let tools_compress_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Compress"), leftIcon: NSImage(named: "tools_compare"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  163. var tools_compress_compress_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Compress"), identifier: KMPDFToolbar_tools_compress_Identifier)
  164. var tools_compress_batchCompress_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Compress"), identifier: KMPDFToolbar_tools_batch_compress_Identifier)
  165. let tools_compare_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Compare"), leftIcon: NSImage(named: "tools_compare"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  166. var tools_compare_Side_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Compare Side-by-Side"), identifier: KMPDFToolbar_tools_compare_side_Identifier)
  167. var tools_compare_Overlay_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Compare by Overlay"), identifier: KMPDFToolbar_tools_compare_Overlay_Identifier)
  168. let tools_extractImage_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Extract Image"), icon: NSImage(named: "tools_extractImg"), identifier: KMPDFToolbar_tools_extractImage_Identifier)
  169. let tools_TTS_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("TTS"), icon: NSImage(named: "tools_TTS"), identifier: KMPDFToolbar_tools_TTS_Identifier)
  170. let tools_batch_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Batch"), icon: NSImage(named: "tools_batch"), identifier: KMPDFToolbar_tools_batch_Identifier)
  171. let tools_AITools_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("AI Tools"), icon: NSImage(named: "tools_AITools"), identifier: KMPDFToolbar_tools_AITools_Identifier)
  172. var totalRightPropertys: [NSObject] = []
  173. var validRightPropertys: [NSObject] = [] {//右侧展示的icon集合
  174. didSet {
  175. var ids: [String] = []
  176. for property in validRightPropertys {
  177. if property is ComponentButtonProperty {
  178. if (property as! ComponentButtonProperty).identifier.count > 0 {
  179. ids.append((property as! ComponentButtonProperty).identifier)
  180. }
  181. } else if property is ComponentDropdownToolProperty {
  182. if (property as! ComponentDropdownToolProperty).identifier.count > 0 {
  183. ids.append((property as! ComponentDropdownToolProperty).identifier)
  184. }
  185. }
  186. }
  187. UserDefaults.standard.setValue(ids, forKey: "ToolBarValidRightPropertysKey")
  188. }
  189. }
  190. //MARK: - func
  191. override init() {
  192. super.init()
  193. self.initData()
  194. }
  195. func initData() {
  196. viewProperty.icon = NSImage(named: "toolbar_View")
  197. pageProperty.icon = NSImage(named: "toolbar_Page")
  198. reloadToolsData()
  199. var menuItemArr: [ComponentMenuitemProperty] = []
  200. if true {
  201. menuItemArr.append(tools_selectProperty)
  202. menuItemArr.append(tools_scrollProperty)
  203. menuItemArr.append(tools_contentProperty)
  204. menuItemArr.append(tools_magnifyProperty)
  205. menuItemArr.append(tools_areaProperty)
  206. toolsProperty.menuItemArr = menuItemArr
  207. }
  208. if true {
  209. selectZoomProperty.menuItemArr = KMPDFToolbarConfig.scaleZoomItems()
  210. }
  211. undoProperty.propertyInfo.leftIcon_nor = NSImage(named: "toolbar_undo")
  212. redoProperty.propertyInfo.leftIcon_nor = NSImage(named: "toolbar_redo")
  213. printProperty.propertyInfo.leftIcon_nor = NSImage(named: "toolbar_print")
  214. fileInfo_Property.propertyInfo.leftIcon_nor = NSImage(named: "toolbar_fileInfo")
  215. rightViewProperty.propertyInfo.leftIcon_nor = NSImage(named: "toolbar_rightView")
  216. shareProperty.menuItemArr = [share_PDF_Property, share_Flatted_Property, share_Original_Property]
  217. totalRightPropertys = [undoProperty, redoProperty, saveProperty, fileInfo_Property, batchProperty, ttsProperty, pptProperty, printProperty, shareProperty]
  218. if let propertys = UserDefaults.standard.array(forKey: "ToolBarValidRightPropertysKey") as? [String] {
  219. validRightPropertys = []
  220. for buttonProperty in [undoProperty, redoProperty, saveProperty, batchProperty, ttsProperty, pptProperty, printProperty, fileInfo_Property] {
  221. if propertys.contains(buttonProperty.identifier) {
  222. validRightPropertys.append(buttonProperty)
  223. }
  224. }
  225. if propertys.contains(shareProperty.identifier) {
  226. validRightPropertys.append(shareProperty)
  227. }
  228. } else {
  229. validRightPropertys = [undoProperty, redoProperty, printProperty, shareProperty]
  230. }
  231. refreshMarkupColorImages()
  232. }
  233. //MARK: - 刷新tools工具
  234. func reloadToolsData() {
  235. let toolsType = pdfViewManager?.viewToolsType ?? .none
  236. if toolsType == .Scroll {
  237. toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_scroll")
  238. } else if toolsType == .Content_Selection {
  239. toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_content")
  240. } else if toolsType == .Magnify {
  241. toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_magnify")
  242. } else if toolsType == .AreaZoom {
  243. toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_zoom")
  244. } else {
  245. toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_select")
  246. }
  247. }
  248. //MARK: - 获取二级工具栏内容
  249. func getSubToolItemIdentifys(_ mainIdentify: String) -> [String] {
  250. var ids: [String] = []
  251. if mainIdentify == KMPDFToolbar_View_Identifier {
  252. ids.append(contentsOf: [KMPDFToolbar_View_Select_Identifier,
  253. KMPDFToolbar_View_Scroll_Identifier,
  254. KMPDFToolbar_View_ContentSelection_Identifier,
  255. KMPDFToolbar_View_Magnify_Identifier,
  256. KMPDFToolbar_View_AreaZoom_Identifier])
  257. } else if mainIdentify == KMPDFToolbar_PageEdit_Identifier {
  258. ids.append(contentsOf: [page_page_oddPage_Property.identifier, page_page_EvenPage_Property.identifier,
  259. page_page_PortraitPage_Property.identifier, page_page_LandscapePage_Property.identifier,
  260. page_page_AllPage_Property.identifier, page_page_CustomPage_Property.identifier])
  261. ids.append(contentsOf: [page_Insert_File_Property.identifier, page_Insert_Blank_Property.identifier,
  262. page_Insert_Clip_Property.identifier,
  263. page_Insert_Scanner_Property.identifier])
  264. ids.append(contentsOf: [page_Extract_Property.identifier,
  265. page_Replace_Property.identifier, page_Split_Property.identifier,
  266. page_Reverse_Property.identifier,
  267. page_LeftRotate_Property.identifier, page_RightRotate_Property.identifier,
  268. page_Delete_Property.identifier])
  269. ids.append(contentsOf: [page_Increase_Property.identifier,page_Reduce_Property.identifier])
  270. } else if mainIdentify == KMPDFToolbar_Markup_Identifier {
  271. ids.append(contentsOf: [highlightProperty.identifier, UnderlineProperty.identifier,
  272. wavelineProperty.identifier, strikethroughProperty.identifier,
  273. textProperty.identifier, noteProperty.identifier,
  274. penProperty.identifier, eraserProperty.identifier,
  275. rectangleProperty.identifier, circleProperty.identifier,
  276. arrowProperty.identifier, lineProperty.identifier,
  277. measureProperty.identifier,
  278. stampProperty.identifier, signProperty.identifier,
  279. eyeProperty.identifier])
  280. } else if mainIdentify == KMPDFToolbar_Edit_Identifier {
  281. ids.append(contentsOf: [KMPDFToolbar_edit_Watermark_Identifier, edit_watermark_add_Property.identifier, edit_watermark_remove_Property.identifier,
  282. edit_watermark_batchAdd_Property.identifier, edit_watermark_batchRemove_Property.identifier])
  283. ids.append(contentsOf: [KMPDFToolbar_edit_BG_Identifier, edit_bg_add_Property.identifier, edit_bg_remove_Property.identifier,
  284. edit_bg_batchAdd_Property.identifier, edit_bg_batchRemove_Property.identifier])
  285. ids.append(contentsOf: [KMPDFToolbar_edit_HF_Identifier, edit_hf_add_Property.identifier, edit_hf_remove_Property.identifier,
  286. edit_hf_batchAdd_Property.identifier, edit_hf_batchRemove_Property.identifier])
  287. ids.append(contentsOf: [KMPDFToolbar_edit_Bates_Identifier, edit_bates_add_Property.identifier, edit_bates_remove_Property.identifier,
  288. edit_bates_batchAdd_Property.identifier, edit_bates_batchRemove_Property.identifier])
  289. ids.append(contentsOf: [edit_text_Property.identifier, edit_image_Property.identifier,
  290. edit_link_Property.identifier, edit_watermark_Property.identifier,
  291. edit_background_Property.identifier, edit_headerfooter_Property.identifier,
  292. edit_bates_Property.identifier, edit_crop_Property.identifier])
  293. } else if mainIdentify == KMPDFToolbar_Form_Identifier {
  294. ids.append(contentsOf: [KMPDFToolbar_form_Align_Left_Identifier, KMPDFToolbar_form_Align_Hori_Identifier,
  295. KMPDFToolbar_form_Align_Right_Identifier, KMPDFToolbar_form_Align_Top_Identifier,
  296. KMPDFToolbar_form_Align_Vert_Identifier, KMPDFToolbar_form_Align_Bottom_Identifier,
  297. KMPDFToolbar_form_Distribute_Vert_Identifier, KMPDFToolbar_form_Distribute_Hori_Identifier])
  298. ids.append(contentsOf: [form_text_Property.identifier, form_checkbox_Property.identifier, form_radio_Property.identifier, form_list_Property.identifier,
  299. form_dropdown_Property.identifier, form_OK_Property.identifier, form_digitalSign_Property.identifier,
  300. form_alignment_Property.identifier, form_more_Property.identifier, KMPDFToolbar_form_HighlightFields_Identifier, KMPDFToolbar_form_ShowName_Identifier,
  301. KMPDFToolbar_form_ClearForm_Identifier])
  302. } else if mainIdentify == KMPDFToolbar_Fill_Identifier {
  303. ids.append(contentsOf: [fill_tick_Property.identifier,
  304. fill_fork_Property.identifier,
  305. fill_rectangle_Property.identifier,
  306. fill_line_Property.identifier,
  307. fill_dot_Property.identifier,
  308. fill_date_Property.identifier,
  309. fill_sign_Property.identifier])
  310. } else if mainIdentify == KMPDFToolbar_Convert_Identifier {
  311. ids.append(contentsOf: [convert_RTF_property.identifier,
  312. convert_CSV_property.identifier,
  313. convert_HTML_property.identifier,
  314. convert_Text_property.identifier,
  315. convert_Json_property.identifier])
  316. ids.append(contentsOf: [convert_word_Property.identifier,
  317. convert_excel_Property.identifier,
  318. convert_ppt_Property.identifier,
  319. convert_image_Property.identifier,
  320. convert_imageToPDF_Property.identifier,
  321. convert_ocr_Property.identifier])
  322. } else if mainIdentify == KMPDFToolbar_Protect_Identifier {
  323. ids.append(contentsOf: [KMPDFToolbar_protect_redact_Property_Identifier,
  324. KMPDFToolbar_protect_redact_Apply_Identifier,
  325. KMPDFToolbar_protect_redact_Exit_Identifier])
  326. ids.append(contentsOf: [protect_redact_Property.identifier,
  327. protect_security_Property.identifier,
  328. protect_removeSecurity_Property.identifier,
  329. protect_digitalSign_Property.identifier])
  330. } else if mainIdentify == KMPDFToolbar_Tools_Identifier {
  331. ids.append(contentsOf: [tools_OCR_Property.identifier,
  332. tools_merge_Property.identifier,
  333. tools_compress_compress_Property.identifier,
  334. tools_compress_batchCompress_Property.identifier,
  335. tools_compare_Property.identifier,
  336. tools_compare_Side_Property.identifier,
  337. tools_compare_Overlay_Property.identifier,
  338. tools_extractImage_Property.identifier,
  339. tools_TTS_Property.identifier,
  340. tools_batch_Property.identifier,
  341. tools_AITools_Property.identifier])
  342. } else if mainIdentify == KMPDFToolbar_Right_Identifiers {
  343. ids.append(contentsOf: [KMPDFToolbar_undo_Identifier,
  344. KMPDFToolbar_redo_Identifier,
  345. KMPDFToolbar_save_Identifier,
  346. KMPDFToolbar_aiTools_Identifier,
  347. KMPDFToolbar_batch_Identifier,
  348. KMPDFToolbar_tts_Identifier,
  349. KMPDFToolbar_ppt_Identifier,
  350. KMPDFToolbar_print_Identifier,
  351. KMPDFToolbar_fileInfo_Identifier,
  352. KMPDFToolbar_share_PDF_Identifier,
  353. KMPDFToolbar_share_Flattened_Identifier,
  354. KMPDFToolbar_share_Original_Identifier])
  355. }
  356. return ids
  357. }
  358. func getSubToolbarItems(_ modeType: KMPDFToolsMode = .None, isPageEditMode: Bool = false) -> [NSObject] {
  359. if isPageEditMode {
  360. page_pageInfo_Property.menuItemArr = [page_page_oddPage_Property, page_page_EvenPage_Property,
  361. page_page_PortraitPage_Property, page_page_LandscapePage_Property,
  362. page_page_AllPage_Property, ComponentMenuitemProperty.divider(),
  363. page_page_CustomPage_Property]
  364. page_Insert_Property.menuItemArr = [page_Insert_File_Property, page_Insert_Blank_Property,
  365. ComponentMenuitemProperty.divider(), page_Insert_Clip_Property,
  366. page_Insert_Scanner_Property]
  367. return [page_pageInfo_Property, dividerProperty,
  368. page_Insert_Property, page_Extract_Property,
  369. page_Replace_Property, page_Split_Property,
  370. page_Reverse_Property, dividerProperty,
  371. page_LeftRotate_Property, page_RightRotate_Property,
  372. page_Delete_Property]
  373. }
  374. if modeType == .Markup {
  375. eyeProperty.propertyInfo.leftIcon_press = NSImage(named: "markup_hide")
  376. return [highlightProperty, UnderlineProperty, wavelineProperty, strikethroughProperty,
  377. dividerProperty, textProperty, noteProperty, dividerProperty,
  378. penProperty, eraserProperty, dividerProperty, rectangleProperty,
  379. circleProperty, arrowProperty, lineProperty, measureProperty,
  380. dividerProperty,stampProperty, signProperty, dividerProperty, eyeProperty]
  381. } else if modeType == .Edit {
  382. edit_watermark_Property.menuItemArr = [edit_watermark_add_Property, edit_watermark_remove_Property,
  383. ComponentMenuitemProperty.divider(),
  384. edit_watermark_batchAdd_Property, edit_watermark_batchRemove_Property]
  385. edit_background_Property.menuItemArr = [edit_bg_add_Property, edit_bg_remove_Property,
  386. ComponentMenuitemProperty.divider(),
  387. edit_bg_batchAdd_Property, edit_bg_batchRemove_Property]
  388. edit_headerfooter_Property.menuItemArr = [edit_hf_add_Property, edit_hf_remove_Property,
  389. ComponentMenuitemProperty.divider(),
  390. edit_hf_batchAdd_Property, edit_hf_batchRemove_Property]
  391. edit_bates_Property.menuItemArr = [edit_bates_add_Property, edit_bates_remove_Property,
  392. ComponentMenuitemProperty.divider(),
  393. edit_bates_batchAdd_Property, edit_bates_batchRemove_Property]
  394. return [edit_text_Property, edit_image_Property, edit_link_Property, dividerProperty, edit_watermark_Property, edit_background_Property, edit_headerfooter_Property,
  395. edit_bates_Property, edit_crop_Property]
  396. } else if modeType == .Form {
  397. form_alignment_Property.menuItemArr = [form_alignment_left_Property, form_alignment_Hori_Property, form_alignment_Right_Property, ComponentMenuitemProperty.divider(),
  398. form_alignment_Top_Property, form_alignment_Vert_Property, form_alignment_Bottom_Property, ComponentMenuitemProperty.divider(),
  399. form_alignment_Distribute_Vert_Property, form_alignment_Distribute_Hori_Property]
  400. self.refreshDefaultConfigItem()
  401. form_more_Property.menuItemArr = [form_Highlight_Fields_Property, form_ShowName_Property, form_ClearForm_Property]
  402. return [form_text_Property, form_checkbox_Property, form_radio_Property, form_list_Property,
  403. form_dropdown_Property, form_OK_Property, form_digitalSign_Property, dividerProperty,
  404. form_alignment_Property, form_more_Property]
  405. } else if modeType == .Fill {
  406. return [fill_tick_Property, fill_fork_Property, fill_rectangle_Property, fill_line_Property,
  407. fill_dot_Property, fill_date_Property, fill_sign_Property]
  408. } else if modeType == .Convert {
  409. var menuItemArr: [ComponentMenuitemProperty] = []
  410. if true {
  411. menuItemArr.append(convert_RTF_property)
  412. menuItemArr.append(convert_CSV_property)
  413. menuItemArr.append(convert_HTML_property)
  414. menuItemArr.append(convert_Text_property)
  415. menuItemArr.append(convert_Json_property)
  416. convert_others_Property.menuItemArr = menuItemArr
  417. }
  418. return [convert_word_Property, convert_excel_Property, convert_ppt_Property, convert_image_Property,
  419. convert_others_Property, dividerProperty, convert_imageToPDF_Property, dividerProperty,
  420. convert_ocr_Property]
  421. } else if modeType == .Protect {
  422. return [protect_redact_Property, protect_security_Property, protect_removeSecurity_Property, protect_digitalSign_Property]
  423. } else if modeType == .Tools {
  424. tools_compress_Property.menuItemArr = [tools_compress_compress_Property,
  425. tools_compress_batchCompress_Property]
  426. tools_compare_Property.menuItemArr = [tools_compare_Side_Property,
  427. tools_compare_Overlay_Property]
  428. return[tools_OCR_Property, tools_merge_Property, tools_compress_Property, tools_compare_Property,
  429. tools_extractImage_Property, tools_TTS_Property, tools_batch_Property, tools_AITools_Property]
  430. }
  431. return []
  432. }
  433. func refreshDefaultConfigItem() {
  434. if CPDFKitConfig.sharedInstance().enableFormFieldHighlight() {
  435. form_Highlight_Fields_Property.righticon = NSImage(named: "tick_Green")
  436. } else {
  437. form_Highlight_Fields_Property.righticon = nil
  438. }
  439. }
  440. //MARK: - 刷新Markup二级工具栏特殊图片
  441. func refreshMarkupColorImages() {
  442. highlightProperty.icon = KMPDFToolbarManager.getMarkup_HighlightImage()
  443. highlightProperty.propertyInfo.leftIcon_hov = highlightProperty.icon
  444. highlightProperty.propertyInfo.leftIcon_press = highlightProperty.icon
  445. UnderlineProperty.icon = KMPDFToolbarManager.getMarkupUnderlineImage()
  446. UnderlineProperty.propertyInfo.leftIcon_hov = UnderlineProperty.icon
  447. UnderlineProperty.propertyInfo.leftIcon_press = UnderlineProperty.icon
  448. wavelineProperty.icon = KMPDFToolbarManager.getMarkupwavylineImage()
  449. wavelineProperty.propertyInfo.leftIcon_hov = wavelineProperty.icon
  450. wavelineProperty.propertyInfo.leftIcon_press = wavelineProperty.icon
  451. strikethroughProperty.icon = KMPDFToolbarManager.getMarkupStrikethroughImage()
  452. strikethroughProperty.propertyInfo.leftIcon_hov = strikethroughProperty.icon
  453. strikethroughProperty.propertyInfo.leftIcon_press = strikethroughProperty.icon
  454. noteProperty.icon = KMPDFToolbarManager.getMarkupNoteImage()
  455. noteProperty.propertyInfo.leftIcon_hov = noteProperty.icon
  456. noteProperty.propertyInfo.leftIcon_press = noteProperty.icon
  457. penProperty.icon = KMPDFToolbarManager.getMarkupPenImage()
  458. penProperty.propertyInfo.leftIcon_hov = penProperty.icon
  459. penProperty.propertyInfo.leftIcon_press = penProperty.icon
  460. }
  461. //MARK: - 获取Markup相关icon图片
  462. class func getMarkup_HighlightImage() -> NSImage? {
  463. let image = NSImage(named: "markup_highlight_base")
  464. let upImage = NSImage(named: "markup_highlight_Cover")
  465. if let img = NSImage.combineImages(images: [image?.filled(with: CPDFMarkupAnnotation.defaultColor(.highlight)), upImage]) {
  466. return img
  467. }
  468. return image
  469. }
  470. class func getMarkupNoteImage() -> NSImage? {
  471. let image = NSImage(named: "markup_note_base")
  472. let upImage = NSImage(named: "markup_note_Cover")
  473. if let img = NSImage.combineImages(images: [image?.filled(with: CPDFTextAnnotation.defaultColor()), upImage]) {
  474. return img
  475. }
  476. return image
  477. }
  478. class func getMarkupPenImage() -> NSImage? {
  479. let image = NSImage(named: "markup_pen_Cover")
  480. let upImage = NSImage(named: "markup_pen_base")
  481. if let img = NSImage.combineImages(images: [(image?.filled(with: CPDFInkAnnotation.defaultColor()))!, upImage!]) {
  482. return img
  483. }
  484. return image
  485. }
  486. class func getMarkupStrikethroughImage() -> NSImage? {
  487. let image = NSImage(named: "markup_strikethrough_Cover")
  488. let upImage = NSImage(named: "markup_strikethrough_base")
  489. if let img = NSImage.combineImages(images: [(image?.filled(with: CPDFMarkupAnnotation.defaultColor(.strikeOut)))!, upImage!]) {
  490. return img
  491. }
  492. return image
  493. }
  494. class func getMarkupUnderlineImage() -> NSImage? {
  495. let image = NSImage(named: "markup_underline_Cover")
  496. let upImage = NSImage(named: "markup_underline_base")
  497. if let img = NSImage.combineImages(images: [(image?.filled(with: CPDFMarkupAnnotation.defaultColor(.underline)))!, upImage!]) {
  498. return img
  499. }
  500. return image
  501. }
  502. class func getMarkupwavylineImage() -> NSImage? {
  503. let image = NSImage(named: "markup_wavyline_Cover")
  504. let upImage = NSImage(named: "markup_wavyline_base")
  505. if let img = NSImage.combineImages(images: [(image?.filled(with: CPDFMarkupAnnotation.defaultColor(.squiggly)))!, upImage!]) {
  506. return img
  507. }
  508. return image
  509. }
  510. }