1 | unit FormImage;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
|
---|
7 | ExtDlgs, ContactImage, FormEx;
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | { TFormImage }
|
---|
12 |
|
---|
13 | TFormImage = class(TFormEx)
|
---|
14 | ButtonCancel: TButton;
|
---|
15 | ButtonOk: TButton;
|
---|
16 | ButtonLoad: TButton;
|
---|
17 | ButtonSave: TButton;
|
---|
18 | ButtonClear: TButton;
|
---|
19 | EditUrl: TEdit;
|
---|
20 | ImagePhoto: TImage;
|
---|
21 | Label1: TLabel;
|
---|
22 | OpenPictureDialog1: TOpenPictureDialog;
|
---|
23 | SavePictureDialog1: TSavePictureDialog;
|
---|
24 | procedure ButtonClearClick(Sender: TObject);
|
---|
25 | procedure ButtonLoadClick(Sender: TObject);
|
---|
26 | procedure ButtonSaveClick(Sender: TObject);
|
---|
27 | procedure EditUrlChange(Sender: TObject);
|
---|
28 | procedure FormCreate(Sender: TObject);
|
---|
29 | procedure FormDestroy(Sender: TObject);
|
---|
30 | procedure FormShow(Sender: TObject);
|
---|
31 | private
|
---|
32 | procedure ImageChange(Sender: TObject);
|
---|
33 | public
|
---|
34 | Image: TContactImage;
|
---|
35 | procedure UpdateInterface;
|
---|
36 | end;
|
---|
37 |
|
---|
38 |
|
---|
39 | implementation
|
---|
40 |
|
---|
41 | {$R *.lfm}
|
---|
42 |
|
---|
43 | uses
|
---|
44 | Core;
|
---|
45 |
|
---|
46 | { TFormImage }
|
---|
47 |
|
---|
48 | procedure TFormImage.FormCreate(Sender: TObject);
|
---|
49 | begin
|
---|
50 | Image := TContactImage.Create(nil);
|
---|
51 | Image.OnChange := ImageChange;
|
---|
52 | end;
|
---|
53 |
|
---|
54 | procedure TFormImage.FormDestroy(Sender: TObject);
|
---|
55 | begin
|
---|
56 | FreeAndNil(Image);
|
---|
57 | end;
|
---|
58 |
|
---|
59 | procedure TFormImage.ButtonLoadClick(Sender: TObject);
|
---|
60 | begin
|
---|
61 | OpenPictureDialog1.InitialDir := ExtractFileDir(Core.Core.LastPhotoFileName);
|
---|
62 | OpenPictureDialog1.FileName := ExtractFileName(Core.Core.LastPhotoFileName);
|
---|
63 | if OpenPictureDialog1.Execute then begin
|
---|
64 | Image.LoadFromFile(OpenPictureDialog1.FileName);
|
---|
65 | Core.Core.LastPhotoFileName := OpenPictureDialog1.FileName;
|
---|
66 | end;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | procedure TFormImage.ButtonClearClick(Sender: TObject);
|
---|
70 | begin
|
---|
71 | Image.Clear;
|
---|
72 | end;
|
---|
73 |
|
---|
74 | procedure TFormImage.ButtonSaveClick(Sender: TObject);
|
---|
75 | begin
|
---|
76 | SavePictureDialog1.InitialDir := ExtractFileDir(Core.Core.LastPhotoFileName);
|
---|
77 | SavePictureDialog1.FileName := ExtractFileName(Core.Core.LastPhotoFileName);
|
---|
78 | if SavePictureDialog1.Execute then begin
|
---|
79 | Image.SaveToFile(SavePictureDialog1.FileName);
|
---|
80 | Core.Core.LastPhotoFileName := SavePictureDialog1.FileName;
|
---|
81 | end;
|
---|
82 | end;
|
---|
83 |
|
---|
84 | procedure TFormImage.EditUrlChange(Sender: TObject);
|
---|
85 | begin
|
---|
86 | Image.Url := EditUrl.Text;
|
---|
87 | end;
|
---|
88 |
|
---|
89 | procedure TFormImage.FormShow(Sender: TObject);
|
---|
90 | begin
|
---|
91 | ImageChange(nil);
|
---|
92 | end;
|
---|
93 |
|
---|
94 | procedure TFormImage.ImageChange(Sender: TObject);
|
---|
95 | begin
|
---|
96 | if Image.Used and (Image.Url = '') then ImagePhoto.Picture.Bitmap.Assign(Image.Bitmap)
|
---|
97 | else ImagePhoto.Picture.Assign(Core.Core.GetProfileImage.Picture);
|
---|
98 | EditUrl.Text := Image.Url;
|
---|
99 | UpdateInterface;
|
---|
100 | end;
|
---|
101 |
|
---|
102 | procedure TFormImage.UpdateInterface;
|
---|
103 | begin
|
---|
104 | ButtonSave.Enabled := Image.Used;
|
---|
105 | ButtonClear.Enabled := Image.Used;
|
---|
106 | end;
|
---|
107 |
|
---|
108 | end.
|
---|
109 |
|
---|