-
Notifications
You must be signed in to change notification settings - Fork 1
/
Container_Preset.xojo_window
1299 lines (1187 loc) · 37.1 KB
/
Container_Preset.xojo_window
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
#tag DesktopWindow
Begin DesktopContainer Container_Preset
AllowAutoDeactivate= True
AllowFocus = False
AllowFocusRing = False
AllowTabs = True
Backdrop = 0
BackgroundColor = &cFFFFFF
Composited = False
Enabled = True
HasBackgroundColor= False
Height = 486
Index = -2147483648
InitialParent = ""
Left = 0
LockBottom = True
LockLeft = True
LockRight = True
LockTop = True
TabIndex = 0
TabPanelIndex = 0
TabStop = True
Tooltip = ""
Top = 0
Transparent = True
Visible = True
Width = 314
Begin DesktopLabel Label_Preset
AllowAutoDeactivate= True
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Height = 20
Index = -2147483648
Italic = False
Left = 0
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = False
LockTop = True
Multiline = False
Scope = 2
Selectable = False
TabIndex = 0
TabPanelIndex = 0
TabStop = False
Text = "Preset:"
TextAlignment = 3
TextColor = &c000000
Tooltip = "Save your current selection of keywords, your example image and your model settings as a preset under a freely selectable name. If you selected a preset from the list below and do not change the name, the selected preset will be updated with your current settings."
Top = 0
Transparent = False
Underline = False
Visible = True
Width = 50
End
Begin DesktopTextField TextField_PresetName
AllowAutoDeactivate= True
AllowFocusRing = True
AllowSpellChecking= False
AllowTabs = False
BackgroundColor = &cFFFFFF
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Format = ""
HasBorder = True
Height = 22
Hint = "Preset Name"
Index = -2147483648
Italic = False
Left = 62
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
MaximumCharactersAllowed= 0
Password = False
ReadOnly = False
Scope = 2
TabIndex = 1
TabPanelIndex = 0
TabStop = True
Text = ""
TextAlignment = 0
TextColor = &c000000
Tooltip = "A name for your current selection of keywords, your example image and your model settings.\n\nIf you selected a preset from the list below and do not change the name, saving the selected preset will update it with your current settings.\n\nPress Enter or the Save Button, to save your current Preset."
Top = 0
Transparent = False
Underline = False
ValidationMask = ""
Visible = True
Width = 164
End
Begin PushButtonSized PushButton_Save_Preset
AllowAutoDeactivate= True
Bold = False
Cancel = False
Caption = "💾"
Default = False
Enabled = False
FontName = "System"
FontSize = 0.0
FontUnit = 0
Height = 20
Index = -2147483648
InitialParent = ""
Italic = False
Left = 238
LockBottom = False
LockedInPosition= False
LockLeft = False
LockRight = True
LockTop = True
MacButtonStyle = 0
Scope = 2
TabIndex = 2
TabPanelIndex = 0
TabStop = True
Tooltip = "Save the currently selected keywords as a preset labeled using the name entered in the Textfield to the left.\n\nIf you selected a preset from the list below and do not change the name, saving the selected preset will update it with your current settings."
Top = 0
Transparent = False
Underline = False
Visible = True
Width = 32
End
Begin PushButtonSized PushButton_Delete_Preset
AllowAutoDeactivate= True
Bold = False
Cancel = False
Caption = "🗑️"
Default = False
Enabled = False
FontName = "System"
FontSize = 0.0
FontUnit = 0
Height = 20
Index = -2147483648
InitialParent = ""
Italic = False
Left = 282
LockBottom = False
LockedInPosition= False
LockLeft = False
LockRight = True
LockTop = True
MacButtonStyle = 0
Scope = 2
TabIndex = 3
TabPanelIndex = 0
TabStop = True
Tooltip = "Delete the currently selected presets."
Top = 0
Transparent = False
Underline = False
Visible = True
Width = 32
End
Begin DesktopListBoxDM ListBox_Presets
AllowAutoDeactivate= True
AllowAutoHideScrollbars= True
AllowExpandableRows= False
AllowFocusRing = False
AllowResizableColumns= False
AllowRowDragging= False
AllowRowReordering= False
Bold = False
ColumnCount = 1
ColumnWidths = ""
DefaultRowHeight= -1
DropIndicatorVisible= False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
GridLineStyle = 0
HasBorder = True
HasHeader = False
HasHorizontalScrollbar= False
HasVerticalScrollbar= True
HeadingIndex = -1
Height = 160
Index = -2147483648
InitialValue = ""
Italic = False
Left = 0
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
NegativeColumn = 3
RequiresSelection= True
RowSelectionType= 1
Scope = 2
TabIndex = 4
TabPanelIndex = 0
TabStop = True
Tooltip = "Press the SPACE-Key to enlarge the example image.\n\nSelect one or more Presets and click the Trashcan Button to delete selected Presets."
Top = 34
Transparent = False
Underline = False
Visible = True
Width = 314
_ScrollOffset = 0
_ScrollWidth = -1
End
Begin DesktopTabPanel TabPanel_Preset
AllowAutoDeactivate= True
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Height = 280
Index = -2147483648
Italic = False
Left = 0
LockBottom = True
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
Panels = ""
Scope = 2
SmallTabs = False
TabDefinition = "Example Image\rSettings"
TabIndex = 5
TabPanelIndex = 0
TabStop = True
Tooltip = "Switch between the example image and the model settings."
Top = 206
Transparent = False
Underline = False
Value = 0
Visible = True
Width = 314
Begin DesktopCanvas Canvas_Sample
AllowAutoDeactivate= True
AllowFocus = False
AllowFocusRing = True
AllowTabs = False
Backdrop = 0
Enabled = True
Height = 222
Index = -2147483648
InitialParent = "TabPanel_Preset"
Left = 20
LockBottom = True
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
Scope = 2
TabIndex = 0
TabPanelIndex = 1
TabStop = False
Tooltip = "Drop an image here or click here with the primary mouse button to add an example image.\r\n\r\nClick with the secondary mouse button to view the example image in a separate Window."
Top = 244
Transparent = False
Visible = True
Width = 274
End
Begin DesktopTextField TextField_PresetScale
AllowAutoDeactivate= True
AllowFocusRing = True
AllowSpellChecking= False
AllowTabs = False
BackgroundColor = &cFFFFFF
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Format = ""
HasBorder = True
Height = 22
Hint = ""
Index = -2147483648
InitialParent = "TabPanel_Preset"
Italic = False
Left = 112
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
MaximumCharactersAllowed= 0
Password = False
ReadOnly = False
Scope = 2
TabIndex = 7
TabPanelIndex = 2
TabStop = True
Text = ""
TextAlignment = 0
TextColor = &c000000
Tooltip = "Enter the guidance Scale valueused for the example image here."
Top = 346
Transparent = False
Underline = False
ValidationMask = ""
Visible = True
Width = 182
End
Begin DesktopLabel Label_PresetInfo
AllowAutoDeactivate= True
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Height = 22
Index = 3
InitialParent = "TabPanel_Preset"
Italic = False
Left = 20
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = False
LockTop = True
Multiline = False
Scope = 2
Selectable = False
TabIndex = 6
TabPanelIndex = 2
TabStop = False
Text = "Scale / CFG:"
TextAlignment = 0
TextColor = &c000000
Tooltip = "Controls how much the image generation process follows the text prompt. The higher the value, the more the image sticks to the given text input."
Top = 346
Transparent = False
Underline = False
Visible = True
Width = 80
End
Begin DesktopTextField TextField_PresetSteps
AllowAutoDeactivate= True
AllowFocusRing = True
AllowSpellChecking= False
AllowTabs = False
BackgroundColor = &cFFFFFF
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Format = ""
HasBorder = True
Height = 22
Hint = ""
Index = -2147483648
InitialParent = "TabPanel_Preset"
Italic = False
Left = 112
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
MaximumCharactersAllowed= 0
Password = False
ReadOnly = False
Scope = 2
TabIndex = 5
TabPanelIndex = 2
TabStop = True
Text = ""
TextAlignment = 0
TextColor = &c000000
Tooltip = "Enter the Diffusion Steps value used for the example image here."
Top = 312
Transparent = False
Underline = False
ValidationMask = ""
Visible = True
Width = 182
End
Begin DesktopLabel Label_PresetInfo
AllowAutoDeactivate= True
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Height = 22
Index = 4
InitialParent = "TabPanel_Preset"
Italic = False
Left = 20
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = False
LockTop = True
Multiline = False
Scope = 2
Selectable = False
TabIndex = 4
TabPanelIndex = 2
TabStop = False
Text = "Steps:"
TextAlignment = 0
TextColor = &c000000
Tooltip = "Controls the number of denoising steps. Usually, higher is better but only to a certain degree."
Top = 312
Transparent = False
Underline = False
Visible = True
Width = 80
End
Begin DesktopTextField TextField_PresetSeed
AllowAutoDeactivate= True
AllowFocusRing = True
AllowSpellChecking= False
AllowTabs = False
BackgroundColor = &cFFFFFF
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Format = ""
HasBorder = True
Height = 22
Hint = ""
Index = -2147483648
InitialParent = "TabPanel_Preset"
Italic = False
Left = 112
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
MaximumCharactersAllowed= 0
Password = False
ReadOnly = False
Scope = 2
TabIndex = 3
TabPanelIndex = 2
TabStop = True
Text = ""
TextAlignment = 0
TextColor = &c000000
Tooltip = "Enter the seed value used for the example image here."
Top = 278
Transparent = False
Underline = False
ValidationMask = ""
Visible = True
Width = 182
End
Begin DesktopLabel Label_PresetInfo
AllowAutoDeactivate= True
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Height = 22
Index = 5
InitialParent = "TabPanel_Preset"
Italic = False
Left = 20
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = False
LockTop = True
Multiline = False
Scope = 2
Selectable = False
TabIndex = 2
TabPanelIndex = 2
TabStop = False
Text = "Seed:"
TextAlignment = 0
TextColor = &c000000
Tooltip = "A number used to initialize the Generation. The seed can help to generate reproducible Images."
Top = 278
Transparent = False
Underline = False
Visible = True
Width = 80
End
Begin DesktopLabel Label_PresetInfo
AllowAutoDeactivate= True
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Height = 22
Index = 6
InitialParent = "TabPanel_Preset"
Italic = False
Left = 20
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = False
LockTop = True
Multiline = False
Scope = 2
Selectable = False
TabIndex = 0
TabPanelIndex = 2
TabStop = False
Text = "Model:"
TextAlignment = 0
TextColor = &c000000
Tooltip = "The Model menu allows you to add models and their recommended prompts."
Top = 244
Transparent = False
Underline = False
Visible = True
Width = 80
End
Begin DesktopComboBox ComboBox_PresetModel
AllowAutoComplete= False
AllowAutoDeactivate= True
AllowFocusRing = True
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Height = 22
Hint = "Name of the used Model"
Index = -2147483648
InitialParent = "TabPanel_Preset"
InitialValue = ""
Italic = False
Left = 112
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
Scope = 0
SelectedRowIndex= 0
TabIndex = 1
TabPanelIndex = 2
TabStop = True
Tooltip = "Enter the name of the model used or select it from a list of previously created models."
Top = 244
Transparent = False
Underline = False
Visible = True
Width = 182
End
Begin DesktopLabel Label_PresetInfo
AllowAutoDeactivate= True
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Height = 22
Index = 7
InitialParent = "TabPanel_Preset"
Italic = False
Left = 20
LockBottom = False
LockedInPosition= False
LockLeft = True
LockRight = False
LockTop = True
Multiline = False
Scope = 2
Selectable = False
TabIndex = 8
TabPanelIndex = 2
TabStop = False
Text = "Notes:"
TextAlignment = 0
TextColor = &c000000
Tooltip = ""
Top = 380
Transparent = False
Underline = False
Visible = True
Width = 80
End
Begin DesktopTextArea TextArea_ModelNotes
AllowAutoDeactivate= True
AllowFocusRing = True
AllowSpellChecking= False
AllowStyledText = True
AllowTabs = False
BackgroundColor = &cFFFFFF00
Bold = False
Enabled = True
FontName = "System"
FontSize = 0.0
FontUnit = 0
Format = ""
HasBorder = True
HasHorizontalScrollbar= False
HasVerticalScrollbar= True
Height = 80
HideSelection = True
Index = -2147483648
InitialParent = "TabPanel_Preset"
Italic = False
Left = 112
LineHeight = 0.0
LineSpacing = 1.0
LockBottom = True
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
MaximumCharactersAllowed= 0
Multiline = True
ReadOnly = True
Scope = 2
TabIndex = 9
TabPanelIndex = 2
TabStop = True
Text = ""
TextAlignment = 0
TextColor = &c000000
Tooltip = "Notes on the selected model preset."
Top = 386
Transparent = False
Underline = False
UnicodeMode = 1
ValidationMask = ""
Visible = True
Width = 182
End
End
End
#tag EndDesktopWindow
#tag WindowCode
#tag Event
Sub Resized()
Var BoxHeight As Integer = Self.Height / 3
ListBox_Presets.Height = BoxHeight
TabPanel_Preset.Top = ListBox_Presets.Top + BoxHeight + 14
TabPanel_Preset.Height = (BoxHeight * 2) - 48
Self.Refresh
End Sub
#tag EndEvent
#tag Method, Flags = &h21
Private Sub Model_Load()
TextArea_ModelNotes.Text = ""
Try
Var RS As RowSet = App.SDP_Database.SelectSQL("SELECT notes FROM model WHERE name=?", ComboBox_PresetModel.Text.Trim)
If RS<>Nil And Not RS.AfterLastRow Then
TextArea_ModelNotes.Text = RS.Column("notes").StringValue
End If
Catch err As DatabaseException
System.Log(System.LogLevelError, CurrentMethodName + " - Error Code: " + err.ErrorNumber.ToString + EndOfLine + "Error Message: " + err.Message)
End Try
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub Presets_List()
Try
Var RS As RowSet = App.SDP_Database.SelectSQL("SELECT * FROM preset ORDER by label")
If RS <> Nil Then
ListBox_Presets.RemoveAllRows
While Not RS.AfterLastRow
If RS.Column("label").StringValue<>"_AUTOSAVE" Then
ListBox_Presets.AddRow(RS.Column("label").StringValue)," "," " // We need to add a Space to each Column, so that PaintCellText fires.
ListBox_Presets.RowTagAt(ListBox_Presets.LastAddedRowIndex) = RS.Column("id").IntegerValue
End If
RS.MoveToNextRow
Wend
End If
Catch err As DatabaseException
System.Log(System.LogLevelError, CurrentMethodName + " - Error Code: " + err.ErrorNumber.ToString + EndOfLine + "Error Message: " + err.Message)
End Try
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub Preset_AddExampleImage()
Var f As New FolderItem
f = FolderItem.ShowOpenFileDialog("")
If f<>Nil And f.Exists Then
CurrentPreset.Sample = Picture.Open(f)
Canvas_Sample.Refresh
End If
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub Preset_Delete()
If ListBox_Presets.SelectedRowIndex=-1 Then Return
If Show_MessageDialog(MessageDialog.IconTypes.Caution, "Delete Preset(s)", "Cancel", "Delete Preset(s)", _
"Are you sure you want to delete the selected Preset(s)?") Then
Var SelectedRowIndex As Integer = ListBox_Presets.SelectedRowIndex
For X As Integer = ListBox_Presets.LastRowIndex DownTo 0
If ListBox_Presets.RowSelectedAt(X) Then
Var PS As New Class_Preset(ListBox_Presets.RowTagAt(X).IntegerValue)
If PS.Delete Then
CurrentPreset.Sample = Nil
Canvas_Sample.Refresh
End If
End If
Next
Presets_List
If SelectedRowIndex<ListBox_Presets.RowCount Then ListBox_Presets.SelectedRowIndex=SelectedRowIndex
End If
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub Preset_Load(DatabaseID As Integer)
TextField_PresetName.Enabled = False
CurrentPreset = New Class_Preset(DatabaseID)
If CurrentPreset.DatabaseID>1 Then
TextField_PresetName.Text = CurrentPreset.Label
ComboBox_PresetModel.Text = CurrentPreset.Diffusion_Model.Name
TextField_PresetSeed.Text = CurrentPreset.Seed
App.SD_Host.Seed = CurrentPreset.Seed.ToInteger
TextField_PresetSteps.Text = CurrentPreset.Steps.ToString
App.SD_Host.Steps = CurrentPreset.Steps
TextField_PresetScale.Text = Format(CurrentPreset.Guidance_Scale, "0.00")
Model_Load
Canvas_Sample.Refresh
End If
TextField_PresetName.Enabled = True
Window_Main.Cont_Keyword.Keywords_List
Window_Main.Cont_Keyword.Prompt_Show
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub Preset_Save()
If ListBox_Presets.SelectedRowIndex=-1 Then CurrentPreset.DatabaseID=0
Window_Main.Cont_Keyword.Keywords_PositionUpdate
If CurrentPreset.Save Then
Presets_List
For X As Integer = 0 To ListBox_Presets.LastRowIndex
If ListBox_Presets.RowTagAt(X).IntegerValue = CurrentPreset.DatabaseID Then
ListBox_Presets.SelectedRowIndex=X
Exit For X
End If
Next
End If
End Sub
#tag EndMethod
#tag EndWindowCode
#tag Events TextField_PresetName
#tag Event
Sub TextChanged()
If Not Me.Enabled Then Return
CurrentPreset.Label = Me.Text.Trim
PushButton_Save_Preset.Enabled = Me.Text <> ""
CurrentPreset.DatabaseID=0
End Sub
#tag EndEvent
#tag Event
Function KeyDown(key As String) As Boolean
If key.Asc = 13 Then // Enter Key
Preset_Save
Me.SetFocus
End If
End Function
#tag EndEvent
#tag EndEvents
#tag Events PushButton_Save_Preset
#tag Event
Sub Action()
Preset_Save
End Sub
#tag EndEvent
#tag EndEvents
#tag Events PushButton_Delete_Preset
#tag Event
Sub Action()
Preset_Delete
End Sub
#tag EndEvent
#tag EndEvents
#tag Events ListBox_Presets
#tag Event
Sub SelectionChanged()
PushButton_Delete_Preset.Enabled = Me.SelectedRowIndex <> DesktopListBox.NoSelection
If Me.SelectedRowIndex=-1 Then Return
PushButton_Save_Preset.Enabled = Me.SelectedRowCount = 1
Preset_Load(Me.RowTagAt(Me.SelectedRowIndex))
End Sub
#tag EndEvent
#tag Event
Sub MouseMove(x As Integer, y As Integer)
#Pragma unused y
#Pragma unused x
Var xLocal,yLocal,row As Integer
xLocal = System.MouseX - Me.Left - Self.Left
yLocal = System.MouseY - Me.Top - Self.Top
row = Me.RowFromXY(xLocal,yLocal)
If row=-1 Or row>Me.LastRowIndex Then Return
Me.Tooltip = Me.CellTextAt(row,0)
End Sub
#tag EndEvent
#tag Event
Function KeyDown(key As String) As Boolean
If Me.SelectedRowIndex = DesktopListBox.NoSelection Then Return False
// Var isShown As Boolean
// For i As Integer = 0 To WindowCount-1
// If Window(i) IsA Window_PresetSample Then
// isShown = True
// Exit
// End
// Next
Select Case key.Asc
Case 30 // Cursor Up
// If isShown Then
//
// Window_PresetSample.PresetSample = CurrentPreset.Sample
// Window_PresetSample.Refresh
//
// End If
Case 31 // Cursor Down
// If isShown Then
//
// Window_PresetSample.PresetSample = CurrentPreset.Sample
// Window_PresetSample.Refresh
//
// End If
Case 32 // Spacebar
If CurrentPreset.Sample<>Nil Then
Window_PresetSample.Show
Window_PresetSample.PresetSample = CurrentPreset.Sample
End If
Return True
End Select
End Function
#tag EndEvent
#tag EndEvents
#tag Events TabPanel_Preset
#tag Event
Sub PanelChanged()
ComboBox_PresetModel.Load_Models
End Sub
#tag EndEvent
#tag EndEvents
#tag Events Canvas_Sample
#tag Event
Sub Paint(g As Graphics, areas() As Rect)
#Pragma unused areas
g.ClearRectangle(0,0,g.Width,g.Height)
If CurrentPreset=Nil Or CurrentPreset.Sample=Nil Then
If Color.IsDarkMode Then
#If TargetWindows Then
g.DrawingColor=&c21212100
#Else
g.DrawingColor=&c2F2F2E00
#EndIf
g.FillRectangle(0,0,g.Width,g.Height)
g.DrawingColor=&c43434300
g.DrawRectangle(0,0,g.Width,g.Height)
g.DrawingColor = &cA9A9A900
Else
#If TargetWindows Then
g.DrawingColor=&cFFFFFF00
#Else
g.DrawingColor=&cE4E4E400
#EndIf
g.FillRectangle(0,0,g.Width,g.Height)
g.DrawingColor=&cB6B6B600
g.DrawRectangle(0,0,g.Width,g.Height)
g.DrawingColor = &c99999900
End If
g.Bold = True
If g.Width<g.Height Then
g.FontSize = g.Width/18
Else
g.FontSize = g.Height/16
End If
g.DrawText("Drop an image here or click here with the primary mouse button to add an example image." + EndOfLine + EndOfLine + _
"Click with the secondary mouse button to view the example image in a separate Window.",16,30,g.Width-32)
Else
Var p As Picture
p = Scale_Proportional(CurrentPreset.Sample,g.Width,g.Height)
If p.Width<p.Height Then
g.DrawPicture(p,(g.Width/2)-(p.Width/2),0)
Else
g.DrawPicture(p,0,(g.Height/2)-(p.Height/2))
End If
End If
End Sub
#tag EndEvent
#tag Event
Function MouseDown(x As Integer, y As Integer) As Boolean
#Pragma unused y
#Pragma unused x
If IsContextualClick Then
If CurrentPreset.Sample<>Nil Then
Window_PresetSample.Show
Window_PresetSample.PresetSample = CurrentPreset.Sample
End If