-
Notifications
You must be signed in to change notification settings - Fork 0
/
PrintWorkshop.vb
1516 lines (1088 loc) · 55.5 KB
/
PrintWorkshop.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 Cadcorp.SIS.GisLink.Library
Imports Cadcorp.SIS.GisLink.Library.Constants
Imports System
Imports System.IO
Imports System.Data
Imports System.Windows.Forms
Imports System.Math
<GisLinkProgram("PrintWorkshop")> Public Class PW
Public Shared APP As SisApplication
Private Shared _sis As Cadcorp.SIS.GisLink.Library.MapEditor
Public Shared Property SIS As Cadcorp.SIS.GisLink.Library.MapEditor
Get
If _sis Is Nothing Then _sis = APP.TakeoverMapEditor
Return _sis
End Get
Set(ByVal value As Cadcorp.SIS.GisLink.Library.MapEditor)
_sis = value
End Set
End Property
Private _currentRibbonButton As SisRibbonButton
Public Sub New(ByVal SISApplication As SisApplication)
APP = SISApplication
SIS.CreateClassTreeFilter("fArea", "-Item +Photo +Area:")
SIS.CreateClassTreeFilter("fPhoto", "-Item +Photo")
SIS.CreateClassTreeFilter("fNoPhoto", "+Item -Photo")
SIS.Dispose()
SIS = Nothing
Dim group As SisRibbonGroup = APP.RibbonGroup
group.Text = "Print Workshop"
'Place
Dim SmallButton_PlaceTemplate As SisRibbonButton = New SisRibbonButton("Place Template", New SisClickHandler(AddressOf PlaceTemplate))
SmallButton_PlaceTemplate.LargeImage = False
SmallButton_PlaceTemplate.Icon = My.Resources.Btn_Place
SmallButton_PlaceTemplate.Help = "Place Template"
SmallButton_PlaceTemplate.Description = "Uses the current map extents and scale to create a print using a Print Template"
SmallButton_PlaceTemplate.MinSelection = -1
SmallButton_PlaceTemplate.Filter = "fNoPhoto"
'Inset
Dim SmallButton_Inset As SisRibbonButton = New SisRibbonButton("Inset Map", New SisClickHandler(AddressOf Inset))
SmallButton_Inset.LargeImage = False
SmallButton_Inset.Icon = My.Resources.Btn_Inset
SmallButton_Inset.Help = "Inset"
SmallButton_Inset.Description = "Creates new Map Frame or edits selected Map Frame"
SmallButton_Inset.MinSelection = -1
SmallButton_Inset.MaxSelection = 1
SmallButton_Inset.Filter = "fArea"
'Key Frames
Dim SmallButton_KeyFrames As SisRibbonButton = New SisRibbonButton("Key Frame", New SisClickHandler(AddressOf KeyFrames))
SmallButton_KeyFrames.LargeImage = False
SmallButton_KeyFrames.Icon = My.Resources.Btn_KeyFrame
SmallButton_KeyFrames.Help = "Key Frame"
SmallButton_KeyFrames.Description = "Creates Key Frames in selected Map Frames"
'Scalebar
Dim SmallButton_ScaleBar As SisRibbonButton = New SisRibbonButton("Scale bar", New SisClickHandler(AddressOf Scalebar))
SmallButton_ScaleBar.LargeImage = False
SmallButton_ScaleBar.Icon = My.Resources.Btn_Scalebar
SmallButton_ScaleBar.Help = "Automatic Scale Bar"
SmallButton_ScaleBar.Description = "Creates an automatic Scale Bar"
'Scaletext
Dim SmallButton_ScaleText As SisRibbonButton = New SisRibbonButton("Scale text", New SisClickHandler(AddressOf Scaletext))
SmallButton_ScaleText.LargeImage = False
SmallButton_ScaleText.Icon = My.Resources.Btn_Scaletxt
SmallButton_ScaleText.Help = "Scale Text"
SmallButton_ScaleText.Description = "Creates Scale Text for selected Map Frame"
SmallButton_ScaleText.MinSelection = 1
SmallButton_ScaleText.MaxSelection = 1
SmallButton_ScaleText.Filter = "fPhoto"
'Label
Dim SmallButton_Label As SisRibbonButton = New SisRibbonButton("Label", New SisClickHandler(AddressOf Label))
SmallButton_Label.LargeImage = False
SmallButton_Label.Icon = My.Resources.Btn_Labels
SmallButton_Label.Help = "Create Label"
SmallButton_Label.Description = "Creates a Map Label"
'Table
Dim SmallButton_Table As SisRibbonButton = New SisRibbonButton("Schema Table", New SisClickHandler(AddressOf Table))
SmallButton_Table.LargeImage = False
SmallButton_Table.Icon = My.Resources.Btn_Table
SmallButton_Table.Help = "Table"
SmallButton_Table.Description = "Adds a table of overlay features displayed in the selected Map Frame"
SmallButton_Table.MinSelection = 1
SmallButton_Table.MaxSelection = 1
SmallButton_Table.Filter = "fPhoto"
'Overlay Legend
Dim SmallButton_OverlayLegend As SisRibbonButton = New SisRibbonButton("Legend", New SisClickHandler(AddressOf OverlayLegend))
SmallButton_OverlayLegend.LargeImage = False
SmallButton_OverlayLegend.Icon = My.Resources.Btn_Legend
SmallButton_OverlayLegend.Help = "Overlay Legend"
SmallButton_OverlayLegend.Description = "Creates a legend based on the Overlay Styles in the selected Map Frame"
SmallButton_OverlayLegend.MinSelection = 1
SmallButton_OverlayLegend.MaxSelection = 1
SmallButton_OverlayLegend.Filter = "fPhoto"
'Watermark
Dim SmallButton_Watermark As SisRibbonButton = New SisRibbonButton("Watermark", New SisClickHandler(AddressOf Watermark))
SmallButton_Watermark.LargeImage = False
SmallButton_Watermark.Icon = My.Resources.Btn_Watermark
SmallButton_Watermark.Help = "Watermark"
SmallButton_Watermark.Description = "Add watermark to selected Map Frame"
SmallButton_Watermark.MinSelection = 1
SmallButton_Watermark.MaxSelection = 1
SmallButton_Watermark.Filter = "fPhoto"
Dim controlgroup_upper As SisRibbonControlGroup = New SisRibbonControlGroup
controlgroup_upper.Controls.Add(SmallButton_PlaceTemplate)
controlgroup_upper.Controls.Add(SmallButton_Inset)
controlgroup_upper.Controls.Add(SmallButton_KeyFrames)
controlgroup_upper.Controls.Add(SmallButton_ScaleBar)
controlgroup_upper.Controls.Add(SmallButton_ScaleText)
group.Controls.Add(controlgroup_upper)
Dim controlgroup_lower As SisRibbonControlGroup = New SisRibbonControlGroup
controlgroup_lower.Controls.Add(SmallButton_Label)
controlgroup_lower.Controls.Add(SmallButton_Table)
controlgroup_lower.Controls.Add(SmallButton_OverlayLegend)
controlgroup_lower.Controls.Add(SmallButton_Watermark)
group.Controls.Add(controlgroup_lower)
'Book Plot
Dim BigButton_Bookplot As SisRibbonButton = New SisRibbonButton("Book Plot", New SisClickHandler(AddressOf Bookplot))
BigButton_Bookplot.LargeImage = True
BigButton_Bookplot.Icon = My.Resources.BookPlot
BigButton_Bookplot.MinSelection = -1
BigButton_Bookplot.Help = "Book Plot"
BigButton_Bookplot.Description = "Book Plot"
group.Controls.Add(BigButton_Bookplot)
End Sub
Private Shared x1, x2, y1, y2, z As Double
Private Sub Bookplot(ByVal sender As Object, ByVal e As SisClickArgs)
SIS = e.MapEditor
Try
If MapFrameCheck() = False Then
SIS.SetInt(SIS_OT_WINDOW, 0, "_bRedraw&", False)
PW.SIS.DefineNolView("vOrg")
Dim dialogBook As New Dialog_Book
dialogBook.StartPosition = FormStartPosition.CenterParent
dialogBook.ShowDialog()
Else
MsgBox("Cannot create book plot from a print template.", MsgBoxStyle.Exclamation, "Cadcorp SIS Print Workshop")
End If
Catch
End Try
SIS.DeselectAll()
PW.SIS.RecallNolView("vOrg")
SIS.SetInt(SIS_OT_WINDOW, 0, "_bRedraw&", True)
SIS.Redraw(SIS_CURRENTWINDOW)
SIS.Dispose()
SIS = Nothing
End Sub
Private Sub PlaceTemplate(ByVal sender As Object, ByVal e As SisClickArgs)
SIS = e.MapEditor
Try
If MapFrameCheck() = False Then
Dim dialogTemplate As New Dialog_Template
dialogTemplate.StartPosition = FormStartPosition.CenterParent
dialogTemplate.ShowDialog()
Else
MsgBox("Cannot place template on template.", MsgBoxStyle.Exclamation, "Cadcorp SIS Print Workshop")
End If
Catch
End Try
SIS.DeselectAll()
SIS.Dispose()
SIS = Nothing
End Sub
Public Shared Label_txt As String
Public Shared Label_alignment As Integer
Public Shared Label_font As Drawing.Font
Public Shared Label_opaque As Boolean = False
Public Shared Label_frame As Boolean = False
Public Shared Label_lines As Boolean = False
Private Sub Label(ByVal sender As Object, ByVal e As SisClickArgs)
SIS = e.MapEditor
Try
SIS.SplitExtent(x1, y1, z, x2, y2, z, SIS.GetViewExtent())
SIS.CreateRectLocus("Locus", x1, y1, x2, y2)
SIS.ChangeLocusTestMode("Locus", SIS_GT_INTERSECT, SIS_GM_EXTENTS)
If SIS.Scan("Scan", "V", "fPhoto", "Locus") > 0 Then
Dim dialogLabel As New Dialog_Label()
If dialogLabel.ShowDialog() = DialogResult.OK Then
SIS.CreateGroup("")
SIS.CreateBoxText(0, 0, 0, Label_font.Size * 0.0003527, Label_txt)
SIS.SetStr(SIS_OT_CURITEM, 0, "_font$", Label_font.Name)
SIS.SetInt(SIS_OT_CURITEM, 0, "_text_bold&", Label_font.Bold)
SIS.SetInt(SIS_OT_CURITEM, 0, "_text_italic&", Label_font.Italic)
SIS.SetStr(SIS_OT_CURITEM, 0, "_pen$", "<Pen><Colour><RGBA>0 0 0 0</RGBA></Colour></Pen>")
SIS.SetInt(SIS_OT_CURITEM, 0, "_text_alignH&", Label_alignment)
SIS.UpdateItem()
Try
APP.RemoveTrigger("AComPlaceGroup::Snap", AddressOf PlaceLabel_Snap)
Catch
End Try
APP.AddTrigger("AComPlaceGroup::Snap", New SisTriggerHandler(AddressOf PlaceLabel_Snap))
End If
Else
MsgBox("No Map Frame item in current window.", MsgBoxStyle.Exclamation, "Cadcorp SIS Print Workshop")
End If
Catch
End Try
SIS.Dispose()
SIS = Nothing
End Sub
Private Sub PlaceLabel_Snap(ByVal sender As Object, ByVal e As SisTriggerArgs)
SIS = e.MapEditor
Try
SendKeys.SendWait("{ENTER}")
APP.RemoveTrigger("AComPlaceGroup::Snap", AddressOf PlaceLabel_Snap)
SIS.OpenSel(0)
EmptyList("lLabel")
SIS.AddToList("lLabel")
Dim ox As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_ox#")
Dim oy As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_oy#")
Dim sx As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_sx#")
Dim sy As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_sy#")
Dim offset As Double = (Label_font.Size * 0.0003527) * 0.17
If Label_opaque = True Or Label_frame = True Then
SIS.CreateRectangle(ox - sx / 2 - offset, oy - sy / 2 - offset, ox + sx / 2 + offset, oy + sy / 2 + offset)
SIS.AddToList("lLabel")
If Label_opaque = True Then
SIS.SetStr(SIS_OT_CURITEM, 0, "_brush$", "<Brush><Style>Solid</Style><Colour><RGBA>255 255 255 50</RGBA></Colour></Brush>")
Else
SIS.SetStr(SIS_OT_CURITEM, 0, "_brush$", "<Brush><Style>Hollow</Style><Colour><RGBA>255 255 255 0</RGBA></Colour></Brush>")
End If
If Label_frame = True Then
SIS.SetStr(SIS_OT_CURITEM, 0, "_pen$", "<Pen><Colour><RGBA>128 128 128 0</RGBA></Colour><Width>" & Str(Label_font.Size * 3) & "</Width></Pen>")
Else
SIS.SetStr(SIS_OT_CURITEM, 0, "_pen$", "<Pen><Style>Null</Style><Colour><RGBA>0 0 0 0</RGBA></Colour></Pen>")
End If
SIS.UpdateItem()
End If
If Label_lines = True Then
Dim iReturn As Integer = 1
Dim x, y As Double
Do
Application.DoEvents()
iReturn = SIS.GetPosEx(x, y, z)
If x > ox - sx / 2 - offset And x < ox + sx / 2 + offset Then
If y > oy + sy / 2 Then
SIS.MoveTo(ox - sx / 2 - offset, oy + sy / 2 + offset, 0)
SIS.LineTo(ox + sx / 2 + offset, oy + sy / 2 + offset, 0)
SIS.UpdateItem()
SIS.AddToList("lLines")
SIS.MoveTo(x, y, 0)
SIS.LineTo(x, oy + sy / 2 + offset, 0)
SIS.UpdateItem()
SIS.AddToList("lLines")
ElseIf y < oy - sy / 2 - offset Then
SIS.MoveTo(ox - sx / 2 - offset, oy - sy / 2 - offset, 0)
SIS.LineTo(ox + sx / 2 + offset, oy - sy / 2 - offset, 0)
SIS.UpdateItem()
SIS.AddToList("lLines")
SIS.MoveTo(x, y, 0)
SIS.LineTo(x, oy - sy / 2 - offset, 0)
SIS.UpdateItem()
SIS.AddToList("lLines")
End If
ElseIf x < ox - sx / 2 - offset Then
SIS.MoveTo(ox - sx / 2 - offset, oy - sy / 2 - offset, 0)
SIS.LineTo(ox - sx / 2 - offset, oy + sy / 2 + offset, 0)
SIS.UpdateItem()
SIS.AddToList("lLines")
If y > oy - sy / 2 - offset And y < oy + sy / 2 Then
SIS.MoveTo(x, y, 0)
SIS.LineTo(ox - sx / 2 - offset, y, 0)
SIS.UpdateItem()
SIS.AddToList("lLines")
Else
SIS.MoveTo(x, y, 0)
SIS.LineTo(x, oy, 0)
SIS.LineTo(ox - sx / 2 - offset, oy, 0)
SIS.UpdateItem()
SIS.AddToList("lLines")
End If
ElseIf x > ox + sx / 2 + offset Then
SIS.MoveTo(ox + sx / 2 + offset, oy - sy / 2 - offset, 0)
SIS.LineTo(ox + sx / 2 + offset, oy + sy / 2 + offset, 0)
SIS.UpdateItem()
SIS.AddToList("lLines")
If y > oy - sy / 2 - offset And y < oy + sy / 2 Then
SIS.MoveTo(x, y, 0)
SIS.LineTo(ox + sx / 2 + offset, y, 0)
SIS.UpdateItem()
SIS.AddToList("lLines")
Else
SIS.MoveTo(x, y, 0)
SIS.LineTo(x, oy, 0)
SIS.LineTo(ox + sx / 2 + offset, oy, 0)
SIS.UpdateItem()
SIS.AddToList("lLines")
End If
End If
SIS.SetListStr("lLines", "_pen$", "<Pen><Colour><RGBA>0 0 0 0</RGBA></Colour><Width>" & Str(Label_font.Size * 3) & "</Width></Pen>")
SIS.CombineLists("lLabel", "lLabel", "lLines", SIS_BOOLEAN_XOR)
If iReturn = 0 Then
Exit Do
End If
Exit Do
Loop
End If
SIS.CreateGroupFromItems("lLabel", True, "")
SIS.OpenItem(SIS.GetInt(SIS_OT_DATASET, SIS.GetInt(SIS_OT_OVERLAY, SIS.GetInt(SIS_OT_WINDOW, 0, "_nDefaultOverlay&"), "_nDataset&"), "_idNextItem&") - 1)
SIS.SetInt(SIS_OT_CURITEM, 0, "_level&", 254)
SIS.UpdateItem()
Catch
End Try
SIS.Dispose()
SIS = Nothing
End Sub
Private Sub Watermark(ByVal sender As Object, ByVal e As SisClickArgs)
SIS = e.MapEditor
Try
Dim sFile As String
Dim lLevel As Long
Dim OpenWatermarkDialog As New OpenFileDialog
OpenWatermarkDialog.Filter = "Image Files(*.BMP;*.GIF;*.PNG)|*.BMP;*.GIF;*.PNG"
OpenWatermarkDialog.Title = "Print Workshop - Add Watermark"
If OpenWatermarkDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
sFile = OpenWatermarkDialog.FileName
SIS.OpenSel(0)
lLevel = SIS.GetInt(SIS_OT_CURITEM, 0, "_level&")
SIS.DoCommand("AComZoomSelect")
SIS.ZoomView(0.7)
SIS.PasteFrom(sFile, False)
SIS.OpenSel(0)
SIS.SetInt(SIS_OT_CURITEM, 0, "_transparent&", True)
SIS.SetInt(SIS_OT_CURITEM, 0, "GBitmapAlphaTransparency&", 200)
SIS.SetStr(SIS_OT_CURITEM, 0, "_pen$", "<Pen><Style>Null</Style><Colour><RGBA>0 0 0 0</RGBA></Colour></Pen>")
SIS.SetStr(SIS_OT_CURITEM, 0, "_brush$", "<Brush><Style>Hollow</Style><Colour><RGBA>255 255 255 0</RGBA></Colour></Brush>")
SIS.SetInt(SIS_OT_CURITEM, 0, "_level&", 255)
SIS.UpdateItem()
SIS.DeselectAll()
SIS.DoCommand("AComViewBack")
SIS.DoCommand("AComViewBack")
End If
Catch
End Try
SIS.Dispose()
SIS = Nothing
End Sub
Private Sub Scalebar(ByVal sender As Object, ByVal e As SisClickArgs)
SIS = e.MapEditor
Try
If SIS.GetAxesType = SIS_AXES_SPHERICAL = True Then
MsgBox("Scalebars can only be created within a cartographic projection.", MsgBoxStyle.Exclamation, "Cadcorp SIS Print Workshop")
SIS.Dispose()
Exit Sub
End If
Dim bDoubleSnap As Boolean
Dim reply As Integer
Dim x, y, x1, y1, x2, y2, x3, y3 As Decimal
Dim dBorder As Decimal = 0.0008
Dim dThickness As Decimal = 0.002
Do
reply = SIS.GetPosEx(x, y, z)
If reply = SIS_ARG_ESCAPE Then
bDoubleSnap = False
Exit Do
ElseIf reply = SIS_ARG_BACKSPACE Then
bDoubleSnap = False
ElseIf reply = SIS_ARG_POSITION Then
If bDoubleSnap Then
x2 = x
y2 = y
x = x2 - x1
y = y2 - y1
Dim Q As Integer
If Abs(x) > Abs(y) And x > 0 And y > 0 Then
Q = 1
ElseIf Abs(x) > Abs(y) And x > 0 And y < 0 Then
Q = 2
ElseIf Abs(x) > Abs(y) And x < 0 And y < 0 Then
Q = 3
ElseIf Abs(x) > Abs(y) And x < 0 And y > 0 Then
Q = 4
ElseIf Abs(y) > Abs(x) And y > 0 Then
Q = 5
Dim tmp As Decimal
tmp = x
x = y
y = tmp
ElseIf Abs(y) > Abs(x) And y < 0 Then
Q = 6
Dim tmp As Decimal
tmp = x
x = y
y = tmp
End If
x = Abs(x)
y = Abs(y)
x = x - y
Dim dScale As Decimal
Dim dScaleBySize As Decimal
Try
SIS.OpenClosestItem(x1, y1, z, 1, "H", "fPhoto")
dScale = SIS.GetFlt(SIS_OT_CURITEM, 0, "_photoscale#")
dScaleBySize = dScale * Decimal.Round(x, 3)
Catch ex As Exception
dScale = 1
dScaleBySize = x
dBorder = 0.0008 * SIS.GetFlt(SIS_OT_WINDOW, 0, "_displayScale#")
dThickness = 0.002 * SIS.GetFlt(SIS_OT_WINDOW, 0, "_displayScale#")
SIS.CreateInternalOverlay("Scalebar", SIS.GetInt(SIS_OT_WINDOW, 0, "_nOverlay&"))
SIS.SetInt(SIS_OT_WINDOW, 0, "_nDefaultOverlay&", SIS.GetInt(SIS_OT_WINDOW, 0, "_nOverlay&") - 1)
SIS.SetFlt(SIS_OT_DATASET, SIS.GetInt(SIS_OT_OVERLAY, SIS.GetInt(SIS_OT_WINDOW, 0, "_nDefaultOverlay&"), "_nDataset&"), "_scale#", SIS.GetFlt(SIS_OT_WINDOW, 0, "_displayScale#"))
End Try
Dim iMagnitude As Integer = 1
Do Until dScaleBySize < 10
iMagnitude = iMagnitude * 10
dScaleBySize = dScaleBySize / 10
Loop
Dim dScaleFactor As Double = 0
Select Case dScaleBySize
Case 1 To 1.5
dScaleFactor = 1
Case 1.5 To 2
dScaleFactor = 1.5
Case 2 To 2.5
dScaleFactor = 2
Case 2.5 To 5
dScaleFactor = 2.5
Case 5 To 7.5
dScaleFactor = 5
Case 7.5 To 10
dScaleFactor = 7.5
Case Else
End Select
Dim dScaleBarSize As Double = (dScaleFactor * iMagnitude) / dScale
'bar
SIS.CreateRectangle(x1, y1, x1 + dScaleBarSize, y1 + dThickness)
SIS.SetInt(SIS_OT_CURITEM, 0, "_level&", 2)
SIS.SetStr(SIS_OT_CURITEM, 0, "_brush$", "<Brush><Style>Solid</Style><Colour><RGBA>0 0 0 50</RGBA></Colour></Brush>")
SIS.SetStr(SIS_OT_CURITEM, 0, "_pen$", "<Pen><Style>Null</Style><Colour><RGBA>0 0 0 0</RGBA></Colour></Pen>")
SIS.UpdateItem()
SIS.AddToList("lScalebar")
'frame
SIS.CreateRectangle(x1 - dBorder, y1 - dBorder, x1 + dScaleBarSize + dBorder, y1 + dBorder + dThickness)
SIS.SetInt(SIS_OT_CURITEM, 0, "_level&", 1)
SIS.SetStr(SIS_OT_CURITEM, 0, "_brush$", "<Brush><Style>Solid</Style><Colour><RGBA>255 255 255 75</RGBA></Colour></Brush>")
SIS.SetStr(SIS_OT_CURITEM, 0, "_pen$", "<Pen><Style>Null</Style><Colour><RGBA>0 0 0 0</RGBA></Colour></Pen>")
SIS.UpdateItem()
SIS.AddToList("lScalebar")
'text
Dim sScaleText As String = Str(dScaleFactor * iMagnitude) + "m"
If iMagnitude > 1000 Then
sScaleText = Str(Abs(dScaleFactor * iMagnitude / 1000)) + "km"
End If
SIS.CreateText(x1 + (dScaleBarSize / 2), y1 + dThickness + dBorder, 0, sScaleText)
SIS.SetInt(SIS_OT_CURITEM, 0, "_point_height&", 12)
SIS.SetInt(SIS_OT_CURITEM, 0, "_level&", 3)
SIS.SetInt(SIS_OT_CURITEM, 0, "_text_alignV&", SIS_BOTTOM)
SIS.SetInt(SIS_OT_CURITEM, 0, "_text_alignH&", SIS_CENTRE)
SIS.SetInt(SIS_OT_CURITEM, 0, "_text_bold&", True)
SIS.SetInt(SIS_OT_CURITEM, 0, "_text_outline&", True)
SIS.SetStr(SIS_OT_CURITEM, 0, "_textFillBrush$", "<Brush><Style>Solid</Style><Colour><RGBA>0 0 0 50</RGBA></Colour></Brush>")
SIS.SetStr(SIS_OT_CURITEM, 0, "_textOutlinePen$", "<Pen><Colour><RGBA>255 255 255 75</RGBA></Colour><Width>100</Width><RoundCaps>true</RoundCaps></Pen>")
SIS.UpdateItem()
SIS.SelectItem()
SIS.CallCommand("AComTextToBox")
SIS.AddToList("lScalebar")
'location
SIS.SplitExtent(x2, y2, z, x3, y3, z, SIS.GetListExtent("lScalebar"))
Select Case Q
Case 1
SIS.MoveList("lScalebar", (x1 + y) - x2, (y1 + y) - y2, z, 0, 1)
Case 2
SIS.MoveList("lScalebar", (x1 + y) - x2, (y1 - y) - y3, z, 0, 1)
Case 3
SIS.MoveList("lScalebar", (x1 - y) - x3, (y1 - y) - y3, z, 0, 1)
Case 4
SIS.MoveList("lScalebar", (x1 - y) - x3, (y1 + y) - y2, z, 0, 1)
Case 5
SIS.MoveList("lScalebar", (x1 - x3) / 2, (y1 + y) - y2, z, 0, 1)
Case 6
SIS.MoveList("lScalebar", (x1 - x3) / 2, (y1 - y) - y3, z, 0, 1)
Case Else
End Select
SIS.CreateGroupFromItems("lScalebar", True, "")
SIS.SetInt(SIS_OT_CURITEM, 0, "_level&", 253)
SIS.DeselectAll()
Exit Do
Else
bDoubleSnap = True
x1 = x
y1 = y
End If
End If
Loop
Catch
End Try
SIS.Dispose()
SIS = Nothing
End Sub
Private PhotoID As Integer = 0
Private Sub Scaletext(ByVal sender As Object, ByVal e As SisClickArgs)
SIS = e.MapEditor
Try
SIS.OpenSel(0)
For i As Integer = 0 To SIS.GetInt(SIS_OT_WINDOW, 0, "_nOverlay&") - 1
If SIS.GetInt(SIS_OT_OVERLAY, i, "_nDataset&") = SIS.GetDataset() Then
SIS.SetInt(SIS_OT_WINDOW, 0, "_nDefaultOverlay&", i)
End If
Next
PhotoID = SIS.GetInt(SIS_OT_CURITEM, 0, "_id&")
Legend_font = New Drawing.Font("Arial", 10)
Legend_opaque = False
CreateScaletext()
Catch
End Try
SIS.Dispose()
SIS = Nothing
End Sub
Private Sub CreateScaletext()
Try
SIS.CreateGroup("")
SIS.CreateText(0, 0, 0, "Scale 1:^(" & PhotoID.ToString & ".FormatFlt(_photoscale#,""%.0f""))")
SIS.SetInt(SIS_OT_CURITEM, 0, "_point_height&", Legend_font.Size)
SIS.SetStr(SIS_OT_CURITEM, 0, "_font$", Legend_font.Name)
SIS.SetStr(SIS_OT_CURITEM, 0, "_pen$", "<Pen><Colour><RGBA>0 0 0 0</RGBA></Colour></Pen>")
SIS.SetStr(SIS_OT_CURITEM, 0, "_textOutlinePen$", "<Pen><Colour><RGBA>255 255 255 75</RGBA></Colour><Width>100</Width><RoundCaps>true</RoundCaps></Pen>")
SIS.SetInt(SIS_OT_CURITEM, 0, "_text_outline&", True)
SIS.SetInt(SIS_OT_CURITEM, 0, "_level&", 253)
If Legend_opaque = True Then
SIS.SetInt(SIS_OT_CURITEM, 0, "_text_outline&", False)
SIS.SetInt(SIS_OT_CURITEM, 0, "_text_opaque&", True)
SIS.SetStr(SIS_OT_CURITEM, 0, "_brush$", "<Brush><Style>Solid</Style><Colour><RGBA>255 255 255 50</RGBA></Colour></Brush>")
End If
APP.AddTrigger("AComPlaceGroup::End", New SisTriggerHandler(AddressOf PlaceScaletext_End))
APP.AddTrigger("AComPlaceGroup::KeyEnter", New SisTriggerHandler(AddressOf PlaceScaletext_KeyEnter))
APP.AddTrigger("AComPlaceGroup::Snap", New SisTriggerHandler(AddressOf PlaceScaletext_Snap))
SIS.UpdateItem()
Catch
End Try
End Sub
Private Sub PlaceScaletext_End(ByVal sender As Object, ByVal e As SisTriggerArgs)
APP.RemoveTrigger("AComPlaceGroup::End", AddressOf PlaceScaletext_End)
APP.RemoveTrigger("AComPlaceGroup::KeyEnter", AddressOf PlaceScaletext_KeyEnter)
APP.RemoveTrigger("AComPlaceGroup::Snap", AddressOf PlaceScaletext_Snap)
End Sub
Private Sub PlaceScaletext_KeyEnter(ByVal sender As Object, ByVal e As SisTriggerArgs)
SIS = e.MapEditor
Try
APP.RemoveTrigger("AComPlaceGroup::End", AddressOf PlaceScaletext_End)
APP.RemoveTrigger("AComPlaceGroup::KeyEnter", AddressOf PlaceScaletext_KeyEnter)
APP.RemoveTrigger("AComPlaceGroup::Snap", AddressOf PlaceScaletext_Snap)
SendKeys.SendWait("{ESC}")
Dim dialogOverlayLegendConfig As New Dialog_OverlayLegend()
If dialogOverlayLegendConfig.ShowDialog() = DialogResult.OK Then
CreateScaletext()
End If
Catch
End Try
SIS.Dispose()
SIS = Nothing
End Sub
Private Sub PlaceScaletext_Snap(ByVal sender As Object, ByVal e As SisTriggerArgs)
SIS = e.MapEditor
Try
APP.RemoveTrigger("AComPlaceGroup::End", AddressOf PlaceScaletext_End)
APP.RemoveTrigger("AComPlaceGroup::KeyEnter", AddressOf PlaceScaletext_KeyEnter)
APP.RemoveTrigger("AComPlaceGroup::Snap", AddressOf PlaceScaletext_Snap)
SendKeys.SendWait("{ENTER}")
SIS.DeselectAll()
Catch
End Try
SIS.Dispose()
SIS = Nothing
End Sub
Private Shared Inset_SnapCount As Integer
Private Sub Inset(ByVal sender As Object, ByVal e As SisClickArgs)
SIS = e.MapEditor
Try
EmptyList("lInsetMap")
EmptyList("lPhoto")
EmptyList("lInsetFrame")
SIS.SplitExtent(x1, y1, z, x2, y2, z, SIS.GetViewExtent())
SIS.CreateRectLocus("Locus", x1, y1, x2, y2)
SIS.ChangeLocusTestMode("Locus", SIS_GT_INTERSECT, SIS_GM_EXTENTS)
Dim frame As Boolean = False
For i As Integer = 0 To SIS.GetInt(SIS_OT_WINDOW, 0, "_nOverlay&") - 1
If SIS.GetStr(SIS_OT_DATASET, SIS.GetInt(SIS_OT_OVERLAY, i, "_nDataset&"), "_class$") = "AInternalDts" Then
If SIS.ScanOverlay("lPhoto", i, "fPhoto", "Locus") > 0 Then
frame = True
Handler = SIS.GetStr(SIS_OT_SYSTEM, 0, "_MainWndTitle$")
SIS.SetInt(SIS_OT_WINDOW, 0, "Handler&", True)
Inset_SnapCount = 0
Inset_SnapCount = InsetMap()
SIS.DeselectAll()
SIS.DoCommand("AComRect")
System.Windows.Forms.Application.DoEvents()
APP.AddTrigger("AComRect::KeyBack", New SisTriggerHandler(AddressOf InsetMap_Keyback))
APP.AddTrigger("AComRect::Snap", New SisTriggerHandler(AddressOf InsetMap_Snap))
APP.AddTrigger("AMainWindow::SetCurWnd", New SisTriggerHandler(AddressOf InsetMap_SetCurWnd))
APP.AddTrigger("AComRect::End", New SisTriggerHandler(AddressOf InsetMap_End))
Exit For
End If
End If
Next
If frame = False Then
MsgBox("No Map Frame item in current window.", MsgBoxStyle.Exclamation, "Cadcorp SIS Print Workshop")
End If
Catch
RemoveInsetTrigger()
End Try
SIS.Dispose()
SIS = Nothing
End Sub
Private Function InsetMap() As Integer
Try
SIS.OpenSel(0)
SIS.SetStr(SIS_OT_CURITEM, 0, "_brush$", "<Brush><Style>Solid</Style><Colour><RGBA>255 255 255 0</RGBA></Colour></Brush>")
SIS.SetStr(SIS_OT_CURITEM, 0, "_pen$", "<Pen><Colour><RGBA>0 0 0 0</RGBA></Colour></Pen>")
SIS.UpdateItem()
SIS.AddToList("lInsetMap")
BringOnTop()
Inset_SnapCount = 2
Catch ex As Exception
Inset_SnapCount = 0
End Try
Return Inset_SnapCount
End Function
Private Sub InsetMap_End(ByVal sender As Object, ByVal e As SisTriggerArgs)
SIS = e.MapEditor
Try
EmptyList("lInsetFrame")
RemoveInsetTrigger()
SIS.SwitchCommand("AComSelectSlide")
Catch
End Try
SIS.Dispose()
SIS = Nothing
End Sub
Private Sub InsetMap_Keyback(ByVal sender As Object, ByVal e As SisTriggerArgs)
SIS = e.MapEditor
Try
If Inset_SnapCount = 1 Then Inset_SnapCount = 0
If Inset_SnapCount = 3 Then Inset_SnapCount = 2
Catch
End Try
SIS.Dispose()
SIS = Nothing
End Sub
Private Sub InsetMap_Snap(ByVal sender As Object, ByVal e As SisTriggerArgs)
SIS = e.MapEditor
Try
If Inset_SnapCount = 1 Then
Inset_SnapCount = InsetMap()
ElseIf Inset_SnapCount = 3 Then
APP.RemoveTrigger("AComRect::End", (AddressOf InsetMap_End))
SendKeys.SendWait("{ESC}")
SIS.SetInt(SIS_OT_WINDOW, 0, "_bRedraw&", False)
SIS.OpenSel(0)
SIS.AddToList("lInsetFrame")
SIS.OpenList("lInsetMap", 0)
Dim ox_inset As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_ox#")
Dim oy_inset As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_oy#")
Dim sx_inset As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_sx#")
Dim sy_inset As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_sy#")
SIS.OpenList("lInsetFrame", 0)
Dim ox_photo As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_ox#")
Dim oy_photo As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_oy#")
Dim sx_photo As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_sx#")
Dim sy_photo As Double = SIS.GetFlt(SIS_OT_CURITEM, 0, "_sy#")
Dim ScaleFactor As Double
If sx_photo / sx_inset > sy_photo / sy_inset Then
ScaleFactor = sx_photo / sx_inset
Else
ScaleFactor = sy_photo / sy_inset
End If
SIS.OpenList("lInsetMap", 0)
If Not SIS.GetStr(SIS_OT_CURITEM, 0, "_class$") = "Photo" Then
SIS.OpenList("lInsetFrame", 0)
SIS.ScanGeometry("ScanList", SIS_GT_INTERSECT, SIS_GM_GEOMETRY, "fPhoto", "")
Dim iLevel As Integer = 0
Dim n As Integer = 0
For i = 0 To SIS.GetListSize("ScanList") - 1
SIS.OpenList("ScanList", i)
If SIS.GetInt(SIS_OT_CURITEM, 0, "_level&") >= iLevel Then
iLevel = SIS.GetInt(SIS_OT_CURITEM, 0, "_level&")
n = i
End If
Next i
SIS.OpenList("ScanList", n)
SIS.AddToList("lPhoto")
SIS.EmptyList("ScanList")
Else
SIS.AddToList("lPhoto")
End If
SIS.OpenList("lPhoto", 0)
Dim dScale = SIS.GetFlt(SIS_OT_CURITEM, 0, "_photoscale#")
Dim dRotation = SIS.GetFlt(SIS_OT_CURITEM, 0, "_photoangleDeg#")
Dim x_photo, y_photo As Double
SIS.SplitPos(x_photo, y_photo, z, SIS.GetPhotoWorldPos(ox_photo, oy_photo))
OpenPhoto("lPhoto", 0)
SIS.SetViewExtent(x_photo - sx_photo, y_photo - sy_photo, 0, x_photo + sx_photo, y_photo + sy_photo, 0)
SIS.SetFlt(SIS_OT_WINDOW, 0, "_displayScale#", dScale)
SIS.Compose()
SIS.SwdClose(SIS_NOSAVE)
ActivateWindow(Handler)
SIS.CreatePhoto(ox_inset - sx_inset / 1.9, oy_inset - sy_inset / 1.9, ox_inset + sx_inset / 1.9, oy_inset + sy_inset / 1.9)
SIS.SetStr(SIS_OT_CURITEM, 0, "_brush$", "<Brush><Style>Solid</Style><Colour><RGBA>255 255 255 0</RGBA></Colour></Brush>")
SIS.SetStr(SIS_OT_CURITEM, 0, "_pen$", "<Pen><Colour><RGBA>0 0 0 0</RGBA></Colour></Pen>")
SIS.SetFlt(SIS_OT_CURITEM, 0, "_photothreshold#", dScale * ScaleFactor)
SIS.SetFlt(SIS_OT_CURITEM, 0, "_photoscale#", dScale * ScaleFactor)
SIS.SetFlt(SIS_OT_CURITEM, 0, "_photoangleDeg#", dRotation)
SIS.UpdateItem()
SIS.AddToList("lInsetMap")
BringOnTop()
SIS.CreateBoolean("lInsetMap", SIS_BOOLEAN_AND)
SIS.Delete("lInsetMap")
SIS.Delete("lInsetFrame")
RemoveInsetTrigger()
SIS.SetInt(SIS_OT_WINDOW, 0, "_bRedraw&", True)
SIS.SwitchCommand("AComSelectSlide")
SIS.SetInt(SIS_OT_WINDOW, 0, "Handler&", False)
Else
Inset_SnapCount += 1
End If
Catch
RemoveInsetTrigger()
End Try
SIS.DeselectAll()
SIS.Redraw(SIS_CURRENTWINDOW)
SIS.Dispose()
SIS = Nothing
End Sub
Private Sub InsetMap_SetCurWnd(ByVal sender As Object, ByVal e As SisTriggerArgs)
SIS = e.MapEditor
Try