-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathf_ViewIcons.pas
665 lines (615 loc) · 20.8 KB
/
f_ViewIcons.pas
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
unit f_ViewIcons;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, System.Skia, Vcl.Skia, Vcl.ControlList,
Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.WinXCtrls, svgViewer.Types, Vcl.ComCtrls,
Vcl.Menus, System.ImageList, Vcl.ImgList, Vcl.VirtualImageList,
Vcl.BaseImageCollection, Vcl.ImageCollection, u_ViewIconsSettings, svgViewer.RightToolbarController;
const
C_CAPTION = 'SVG Icon Viewer';
type
TViewIconsForm = class(TForm)
pnlToolbar: TPanel;
ControlList1: TControlList;
svgIcon: TSkSvg;
dlgColor: TColorDialog;
lblAvailableIconsCaption: TLabel;
Shape1: TShape;
lblAvailableIconCount: TLabel;
SearchBox1: TSearchBox;
Shape2: TShape;
StatusBar1: TStatusBar;
pmIcon: TPopupMenu;
mniCopySvgClipboard: TMenuItem;
mniSaveSVGFile: TMenuItem;
mniSavePNGToFile: TMenuItem;
svgSaveDlg: TSaveDialog;
pngSaveDlg: TSaveDialog;
ImageCollection1: TImageCollection;
VirtualImageList1: TVirtualImageList;
pmFill: TPopupMenu;
pmSelectFillNone: TMenuItem;
pmSelectFillColor: TMenuItem;
Shape3: TShape;
pmLibrary: TPopupMenu;
pnlSearchInfo: TPanel;
lstRightToolbar: TControlList;
shpRBtnBorder: TShape;
svgColorIcon: TSkSvg;
lblColorLbl: TLabel;
svgRightIcon: TSkSvg;
lstIconTypes: TControlList;
shpTypeBtnBorder: TShape;
svgIconType: TSkSvg;
lstLibrary: TControlList;
shpLibBorder: TShape;
svgLibrary: TSkSvg;
mniCopyIconName: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure svgRegularClick(Sender: TObject);
procedure svgFilledClick(Sender: TObject);
procedure svgTwoToneClick(Sender: TObject);
procedure dlgColorShow(Sender: TObject);
procedure ClickBackColor(Sender: TObject);
procedure ClickToneColor(Sender: TObject);
procedure ClickFillColor(Sender: TObject);
procedure ControlList1BeforeDrawItem(AIndex: Integer; ACanvas: TCanvas;
ARect: TRect; AState: TOwnerDrawState);
procedure ControlList1ItemClick(Sender: TObject);
procedure SearchBox1InvokeSearch(Sender: TObject);
procedure mniCopySvgClipboardClick(Sender: TObject);
procedure mniSaveSVGFileClick(Sender: TObject);
procedure pmIconPopup(Sender: TObject);
procedure mniSavePNGToFileClick(Sender: TObject);
procedure ClickSettings(Sender: TObject);
procedure pmSelectFillNoneClick(Sender: TObject);
procedure pmSelectFillColorClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure LibraryClick(Sender: TObject);
procedure pmLibraryPopup(Sender: TObject);
procedure ClickGenerateCollection(Sender: TObject);
procedure lstIconTypesBeforeDrawItem(AIndex: Integer; ACanvas: TCanvas;
ARect: TRect; AState: TOwnerDrawState);
procedure lstIconTypesItemClick(Sender: TObject);
procedure lstIconTypesEnableItem(const AIndex: Integer;
var AEnabled: Boolean);
procedure mniCopyIconNameClick(Sender: TObject);
private
fFillColor : TColor;
fToneColor : TColor;
fList : ISVGIconList;
fSettings : ISVGIconConfig;
fStyle : TSVGIconListType;
fIconLibrary : ISVGLibrary;
fCollectionIdx : integer;
fCollection : ISVGLibraryCollection;
fUserDir : String;
fRightToolbar : ISVGViewerRightToolbar;
procedure LoadFormPosition;
procedure SaveFormPosition;
procedure SetFillColor(Value:TColor);
procedure SetToneColor(Value:TColor);
procedure SetBackColor(Value:TColor);
procedure SelectRegular;
procedure SelectFilled;
procedure SelectTwoTone;
procedure Updatelist;
procedure SetList(Value:ISVGIconList);
procedure SelectCollection(Sender:TObject);
procedure ClickShowLicense(Sender: TObject);
procedure CountAllIcons;
public
{ Public declarations }
end;
var
ViewIconsForm: TViewIconsForm;
implementation
uses
Vcl.Themes,
vcl.GraphUtil,
System.IOUtils,
System.Math,
VCL.Clipbrd,
f_ViewIconsConfig,
System.Types,
svgIcon.Utils,
svgViewer.ShowLicenseDialog,
svgViewer.IconLibrary,
svgViewer.Icons.Search,
svgViewer.GenerateImageCollection,
svgIcons.FluentUIRegular20.Source,
svgIcons.FluentUIFilled20.Source,
IconCollections.Bootstrap,
IconCollections.UserFolderIcons,
IconCollections.RegisterTablerIcons,
IconCollections.RegisterMicrosoftFluentUI;
{$R *.dfm}
procedure TViewIconsForm.ClickFillColor(Sender: TObject);
var
pt : TPoint;
begin
Pt := ClientToScreen(Point(lstRightToolbar.left+lstRightToolbar.GetItemRect(lstRightToolbar.ItemIndex).Left,lstRightToolbar.Top+lstRightToolbar.height-2));
pmFill.Popup(pt.X,pt.Y);
end;
procedure TViewIconsForm.ClickGenerateCollection(Sender: TObject);
var
Obj : IUnknown;
begin
if Application.MessageBox('This may copy a large amount of data to the clipboard.'
+ #13#10#13#10 + 'Are you sure you wish to procede?', 'Confirm',
MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2) = IDNO then exit;
Obj := TGenerateImageCollection.Create(fList,fSettings.GetOptionIntDefault('pngsize',20));
ShowMessage('A TImageCollection Component containing all SVG images in the user directory which were then converted to PNG images was copied to clipboard.');
end;
procedure TViewIconsForm.ClickSettings(Sender: TObject);
var
dlg : TViewIconsConfigDlg;
bNewUserDir : boolean;
FolderList : ISVGUserFolderList;
begin
dlg := TViewIconsConfigDlg.create(Self);
try
dlg.Config := fSettings;
if dlg.ShowModal = mrOk then
begin
// if we didn't have a previous user folder, but there is one now,
// add the user folder collection
bNewUserDir := fUserDir = '';
fUserDir := fSettings.GetOptionStrDefault('userdir',fUserDir);
// consider if we need to register a new collection
bNewUserDir := (bNewUserDir and (fUSerDir <> ''));
if bNewUSerDir then
fIconLibrary.RegisterIconCollection(TUserFolderIcons.Create(fUserDir));
// only update if the current list is a folderlist
if Supports(fCollection,ISVGUserFolderList) and
Supports(fList,ISVGUserFolderList,FolderList) and
(fUserDir <> '') then
begin
FolderList.Directory := fUserDir;
ControlList1.ItemCount := fList.Count;
end;
end;
finally
dlg.free;
end;
end;
procedure TViewIconsForm.ClickShowLicense(Sender: TObject);
var
dlg : TShowLicenseDlg;
begin
dlg := TShowLicenseDlg.create(Self);
try
dlg.execute(fCollection.GetLicense);
finally
dlg.free;
end;
end;
procedure TViewIconsForm.ClickToneColor(Sender: TObject);
begin
dlgColor.color := fToneColor;
dlgColor.Tag := 2;
if dlgColor.Execute then
begin
SetToneColor(dlgColor.Color);
fSettings.SetOptionColor('tonecolor',fToneColor);
end;
end;
procedure TViewIconsForm.ControlList1BeforeDrawItem(AIndex: Integer; ACanvas: TCanvas;
ARect: TRect; AState: TOwnerDrawState);
begin
svgIcon.svg.source := fList.Source[aindex];
end;
procedure TViewIconsForm.ControlList1ItemClick(Sender: TObject);
begin
Statusbar1.SimpleText := ' '+fList.Name[ControlLIst1.ItemIndex];
end;
procedure TViewIconsForm.CountAllIcons;
var
aCollection : ISVGLibraryCollection;
Ix, Count : integer;
begin
Count := 0;
for Ix := 0 to fIconLibrary.CollectionCount-1 do
begin
aCollection := fIconLibrary.Collection(ix);
// IGNORE any user folder icon collections in the count!
if supports(aCollection,ISVGUserFolderList) then
continue;
if ltOutline in aCollection.Available then
Count := Count + aCollection.list[ltOutline].count;
if ltFilled in aCollection.Available then
Count := Count + aCollection.list[ltFilled].count;
if ltTwoTone in aCollection.Available then
Count := Count + aCollection.list[ltTwoTone].count;
end;
StatusBar1.SimpleText := Format(' There are a total of %.0n available icons!',[count+0.0]);
end;
procedure TViewIconsForm.dlgColorShow(Sender: TObject);
begin
case dlgColor.Tag of
0 : SendMessage(dlgColor.Handle, WM_SETTEXT, 0, Longint(PChar('Set Background Color')));
1 : SendMessage(dlgColor.Handle, WM_SETTEXT, 0, Longint(PChar('Set Icon Fill Color')));
2 : SendMessage(dlgColor.Handle, WM_SETTEXT, 0, Longint(PChar('Set Icon Tone Color')));
end;
end;
procedure TViewIconsForm.FormCreate(Sender: TObject);
begin
// service registrations
fSettings := TSettings.create;
fList := TSearchIconList.create;
fIconLibrary := TIconLibrary.create;
// library collection registrations
IconCollections.RegisterMicrosoftFluentUI.RegisterCollections(fIconLIbrary);
IconCollections.RegisterTablerIcons.RegisterCollections(fIconLibrary);
fIconLibrary.RegisterIconCollection(TBootstrapIcons16.create);
fUserDir := fSettings.GetOptionStrDefault('userdir','');
if fUserDir <> '' then
begin
fIconLibrary.RegisterIconCollection(TUserFolderIcons.Create(fUserDir));
end;
// defaults
fStyle := TSVGIconListType(fSettings.GetOptionIntDefault('style',0));
fCollectionIdx := fSettings.GetOptionIntDefault('collection',4);
if fCollectionIdx > fIconLibrary.CollectionCount-1 then
fCollectionIdx := 0;
LoadFormPosition;
fRightToolbar := TRightToolbarController.create(lstRightToolbar,svgColorIcon,lblColorLbl,svgRightIcon);
fRightToolbar.ButtonEvents[btnFillColor] := ClickFillColor;
fRightToolbar.ButtonEvents[btnToneColor] := ClickToneColor;
fRightToolbar.ButtonEvents[btnBackColor] := ClickBackColor;
fRightToolbar.ButtonEvents[btnCopyCode] := ClickGenerateCollection;
fRightToolbar.ButtonEvents[btnSettings] := ClickSettings;
fRightToolbar.ButtonEvents[btnLicense] := ClickShowLicense;
SelectCollection(nil);
SetFillColor(fSettings.GetOptionColorDefault('fillcolor',clNone));
SetToneColor(fSettings.GetOptionColorDefault('tonecolor',clSilver));
SetBackColor(fSettings.GetOptionColorDefault('backcolor',StyleServices.GetSystemColor(clWindow)));
CountAllIcons;
end;
procedure TViewIconsForm.FormDestroy(Sender: TObject);
begin
fSettings.SetOptionInt('collection',fCollectionIdx);
fSettings.SetOptionInt('style',ord(fStyle));
SaveFormPosition;
end;
procedure TViewIconsForm.LibraryClick(Sender: TObject);
var
pt : TPoint;
begin
Pt := ClientToScreen(Point(lstLibrary.left,lstLibrary.Top+lstLibrary.height-2));
pmLibrary.popup(pt.x,pt.y);
lstLibrary.ItemIndex := -1;
end;
procedure TViewIconsForm.LoadFormPosition;
begin
width := fSettings.GetOptionIntDefault('mainform.width',width);
if Width > screen.Width then
Width := 800;
height := fSettings.GetoptionIntDefault('mainform.height',height);
if height > screen.height then
height := max(constraints.minheight,550);
left := fSettings.GetOptionIntDefault('mainform.left',(Screen.Width DIV 2) - (width DIV 2));
if Left > screen.width then
left := (Screen.Width DIV 2) - (width DIV 2);
top := fSettings.GetOptionIntDefault('mainform.top',(Screen.Height DIV 2) - (height DIV 2));
if top > screen.height then
Top := (Screen.Height DIV 2) - (height DIV 2);
end;
procedure TViewIconsForm.lstIconTypesBeforeDrawItem(AIndex: Integer; ACanvas: TCanvas;
ARect: TRect; AState: TOwnerDrawState);
const
C_SVG = '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">';
C_END = '</svg>';
begin
case aIndex of
0 : svgIconType.svg.Source := C_SVG+C_FluentUI_Icons_Regular_20+C_END;
1 : svgIconType.svg.Source := C_SVG+C_FluentUI_Icons_Filled_20+C_END;
2 : svgIconType.svg.Source := C_SVG+
StringReplace(C_FluentUI_Icons_Filled_20,'"#212121"','"silver"',[rfReplaceAll])+
C_FluentUI_Icons_Regular_20+
C_END;
end;
end;
procedure TViewIconsForm.lstIconTypesEnableItem(const AIndex: Integer;
var AEnabled: Boolean);
begin
case aIndex of
0 : AEnabled := true;
1 : AEnabled := ltFilled in fCollection.Available;
2 : AEnabled := ltTwoTone in fCollection.Available;
end;
end;
procedure TViewIconsForm.lstIconTypesItemClick(Sender: TObject);
begin
case lstIconTypes.Itemindex of
0 : SelectRegular;
1 : SelectFilled;
2 : SelectTwoTone;
end;
end;
procedure TViewIconsForm.mniCopyIconNameClick(Sender: TObject);
begin
if ControlList1.ItemIndex <> -1 then
Clipboard.AsText := fList.name[ControlList1.ItemIndex];
end;
procedure TViewIconsForm.mniCopySvgClipboardClick(Sender: TObject);
begin
if (ControlList1.itemindex > -1) then
Clipboard.asText := fList.Source[ControlList1.itemindex];
end;
procedure TViewIconsForm.mniSavePNGToFileClick(Sender: TObject);
var
LBitmap : TBitmap;
pngImg : TWICImage;
Sizes : TArray<INteger>;
Size : integer;
mRes : TModalResult;
bFileExists : boolean;
begin
SetLength(Sizes,1);
Sizes[0] := fSettings.GetOptionIntDefault('pngsize',20);
if fSettings.GetOptionBooleanDefault('pngscaled',true) then
begin
SetLength(Sizes,5);
Sizes[1] := Trunc(Sizes[0] * 1.25);
Sizes[2] := Trunc(Sizes[0] * 1.5);
Sizes[3] := Trunc(Sizes[0] * 1.75);
Sizes[4] := Trunc(Sizes[0] * 2);
end;
pngSaveDlg.Title := 'Save '+fList.name[ControlList1.itemindex]+' as SVG file';
pngSavedlg.filename := STringReplace(fList.name[ControlList1.itemindex],#32,'_',[rfReplaceAll])+'.png';
mRes := mrYes;
bFileExists := false;
repeat
if not pngSavedlg.execute then
mRes := mrCancel
else
begin
if Length(Sizes)=1 then
bFileExists := TFile.Exists(pngSaveDlg.FileName)
else
for size in Sizes do
bFileExists := bFileExists or TFile.Exists(StringReplace(pngSaveDlg.FileName,'.png','-'+INtToStr(Size)+'.png',[]));
if bFileExists then
mRes := Application.MessageBox('There is already a file with the same name in the target location. Do you want to overwrite the file?',
'Confirm Overwrite', MB_YESNOCANCEL + MB_ICONWARNING + MB_DEFBUTTON2);
end;
until mRes in [mrCancel,mrYes];
if mRes = mrYes then
begin
for size in Sizes do
begin
LBitmap := TBitmap.Create;
LBitmap.SetSize(Size, Size);
LBitmap.SkiaDraw(
procedure (const ACanvas: ISKCanvas)
var
LSvgBrush: TSkSvgBrush;
begin
LSvgBrush := TSkSvgBrush.Create;
try
LSvgBrush.Source := fList.Source[ControlList1.itemindex];
LSvgBrush.Render(ACanvas, RectF(0, 0, LBitmap.Width, LBitmap.Height), 1);
finally
LSvgBrush.Free;
end;
end);
pngImg := TWICImage.Create;
try
LBitmap.AlphaFormat := afDefined;
pngImg.Assign(LBitmap);
pngImg.ImageFormat := wifPng;
if Length(Sizes) > 1 then
pngImg.SaveToFile(StringReplace(pngSaveDlg.FileName,'.png','-'+INtToStr(Size)+'.png',[]))
else
pngImg.SaveToFile(pngSaveDlg.FileName);
finally
pngImg.Free;
end;
end;
end;
end;
procedure TViewIconsForm.mniSaveSVGFileClick(Sender: TObject);
var
mres : TModalREsult;
begin
svgSaveDlg.title := 'Save '+fList.name[ControlList1.itemindex]+' as SVG file';
svgSavedlg.filename := STringReplace(fList.name[ControlList1.itemindex],#32,'_',[rfReplaceAll])+'.svg';
repeat
mRes := mrYes;
if svgSaveDlg.execute then
begin
if TFile.exists(svgSaveDlg.filename) then
mRes := Application.MessageBox('There is already a file with the same name in the target location. Do you want to overwrite the file?',
'Confirm Overwrite', MB_YESNOCANCEL + MB_ICONWARNING + MB_DEFBUTTON2);
if mRes = mrYes then
TFile.WriteAllText(svgSaveDlg.filename,fList.Source[Controllist1.itemindex]);
end;
until mRes in [mrCancel,mrYes];
end;
procedure TViewIconsForm.pmIconPopup(Sender: TObject);
begin
mniCopyIconName.enabled := ControlList1.ItemIndex <> -1;
mniCopySvgClipboard.enabled := ControlList1.itemindex <> -1;
mniSaveSVGFile.enabled := ControlList1.itemindex <> -1;
mniSavePNGToFile.enabled := ControlList1.itemindex <> -1;
end;
procedure TViewIconsForm.pmLibraryPopup(Sender: TObject);
var
ix : integer;
mitem : TMenuItem;
begin
pmLibrary.Items.Clear;
if pmLibrary.items.count = 0 then
begin
for ix := 0 to fIconLibrary.CollectionCount-1 do
begin
mItem := TMenuItem.Create(pmLibrary);
mItem.Caption := fIconLibrary.CollectioName(ix);
if fCollectionIdx = ix then
mItem.Default := true;
mItem.tag := ix;
mItem.ImageIndex := 6;
mItem.OnClick := SelectCollection;
pmLibrary.items.Add(mItem);
end;
end;
end;
procedure TViewIconsForm.SaveFormPosition;
begin
fSettings.SetOptionInt('mainform.width',width);
fSettings.SetoptionInt('mainform.height',height);
fSettings.SetOptionInt('mainform.left',left);
fSettings.SetOptionInt('mainform.top',top);
end;
procedure TViewIconsForm.SearchBox1InvokeSearch(Sender: TObject);
var
SearchList : ISVGSearchList;
begin
if not Supports(fList,ISVGSearchList,SearchList) then
Raise ENotImplemented.create('Search is not supported for the current list');
SearchList.SearchText := SearchBox1.Text;
SearchBox1.SelectAll;
ControlList1.ItemCount := fList.count;
lblAvailableIconCount.caption := IntToStr(fList.Count);
ControlList1.Invalidate;
end;
procedure TViewIconsForm.pmSelectFillColorClick(Sender: TObject);
begin
dlgColor.color := fFillColor;
dlgColor.Tag := 1;
if dlgColor.Execute then
begin
SetFillColor(dlgColor.Color);
fSettings.SetOptionColor('fillcolor',fFillColor);
end;
end;
procedure TViewIconsForm.pmSelectFillNoneClick(Sender: TObject);
begin
SetFillColor(clNone);
fSettings.SetOptionColor('fillcolor',fFillColor);
end;
procedure TViewIconsForm.SelectCollection(Sender: TObject);
var
FolderList : ISVGUserFolderList;
bShowImageCollection : boolean;
bTwoToneEnabled, bFilledEnabled : boolean;
begin
if Sender is TMenuItem then
fCollectionIdx := TMenuItem(Sender).tag;
fCollection := fIconLibrary.Collection(fCollectionIdx);
bShowImageCollection := false;
if Supports(fCollection,ISVGUserFolderList,FolderList) then
begin
FolderList.Directory := fUserDir;
bShowImageCollection := true;
end;
fRightToolbar.CopyCodeEnabled := bShowImageCollection;
Caption := C_CAPTION +' : '+fCollection.Name;
bTwoToneEnabled := ltTwoTone in fCollection.Available;
bFilledEnabled := ltFilled in fCollection.Available;
if (not bFilledEnabled) and (fStyle = ltFilled) then
fStyle := ltOutline;
if (not bTwoToneEnabled) and (fstyle = ltTwoTone) then
fStyle := ltOutline;
case fStyle of
ltOutline : SelectRegular;
ltFilled : SelectFilled;
ltTwoTone : selectTwoTone;
end;
lstIconTypes.Invalidate;
end;
procedure TViewIconsForm.SelectFilled;
begin
fStyle := ltFilled;
lstIconTypes.itemIndex := 1;
fRightToolbar.ToneColorEnabled := false;
SetList(fCollection.list[ltFilled]);
fList.FillColor := fFillColor;
UpdateList;
end;
procedure TViewIconsForm.SelectRegular;
begin
fStyle := ltOutline;
lstIconTypes.itemIndex := 0;
fRightToolbar.ToneColorEnabled := false;
SetList(fCollection.list[ltOutline]);
fList.FillColor := fFillColor;
UpdateList;
end;
procedure TViewIconsForm.SelectTwoTone;
var
IconTone : ISVGTwoToneIconList;
begin
fStyle := ltTwoTone;
lstIconTypes.itemIndex := 2;
fRightToolbar.ToneColorEnabled := True;
SetList(fCollection.list[ltTwoTone]);
if Supports(fList,ISVGTwoToneIconList,IconTone) then
IconTone.ToneColor := fToneColor;
fList.FillColor := fFillColor;
UpdateList;
end;
procedure TViewIconsForm.SetBackColor(Value: TColor);
begin
ControlList1.Color := Value;
fRightToolbar.BackColor := value;
end;
procedure TViewIconsForm.SetFillColor(Value: TColor);
begin
fFillColor := Value;
fList.FillColor := fFillColor;
fRightToolbar.FillColor := value;
ControlList1.Invalidate;
end;
procedure TViewIconsForm.SetList(Value: ISVGIconList);
var
SearchList : ISVGSearchList;
begin
if assigned(fList) and Supports(fList,ISVGSearchList,SearchList) then
SearchList.BaseList := Value
else
fList := Value;
end;
procedure TViewIconsForm.SetToneColor(Value: TColor);
var
iconTone : ISVGTwoToneIconList;
begin
fToneColor := Value;
fRightToolbar.ToneColor := value;
fSettings.SetOptionColor('tonecolor',fToneColor);
if Supports(fList,ISVGTwoToneIconList,IconTone) then
IconTone.ToneColor := fToneColor;
ControlList1.invalidate;
end;
procedure TViewIconsForm.ClickBackColor(Sender: TObject);
begin
dlgColor.color := ControlList1.Color;
dlgColor.Tag := 0;
if dlgColor.Execute then
begin
SetBackColor(dlgColor.Color);
fSettings.SetOptionColor('backcolor',ControlList1.Color);
end;
end;
procedure TViewIconsForm.svgFilledClick(Sender: TObject);
begin
SelectFilled;
end;
procedure TViewIconsForm.svgRegularClick(Sender: TObject);
begin
SelectRegular;
end;
procedure TViewIconsForm.svgTwoToneClick(Sender: TObject);
begin
SelectTwoTone;
end;
procedure TViewIconsForm.Updatelist;
begin
lblAvailableIconCount.caption := IntToSTr(fList.Count);
ControlList1.Itemindex := -1;
ControlList1.ItemCount := fList.Count;
ControlList1.Invalidate;
end;
end.