feat: add current-project PDF export
This commit is contained in:
1 parent
771d8efb87
commit
c8caaf8daf
22 files changed
+1959
-1
No files matched your search
@@ -61,6 +61,10 @@ Sub DxToolsInstallMenu()
|
||||
button.Caption = DxToolsBomCaption()
|
||||
button.OnAction = "DxToolsOpenBom"
|
||||
|
||||
Set button = DxToolsMenu.Controls.Add
|
||||
button.Caption = DxToolsPdfExportCaption()
|
||||
button.OnAction = "DxToolsOpenPdfExport"
|
||||
|
||||
Set button = DxToolsMenu.Controls.Add
|
||||
button.Caption = DxToolsCompatibilityCaption()
|
||||
button.OnAction = "DxToolsOpenCompatibility"
|
||||
@@ -68,6 +72,10 @@ Sub DxToolsInstallMenu()
|
||||
Set button = DxToolsMenu.Controls.Add
|
||||
button.Caption = DxToolsGuideCaption()
|
||||
button.OnAction = "DxToolsOpenGuide"
|
||||
On Error Resume Next
|
||||
Call DxToolsMaybeStartPdfListener()
|
||||
Err.Clear
|
||||
On Error GoTo 0
|
||||
End Sub
|
||||
|
||||
Sub DxToolsOpenRefDes()
|
||||
@@ -90,6 +98,10 @@ Sub DxToolsOpenBom()
|
||||
Call DxToolsStartFeature("bom")
|
||||
End Sub
|
||||
|
||||
Sub DxToolsOpenPdfExport()
|
||||
Call DxToolsStartFeature("pdf-export")
|
||||
End Sub
|
||||
|
||||
Sub DxToolsStartFeature(featureKey)
|
||||
If Not DxToolsEnsureRoot() Then Exit Sub
|
||||
Call DxToolsEnsureCommonLoaded()
|
||||
@@ -132,6 +144,59 @@ Sub DxToolsOpenGuide()
|
||||
shell.Run Chr(34) & guidePath & Chr(34), 1, False
|
||||
End Sub
|
||||
|
||||
Sub DxToolsMaybeStartPdfListener()
|
||||
Dim shell
|
||||
Dim fso
|
||||
Dim stream
|
||||
Dim settingsPath
|
||||
Dim settingsText
|
||||
Dim expression
|
||||
Dim listenerPath
|
||||
Dim executablePath
|
||||
Dim hostPath
|
||||
Dim commandLine
|
||||
|
||||
Call DxToolsEnsureCommonLoaded()
|
||||
Set shell = CreateObject("WScript.Shell")
|
||||
Set fso = CreateObject("Scripting.FileSystemObject")
|
||||
settingsPath = shell.ExpandEnvironmentStrings( _
|
||||
"%LOCALAPPDATA%\DxProductivity\pdf-export-settings.json")
|
||||
If Not fso.FileExists(settingsPath) Then Exit Sub
|
||||
|
||||
On Error Resume Next
|
||||
Set stream = CreateObject("ADODB.Stream")
|
||||
stream.Type = 2
|
||||
stream.Charset = "utf-8"
|
||||
stream.Open
|
||||
stream.LoadFromFile settingsPath
|
||||
settingsText = stream.ReadText
|
||||
stream.Close
|
||||
If Err.Number <> 0 Then
|
||||
Err.Clear
|
||||
On Error GoTo 0
|
||||
Exit Sub
|
||||
End If
|
||||
On Error GoTo 0
|
||||
|
||||
Set expression = CreateObject("VBScript.RegExp")
|
||||
expression.Pattern = Chr(34) & "auto_export" & Chr(34) & "\s*:\s*true"
|
||||
expression.IgnoreCase = True
|
||||
expression.Global = False
|
||||
If Not expression.Test(settingsText) Then Exit Sub
|
||||
|
||||
listenerPath = fso.BuildPath(DxToolsHome, "PdfSaveListener.vbs")
|
||||
executablePath = fso.BuildPath(DxToolsHome, "DxDesignerTools.exe")
|
||||
hostPath = shell.ExpandEnvironmentStrings( _
|
||||
"%WINDIR%\SysWOW64\wscript.exe")
|
||||
If Not fso.FileExists(listenerPath) Then Exit Sub
|
||||
If Not fso.FileExists(executablePath) Then Exit Sub
|
||||
If Not fso.FileExists(hostPath) Then Exit Sub
|
||||
commandLine = DxToolsQuote(hostPath) & " //B //NoLogo " & _
|
||||
DxToolsQuote(listenerPath) & " " & DxToolsQuote(settingsPath) & " " & _
|
||||
DxToolsQuote(executablePath) & " exe " & DxToolsQuote(DxToolsHome)
|
||||
shell.Run commandLine, 0, False
|
||||
End Sub
|
||||
|
||||
Function DxToolsEnsureRoot()
|
||||
If DxToolsHome = "" Then DxToolsHome = DxToolsResolveRoot()
|
||||
DxToolsEnsureRoot = (DxToolsHome <> "")
|
||||
@@ -256,6 +321,10 @@ Function DxToolsBomCaption()
|
||||
DxToolsBomCaption = "BOM " & ChrW(&H5BFC) & ChrW(&H51FA)
|
||||
End Function
|
||||
|
||||
Function DxToolsPdfExportCaption()
|
||||
DxToolsPdfExportCaption = "PDF " & ChrW(&H5BFC) & ChrW(&H51FA)
|
||||
End Function
|
||||
|
||||
Function DxToolsCompatibilityCaption()
|
||||
DxToolsCompatibilityCaption = ChrW(&H517C) & ChrW(&H5BB9) & _
|
||||
ChrW(&H6027) & ChrW(&H68C0) & ChrW(&H6D4B)
|
||||
|
||||
Reference in new issue
Block a user