source: trunk/Forms/FormImage.pas

Last change on this file was 168, checked in by chronos, 17 months ago
File size: 2.6 KB
Line 
1unit FormImage;
2
3interface
4
5uses
6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
7 ExtDlgs, ContactImage, FormEx;
8
9type
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
39implementation
40
41{$R *.lfm}
42
43uses
44 Core;
45
46{ TFormImage }
47
48procedure TFormImage.FormCreate(Sender: TObject);
49begin
50 Image := TContactImage.Create(nil);
51 Image.OnChange := ImageChange;
52end;
53
54procedure TFormImage.FormDestroy(Sender: TObject);
55begin
56 FreeAndNil(Image);
57end;
58
59procedure TFormImage.ButtonLoadClick(Sender: TObject);
60begin
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;
67end;
68
69procedure TFormImage.ButtonClearClick(Sender: TObject);
70begin
71 Image.Clear;
72end;
73
74procedure TFormImage.ButtonSaveClick(Sender: TObject);
75begin
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;
82end;
83
84procedure TFormImage.EditUrlChange(Sender: TObject);
85begin
86 Image.Url := EditUrl.Text;
87end;
88
89procedure TFormImage.FormShow(Sender: TObject);
90begin
91 ImageChange(nil);
92end;
93
94procedure TFormImage.ImageChange(Sender: TObject);
95begin
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;
100end;
101
102procedure TFormImage.UpdateInterface;
103begin
104 ButtonSave.Enabled := Image.Used;
105 ButtonClear.Enabled := Image.Used;
106end;
107
108end.
109
Note: See TracBrowser for help on using the repository browser.