forked from saniainf/CorelDraw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintMarksR5.frm
More file actions
513 lines (464 loc) · 16.3 KB
/
PrintMarksR5.frm
File metadata and controls
513 lines (464 loc) · 16.3 KB
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} PrintMarksR5
Caption = "Print Marks Ryobi 5xx"
ClientHeight = 3015
ClientLeft = 45
ClientTop = 390
ClientWidth = 5415
OleObjectBlob = "PrintMarksR5.frx":0000
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "PrintMarksR5"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' version 2.0.4
' remove CommandGroup
' maybe this call bug
' verison 2.0.3
' add create color bar in new document
' correct values of tint on color bar
Option Explicit
Dim cColor As New Collection, cColorOnly As New Collection, cColorBar As New Collection, cColorSign As New Collection
Dim cyanColor As New Color, magentaColor As New Color, yellowColor As New Color, blackColor As New Color
Dim whiteColor As New Color
Dim cBlack40 As New Color, cGrayBalance As New Color
Dim tint80 As String, tint40 As String, grayBalance As String, black40 As String
Dim x As Double, spaceWidth As Double, barWidth As Double, startPos As Double
Dim sBar As Shape, sText As Shape, sSign As Shape
Dim sectionCount As Integer, barInSection As Integer
Dim prevSelected As Integer
Dim oClr As New Color, saveClr As New Color, pickClr As New Color, tintClr As New Color
Dim i As Integer, e As Integer, a As Integer
Dim objCColorForList As Variant, objCColorForBar As Variant
Dim typeStr As Boolean
Dim str As String, saveStr As String
Dim icClr As Integer, icClrOnly As Integer
Dim srBar As New ShapeRange
Dim listHeight As Double
Private Sub UserForm_Initialize()
Application.ActiveDocument.Unit = cdrMillimeter
cyanColor.CMYKAssign 100, 0, 0, 0
magentaColor.CMYKAssign 0, 100, 0, 0
yellowColor.CMYKAssign 0, 0, 100, 0
blackColor.CMYKAssign 0, 0, 0, 100
whiteColor.CMYKAssign 0, 0, 0, 0
cBlack40.CMYKAssign 0, 0, 0, 40
cGrayBalance.CMYKAssign 38, 26, 26, 0
grayBalance = "grayBalance"
black40 = "black40"
tint80 = "tint80"
tint40 = "tint40"
sectionCount = 16
barInSection = 8
spaceWidth = 0.3
barWidth = 3.9
startPos = 0#
listHeight = lbColorList.Height
cColor.Add cyanColor
cColor.Add magentaColor
cColor.Add yellowColor
cColor.Add blackColor
cColor.Add grayBalance
cColor.Add black40
cColor.Add tint40
cColor.Add tint80
colorListUpdate
End Sub
Private Sub lbColorList_Change()
If lbColorList.ListCount <= 0 Or lbColorList.ListIndex < 0 Then Exit Sub
prevSelected = lbColorList.ListIndex
End Sub
Private Sub lbColorList_Click()
If lbColorList.ListCount <= 0 Or lbColorList.ListIndex < 0 Then Exit Sub
sbColorList.Value = lbColorList.ListIndex
End Sub
Private Sub sbColorList_Change()
If lbColorList.ListCount <= 0 Or lbColorList.ListIndex < 0 Then Exit Sub
If prevSelected < sbColorList.Value Then
'save color or str
If TypeName(cColor.Item(prevSelected + 1)) = "String" Then
saveStr = cColor.Item(prevSelected + 1)
typeStr = True
End If
If TypeName(cColor.Item(prevSelected + 1)) = "Color" Then
Set saveClr = cColor.Item(prevSelected + 1)
typeStr = False
End If
'remove item
cColor.Remove prevSelected + 1
'add item in new position
If typeStr Then
cColor.Add saveStr, , , prevSelected + 1
Else
cColor.Add saveClr, , , prevSelected + 1
End If
lbColorList.ListIndex = sbColorList.Value
colorListUpdate
End If
If prevSelected > sbColorList.Value Then
If TypeName(cColor.Item(prevSelected + 1)) = "String" Then
saveStr = cColor.Item(prevSelected + 1)
typeStr = True
End If
If TypeName(cColor.Item(prevSelected + 1)) = "Color" Then
Set saveClr = cColor.Item(prevSelected + 1)
typeStr = False
End If
cColor.Remove prevSelected + 1
If typeStr Then
cColor.Add saveStr, , prevSelected
Else
cColor.Add saveClr, , prevSelected
End If
lbColorList.ListIndex = sbColorList.Value
colorListUpdate
End If
End Sub
'Private Sub sbColorList_Change()
' If lbColorList.ListCount <= 0 Or lbColorList.ListIndex < 0 Then Exit Sub
' Dim vObj As Variant
'
' If prevSelected < sbColorList.Value Then
' vObj = cColor.Item(prevSelected + 1)
' cColor.Remove prevSelected + 1
' cColor.Add vObj, , , prevSelected + 1
' lbColorList.ListIndex = sbColorList.Value
' colorListUpdate
' End If
'
' If prevSelected > sbColorList.Value Then
' vObj = cColor.Item(prevSelected + 1)
' cColor.Remove prevSelected + 1
' cColor.Add vObj, , prevSelected
' lbColorList.ListIndex = sbColorList.Value
' colorListUpdate
' End If
'End Sub
Private Sub btnAddColor_Click()
Set pickClr = New Color
If pickClr.UserAssignEx Then
If pickClr.Name = "unnamed color" Then
MsgBox "Unnamed Color", vbCritical, "Error"
Exit Sub
End If
If pickClr.Type = cdrColorPantone Or pickClr.Type = cdrColorSpot Then
pickClr.Tint = 100
End If
'if not selected
If lbColorList.ListIndex = -1 Then lbColorList.ListIndex = lbColorList.ListCount - 1
cColor.Add pickClr, , lbColorList.ListIndex + 1
colorListUpdate
End If
End Sub
Private Sub btnDeleteColor_Click()
If lbColorList.ListCount = 1 Then Exit Sub
'if not selected
If lbColorList.ListIndex = -1 Then lbColorList.ListIndex = lbColorList.ListCount - 1
cColor.Remove lbColorList.ListIndex + 1
colorListUpdate
End Sub
Private Sub btnAddCyan_Click()
cColor.Add cyanColor, , lbColorList.ListIndex + 1
colorListUpdate
End Sub
Private Sub btnAddMagenta_Click()
cColor.Add magentaColor, , lbColorList.ListIndex + 1
colorListUpdate
End Sub
Private Sub btnAddYellow_Click()
cColor.Add yellowColor, , lbColorList.ListIndex + 1
colorListUpdate
End Sub
Private Sub btnAddBlack_Click()
cColor.Add blackColor, , lbColorList.ListIndex + 1
colorListUpdate
End Sub
Private Sub btnAdd40_Click()
cColor.Add tint40, , lbColorList.ListIndex + 1
colorListUpdate
End Sub
Private Sub btnAdd80_Click()
cColor.Add tint80, , lbColorList.ListIndex + 1
colorListUpdate
End Sub
Private Sub btnAddGrayBalance_Click()
cColor.Add black40, , lbColorList.ListIndex + 1
cColor.Add grayBalance, , lbColorList.ListIndex + 1
colorListUpdate
End Sub
Private Sub btnCreateMarks_Click()
If (Documents.Count = 0) Then
Unload Me
Exit Sub
End If
'maybe this call bug
'ActiveDocument.BeginCommandGroup "Ñreate Print Marks"
Application.Optimization = True
'create color bar in new document
Dim mainDoc As Document
Dim mainPage As Page
Dim cbarDoc As Document
Set mainDoc = ActiveDocument
Set mainPage = mainDoc.ActivePage
Set cbarDoc = CreateDocument
cbarDoc.Activate
cbarDoc.Unit = cdrMillimeter
cbarDoc.ActivePage.SizeWidth = mainPage.SizeWidth
cbarDoc.ActivePage.SizeHeight = mainPage.SizeHeight
ActiveDocument.ReferencePoint = cdrTopLeft
Set cColorBar = New Collection
Set cColorSign = New Collection
If cColor.Count <= 8 Then createStandartBar
If cColor.Count > 8 Then createExtendetBar
'color bar
signBar
Set srBar = New ShapeRange
ActiveDocument.ClearSelection
For Each sBar In cColorBar
srBar.Add sBar
Next sBar
Set sBar = srBar.Group
'sign color
signColor
Set srBar = New ShapeRange
ActiveDocument.ClearSelection
For Each sSign In cColorSign
srBar.Add sSign
Next sSign
Set sSign = srBar.Group
PrintMarksR5v2.PrintMarksR5v2 sBar, sSign
mainPage.ActiveLayer.Paste
cbarDoc.Dirty = False
cbarDoc.Close
mainDoc.Activate
mainPage.Activate
ActiveDocument.ClearSelection
Application.Optimization = False
ActiveWindow.Refresh
Application.Refresh
'ActiveDocument.EndCommandGroup
End Sub
Private Sub btnCancel_Click()
Unload Me
End Sub
Sub colorListUpdate()
'save selected item
i = lbColorList.ListIndex
lbColorList.Clear
Set cColorOnly = New Collection
For Each objCColorForList In cColor
Select Case TypeName(objCColorForList)
Case "Color"
lbColorList.AddItem objCColorForList.Name
cColorOnly.Add objCColorForList
Case "String"
lbColorList.AddItem parserStringToColorList(objCColorForList)
End Select
Next objCColorForList
'if delete item and reduce items count
If i >= lbColorList.ListCount Then i = lbColorList.ListCount - 1
'restore selected item
lbColorList.ListIndex = i
'if not selected
If lbColorList.ListIndex = -1 Then lbColorList.ListIndex = 0
'label fill
fillLabel
'scroll color list min_max
sbColorList.Min = 0
sbColorList.Max = lbColorList.ListCount - 1
End Sub
Sub createExtendetBar()
x = startPos
icClr = 1
icClrOnly = 1
For i = 0 To sectionCount - 1
'color bar
For a = 1 To barInSection
Set sBar = ActiveLayer.CreateRectangle(x, barWidth, x + barWidth, 0)
cColorBar.Add sBar
sBar.Outline.SetNoOutline
If TypeName(cColor.Item(icClr)) = "Color" Then
sBar.Fill.UniformColor = cColor.Item(icClr)
Else
sBar.Fill.UniformColor = parserStringToExtColorBar(cColor.Item(icClr))
End If
x = x + barWidth
icClr = icClr + 1
If icClrOnly > cColorOnly.Count Then icClrOnly = 1
If icClr > cColor.Count Then icClr = 1
Next a
'white space
Set sBar = ActiveLayer.CreateRectangle(x, barWidth, x + spaceWidth, 0)
cColorBar.Add sBar
sBar.Outline.SetNoOutline
sBar.Fill.ApplyNoFill
x = x + spaceWidth
Next i
End Sub
Sub createStandartBar()
x = startPos
For i = 0 To sectionCount - 1
'color bar
For a = 1 To barInSection \ cColor.Count
For Each objCColorForBar In cColor
Set sBar = ActiveLayer.CreateRectangle(x, barWidth, x + barWidth, 0)
cColorBar.Add sBar
sBar.Outline.SetNoOutline
If TypeName(objCColorForBar) = "Color" Then
sBar.Fill.UniformColor = objCColorForBar
Else
sBar.Fill.UniformColor = parserStringToColorBar(objCColorForBar, i)
End If
x = x + barWidth
Next objCColorForBar
Next a
'white bar
For a = 0 To barInSection Mod cColor.Count - 1
Set sBar = ActiveLayer.CreateRectangle(x, barWidth, x + barWidth, 0)
cColorBar.Add sBar
sBar.Outline.SetNoOutline
sBar.Fill.ApplyNoFill
x = x + barWidth
Next a
'white space
Set sBar = ActiveLayer.CreateRectangle(x, barWidth, x + spaceWidth, 0)
cColorBar.Add sBar
sBar.Outline.SetNoOutline
sBar.Fill.ApplyNoFill
x = x + spaceWidth
Next i
End Sub
Private Sub cbCustomSign_Click()
If cbCustomSign.Value = True Then
lbColorList.ListStyle = fmListStyleOption
colorListUpdate
lbColorList.Height = listHeight
Else
lbColorList.ListStyle = fmListStylePlain
colorListUpdate
lbColorList.Height = listHeight
End If
End Sub
Private Sub signBar()
If cbCustomSign.Value Then
If lbColorList.ListIndex + 1 > barInSection Then
x = startPos + barWidth * barInSection / 2
Else
x = startPos + barWidth * lbColorList.ListIndex
End If
Else
x = startPos + barWidth * barInSection / 2
End If
For i = sectionCount - 1 To 0 Step -1
Set sText = ActiveLayer.CreateArtisticText(x, barWidth, i + 1, , , "Arial", 4, cdrFalse, cdrFalse, cdrNoFontLine, cdrLeftAlignment)
sText.ConvertToCurves
sText.PositionY = sText.PositionY - sText.BoundingBox.Height
sText.Fill.UniformColor = whiteColor
sText.Outline.SetNoOutline
cColorBar.Add sText
x = x + barWidth * barInSection + spaceWidth
Next i
End Sub
Private Sub signColor()
x = startPos
For Each oClr In cColorOnly
Set sText = ActiveLayer.CreateArtisticText(x, 0, oClr.Name, , , "Arial", 6, cdrTrue, cdrFalse, cdrNoFontLine, cdrLeftAlignment)
sText.ConvertToCurves
sText.Fill.UniformColor = oClr
sText.Outline.SetNoOutline
cColorSign.Add sText
x = x + sText.BoundingBox.Width + barWidth / 2
Next oClr
End Sub
Public Function parserStringToColorList(pStr As Variant) As String
Select Case pStr
Case grayBalance
parserStringToColorList = "Gray Balance"
Case black40
parserStringToColorList = "K: 40%"
Case tint80
parserStringToColorList = "Tint: 80%"
Case tint40
parserStringToColorList = "Tint: 40%"
End Select
End Function
Public Function parserStringToExtColorBar(pStr As Variant) As Color
Select Case pStr
Case grayBalance
Set parserStringToExtColorBar = cGrayBalance
Case black40
Set parserStringToExtColorBar = cBlack40
Case tint80
'get copy color from ColorOnly collection
Set tintClr = cColorOnly.Item(icClrOnly).GetCopy
'tint color differently for spot or cmyk
If tintClr.Type = cdrColorCMYK Then
tintClr.BlendWith whiteColor, 20
ElseIf tintClr.Type = cdrColorSpot Or tintClr.Type = cdrColorPantone Then
Set tintClr = CreateSpotColor(tintClr.PaletteIdentifier, tintClr.SpotColorID, 80)
End If
icClrOnly = icClrOnly + 1
'return value
Set parserStringToExtColorBar = tintClr
Case tint40
'get copy color from ColorOnly collection
Set tintClr = cColorOnly.Item(icClrOnly).GetCopy
'tint color differently for spot or cmyk
If tintClr.Type = cdrColorCMYK Then
tintClr.BlendWith whiteColor, 60
ElseIf tintClr.Type = cdrColorSpot Or tintClr.Type = cdrColorPantone Then
Set tintClr = CreateSpotColor(tintClr.PaletteIdentifier, tintClr.SpotColorID, 40)
End If
icClrOnly = icClrOnly + 1
'return value
Set parserStringToExtColorBar = tintClr
End Select
End Function
Public Function parserStringToColorBar(pStr As Variant, nSection As Integer) As Color
Select Case pStr
Case grayBalance
Set parserStringToColorBar = cGrayBalance
Case black40
Set parserStringToColorBar = cBlack40
Case tint80
'get copy color from ColorOnly collection
Set tintClr = cColorOnly.Item((nSection Mod cColorOnly.Count) + 1).GetCopy
'tint color differently for spot or cmyk
If tintClr.Type = cdrColorCMYK Then
tintClr.BlendWith whiteColor, 20
ElseIf tintClr.Type = cdrColorSpot Or tintClr.Type = cdrColorPantone Then
Set tintClr = CreateSpotColor(tintClr.PaletteIdentifier, tintClr.SpotColorID, 80)
End If
'return value
Set parserStringToColorBar = tintClr
Case tint40
Set tintClr = cColorOnly.Item((nSection Mod cColorOnly.Count) + 1).GetCopy
If tintClr.Type = cdrColorCMYK Then
tintClr.BlendWith whiteColor, 60
ElseIf tintClr.Type = cdrColorSpot Or tintClr.Type = cdrColorPantone Then
Set tintClr = CreateSpotColor(tintClr.PaletteIdentifier, tintClr.SpotColorID, 40)
End If
Set parserStringToColorBar = tintClr
End Select
End Function
Sub fillLabel()
If cColor.Count > barInSection Then
lblBarCount.ForeColor = &HFF&
Else
lblBarCount.ForeColor = &H80000012
End If
lblBarCount.Caption = "Bar count: " & cColor.Count
i = 0
e = 0
For Each oClr In cColorOnly
If oClr.Type = cdrColorCMYK Then
i = i + 1
ElseIf oClr.Type = cdrColorSpot Or oClr.Type = cdrColorPantone Then
e = e + 1
End If
Next oClr
lblCmykCount.Caption = "CMYK count: " & i
lblSpotCount.Caption = "Spot count: " & e
End Sub