-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
UpdResLegendForm.pas
124 lines (107 loc) · 3.19 KB
/
UpdResLegendForm.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
unit UpdResLegendForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,
InflatablesList_Manager;
type
TfUpdResLegendForm = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
fILManager: TILManager;
protected
procedure BuildForm;
public
{ Public declarations }
procedure Initialize(ILManager: TILManager);
procedure Finalize;
procedure ShowLegend;
end;
var
fUpdResLegendForm: TfUpdResLegendForm;
implementation
{$R *.dfm}
uses
InflatablesList_Types;
procedure TfUpdResLegendForm.BuildForm;
const
BOX_WIDTH = 33;
BOX_HEIGH = 33;
TEXT_VSPACE = 15;
RES_NAMES: array[TILItemShopUpdateResult] of String = (
'Success','Mild success','Data fail','Soft fail','Hard fail',
'Download fail','Parsing fail','Fatal error');
RES_TEXTS: array[TILItemShopUpdateResult] of String = (
'Update was completed succesfully',
'Successful update on untracked link',
'No download link or no parsing data',
'Failed to find or extract available count',
'Failed to find or extract price',
'Download was not successfull',
'Failed parsing of downloaded page',
'Unknown exception or other fatal error occured');
var
CurrentRes: TILItemShopUpdateResult;
VOrigin: Integer;
TempShape: TShape;
TempLabel: TLabel;
MaxWidth: Integer;
begin
VOrigin := 8;
MaxWidth := 0;
For CurrentRes := Low(TILItemShopUpdateResult) to High(TILItemShopUpdateResult) do
begin
// box
TempShape := TShape.Create(Self);
TempShape.Parent := Self;
TempShape.Width := BOX_WIDTH;
TempShape.Height := BOX_HEIGH;
TempShape.Pen.Style := psClear;
TempShape.Brush.Color := IL_ItemShopUpdateResultToColor(CurrentRes);
TempShape.Left := 8;
TempShape.Top := VOrigin;
// name label
TempLabel := TLabel.Create(Self);
TempLabel.Parent := Self;
TempLabel.Left := BOX_WIDTH + 15;
TempLabel.Top := VOrigin + 2;
TempLabel.Font.Style := [fsBold];
TempLabel.Caption := RES_NAMES[CurrentRes];
If TempLabel.Width > MaxWidth then
MaxWidth := TempLabel.Width;
// text label
TempLabel := TLabel.Create(Self);
TempLabel.Parent := Self;
TempLabel.Left := BOX_WIDTH + 16;
TempLabel.Top := VOrigin + TEXT_VSPACE;
TempLabel.Caption := RES_TEXTS[CurrentRes];
If TempLabel.Width > MaxWidth then
MaxWidth := TempLabel.Width;
// move origin
Inc(VOrigin,BOX_HEIGH + 8);
end;
Self.ClientHeight := VOrigin;
Self.ClientWidth := MaxWidth + BOX_WIDTH + 24;
end;
//==============================================================================
procedure TfUpdResLegendForm.Initialize(ILManager: TILManager);
begin
fILManager := ILManager;
end;
//------------------------------------------------------------------------------
procedure TfUpdResLegendForm.Finalize;
begin
// nothing to do here
end;
//------------------------------------------------------------------------------
procedure TfUpdResLegendForm.ShowLegend;
begin
ShowModal;
end;
//==============================================================================
procedure TfUpdResLegendForm.FormCreate(Sender: TObject);
begin
BuildForm;
end;
end.