-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathColorBlockSheet.vb
3598 lines (2940 loc) · 138 KB
/
ColorBlockSheet.vb
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
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Imports GCA5Engine
Imports C1.C1Preview
Imports System.Drawing
Imports System.Reflection
'Any such DLL needs to add References to:
'
' System.Drawing (System.Drawing; v4.X)
' C1.C1Report.4 (ComponentOne Reports; v4.X)
' GCA5Engine.DLL
' GCA5.Interfaces.DLL
'
'in order to work as a print sheet.
'
Public Class ColorBlockSheet
Implements GCA5.Interfaces.IPrinterSheet
Private Const Hand As Integer = 1
Private Const Ranged As Integer = 2
Private NewPage As Boolean = True
Private ShadeAltLines As Boolean = True
Private LineBefore As Boolean = True
Private MarginLeft, MarginRight, MarginTop, MarginBottom As Double
Private PageWidth, PageHeight As Double
Private MyOptions As GCA5Engine.SheetOptionsManager
Private ShowHidden() As Boolean
Private ShowComponents() As Boolean
Private BonusesAsFootnotes() As Boolean
Private BonusesInline() As Boolean
Private Fields As ArrayList '0 based
Dim IconColLeft As Double
Dim IconColWidth As Double
Dim IndentStepSize As Double = 0.125
Dim ComponentDrawCol As Integer
Dim FooterHeight As Double = 0.25
Dim pointBoxWidth As Double = 7 / 16
Dim numCols As Integer = 0
Dim PointsCol As Integer = 0
Dim ColWidths(0) As Double
Dim ColAligns(0) As AlignHorzEnum
Dim AltColLefts(0) As Double 'for combos
Dim AltColWidths(0) As Double 'for combos
Dim SubHeads(0) As String
Private MyChar As GCACharacter
Public Property Character As GCACharacter
Get
Return MyChar
End Get
Set(value As GCACharacter)
MyChar = value
End Set
End Property
Private WithEvents MyPrintDoc As C1.C1Preview.C1PrintDocument
Public Property PrintDoc As C1.C1Preview.C1PrintDocument
Get
Return MyPrintDoc
End Get
Set(value As C1.C1Preview.C1PrintDocument)
MyPrintDoc = value
End Set
End Property
Public ReadOnly Property Name() As String Implements GCA5.Interfaces.IPrinterSheet.Name
Get
Return "Color Block Sheet"
End Get
End Property
Public ReadOnly Property Description() As String Implements GCA5.Interfaces.IPrinterSheet.Description
Get
Return "Prints a sheet in the style of the blocks used in the Compact View of GCA5."
End Get
End Property
Public ReadOnly Property Version() As String Implements GCA5.Interfaces.IPrinterSheet.Version
Get
'Return "1.0.0.13"
Return AutoFindVersion()
End Get
End Property
Public Function AutoFindVersion() As String
Dim longFormVersion As String = ""
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
'Provide the current application domain evidence for the assembly.
'Load the assembly from the application directory using a simple name.
currentDomain.Load("ColorBlockSheet")
'Make an array for the list of assemblies.
Dim assems As [Assembly]() = currentDomain.GetAssemblies()
'List the assemblies in the current application domain.
'Echo("List of assemblies loaded in current appdomain:")
Dim assem As [Assembly]
'Dim co As New ArrayList
For Each assem In assems
If assem.FullName.StartsWith("ColorBlockSheet") Then
Dim parts(0) As String
parts = assem.FullName.Split(",")
'name and version are the first two parts
longFormVersion = parts(1)
'Version=1.2.3.4
parts = longFormVersion.Split("=")
Return parts(1)
End If
Next assem
Return longFormVersion
End Function
Public Sub New()
'For testing, I'm creating an Options object with different
'values than those I'm using for the defaults for the
'IPrinterSheet routines.
MyOptions = New GCA5Engine.SheetOptionsManager(Name)
CreateOptions(MyOptions)
MyOptions.Value("SheetFont") = New Font("Arial Narrow", 10)
End Sub
Public Sub UpgradeOptions(Options As GCA5Engine.SheetOptionsManager) Implements GCA5.Interfaces.IPrinterSheet.UpgradeOptions
'This is called only when a particular plug-in is loaded the first time,
'and before SetOptions.
'I don't do anything with this.
End Sub
Public Sub CreateOptions(Options As GCA5Engine.SheetOptionsManager) Implements GCA5.Interfaces.IPrinterSheet.CreateOptions
'This is the routine where all the Options we want to use are created,
'and where the UI for the Preferences dialog is filled out.
'
'This is equivalent to CharacterSheetOptions from previous implementations
Dim i As Integer
Dim ok As Boolean
Dim newOption As GCA5Engine.SheetOption
Dim descFormat As New SheetOptionDisplayFormat
descFormat.BackColor = Color.Gold
descFormat.ForeColor = Color.Black
'descFormat.CaptionLocalBackColor = SystemColors.Info
descFormat.BoxDescriptionForeColor = Color.Black
descFormat.BoxDescriptionBackColor = Color.LightGoldenrodYellow
Dim boxFormat As New SheetOptionDisplayFormat
boxFormat.ForeColor = Color.White
boxFormat.BackColor = Color.Gray
boxFormat.BoxDescriptionForeColor = Color.Black
boxFormat.BoxDescriptionBackColor = Color.LightGray
'**************************************************
'* Description block at top *
'**************************************************
newOption = New GCA5Engine.SheetOption
newOption.Name = "Box_Description"
newOption.Type = GCA5Engine.OptionType.Box
newOption.Value = Name & " " & Version()
newOption.UserPrompt = Description
newOption.DisplayFormat = descFormat
ok = Options.AddOption(newOption)
'**************************************************
'* Fonts *
'**************************************************
newOption = New GCA5Engine.SheetOption
newOption.Name = "Box_Fonts" '"Header_Fonts"
newOption.Type = GCA5Engine.OptionType.Box ' GCA5Engine.OptionType.Header
newOption.Value = "Font Options"
newOption.UserPrompt = "There is a bug in Windows which will allow you to select fonts that are not actually supported for display. We are sorry about that. If that happens here, GCA will post an error to the Log, and the font value will not change."
newOption.DisplayFormat = New SheetOptionDisplayFormat(boxFormat)
newOption.DisplayFormat.BoxDescriptionBackColor = Color.MistyRose
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "SheetFont"
newOption.Type = GCA5Engine.OptionType.Font
newOption.UserPrompt = "Font for the form text items"
newOption.DefaultValue = New Font("Arial", 10)
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "FootnotesFont"
newOption.Type = GCA5Engine.OptionType.Font
newOption.UserPrompt = "Font for the various footnote items."
newOption.DefaultValue = New Font("Arial Narrow", 8)
ok = Options.AddOption(newOption)
'**************************************************
'* Trait Options *
'**************************************************
newOption = New GCA5Engine.SheetOption
newOption.Name = "Box_Traits"
newOption.Type = GCA5Engine.OptionType.Box
newOption.Value = "Miscellaneous Trait Options"
newOption.DisplayFormat = boxFormat
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "ShowWhere"
newOption.Type = GCA5Engine.OptionType.YesNo
newOption.UserPrompt = "Do you want to show 'Location' or 'Where' information for traits that have it?"
newOption.DefaultValue = True
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "WhereNote"
newOption.Type = GCA5Engine.OptionType.Caption
newOption.UserPrompt = "'Location' or 'Where' will be included in the footnote font directly under the applicable item."
newOption.DisplayFormat.BackColor = SystemColors.Info
newOption.DisplayFormat.ForeColor = SystemColors.InfoText
newOption.DisplayFormat.CaptionLocalBackColor = SystemColors.Info
ok = Options.AddOption(newOption)
'**************************************************
'* Options by ItemType *
'**************************************************
newOption = New GCA5Engine.SheetOption
newOption.Name = "Box_ByType" '"Header_Hidden"
newOption.Type = GCA5Engine.OptionType.Box ' GCA5Engine.OptionType.Header
newOption.Value = "Options by Trait Type"
newOption.DisplayFormat = boxFormat
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "Header_Hidden"
newOption.Type = GCA5Engine.OptionType.Header
newOption.UserPrompt = "Show Hidden Traits"
ok = Options.AddOption(newOption)
Dim a1(LastItemType - 1) As Boolean
Dim t1(LastItemType - 1) As String
For i = 1 To LastItemType
a1(i - 1) = False
t1(i - 1) = ReturnListNameNew(i)
Next
newOption = New GCA5Engine.SheetOption
newOption.Name = "ShowHidden"
newOption.Type = OptionType.ListArray
newOption.UserPrompt = "Check the sections for which you'd like to display traits that are normally hidden."
newOption.DefaultValue = a1
newOption.List = t1
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "Header_Components"
newOption.Type = GCA5Engine.OptionType.Header
newOption.UserPrompt = "Show Component Traits"
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "CompNote"
newOption.Type = GCA5Engine.OptionType.Caption
newOption.UserPrompt = "Components are the traits that make up meta-traits and templates. If you would like to have them listed under their owning trait, turn that on here."
newOption.DisplayFormat.CaptionLocalBackColor = Color.LightGray
newOption.DisplayFormat.ForeColor = Color.Black
newOption.DisplayFormat.BackColor = Color.LightGray
ok = Options.AddOption(newOption)
Dim a2(LastItemType - 1) As Boolean
Dim t2(LastItemType - 1) As String
For i = 1 To LastItemType
a2(i - 1) = False
t2(i - 1) = ReturnListNameNew(i)
Next
newOption = New GCA5Engine.SheetOption
newOption.Name = "ShowComponents"
newOption.Type = OptionType.ListArray
newOption.UserPrompt = "Check the sections for which you'd like to display any component traits."
newOption.DefaultValue = a2
newOption.List = t2
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "Header_BonusFootnotes"
newOption.Type = GCA5Engine.OptionType.Header
newOption.UserPrompt = "Show Bonuses to Traits"
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "BonusNote"
newOption.Type = GCA5Engine.OptionType.Caption
newOption.UserPrompt = "If you don't want a section to display bonuses (common for spells), then make sure Spells is not checked for either section. If you have sections checked for both Footnotes and Inline, then both versions will display. These bonus options use the Footnote font."
newOption.DisplayFormat.CaptionLocalBackColor = Color.LightGray
newOption.DisplayFormat.ForeColor = Color.Black
newOption.DisplayFormat.BackColor = Color.LightGray
ok = Options.AddOption(newOption)
Dim a3(LastItemType - 1) As Boolean
Dim t3(LastItemType - 1) As String
For i = 1 To LastItemType
a3(i - 1) = True
t3(i - 1) = ReturnListNameNew(i)
Next
newOption = New GCA5Engine.SheetOption
newOption.Name = "BonusesAsFootnotes"
newOption.Type = OptionType.ListArray
newOption.UserPrompt = "Check the sections for which you'd like to display all bonuses to traits as footnotes at the end of the listings."
newOption.DefaultValue = a3
newOption.List = t3
ok = Options.AddOption(newOption)
Dim a4(LastItemType - 1) As Boolean
Dim t4(LastItemType - 1) As String
For i = 1 To LastItemType
a4(i - 1) = False
t4(i - 1) = ReturnListNameNew(i)
Next
newOption = New GCA5Engine.SheetOption
newOption.Name = "BonusesInline"
newOption.Type = OptionType.ListArray
newOption.UserPrompt = "Check the sections for which you'd like to display bonuses to traits as 'inline' notes under each trait item."
newOption.DefaultValue = a4
newOption.List = t4
ok = Options.AddOption(newOption)
'**************************************************
'* Color Options *
'**************************************************
'* Description block at top *
newOption = New GCA5Engine.SheetOption
newOption.Name = "Box_Colors" ' "Header_Colors"
newOption.Type = GCA5Engine.OptionType.Box 'GCA5Engine.OptionType.Header
newOption.Value = "Color Options"
newOption.UserPrompt = "Set the colors for the various blocks here."
newOption.DisplayFormat = boxFormat
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "EncumbranceLevelColor"
newOption.Type = GCA5Engine.OptionType.Color
newOption.UserPrompt = "The Encumbrance block is drawn in the Attributes colors selected below. However, please select the color used to highlight the current encumbrance level (a border will be drawn around those values in this color)."
newOption.DefaultValue = Color.ForestGreen
ok = Options.AddOption(newOption)
'* Colors *
For i = Stats To LastItemType
newOption = New GCA5Engine.SheetOption
newOption.Name = i & "Colors"
newOption.Type = GCA5Engine.OptionType.Header
newOption.UserPrompt = ReturnListNameNew(i) & " Block Colors"
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = i & "BackColor"
newOption.Type = GCA5Engine.OptionType.Color
newOption.UserPrompt = "Color for the background."
newOption.DefaultValue = Color.White
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = i & "BorderColor"
newOption.Type = GCA5Engine.OptionType.Color
newOption.UserPrompt = "Color for the border lines and header background."
Select Case i
Case Attributes, Cultures, Languages
newOption.DefaultValue = Color.Maroon
Case Ads, Perks
newOption.DefaultValue = Color.Blue
Case Disads, Quirks
newOption.DefaultValue = Color.Brown
Case Skills
newOption.DefaultValue = Color.Purple
Case Spells
newOption.DefaultValue = Color.SaddleBrown
Case Templates
newOption.DefaultValue = Color.Red
Case Equipment
newOption.DefaultValue = Color.DeepSkyBlue
End Select
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = i & "ShadeColor"
newOption.Type = GCA5Engine.OptionType.Color
newOption.UserPrompt = "Color for the background of the alternate lines."
Select Case i
Case Attributes, Cultures, Languages
newOption.DefaultValue = Color.Linen
Case Ads, Perks
newOption.DefaultValue = Color.AliceBlue
Case Disads, Quirks
newOption.DefaultValue = Color.Linen
Case Skills
newOption.DefaultValue = Color.LavenderBlush
Case Spells
newOption.DefaultValue = Color.OldLace
Case Templates
newOption.DefaultValue = Color.LavenderBlush
Case Equipment
newOption.DefaultValue = Color.Azure
End Select
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = i & "TextColor"
newOption.Type = GCA5Engine.OptionType.Color
newOption.UserPrompt = "Color for the main text (printed against the background and alternate colors)."
newOption.DefaultValue = Color.Black
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = i & "HeaderTextColor"
newOption.Type = GCA5Engine.OptionType.Color
newOption.UserPrompt = "Color for the header text (printed against the border color)."
newOption.DefaultValue = Color.White
ok = Options.AddOption(newOption)
Next
'* *
'* Testing Only Options *
'* *
newOption = New GCA5Engine.SheetOption
newOption.Name = "Box_Testing" ' "Header_Testing"
newOption.Type = GCA5Engine.OptionType.Box ' GCA5Engine.OptionType.Header
newOption.Value = "Test Options"
newOption.UserPrompt = "Test Options for Testing Purposes"
newOption.DisplayFormat = New SheetOptionDisplayFormat(boxFormat)
newOption.DisplayFormat.BackColor = Color.Purple
newOption.DisplayFormat.ForeColor = Color.White
newOption.DisplayFormat.BoxDescriptionBackColor = Color.LavenderBlush
newOption.DisplayFormat.BoxDescriptionForeColor = Color.Black
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "TestList"
newOption.Type = GCA5Engine.OptionType.List
newOption.UserPrompt = "TestList: Please pick an item from the list of items."
newOption.DefaultValue = "Charlie"
newOption.List = {"Alpha", "Bravo", "Charlie", "Delta"}
ok = Options.AddOption(newOption)
'NOTE: Because List is now a 0-based Array, the number of the
'DefaultValue and the selected Value is 0-based!
newOption = New GCA5Engine.SheetOption
newOption.Name = "TestListNumber"
newOption.Type = GCA5Engine.OptionType.ListNumber
newOption.UserPrompt = "TestListNumber: Please pick an item from the list of items."
newOption.DefaultValue = 3
newOption.List = {"Alpha", "Bravo", "Charlie", "Delta"}
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "TestListFlag"
newOption.Type = GCA5Engine.OptionType.ListFlag
newOption.UserPrompt = "TestListFlag: Please pick the items you like from the list of available items."
newOption.DefaultValue = 8
newOption.List = {"Alpha", "Bravo", "Charlie", "Delta"}
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "TestListArray"
newOption.Type = GCA5Engine.OptionType.ListArray
newOption.UserPrompt = "TestListArray: Please pick the items you like from the list of available items."
Dim defA() As Boolean = {True, False, True, False}
newOption.DefaultValue = defA
newOption.List = {"Alpha", "Bravo", "Charlie", "Delta"}
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "TestListOrdered"
newOption.Type = GCA5Engine.OptionType.ListOrdered
newOption.UserPrompt = "TestListOrdered: Please arrange these items into the order that you prefer."
newOption.DefaultValue = ""
newOption.List = {"Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India"}
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "TestListText"
newOption.Type = GCA5Engine.OptionType.Text
newOption.UserPrompt = "TestListText: Please enter some text here."
newOption.DefaultValue = "The quick brown fox jumped over a lazy dog."
ok = Options.AddOption(newOption)
newOption = New GCA5Engine.SheetOption
newOption.Name = "TestListFlag2"
newOption.Type = GCA5Engine.OptionType.ListFlag
newOption.UserPrompt = "TestListFlag2: Please pick the items you like from the list of available items."
newOption.DefaultValue = 0
Dim defS(63) As String
For i = 0 To 63
defS(i) = i + 1
Next
newOption.List = defS
ok = Options.AddOption(newOption)
End Sub
Public Function GeneratePrinterDocument(GCAParty As Party, PageSettings As C1PageSettings, Options As GCA5Engine.SheetOptionsManager) As C1.C1Preview.C1PrintDocument Implements GCA5.Interfaces.IPrinterSheet.GeneratePrinterDocument
'Set our Options to the stored values we've just been given
MyOptions = Options
MyChar = GCAParty.Current
'initialize some working values
'Initialize some page values
'Notify(Name & " " & Version, Priority.Green) 'GCA should now print this to the log itself in SheetView.
'Notify("Home: " & Options.SheetHomeFolder, Priority.Blue)
MyPrintDoc = New C1.C1Preview.C1PrintDocument
MyPrintDoc.TagOpenParen = "[["
MyPrintDoc.TagCloseParen = "]]"
'I think in inches. Note that some values returned from the engine won't be in the value set here
MyPrintDoc.DefaultUnit = C1.C1Preview.UnitTypeEnum.Inch
MyPrintDoc.ResolvedUnit = UnitTypeEnum.Inch
MyPrintDoc.Style.Font = MyOptions.Value("SheetFont") 'New Font("Times New Roman", 10)
'MyPrintDoc.Style.TextColor = MyOptions.Value("SheetTextColor")
' Create page layout.
Dim pl As New PageLayout
pl.PageSettings = New C1.C1Preview.C1PageSettings()
pl.PageSettings.PaperKind = PageSettings.PaperKind
pl.PageSettings.Landscape = PageSettings.Landscape
pl.PageSettings.TopMargin = PageSettings.TopMargin ' 0.5
pl.PageSettings.BottomMargin = PageSettings.BottomMargin '0.5
pl.PageSettings.LeftMargin = PageSettings.LeftMargin '0.5
pl.PageSettings.RightMargin = PageSettings.RightMargin '0.75
pl.Columns.Add()
pl.Columns.Add()
MyPrintDoc.PageLayouts.Default = pl
'The document settings for these values will be in inches for US page types, and in
'millimeters for international types, and possibly other values for ANSI types and whatnot,
'so we need to get the values in the measurement system we want, and we do that here.
MarginLeft = MyPrintDoc.PageLayout.PageSettings.LeftMargin.ConvertUnit(UnitTypeEnum.Inch)
MarginRight = MyPrintDoc.PageLayout.PageSettings.RightMargin.ConvertUnit(UnitTypeEnum.Inch)
MarginTop = MyPrintDoc.PageLayout.PageSettings.TopMargin.ConvertUnit(UnitTypeEnum.Inch)
MarginBottom = MyPrintDoc.PageLayout.PageSettings.BottomMargin.ConvertUnit(UnitTypeEnum.Inch)
PageWidth = MyPrintDoc.PageLayout.PageSettings.Width.ConvertUnit(UnitTypeEnum.Inch)
PageHeight = MyPrintDoc.PageLayout.PageSettings.Height.ConvertUnit(UnitTypeEnum.Inch)
If MyChar Is Nothing Then
Dim boxWidth, boxHeight, boxLeft, boxTop As Double
Dim ld As C1.C1Preview.LineDef
MyPrintDoc.StartDoc()
boxLeft = MarginLeft
boxTop = MarginTop
boxWidth = PageWidth - MarginRight - boxLeft
boxHeight = PageHeight - MarginBottom - boxTop
ld = New C1.C1Preview.LineDef(0.06, Color.AliceBlue, Drawing2D.DashStyle.Dash)
MyPrintDoc.RenderDirectRectangle(boxLeft, boxTop, boxWidth, boxHeight, ld)
Dim EmptyPageStyle As Style = MyPrintDoc.Style.Children.Add()
EmptyPageStyle.Font = New Font(MyPrintDoc.Style.Font.Name, 24, FontStyle.Bold)
EmptyPageStyle.TextAlignVert = AlignVertEnum.Center
EmptyPageStyle.TextAlignHorz = AlignHorzEnum.Center
MyPrintDoc.RenderDirectText(boxLeft, boxTop, "There are no characters loaded.", boxWidth, boxHeight, EmptyPageStyle)
MyPrintDoc.EndDoc()
Return MyPrintDoc
End If
CreateStyles()
CreateHeader()
CreateFooter()
ShowHidden = MyOptions.Value("ShowHidden")
ShowComponents = MyOptions.Value("ShowComponents")
BonusesAsFootnotes = MyOptions.Value("BonusesAsFootnotes")
BonusesInline = MyOptions.Value("BonusesInline")
'Start working
'MyPrintDoc.StartDoc()
PrintBlocks()
'MyPrintDoc.EndDoc()
Return MyPrintDoc
End Function
Private Sub PrintBlocks()
Dim i As Integer
PrintGeneralInfoBlock()
PrintSpacer()
For i = 1 To LastItemType
If i = TraitTypes.Advantages Then
'before we print ads, print the Enc & Move block
PrintEncumbranceBlock()
PrintSpacer()
End If
SetTraitColumns(i, 0)
CreateFields(i)
If Fields.Count > 0 Then
SetFieldSizes()
'print
PrintTraitsBlock(i)
PrintSpacer()
End If
Next
PrintProtectionBlock()
PrintSpacer()
'Dim pl As New PageLayout
'pl.AssignFrom(MyPrintDoc.PageLayouts.Default)
'pl.Columns.RemoveAt(1)
'MyPrintDoc.PageLayouts.Default = pl
'MyPrintDoc.NewPage(pl)
SetWeaponColumns(Hand, 0)
CreateWeaponFields(Hand)
If Fields.Count > 0 Then
SetFieldSizes()
'print
PrintWeaponsBlock(Hand)
PrintSpacer()
End If
SetWeaponColumns(Ranged, 0)
CreateWeaponFields(Ranged)
If Fields.Count > 0 Then
SetFieldSizes()
'print
PrintWeaponsBlock(Ranged)
PrintSpacer()
End If
MyPrintDoc.Generate()
End Sub
Private Sub PrintSpacer()
Dim rt As RenderText = New RenderText(vbCrLf)
MyPrintDoc.Body.Children.Add(rt)
End Sub
Private Sub PrintEncumbranceBlock()
Dim Title As String = "Encumbrance & Move"
Dim ItemType As Integer = Attributes
Dim o As RenderText
Dim i As Integer
'8 columns: icon & name & none & light & med & hvy & x-hvy & icon
Dim curCol As Integer
Dim curRow As Integer
numCols = 7
ReDim ColAligns(numCols)
ReDim ColWidths(numCols)
ReDim SubHeads(numCols)
PointsCol = 0
ComponentDrawCol = 1
IconColLeft = 0 'LeftOffset
IconColWidth = 1 / 32 ' 0
curCol = 0
ColWidths(curCol) = IconColWidth
'icon col
curCol += 1
SubHeads(curCol) = "Name"
ColAligns(curCol) = AlignHorzEnum.Left
ColWidths(curCol) = 0
curCol += 1
SubHeads(curCol) = "None"
ColAligns(curCol) = AlignHorzEnum.Right
ColWidths(curCol) = GetSize(SubHeads(curCol)).Width + 1 / 8 'to allow for padding
curCol += 1
SubHeads(curCol) = "Light"
ColAligns(curCol) = AlignHorzEnum.Right
ColWidths(curCol) = GetSize(SubHeads(curCol)).Width + 1 / 8 'to allow for padding
curCol += 1
SubHeads(curCol) = "Med"
ColAligns(curCol) = AlignHorzEnum.Right
ColWidths(curCol) = GetSize(SubHeads(curCol)).Width + 1 / 8 'to allow for padding
curCol += 1
SubHeads(curCol) = "Hvy"
ColAligns(curCol) = AlignHorzEnum.Right
ColWidths(curCol) = GetSize(SubHeads(curCol)).Width + 1 / 8 'to allow for padding
curCol += 1
SubHeads(curCol) = "X-Hvy"
ColAligns(curCol) = AlignHorzEnum.Right
ColWidths(curCol) = GetSize(SubHeads(curCol)).Width + 1 / 8 'to allow for padding
curCol += 1
'icon col
ColWidths(curCol) = IconColWidth
'** Create Data Table
'set styles
Dim rtab As New RenderTable
rtab.Style.BackColor = MyOptions.Value(ItemType & "BackColor")
rtab.CellStyle.Padding.Left = 1 / 32
rtab.CellStyle.Padding.Right = 1 / 32
rtab.Style.Borders.All = New LineDef(0.02, MyOptions.Value(ItemType & "BorderColor"))
'rtab.Style.GridLines.All = New LineDef(0.01, MyOptions.Value(ItemType & "BorderColor"), System.Drawing.Drawing2D.DashStyle.Dot)
rtab.Style.GridLines.Horz = New LineDef(0.01, MyOptions.Value(ItemType & "BorderColor"), System.Drawing.Drawing2D.DashStyle.Dot)
rtab.Style.GridLines.Vert = New LineDef(0.01, MyOptions.Value(ItemType & "BorderColor"), System.Drawing.Drawing2D.DashStyle.Dot)
'create top two header rows
rtab.Rows(0).Style.BackColor = MyOptions.Value(ItemType & "BorderColor")
rtab.Rows(0).Style.TextColor = MyOptions.Value(ItemType & "HeaderTextColor")
rtab.Rows(1).Style.BackColor = MyOptions.Value(ItemType & "BorderColor")
rtab.Rows(1).Style.TextColor = MyOptions.Value(ItemType & "HeaderTextColor")
'print header area
rtab.Cells(0, 0).Style.TextAlignHorz = AlignHorzEnum.Left
rtab.Cells(0, 0).SpanCols = numCols - 1
Dim rt1 As New RenderText(Title, New Font(MyPrintDoc.Style.FontName, MyPrintDoc.Style.FontSize, FontStyle.Bold), AlignHorzEnum.Left)
rtab.Cells(0, 0).Area.Children.Add(rt1)
'set col widths
For i = 0 To UBound(ColWidths)
'leave 0 widths to the table layout engine to fit in
If ColWidths(i) > 0 Then
rtab.Cols(i).Width = ColWidths(i)
End If
Next
'print sub-heads
curRow = 1
For i = 1 To UBound(SubHeads)
rtab.Cells(curRow, i).Text = SubHeads(i)
rtab.Cols(i).Style.TextAlignHorz = ColAligns(i)
Next
rtab.RowGroups(0, 2).Header = TableHeaderEnum.Page
'Add table to sheet
MyPrintDoc.Body.Children.Add(rtab)
'** Create Data
Dim tmpName As String
Dim curTrait As GCATrait
Dim NeededStats(8) As String
NeededStats(0) = "Basic Lift"
NeededStats(1) = "Air Move"
NeededStats(2) = "Brachiation Move"
NeededStats(3) = "Ground Move"
NeededStats(4) = "Space Move"
NeededStats(5) = "TK Move"
NeededStats(6) = "Tunneling Move"
NeededStats(7) = "Water Move"
NeededStats(8) = "Dodge"
curRow = 2
If MyChar.Items.Count > 0 Then
'look for the move scores we need.
For Each tmpName In NeededStats
i = MyChar.ItemPositionByNameAndExt(tmpName, Stats)
If i > 0 Then
curTrait = MyChar.Items.Item(i)
If curTrait.TagItem("hide") = "" Then
'okay, print this one.
Dim Values(numCols) As String
'Get Trait Values
Values(1) = curTrait.Name
Values(2) = curTrait.Score
Values(3) = Int(curTrait.Score * 0.8)
Values(4) = Int(curTrait.Score * 0.6)
Values(5) = Int(curTrait.Score * 0.4)
Values(6) = Int(curTrait.Score * 0.2)
'Min 1, unless score is 0
For i = 3 To numCols
If Val(Values(i)) < 1 Then
If curTrait.Score >= 1 Then
Values(i) = 1
Else
Values(i) = 0
End If
End If
Next
'Special Cases!
If curTrait.LCaseName = "basic lift" Then
Values(1) = "Carry (lbs)"
Values(3) = curTrait.Score * 2
Values(4) = curTrait.Score * 3
Values(5) = curTrait.Score * 6
Values(6) = curTrait.Score * 10
ElseIf curTrait.LCaseName = "dodge" Then
Values(3) = curTrait.Score - 1
Values(4) = curTrait.Score - 2
Values(5) = curTrait.Score - 3
Values(6) = curTrait.Score - 4
Else
Values(1) = Values(1) & " (yds)"
End If
'Print the column values
For curCol = 0 To numCols
o = New RenderText
o.Text = Values(curCol)
rtab.Cells(curRow, curCol).RenderObject = o
Next
'*****
'* Alt color for basic lift and dodge
Select Case tmpName
Case "Basic Lift", "Dodge"
rtab.Rows(curRow).Style.BackColor = MyOptions.Value(ItemType & "ShadeColor")
End Select
'*****
'*****
'* Highlight cur enc level col
curCol = MyChar.EncumbranceLevel + 2 '+2 to skip the icon and name cols
If curCol <= 7 Then
rtab.Cells(curRow, curCol).Style.GridLines.Left = New LineDef(0.02, MyOptions.Value("EncumbranceLevelColor"), System.Drawing.Drawing2D.DashStyle.Solid)
rtab.Cells(curRow, curCol).Style.GridLines.Right = New LineDef(0.02, MyOptions.Value("EncumbranceLevelColor"), System.Drawing.Drawing2D.DashStyle.Solid)
End If
'*****
curRow += 1
End If
End If
Next
'*****
'* Highlight cur enc level col
curCol = MyChar.EncumbranceLevel + 2 '+2 to skip the icon and name cols
If curCol <= 7 Then
'rtab.Cols(curCol).Style.GridLines.Left = New LineDef(0.02, Color.ForestGreen, System.Drawing.Drawing2D.DashStyle.Solid)
'rtab.Cols(curCol).Style.GridLines.Right = New LineDef(0.02, Color.ForestGreen, System.Drawing.Drawing2D.DashStyle.Solid)
rtab.Cells(1, curCol).Style.GridLines.Top = New LineDef(0.02, MyOptions.Value("EncumbranceLevelColor"), System.Drawing.Drawing2D.DashStyle.Solid)
rtab.Cells(curRow - 1, curCol).Style.GridLines.Bottom = New LineDef(0.02, MyOptions.Value("EncumbranceLevelColor"), System.Drawing.Drawing2D.DashStyle.Solid)
rtab.Cells(1, curCol).Style.GridLines.Left = New LineDef(0.02, MyOptions.Value("EncumbranceLevelColor"), System.Drawing.Drawing2D.DashStyle.Solid)
rtab.Cells(1, curCol).Style.GridLines.Right = New LineDef(0.02, MyOptions.Value("EncumbranceLevelColor"), System.Drawing.Drawing2D.DashStyle.Solid)
End If
'*****
'* print our loadout
o = New RenderText
o.Text = "Loadout"
rtab.Cells(curRow, 1).RenderObject = o
rtab.Cells(curRow, 1).Style.TextAlignHorz = AlignHorzEnum.Left
o = New RenderText
o.Text = MyChar.CurrentLoadout
rtab.Cells(curRow, 2).RenderObject = o
rtab.Cells(curRow, 2).Style.TextAlignHorz = AlignHorzEnum.Left
rtab.Cells(curRow, 2).SpanCols = 4
o = New RenderText
o.Text = Format(MyChar.CurrentLoad, "#,0.0") '& " lbs"
rtab.Cells(curRow, 6).RenderObject = o
rtab.Cells(curRow, 6).Style.TextAlignHorz = AlignHorzEnum.Right
rtab.Rows(curRow).Style.BackColor = MyOptions.Value(ItemType & "BorderColor")
rtab.Rows(curRow).Style.TextColor = MyOptions.Value(ItemType & "HeaderTextColor")
'*****
End If
End Sub
Private Sub PrintProtectionBlock()
Dim Title As String
Dim ItemType As Integer = Equipment
Dim rtab As New RenderTable
rtab.Style.BackColor = MyOptions.Value(ItemType & "BackColor")
rtab.CellStyle.Padding.Left = 1 / 32
rtab.CellStyle.Padding.Right = 1 / 32
rtab.Style.Borders.All = New LineDef(0.02, MyOptions.Value(ItemType & "BorderColor"))
rtab.Style.GridLines.All = New LineDef(0.01, MyOptions.Value(ItemType & "BorderColor"), System.Drawing.Drawing2D.DashStyle.Dot)
'create header row
rtab.Rows(0).Style.BackColor = MyOptions.Value(ItemType & "BorderColor")
rtab.Rows(0).Style.TextColor = MyOptions.Value(ItemType & "HeaderTextColor")
'print header area
Title = "Protection"
rtab.Cells(0, 0).Style.TextAlignHorz = AlignHorzEnum.Left
rtab.Cells(0, 0).Text = Title
rtab.RowGroups(0, 1).Header = TableHeaderEnum.Page
'print contents
Dim ri As New RenderImage
Dim Settings As New ProtectionPaperDollSettings
Settings.Character = MyChar
Settings.TextFont = New Font(MyPrintDoc.Style.Font.Name, 14)
Settings.TextColor = MyOptions.Value(ItemType & "TextColor") 'NEW 2015 09 11 'Color.Black
Settings.TextColorAlt = Color.Black
Settings.ShadeColor = MyOptions.Value(ItemType & "ShadeColor")
Settings.BackColor = Color.White
Settings.BorderColor = MyOptions.Value(ItemType & "BorderColor")
ri.Image = GetProtectionPaperDoll(Settings)
ri.Width = "100%"
rtab.Cells(1, 0).Area.Children.Add(ri)
'Add table to sheet
MyPrintDoc.Body.Children.Add(rtab)
'NEW 2015 03 31
'*************************
'Print included armor items; by layers, if applicable
'*************************
'NEW 2015 05 29 safety check
If MyChar.CurrentLoadout = "" Then Return
If MyChar.LoadOuts.Count = 0 Then Return
'END NEW 2015 05 29
Dim MyCurrentLoadOut As LoadOut = MyChar.LoadOuts(MyChar.CurrentLoadout)
Const IconCol = 0
Const LetterCol = 1
Const DRCol = 2
Const LocCol = 3
rtab = New RenderTable
rtab.Style.BackColor = MyOptions.Value(ItemType & "BackColor")
rtab.CellStyle.Padding.Left = 1 / 32
rtab.CellStyle.Padding.Right = 1 / 32
rtab.Style.Borders.All = New LineDef(0.02, MyOptions.Value(ItemType & "BorderColor"))
rtab.Style.GridLines.Horz = New LineDef(0.01, MyOptions.Value(ItemType & "BorderColor"), System.Drawing.Drawing2D.DashStyle.Dot)
rtab.Style.GridLines.Vert = New LineDef(0.01, MyOptions.Value(ItemType & "BorderColor"), System.Drawing.Drawing2D.DashStyle.Dot)
rtab.Cols(IconCol).Width = GetSize("[MM]").Width
rtab.Cols(LetterCol).Width = GetSize("[MM]").Width
rtab.Cols(LocCol).Width = GetSize(" Overall DR Bonus ").Width '0.5
rtab.Cols(LocCol).Style.TextAlignHorz = AlignHorzEnum.Right
'create header row
rtab.Rows(0).Style.BackColor = MyOptions.Value(ItemType & "BorderColor")
rtab.Rows(0).Style.TextColor = MyOptions.Value(ItemType & "HeaderTextColor")
'print header area
If MyCurrentLoadOut.UserOrderedLayers Then
Title = "Layered Armor" 'MyChar.CurrentLoadout '"Protection"
Else
Title = "Armor" 'MyChar.CurrentLoadout '"Protection"
End If
rtab.Cells(IconCol, 0).Style.TextAlignHorz = AlignHorzEnum.Left
rtab.Cells(IconCol, 0).Text = Title
rtab.Cells(IconCol, 0).SpanCols = 4
rtab.RowGroups(0, 1).Header = TableHeaderEnum.Page