KMPDFToolbarManager.swift 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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. class KMPDFToolbarManager: NSObject {
  10. var pdfViewManager: KMPDFViewManager?
  11. let dividerProperty = ComponentDividerProperty(type: .vertical, dash: false)
  12. //MARK: -View
  13. var viewProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, identifier: KMPDFToolbar_ViewDisplay_Identifier)
  14. //MARK: -页面编辑
  15. var pageProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, identifier: KMPDFToolbar_PageEdit_Identifier)
  16. 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: "")
  17. var page_page_oddPage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Odd Pages Only"), identifier: KMPDFToolbar_PageEdit_page_oddPage_Identifier)
  18. var page_page_EvenPage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Even Pages Only"), identifier: KMPDFToolbar_PageEdit_page_EvenPage_Identifier)
  19. var page_page_PortraitPage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Portrait pages"), identifier: KMPDFToolbar_PageEdit_page_PortraitPage_Identifier)
  20. var page_page_LandscapePage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Landscape pages"), identifier: KMPDFToolbar_PageEdit_page_LandscapePage_Identifier)
  21. var page_page_AllPage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("All Pages"), identifier: KMPDFToolbar_PageEdit_page_AllPage_Identifier)
  22. var page_page_CustomPage_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Custom"), identifier: KMPDFToolbar_PageEdit_page_CustomPage_Identifier)
  23. var page_Insert_Property: ComponentDropdownToolProperty = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Insert"), leftIcon: NSImage(named: "pageEdit_insert"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  24. var page_Insert_File_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Insert File"), identifier: KMPDFToolbar_PageEdit_InsertFile_Identifier)
  25. var page_Insert_Blank_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("Insert Blank File"), identifier: KMPDFToolbar_PageEdit_InsertBlank_Identifier)
  26. var page_Insert_Clip_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("From Clipboard"), identifier: KMPDFToolbar_PageEdit_InsertClip_Identifier)
  27. var page_Insert_Scanner_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, text: KMLocalizedString("From Scanner"), identifier: KMPDFToolbar_PageEdit_InsertScanner_Identifier)
  28. 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)
  29. 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)
  30. 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)
  31. 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)
  32. var page_LeftRotate_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "pageEdit_rotateLeft"), keepPressState: false,identifier: KMPDFToolbar_PageEdit_LeftRotate_Identifier)
  33. var page_RightRotate_Property: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "pageEdit_rotateRight"), keepPressState: false,identifier: KMPDFToolbar_PageEdit_RightRotate_Identifier)
  34. 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)
  35. 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)
  36. 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)
  37. //MARK: -ToosView
  38. var toolsProperty: ComponentDropdownToolProperty = ComponentDropdownToolProperty(state: .normal, leftIcon: NSImage(named: "toolbar_Tools_select"), showDropdown: true)
  39. 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)
  40. 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)
  41. 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)
  42. 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)
  43. 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)
  44. //MARK: -缩放比例
  45. 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"))
  46. //MARK: -工具栏
  47. let markupMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Markup"), identifier: KMPDFToolbar_Markup_Identifier)
  48. let editMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Edit"), identifier: KMPDFToolbar_Edit_Identifier)
  49. let formMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Form"), identifier: KMPDFToolbar_Form_Identifier)
  50. let fillMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Fill"), identifier: KMPDFToolbar_Fill_Identifier)
  51. let convertMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Convert"), identifier: KMPDFToolbar_Convert_Identifier)
  52. let protectMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Protect"), identifier: KMPDFToolbar_Protect_Identifier)
  53. let toolsMode_Property = ComponentTabsProperty(tabsType: .underline_Center, state: .normal, showIcon: false, title: KMLocalizedString("Tools"), identifier: KMPDFToolbar_Tools_Identifier)
  54. //MARK: -右侧模块
  55. var undoProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_undo"), keepPressState: false, identifier: KMPDFToolbar_undo_Identifier)
  56. var redoProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_redo"), keepPressState: false,identifier: KMPDFToolbar_redo_Identifier)
  57. var saveProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_save"), keepPressState: false,identifier: KMPDFToolbar_save_Identifier)
  58. var aiToolsProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_ai"), keepPressState: false,identifier: KMPDFToolbar_aiTools_Identifier)
  59. var batchProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_batch"), keepPressState: false,identifier: KMPDFToolbar_batch_Identifier)
  60. var ttsProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_TTS"), keepPressState: false,identifier: KMPDFToolbar_tts_Identifier)
  61. var pptProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_ppt"), keepPressState: false,identifier: KMPDFToolbar_ppt_Identifier)
  62. var printProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_print"), keepPressState: false, identifier: KMPDFToolbar_print_Identifier)
  63. var shareProperty: ComponentDropdownToolProperty = ComponentDropdownToolProperty(state: .normal, leftIcon: NSImage(named: "toolbar_share"), identifier: KMPDFToolbar_share_Identifier)
  64. var share_PDF_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("PDF"), identifier: KMPDFToolbar_share_PDF_Identifier)
  65. var share_Flatted_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Flattened Copy"), identifier: KMPDFToolbar_share_Flattened_Identifier)
  66. var share_Original_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Original PDF"), identifier: KMPDFToolbar_share_Original_Identifier)
  67. var rightViewProperty: ComponentButtonProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_rightView"), identifier: KMPDFToolbar_rightView_Identifier)
  68. //MARK: -Markup
  69. let highlightProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkup_HighlightImage(), identifier: KMPDFToolbar_highlight_Identifier)
  70. let UnderlineProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkupUnderlineImage(), identifier: KMPDFToolbar_underline_Identifier)
  71. let wavelineProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkupwavylineImage(), identifier: KMPDFToolbar_waveline_Identifier)
  72. let strikethroughProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkupStrikethroughImage(), identifier: KMPDFToolbar_strikethrough_Identifier)
  73. let textProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_text"), identifier: KMPDFToolbar_text_Identifier)
  74. let noteProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkupNoteImage(), identifier: KMPDFToolbar_note_Identifier)
  75. let penProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: KMPDFToolbarManager.getMarkupPenImage(), identifier: KMPDFToolbar_pen_Identifier)
  76. let eraserProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_erase"), identifier: KMPDFToolbar_eraser_Identifier)
  77. let rectangleProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_rectangle"), identifier: KMPDFToolbar_rectangle_Identifier)
  78. let circleProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_oval"), identifier: KMPDFToolbar_circle_Identifier)
  79. let arrowProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_arrow"), identifier: KMPDFToolbar_arrow_Identifier)
  80. let lineProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_line"), identifier: KMPDFToolbar_line_Identifier)
  81. let measureProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "toolbar_measure"), identifier: KMPDFToolbar_measure_Identifier)
  82. let stampProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_stamp"), identifier: KMPDFToolbar_stamp_Identifier)
  83. let signProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_sign"), identifier: KMPDFToolbar_sign_Identifier)
  84. let eyeProperty = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_show"), identifier: KMPDFToolbar_eye_Identifier)
  85. //MARK: -Edit
  86. 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)
  87. 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)
  88. 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)
  89. 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)
  90. let edit_watermark_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Watermark"), leftIcon: NSImage(named: "edit_watermark"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  91. var edit_watermark_add_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Add Watermark"), identifier: KMPDFToolbar_edit_addWatermark_Identifier)
  92. var edit_watermark_remove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Remove Watermark"), identifier: KMPDFToolbar_edit_removeWatermark_Identifier)
  93. var edit_watermark_batchAdd_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Add Watermarks"), identifier: KMPDFToolbar_edit_batch_AddWatermark_Identifier)
  94. var edit_watermark_batchRemove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Remove Watermarks"), identifier: KMPDFToolbar_edit_batchRemoveWatermark_Identifier)
  95. let edit_background_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Background"), leftIcon: NSImage(named: "edit_background"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  96. var edit_bg_add_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Add Background"), identifier: KMPDFToolbar_edit_addBG_Identifier)
  97. var edit_bg_remove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Remove Background"), identifier: KMPDFToolbar_edit_removeBG_Identifier)
  98. var edit_bg_batchAdd_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Add Background"), identifier: KMPDFToolbar_edit_batch_AddBG_Identifier)
  99. var edit_bg_batchRemove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Remove Background"), identifier: KMPDFToolbar_edit_batchRemoveBG_Identifier)
  100. let edit_headerfooter_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Header & Footer"), leftIcon: NSImage(named: "edit_headerfooter"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  101. var edit_hf_add_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Add Header & Footer"), identifier: KMPDFToolbar_edit_addHF_Identifier)
  102. var edit_hf_remove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Remove Header & Footer"), identifier: KMPDFToolbar_edit_removeHF_Identifier)
  103. var edit_hf_batchAdd_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Add Header & Footer"), identifier: KMPDFToolbar_edit_batch_AddHF_Identifier)
  104. var edit_hf_batchRemove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Remove Header & Footer"), identifier: KMPDFToolbar_edit_batchRemoveHF_Identifier)
  105. let edit_bates_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("Bates Numbers"), leftIcon: NSImage(named: "edit_bates"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  106. var edit_bates_add_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Add Bates Numbers"), identifier: KMPDFToolbar_edit_addBates_Identifier)
  107. var edit_bates_remove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Remove Bates Numbers"), identifier: KMPDFToolbar_edit_removeBates_Identifier)
  108. var edit_bates_batchAdd_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Add Bates Numbers"), identifier: KMPDFToolbar_edit_batch_AddBates_Identifier)
  109. var edit_bates_batchRemove_Property: ComponentMenuitemProperty = ComponentMenuitemProperty(text: KMLocalizedString("Batch Remove Bates Numbers"), identifier: KMPDFToolbar_edit_batchRemoveBates_Identifier)
  110. //MARK: -Form
  111. 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)
  112. 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)
  113. 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)
  114. 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)
  115. 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)
  116. 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)
  117. 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)
  118. let form_alignment_Property = ComponentDropdownToolProperty(state: .normal, text: nil, leftIcon: NSImage(named: "form_alignment"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  119. let form_more_Property = ComponentDropdownToolProperty(state: .normal, text: nil, leftIcon: NSImage(named: "form_more"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  120. //MARK: -Fill
  121. let fill_tick_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_tick"), identifier: KMPDFToolbar_fill_tick_Identifier)
  122. let fill_fork_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_fork"), identifier: KMPDFToolbar_fill_fork_Identifier)
  123. let fill_rectangle_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_rectangle"), identifier: KMPDFToolbar_fill_rectangle_Identifier)
  124. let fill_line_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_line"), identifier: KMPDFToolbar_fill_line_Identifier)
  125. let fill_dot_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_dot"), identifier: KMPDFToolbar_fill_dot_Identifier)
  126. let fill_date_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "fill_date"), identifier: KMPDFToolbar_fill_date_Identifier)
  127. let fill_sign_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, onlyIcon: true, icon: NSImage(named: "markup_sign"), identifier: KMPDFToolbar_fill_sign_Identifier)
  128. //MARK: -Convert
  129. 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)
  130. 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)
  131. 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)
  132. 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)
  133. let convert_others_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("To Others"), leftIcon: NSImage(named: "form_more"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  134. 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)
  135. 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)
  136. 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)
  137. 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)
  138. 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)
  139. 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)
  140. 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)
  141. //MARK: -Protect
  142. 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)
  143. 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)
  144. 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)
  145. 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)
  146. //MARK: -Tools
  147. 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)
  148. 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)
  149. let tools_compress_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Compress"), icon: NSImage(named: "tools_compress"), identifier: KMPDFToolbar_tools_compress_Identifier)
  150. let tools_compare_Property = ComponentDropdownToolProperty(state: .normal, text: KMLocalizedString("compare"), leftIcon: NSImage(named: "tools_compare"), showDropdown: true, arrowIcon: NSImage(named: "toolbar_arrowDown_fill"))
  151. 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)
  152. 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)
  153. 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)
  154. 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)
  155. var totalRightPropertys: [NSObject] = []
  156. var validRightPropertys: [NSObject] = [] //右侧展示的icon集合
  157. //MARK: - func
  158. override init() {
  159. super.init()
  160. self.initData()
  161. }
  162. func initData() {
  163. viewProperty.icon = NSImage(named: "toolbar_View")
  164. pageProperty.icon = NSImage(named: "toolbar_Page")
  165. reloadToolsData()
  166. var menuItemArr: [ComponentMenuitemProperty] = []
  167. if true {
  168. menuItemArr.append(tools_selectProperty)
  169. menuItemArr.append(tools_scrollProperty)
  170. menuItemArr.append(tools_contentProperty)
  171. menuItemArr.append(tools_magnifyProperty)
  172. menuItemArr.append(tools_areaProperty)
  173. toolsProperty.menuItemArr = menuItemArr
  174. }
  175. if true {
  176. selectZoomProperty.menuItemArr = KMPDFToolbarConfig.scaleZoomItems()
  177. }
  178. undoProperty.propertyInfo.leftIcon_nor = NSImage(named: "toolbar_undo")
  179. redoProperty.propertyInfo.leftIcon_nor = NSImage(named: "toolbar_redo")
  180. printProperty.propertyInfo.leftIcon_nor = NSImage(named: "toolbar_print")
  181. rightViewProperty.propertyInfo.leftIcon_nor = NSImage(named: "toolbar_rightView")
  182. shareProperty.menuItemArr = [share_PDF_Property, share_Flatted_Property, share_Original_Property]
  183. totalRightPropertys = [undoProperty, redoProperty, saveProperty, aiToolsProperty, batchProperty, ttsProperty, pptProperty, printProperty, shareProperty]
  184. validRightPropertys = [aiToolsProperty, batchProperty, shareProperty]
  185. refreshMarkupColorImages()
  186. }
  187. //MARK: - 刷新tools工具
  188. func reloadToolsData() {
  189. let toolsType = pdfViewManager?.viewToolsType ?? .none
  190. if toolsType == .Scroll {
  191. toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_scroll")
  192. } else if toolsType == .Content_Selection {
  193. toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_content")
  194. } else if toolsType == .Magnify {
  195. toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_magnify")
  196. } else if toolsType == .AreaZoom {
  197. toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_zoom")
  198. } else {
  199. toolsProperty.leftIcon = NSImage(named: "toolbar_Tools_select")
  200. }
  201. }
  202. //MARK: - 获取二级工具栏内容
  203. func getSubToolItemIdentifys(_ mainIdentify: String) -> [String] {
  204. var ids: [String] = []
  205. if mainIdentify == KMPDFToolbar_PageEdit_Identifier {
  206. ids.append(contentsOf: [page_page_oddPage_Property.identifier, page_page_EvenPage_Property.identifier,
  207. page_page_PortraitPage_Property.identifier, page_page_LandscapePage_Property.identifier,
  208. page_page_AllPage_Property.identifier, page_page_CustomPage_Property.identifier])
  209. ids.append(contentsOf: [page_Insert_File_Property.identifier, page_Insert_Blank_Property.identifier,
  210. page_Insert_Clip_Property.identifier,
  211. page_Insert_Scanner_Property.identifier])
  212. ids.append(contentsOf: [page_Extract_Property.identifier,
  213. page_Replace_Property.identifier, page_Split_Property.identifier,
  214. page_Reverse_Property.identifier,
  215. page_LeftRotate_Property.identifier, page_RightRotate_Property.identifier,
  216. page_Delete_Property.identifier])
  217. } else if mainIdentify == KMPDFToolbar_Markup_Identifier {
  218. ids.append(contentsOf: [highlightProperty.identifier, UnderlineProperty.identifier,
  219. wavelineProperty.identifier, strikethroughProperty.identifier,
  220. textProperty.identifier, noteProperty.identifier,
  221. penProperty.identifier, eraserProperty.identifier,
  222. rectangleProperty.identifier, circleProperty.identifier,
  223. arrowProperty.identifier, lineProperty.identifier,
  224. measureProperty.identifier,
  225. stampProperty.identifier, signProperty.identifier,
  226. eyeProperty.identifier])
  227. } else if mainIdentify == KMPDFToolbar_Edit_Identifier {
  228. ids.append(contentsOf: [edit_watermark_add_Property.identifier, edit_watermark_remove_Property.identifier,
  229. edit_watermark_batchAdd_Property.identifier, edit_watermark_batchRemove_Property.identifier])
  230. ids.append(contentsOf: [edit_bg_add_Property.identifier, edit_bg_remove_Property.identifier,
  231. edit_bg_batchAdd_Property.identifier, edit_bg_batchRemove_Property.identifier])
  232. ids.append(contentsOf: [edit_hf_add_Property.identifier, edit_hf_remove_Property.identifier,
  233. edit_hf_batchAdd_Property.identifier, edit_hf_batchRemove_Property.identifier])
  234. ids.append(contentsOf: [edit_bates_add_Property.identifier, edit_bates_remove_Property.identifier,
  235. edit_bates_batchAdd_Property.identifier, edit_bates_batchRemove_Property.identifier])
  236. ids.append(contentsOf: [edit_text_Property.identifier, edit_image_Property.identifier,
  237. edit_link_Property.identifier, edit_watermark_Property.identifier,
  238. edit_background_Property.identifier, edit_headerfooter_Property.identifier,
  239. edit_bates_Property.identifier, edit_crop_Property.identifier])
  240. } else if mainIdentify == KMPDFToolbar_Form_Identifier {
  241. ids.append(contentsOf: [form_text_Property.identifier, form_checkbox_Property.identifier, form_radio_Property.identifier, form_list_Property.identifier,
  242. form_dropdown_Property.identifier, form_OK_Property.identifier, form_digitalSign_Property.identifier,
  243. form_alignment_Property.identifier, form_more_Property.identifier])
  244. } else if mainIdentify == KMPDFToolbar_Fill_Identifier {
  245. ids.append(contentsOf: [fill_tick_Property.identifier, fill_fork_Property.identifier, fill_rectangle_Property.identifier, fill_line_Property.identifier,
  246. fill_dot_Property.identifier, fill_date_Property.identifier, fill_sign_Property.identifier])
  247. } else if mainIdentify == KMPDFToolbar_Convert_Identifier {
  248. ids.append(contentsOf: [convert_RTF_property.identifier, convert_CSV_property.identifier, convert_HTML_property.identifier,
  249. convert_Text_property.identifier,convert_Json_property.identifier])
  250. ids.append(contentsOf: [convert_word_Property.identifier, convert_excel_Property.identifier, convert_ppt_Property.identifier, convert_image_Property.identifier,
  251. convert_imageToPDF_Property.identifier,
  252. convert_ocr_Property.identifier])
  253. } else if mainIdentify == KMPDFToolbar_Protect_Identifier {
  254. ids.append(contentsOf: [protect_redact_Property.identifier, protect_security_Property.identifier, protect_removeSecurity_Property.identifier, protect_digitalSign_Property.identifier])
  255. } else if mainIdentify == KMPDFToolbar_Tools_Identifier {
  256. ids.append(contentsOf: [tools_OCR_Property.identifier, tools_merge_Property.identifier,
  257. tools_compress_Property.identifier, tools_compare_Property.identifier,
  258. tools_extractImage_Property.identifier, tools_TTS_Property.identifier,
  259. tools_batch_Property.identifier, tools_AITools_Property.identifier])
  260. }
  261. return ids
  262. }
  263. func getSubToolbarItems(_ modeType: KMPDFToolsMode = .None, isPageEditMode: Bool = false) -> [NSObject] {
  264. if isPageEditMode {
  265. page_pageInfo_Property.menuItemArr = [page_page_oddPage_Property, page_page_EvenPage_Property,
  266. page_page_PortraitPage_Property, page_page_LandscapePage_Property,
  267. page_page_AllPage_Property, ComponentMenuitemProperty.divider(),
  268. page_page_CustomPage_Property]
  269. page_Insert_Property.menuItemArr = [page_Insert_File_Property, page_Insert_Blank_Property,
  270. ComponentMenuitemProperty.divider(), page_Insert_Clip_Property,
  271. page_Insert_Scanner_Property]
  272. return [page_pageInfo_Property, dividerProperty,
  273. page_Insert_Property, page_Extract_Property,
  274. page_Replace_Property, page_Split_Property,
  275. page_Reverse_Property, dividerProperty,
  276. page_LeftRotate_Property, page_RightRotate_Property,
  277. page_Delete_Property]
  278. }
  279. if modeType == .Markup {
  280. return [highlightProperty, UnderlineProperty, wavelineProperty, strikethroughProperty,
  281. dividerProperty, textProperty, noteProperty, dividerProperty,
  282. penProperty, eraserProperty, dividerProperty, rectangleProperty,
  283. circleProperty, arrowProperty, lineProperty, measureProperty,
  284. dividerProperty,stampProperty, signProperty, dividerProperty, eyeProperty]
  285. } else if modeType == .Edit {
  286. edit_watermark_Property.menuItemArr = [edit_watermark_add_Property, edit_watermark_remove_Property,
  287. ComponentMenuitemProperty.divider(),
  288. edit_watermark_batchAdd_Property, edit_watermark_batchRemove_Property]
  289. edit_background_Property.menuItemArr = [edit_bg_add_Property, edit_bg_remove_Property,
  290. ComponentMenuitemProperty.divider(),
  291. edit_bg_batchAdd_Property, edit_bg_batchRemove_Property]
  292. edit_headerfooter_Property.menuItemArr = [edit_hf_add_Property, edit_hf_remove_Property,
  293. ComponentMenuitemProperty.divider(),
  294. edit_hf_batchAdd_Property, edit_hf_batchRemove_Property]
  295. edit_bates_Property.menuItemArr = [edit_bates_add_Property, edit_bates_remove_Property,
  296. ComponentMenuitemProperty.divider(),
  297. edit_bates_batchAdd_Property, edit_bates_batchRemove_Property]
  298. return [edit_text_Property, edit_image_Property, edit_link_Property, dividerProperty, edit_watermark_Property, edit_background_Property, edit_headerfooter_Property,
  299. edit_bates_Property, edit_crop_Property]
  300. } else if modeType == .Form {
  301. return [form_text_Property, form_checkbox_Property, form_radio_Property, form_list_Property,
  302. form_dropdown_Property, form_OK_Property, form_digitalSign_Property, dividerProperty,
  303. form_alignment_Property, form_more_Property]
  304. } else if modeType == .Fill {
  305. return [fill_tick_Property, fill_fork_Property, fill_rectangle_Property, fill_line_Property,
  306. fill_dot_Property, fill_date_Property, fill_sign_Property]
  307. } else if modeType == .Convert {
  308. var menuItemArr: [ComponentMenuitemProperty] = []
  309. if true {
  310. menuItemArr.append(convert_RTF_property)
  311. menuItemArr.append(convert_CSV_property)
  312. menuItemArr.append(convert_HTML_property)
  313. menuItemArr.append(convert_Text_property)
  314. menuItemArr.append(convert_Json_property)
  315. convert_others_Property.menuItemArr = menuItemArr
  316. }
  317. return [convert_word_Property, convert_excel_Property, convert_ppt_Property, convert_image_Property,
  318. convert_others_Property, dividerProperty, convert_imageToPDF_Property, dividerProperty,
  319. convert_ocr_Property]
  320. } else if modeType == .Protect {
  321. return [protect_redact_Property, protect_security_Property, protect_removeSecurity_Property, protect_digitalSign_Property]
  322. } else if modeType == .Tools {
  323. return[tools_OCR_Property, tools_merge_Property, tools_compress_Property, tools_compare_Property,
  324. tools_extractImage_Property, tools_TTS_Property, tools_batch_Property, tools_AITools_Property]
  325. }
  326. return []
  327. }
  328. //MARK: - 刷新Markup二级工具栏特殊图片
  329. func refreshMarkupColorImages() {
  330. highlightProperty.icon = KMPDFToolbarManager.getMarkup_HighlightImage()
  331. highlightProperty.propertyInfo.leftIcon_hov = highlightProperty.icon
  332. highlightProperty.propertyInfo.leftIcon_press = highlightProperty.icon
  333. UnderlineProperty.icon = KMPDFToolbarManager.getMarkupUnderlineImage()
  334. UnderlineProperty.propertyInfo.leftIcon_hov = UnderlineProperty.icon
  335. UnderlineProperty.propertyInfo.leftIcon_press = UnderlineProperty.icon
  336. wavelineProperty.icon = KMPDFToolbarManager.getMarkupwavylineImage()
  337. wavelineProperty.propertyInfo.leftIcon_hov = wavelineProperty.icon
  338. wavelineProperty.propertyInfo.leftIcon_press = wavelineProperty.icon
  339. strikethroughProperty.icon = KMPDFToolbarManager.getMarkupStrikethroughImage()
  340. strikethroughProperty.propertyInfo.leftIcon_hov = strikethroughProperty.icon
  341. strikethroughProperty.propertyInfo.leftIcon_press = strikethroughProperty.icon
  342. noteProperty.icon = KMPDFToolbarManager.getMarkupNoteImage()
  343. noteProperty.propertyInfo.leftIcon_hov = noteProperty.icon
  344. noteProperty.propertyInfo.leftIcon_press = noteProperty.icon
  345. penProperty.icon = KMPDFToolbarManager.getMarkupPenImage()
  346. penProperty.propertyInfo.leftIcon_hov = penProperty.icon
  347. penProperty.propertyInfo.leftIcon_press = penProperty.icon
  348. }
  349. //MARK: - 获取Markup相关icon图片
  350. static func getMarkup_HighlightImage() -> NSImage? {
  351. let image = NSImage(named: "markup_highlight_base")
  352. let upImage = NSImage(named: "markup_highlight_Cover")
  353. if let img = NSImage.combineImages(images: [image?.filled(with: NSColor.red), upImage]) {
  354. return img
  355. }
  356. return image
  357. }
  358. static func getMarkupNoteImage() -> NSImage? {
  359. let image = NSImage(named: "markup_note_base")
  360. let upImage = NSImage(named: "markup_note_Cover")
  361. if let img = NSImage.combineImages(images: [image?.filled(with: NSColor.red), upImage]) {
  362. return img
  363. }
  364. return image
  365. }
  366. static func getMarkupPenImage() -> NSImage? {
  367. let image = NSImage(named: "markup_pen_Cover")
  368. let upImage = NSImage(named: "markup_pen_base")
  369. if let img = NSImage.combineImages(images: [(image?.filled(with: NSColor.red))!, upImage!]) {
  370. return img
  371. }
  372. return image
  373. }
  374. static func getMarkupStrikethroughImage() -> NSImage? {
  375. let image = NSImage(named: "markup_strikethrough_Cover")
  376. let upImage = NSImage(named: "markup_strikethrough_base")
  377. if let img = NSImage.combineImages(images: [(image?.filled(with: NSColor.red))!, upImage!]) {
  378. return img
  379. }
  380. return image
  381. }
  382. static func getMarkupUnderlineImage() -> NSImage? {
  383. let image = NSImage(named: "markup_underline_Cover")
  384. let upImage = NSImage(named: "markup_underline_base")
  385. if let img = NSImage.combineImages(images: [(image?.filled(with: NSColor.red))!, upImage!]) {
  386. return img
  387. }
  388. return image
  389. }
  390. static func getMarkupwavylineImage() -> NSImage? {
  391. let image = NSImage(named: "markup_wavyline_Cover")
  392. let upImage = NSImage(named: "markup_wavyline_base")
  393. if let img = NSImage.combineImages(images: [(image?.filled(with: NSColor.red))!, upImage!]) {
  394. return img
  395. }
  396. return image
  397. }
  398. }