This repository has been archived by the owner on Aug 29, 2022. It is now read-only.
forked from Jonathan-LeRoux/IguanaTex
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathSetTempForm.frm
326 lines (249 loc) · 10.9 KB
/
SetTempForm.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} SetTempForm
Caption = "Default Settings and Paths"
ClientHeight = 7230
ClientLeft = 20
ClientTop = 340
ClientWidth = 6280
OleObjectBlob = "SetTempForm.frx":0000
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "SetTempForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim LaTexEngineList As Variant
Dim LaTexEngineDisplayList As Variant
Dim UsePDFList As Variant
Private Sub ButtonAbsTempPath_Click()
AbsPathTextBox.Text = MacChooseFolder(AbsPathTextBox.Text)
End Sub
Private Sub ButtonCancelTemp_Click()
Unload SetTempForm
End Sub
Private Sub ButtonEditorPath_Click()
TextBoxExternalEditor.Text = "open -b " & ShellEscape(MacChooseApp(TextBoxExternalEditor.Text))
TextBoxExternalEditor.SetFocus
End Sub
Private Sub ButtonGSPath_Click()
TextBoxGS.Text = MacChooseFile(TextBoxGS.Text)
TextBoxGS.SetFocus
End Sub
Private Sub ButtonIMPath_Click()
TextBoxIMconv.Text = MacChooseFile(TextBoxIMconv.Text)
TextBoxIMconv.SetFocus
End Sub
Private Sub ButtonTeX2img_Click()
TextBoxTeX2img.Text = MacChooseFile(TextBoxTeX2img.Text)
TextBoxTeX2img.SetFocus
End Sub
Private Sub ButtonTeXExePath_Click()
TextBoxTeXExePath.Text = MacChooseFolder(TextBoxTeXExePath.Text)
TextBoxTeXExePath.SetFocus
End Sub
Private Sub ButtonSetTemp_Click()
Dim RegPath As String
Dim res As String
RegPath = "Software\IguanaTex"
' Temp folder
SetRegistryValue HKEY_CURRENT_USER, RegPath, "AbsOrRel", REG_DWORD, BoolToInt(AbsPathButton.Value)
SetRegistryValue HKEY_CURRENT_USER, RegPath, "Abs Temp Dir", REG_SZ, CStr(AbsPathTextBox.Text)
If Left(RelPathTextBox.Text, 2) = "." & PathSeperator Then
RelPathTextBox.Text = Mid(RelPathTextBox.Text, 3, Len(RelPathTextBox.Text) - 2)
End If
SetRegistryValue HKEY_CURRENT_USER, RegPath, "Rel Temp Dir", REG_SZ, CStr(RelPathTextBox.Text)
If AbsPathButton.Value = True Then
res = AbsPathTextBox.Text
Else
res = "." & PathSeperator & RelPathTextBox.Text
End If
If res <> "" And Right(res, 1) <> PathSeperator Then
res = res & PathSeperator
End If
SetRegistryValue HKEY_CURRENT_USER, RegPath, "Temp Dir", REG_SZ, CStr(res)
' UTF8
SetRegistryValue HKEY_CURRENT_USER, RegPath, "UseUTF8", REG_DWORD, BoolToInt(CheckBoxUTF8.Value)
' Vector or Bitmap (EMF or PNG)
'SetRegistryValue HKEY_CURRENT_USER, RegPath, "EMFoutput", REG_DWORD, BoolToInt(CheckBoxEMF.Value)
SetRegistryValue HKEY_CURRENT_USER, RegPath, "BitmapVector", REG_DWORD, ComboBoxBitmapVector.ListIndex
' GS command
res = TextBoxGS.Text
' no need to remove quotes on mac because we use open -b '....'
' If Left(res, 1) = """" Then res = Mid(res, 2, Len(res) - 1)
' If Right(res, 1) = """" Then res = Left(res, Len(res) - 1)
SetRegistryValue HKEY_CURRENT_USER, RegPath, "GS Command", REG_SZ, CStr(res)
' Path to ImageMagick Convert
res = TextBoxIMconv.Text
If Left(res, 1) = """" Then res = Mid(res, 2, Len(res) - 1)
If Right(res, 1) = """" Then res = Left(res, Len(res) - 1)
SetRegistryValue HKEY_CURRENT_USER, RegPath, "IMconv", REG_SZ, CStr(res)
' Path to External Editor
res = TextBoxExternalEditor.Text
If Left(res, 1) = """" Then res = Mid(res, 2, Len(res) - 1)
If Right(res, 1) = """" Then res = Left(res, Len(res) - 1)
SetRegistryValue HKEY_CURRENT_USER, RegPath, "Editor", REG_SZ, CStr(res)
' Path to TeX2img (Vector output)
res = TextBoxTeX2img.Text
If Left(res, 1) = """" Then res = Mid(res, 2, Len(res) - 1)
If Right(res, 1) = """" Then res = Left(res, Len(res) - 1)
SetRegistryValue HKEY_CURRENT_USER, RegPath, "TeX2img Command", REG_SZ, CStr(res)
' Path to TeX Executables Folder
res = TextBoxTeXExePath.Text
If Left(res, 1) = """" Then res = Mid(res, 2, Len(res) - 1)
If Right(res, 1) = """" Then res = Left(res, Len(res) - 1)
If res <> "" And Right(res, 1) <> PathSeperator Then res = res & PathSeperator
SetRegistryValue HKEY_CURRENT_USER, RegPath, "TeXExePath", REG_SZ, CStr(res)
' Magic scaling factor to fine-tune the scaling of Vector displays
SetRegistryValue HKEY_CURRENT_USER, RegPath, "VectorScalingX", REG_SZ, TextBoxVectorScalingX.Text
SetRegistryValue HKEY_CURRENT_USER, RegPath, "VectorScalingY", REG_SZ, TextBoxVectorScalingY.Text
' Magic scaling factor to fine-tune the scaling of PNG displays
SetRegistryValue HKEY_CURRENT_USER, RegPath, "BitmapScalingX", REG_SZ, TextBoxBitmapScalingX.Text
SetRegistryValue HKEY_CURRENT_USER, RegPath, "BitmapScalingY", REG_SZ, TextBoxBitmapScalingY.Text
' Global dpi setting for latex output
SetRegistryValue HKEY_CURRENT_USER, RegPath, "OutputDpi", REG_DWORD, CLng(val(TextBoxDpi.Text))
' Time Out Interval for Processes
SetRegistryValue HKEY_CURRENT_USER, RegPath, "TimeOutTime", REG_DWORD, CLng(val(TextBoxTimeOut.Text))
' Font size for text in editor/template windows
SetRegistryValue HKEY_CURRENT_USER, RegPath, "EditorFontSize", REG_DWORD, CLng(val(TextBoxFontSize.Text))
' LaTeX Engine
'SetRegistryValue HKEY_CURRENT_USER, RegPath, "LaTeXEngine", REG_SZ, CStr(ComboBoxEngine.Text)
SetRegistryValue HKEY_CURRENT_USER, RegPath, "LaTeXEngineID", REG_DWORD, ComboBoxEngine.ListIndex
Unload SetTempForm
End Sub
Private Sub AbsPathButton_Click()
AbsPathButton.Value = True
SetAbsRelDependencies
End Sub
Private Sub LabelDLgs_Click()
Link = "http://www.ghostscript.com/download/gsdnld.html"
Dim lSuccess As Long
lSuccess = OpenLink(Link)
If (lSuccess = 0) Then
MsgBox "Cannot open " & Link
End If
End Sub
Private Sub LabelDLImageMagick_Click()
Link = "http://www.imagemagick.org/script/download.php#windows"
Dim lSuccess As Long
lSuccess = OpenLink(Link)
If (lSuccess = 0) Then
MsgBox "Cannot open " & Link
End If
End Sub
Private Sub LabelDLTeX2img_Click()
Link = "https://www.ms.u-tokyo.ac.jp/~abenori/soft/bin/TeX2img_2.1.0.zip"
Dim lSuccess As Long
lSuccess = OpenLink(Link)
If (lSuccess = 0) Then
MsgBox "Cannot open " & Link
End If
End Sub
Private Sub LabelTeX2imgGithub_Click()
Link = "https://github.com/abenori/TeX2img"
Dim lSuccess As Long
lSuccess = OpenLink(Link)
If (lSuccess = 0) Then
MsgBox "Cannot open " & Link
End If
End Sub
Private Sub LabelDLtexstudio_Click()
Link = "http://www.texstudio.org/"
Dim lSuccess As Long
lSuccess = OpenLink(Link)
If (lSuccess = 0) Then
MsgBox "Cannot open " & Link
End If
End Sub
Private Sub RelPathButton_Click()
AbsPathButton.Value = False
SetAbsRelDependencies
End Sub
Private Sub SetAbsRelDependencies()
RelPathButton.Value = Not AbsPathButton.Value
AbsPathTextBox.Enabled = AbsPathButton.Value
RelPathTextBox.Enabled = RelPathButton.Value
End Sub
'Private Sub CheckBoxPDF_Click()
'
' If CheckBoxPDF.Value = True Then
' TextBoxGS.Enabled = True
' TextBoxIMconv.Enabled = True
' Else
' TextBoxGS.Enabled = False
' TextBoxIMconv.Enabled = False
' End If
'End Sub
Private Sub SetPDFdependencies()
If UsePDFList(ComboBoxEngine.ListIndex) = True Then
TextBoxGS.Enabled = True
TextBoxIMconv.Enabled = True
Else
TextBoxGS.Enabled = False
TextBoxIMconv.Enabled = False
End If
End Sub
Private Sub Reset_Click()
AbsPathButton.Value = True
CheckBoxUTF8.Value = True
'CheckBoxEMF.Value = False
ComboBoxBitmapVector.ListIndex = 0
TextBoxGS.Text = DEFAULT_GS_COMMAND
TextBoxIMconv.Text = DEFAULT_IM_CONV
TextBoxTeX2img.Text = DEFAULT_TEX2IMG_COMMAND
TextBoxTeXExePath.Text = DEFAULT_TEX_EXE_PATH
TextBoxDpi.Text = "1200"
TextBoxVectorScalingX.Text = "1"
TextBoxVectorScalingY.Text = "1"
TextBoxBitmapScalingX.Text = "1"
TextBoxBitmapScalingY.Text = "1"
TextBoxTimeOut.Text = "60"
TextBoxFontSize.Text = "10"
ComboBoxEngine.ListIndex = 0
'SetPDFdependencies
SetAbsRelDependencies
End Sub
Private Sub UserForm_Initialize()
Me.Top = Application.Top + 110
Me.Left = Application.Left + 25
Dim res As String
RegPath = "Software\IguanaTex"
res = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "Abs Temp Dir", "")
If res <> "" And Right(res, 1) <> PathSeperator Then
res = res & PathSeperator
End If
AbsPathTextBox.Text = res
res = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "Rel Temp Dir", "")
RelPathTextBox.Text = res
AbsPathButton.Value = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "AbsOrRel", True)
CheckBoxUTF8.Value = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "UseUTF8", True)
TextBoxGS.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "GS Command", DEFAULT_GS_COMMAND)
TextBoxIMconv.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "IMconv", DEFAULT_IM_CONV)
TextBoxDpi.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "OutputDpi", "1200")
TextBoxTimeOut.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "TimeOutTime", "60")
TextBoxFontSize.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "EditorFontSize", "10")
TextBoxVectorScalingX.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "VectorScalingX", "1")
TextBoxVectorScalingY.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "VectorScalingY", "1")
TextBoxBitmapScalingX.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "BitmapScalingX", "1")
TextBoxBitmapScalingY.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "BitmapScalingY", "1")
TextBoxExternalEditor.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "Editor", DEFAULT_EDITOR)
TextBoxTeX2img.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "TeX2img Command", DEFAULT_TEX2IMG_COMMAND)
TextBoxTeXExePath.Text = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "TeXExePath", DEFAULT_TEX_EXE_PATH)
'CheckBoxEMF.Value = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "EMFoutput", False)
ComboBoxBitmapVector.List = Array("Bitmap", "Vector")
ComboBoxBitmapVector.ListIndex = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "BitmapVector", 0)
LaTexEngineDisplayList = Array("latex", "pdflatex", "xelatex", "lualatex", "platex")
UsePDFList = Array(False, True, True, True, True)
ComboBoxEngine.List = LaTexEngineDisplayList
ComboBoxEngine.ListIndex = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "LaTeXEngineID", 0)
'CheckBoxPDF.Value = GetRegistryValue(HKEY_CURRENT_USER, RegPath, "UsePDF", False)
'SetPDFdependencies
SetAbsRelDependencies
End Sub
Private Function BoolToInt(val) As Long
If val Then
BoolToInt = 1&
Else
BoolToInt = 0&
End If
End Function