-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
ItemPictureFrame.pas
216 lines (182 loc) · 6.17 KB
/
ItemPictureFrame.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
unit ItemPictureFrame;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls,
InflatablesList_ItemPictures,
InflatablesList_Manager;
type
TfrmItemPictureFrame = class(TFrame)
pnlMain: TPanel;
shbPicsBackground: TShape;
lblThumbFull: TLabel;
imgThumbFull: TImage;
shpThumbFull: TShape;
lblThumbHalf: TLabel;
imgThumbHalf: TImage;
shpThumbHalf: TShape;
lblThumbThirdth: TLabel;
imgThumbThirdth: TImage;
shpThumbThirdth: TShape;
btnViewPicture: TButton;
procedure imgThumbFullClick(Sender: TObject);
procedure imgThumbHalfClick(Sender: TObject);
procedure imgThumbThirdthClick(Sender: TObject);
procedure btnViewPictureClick(Sender: TObject);
private
fILManager: TILManager;
fCurrentPictures: TILItemPictures;
fCurrentPicture: Integer;
fInitializing: Boolean; // not really used, but meh...
protected
Function ValidItem(PicturesManager: TILItemPictures; Index: Integer): Boolean;
Function ValidCurrentItem: Boolean;
// frame methods
procedure FrameClear;
procedure FrameSave;
procedure FrameLoad;
public
procedure Initialize(ILManager: TILManager);
procedure Finalize;
procedure Save;
procedure Load;
procedure SetPicture(PicturesManager: TILItemPictures; Index: Integer; ProcessChange: Boolean);
end;
implementation
uses
InflatablesList_ItemPictures_Base;
{$R *.dfm}
Function TfrmItemPictureFrame.ValidItem(PicturesManager: TILItemPictures; Index: Integer): Boolean;
begin
If Assigned(PicturesManager) then
Result := PicturesManager.CheckIndex(Index)
else
REsult := False;
end;
//------------------------------------------------------------------------------
Function TfrmItemPictureFrame.ValidCurrentItem: Boolean;
begin
Result := ValidItem(self.fCurrentPictures,fCurrentPicture);
end;
//------------------------------------------------------------------------------
procedure TfrmItemPictureFrame.FrameClear;
begin
imgThumbFull.Picture.Assign(nil);
shpThumbFull.Visible := True;
imgThumbHalf.Picture.Assign(nil);
shpThumbHalf.Visible := True;
imgThumbThirdth.Picture.Assign(nil);
shpThumbThirdth.Visible := True;
end;
//------------------------------------------------------------------------------
procedure TfrmItemPictureFrame.FrameSave;
begin
// do nothing
end;
//------------------------------------------------------------------------------
procedure TfrmItemPictureFrame.FrameLoad;
begin
If ValidCurrentItem then
begin
fInitializing := True;
try
If fILManager.StaticSettings.NoPictures then
begin
If Assigned(fCurrentPictures[fCurrentPicture].Thumbnail) then
imgThumbFull.Picture.Assign(fILManager.DataProvider.EmptyPicture);
If Assigned(fCurrentPictures[fCurrentPicture].ThumbnailSmall) then
imgThumbHalf.Picture.Assign(fILManager.DataProvider.EmptyPictureSmall);
If Assigned(fCurrentPictures[fCurrentPicture].ThumbnailMini) then
imgThumbThirdth.Picture.Assign(fILManager.DataProvider.EmptyPictureMini);
end
else
begin
imgThumbFull.Picture.Assign(fCurrentPictures[fCurrentPicture].Thumbnail);
imgThumbHalf.Picture.Assign(fCurrentPictures[fCurrentPicture].ThumbnailSmall);
imgThumbThirdth.Picture.Assign(fCurrentPictures[fCurrentPicture].ThumbnailMini);
end;
shpThumbFull.Visible := not Assigned(fCurrentPictures[fCurrentPicture].Thumbnail);
shpThumbHalf.Visible := not Assigned(fCurrentPictures[fCurrentPicture].ThumbnailSmall);
shpThumbThirdth.Visible := not Assigned(fCurrentPictures[fCurrentPicture].ThumbnailMini);
finally
fInitializing := False;
end;
end;
end;
//==============================================================================
procedure TfrmItemPictureFrame.Initialize(ILManager: TILManager);
begin
fILManager := ILManager;
end;
//------------------------------------------------------------------------------
procedure TfrmItemPictureFrame.Finalize;
begin
// nothing to do
end;
//------------------------------------------------------------------------------
procedure TfrmItemPictureFrame.Save;
begin
FrameSave;
end;
//------------------------------------------------------------------------------
procedure TfrmItemPictureFrame.Load;
begin
FrameLoad;
end;
//------------------------------------------------------------------------------
procedure TfrmItemPictureFrame.SetPicture(PicturesManager: TILItemPictures; Index: Integer; ProcessChange: Boolean);
var
Reassigned: Boolean;
begin
Reassigned := (fCurrentPictures = PicturesManager) and (fCurrentPicture = Index);
If ProcessChange then
begin
If ValidCurrentItem and not Reassigned then
FrameSave;
If ValidItem(PicturesManager,Index) then
begin
fCurrentPictures := PicturesManager;
fCurrentPicture := Index;
If not Reassigned then
FrameLoad;
end
else
begin
fCurrentPictures := nil;
fCurrentPicture := -1;
FrameClear;
end;
Visible := ValidCurrentItem;
Enabled := ValidCurrentItem;
end
else
begin
fCurrentPictures := PicturesManager;
fCurrentPicture := Index;
end;
end;
//==============================================================================
procedure TfrmItemPictureFrame.imgThumbFullClick(Sender: TObject);
begin
If ValidCurrentItem then
fCurrentPictures.OpenThumbnailFile(fCurrentPicture,iltsFull);
end;
//------------------------------------------------------------------------------
procedure TfrmItemPictureFrame.imgThumbHalfClick(Sender: TObject);
begin
If ValidCurrentItem then
fCurrentPictures.OpenThumbnailFile(fCurrentPicture,iltsSmall);
end;
//------------------------------------------------------------------------------
procedure TfrmItemPictureFrame.imgThumbThirdthClick(Sender: TObject);
begin
If ValidCurrentItem then
fCurrentPictures.OpenThumbnailFile(fCurrentPicture,iltsMini);
end;
//------------------------------------------------------------------------------
procedure TfrmItemPictureFrame.btnViewPictureClick(Sender: TObject);
begin
If ValidCurrentItem then
fCurrentPictures.OpenPictureFile(fCurrentPicture);
end;
end.