Changeset 31 for trunk/Forms/UFormContact.pas
- Timestamp:
- Nov 25, 2021, 1:18:44 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormContact.pas
r29 r31 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, ActnList, Menus, UContact;9 ComCtrls, ActnList, Menus, ExtCtrls, UContact, base64; 10 10 11 11 type … … 40 40 EditName: TEdit; 41 41 EditCellPhone: TEdit; 42 ImagePhoto: TImage; 42 43 Label1: TLabel; 43 44 Label10: TLabel; … … 55 56 Label21: TLabel; 56 57 Label22: TLabel; 58 Label23: TLabel; 57 59 LabelOrganization: TLabel; 58 60 Label3: TLabel; … … 110 112 procedure TFormContact.ListView1Data(Sender: TObject; Item: TListItem); 111 113 begin 112 if Item.Index < Contact.Parent.Fields.Count then 113 with TContactField(Contact.Parent.Fields[Item.Index]) do begin 114 Item.Caption := Name; 115 Item.SubItems.Add(Contact.Fields[Index]); 114 if Item.Index < Contact.Properties.Count then 115 with Contact.Properties[Item.Index] do begin 116 Item.Caption := Contact.Properties[Item.Index].Name; 117 Item.SubItems.Add(Attributes.DelimitedText); 118 Item.SubItems.Add(Contact.Properties[Item.Index].Values.DelimitedText); 119 Item.Data := Contact.Properties[Item.Index]; 116 120 end; 117 121 end; … … 125 129 begin 126 130 if Assigned(Contact) then begin 127 ListView1.Items.Count := Contact.P arent.Fields.Count;131 ListView1.Items.Count := Contact.Properties.Count; 128 132 end else ListView1.Items.Count := 0; 129 133 ListView1.Refresh; … … 139 143 begin 140 144 if Assigned(ListView1.Selected) then begin 141 Contact.Fields[TContactFieldIndex(ListView1.Selected.Index)]:=142 InputBox(SFieldEdit, SEditFieldValue, Contact.Fields[TContactFieldIndex(ListView1.Selected.Index)]);145 TContactProperty(ListView1.Selected.Data).Values.DelimitedText := 146 InputBox(SFieldEdit, SEditFieldValue, TContactProperty(ListView1.Selected.Data).Values.DelimitedText); 143 147 end; 144 148 end; … … 152 156 153 157 procedure TFormContact.LoadData(Contact: TContact); 158 var 159 Photo: string; 160 JpegImage: TJpegImage; 161 Stream: TMemoryStream; 162 PhotoProperty: TContactProperty; 154 163 begin 155 164 Self.Contact := Contact; 156 EditName.Text := Contact.FirstName; 157 EditSurname.Text := Contact.LastName; 158 EditCellPhone.Text := Contact.TelCell; 159 EditPhoneHome.Text := Contact.TelHome; 160 EditPhoneWork.Text := Contact.TelWork; 161 EditEmail.Text := Contact.EmailHome; 162 MemoNotes.Lines.Text := Contact.Note; 163 EditTitle.Text := Contact.Title; 164 EditOrganization.Text := Contact.Organization; 165 EditAddress.Text := Contact.AdrHome; 166 EditEmailHome.Text := Contact.EmailHome; 165 EditName.Text := Contact.Fields[cfFirstName]; 166 EditSurname.Text := Contact.Fields[cfLastName]; 167 EditCellPhone.Text := Contact.Fields[cfTelCell]; 168 EditPhoneHome.Text := Contact.Fields[cfTelHome]; 169 EditPhoneWork.Text := Contact.Fields[cfTelWork]; 170 EditEmail.Text := Contact.Fields[cfEmail]; 171 MemoNotes.Lines.Text := Contact.Fields[cfNote]; 172 EditTitle.Text := Contact.Fields[cfTitle]; 173 EditOrganization.Text := Contact.Fields[cfOrganization]; 174 EditAddress.Text := Contact.Fields[cfAdrHome]; 175 EditEmailHome.Text := Contact.Fields[cfEmailHome]; 176 177 ImagePhoto.Picture.Bitmap.Clear; 178 PhotoProperty := Contact.GetProperty(cfPhoto); 179 if Assigned(PhotoProperty) then begin 180 Photo := Contact.Fields[cfPhoto]; 181 if (Photo <> '') and (PhotoProperty.Encoding <> '') then begin 182 Photo := PhotoProperty.GetDecodedValue; 183 Stream := TMemoryStream.Create; 184 Stream.Write(Photo[1], Length(Photo)); 185 Stream.Position := 0; 186 JpegImage := TJPEGImage.Create; 187 JpegImage.LoadFromStream(Stream); 188 ImagePhoto.Picture.Bitmap.SetSize(JpegImage.Width, JpegImage.Height); 189 ImagePhoto.Picture.Bitmap.Canvas.Draw(0, 0, JpegImage); 190 JpegImage.Free; 191 Stream.Free; 192 end; 193 end; 167 194 end; 168 195 169 196 procedure TFormContact.SaveData(Contact: TContact); 170 197 begin 171 Contact.Fi rstName:= EditName.Text;172 Contact. LastName:= EditSurname.Text;173 Contact. TelCell:= EditCellPhone.Text;174 Contact. TelHome:= EditPhoneHome.Text;175 Contact. TelWork:= EditPhoneWork.Text;176 Contact. EmailHome:= EditEmail.Text;177 Contact. Note:= MemoNotes.Lines.Text;178 Contact. Title:= EditTitle.Text;179 Contact. Organization:= EditOrganization.Text;180 Contact. AdrHome:= EditAddress.Text;181 Contact. EmailHome:= EditEmailHome.Text;198 Contact.Fields[cfFirstName] := EditName.Text; 199 Contact.Fields[cfLastName] := EditSurname.Text; 200 Contact.Fields[cfTelCell] := EditCellPhone.Text; 201 Contact.Fields[cfTelHome] := EditPhoneHome.Text; 202 Contact.Fields[cfTelWork] := EditPhoneWork.Text; 203 Contact.Fields[cfEmail] := EditEmail.Text; 204 Contact.Fields[cfNote] := MemoNotes.Lines.Text; 205 Contact.Fields[cfTitle] := EditTitle.Text; 206 Contact.Fields[cfOrganization] := EditOrganization.Text; 207 Contact.Fields[cfAdrHome] := EditAddress.Text; 208 Contact.Fields[cfEmailHome] := EditEmailHome.Text; 182 209 end; 183 210
Note:
See TracChangeset
for help on using the changeset viewer.