Changeset 49 for trunk/Forms/UFormContact.pas
- Timestamp:
- Dec 3, 2021, 6:52:12 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormContact.pas
r48 r49 14 14 15 15 TFormContact = class(TForm) 16 APhotoClear: TAction; 16 17 APhotoSave: TAction; 17 18 APhotoLoad: TAction; … … 116 117 MenuItem1: TMenuItem; 117 118 MenuItem2: TMenuItem; 119 MenuItem3: TMenuItem; 118 120 OpenPictureDialog1: TOpenPictureDialog; 119 121 PageControlContact: TPageControl; … … 125 127 TabSheetGeneral: TTabSheet; 126 128 TabSheetAll: TTabSheet; 129 procedure APhotoClearExecute(Sender: TObject); 127 130 procedure APhotoLoadExecute(Sender: TObject); 128 131 procedure APhotoSaveExecute(Sender: TObject); … … 143 146 procedure TabSheetWorkShow(Sender: TObject); 144 147 private 148 FProfilePhotoActive: Boolean; 149 procedure SetProfilePhotoActive(AValue: Boolean); 150 private 145 151 FContact: TContact; 146 152 FOnNext: TNotifyEvent; 147 153 FOnPrevious: TNotifyEvent; 148 154 FormProperties: TFormProperties; 149 ProfilePhotoActive: Boolean;150 procedure DefaultPhoto;151 155 procedure SetContact(AValue: TContact); 152 156 procedure ReloadAllPropertiesTab; 157 property ProfilePhotoActive: Boolean read FProfilePhotoActive 158 write SetProfilePhotoActive; 153 159 public 154 160 procedure UpdateInterface; … … 178 184 FormProperties.Align := alClient; 179 185 FormProperties.Show; 186 187 // Force to load default profile image 188 ProfilePhotoActive := True; 189 ProfilePhotoActive := False; 190 191 PageControlContact.TabIndex := Core.LastContactTabIndex; 180 192 UpdateInterface; 181 193 end; … … 249 261 Stream.Free; 250 262 end; 263 end else begin 264 PhotoProperty := Contact.GetProperty(cfPhoto); 265 if Assigned(PhotoProperty) then 266 Contact.Properties.Remove(PhotoProperty); 251 267 end; 252 268 … … 278 294 279 295 // Photo 280 ImagePhoto.Picture.Bitmap.Clear;281 296 PhotoProperty := Contact.GetProperty(cfPhoto); 282 297 if Assigned(PhotoProperty) then begin … … 292 307 try 293 308 JpegImage.LoadFromStream(Stream); 309 ImagePhoto.Picture.Bitmap.Clear; 294 310 ImagePhoto.Picture.Bitmap.SetSize(JpegImage.Width, JpegImage.Height); 295 311 ImagePhoto.Picture.Bitmap.Canvas.Draw(0, 0, JpegImage); 296 312 ProfilePhotoActive := True; 297 313 except 298 DefaultPhoto;314 ProfilePhotoActive := False; 299 315 end; 300 316 finally … … 306 322 ProfilePhotoActive := True; 307 323 except 308 DefaultPhoto;324 ProfilePhotoActive := False; 309 325 end; 310 326 end; … … 312 328 Stream.Free; 313 329 end; 314 end else DefaultPhoto;315 end else DefaultPhoto;330 end else ProfilePhotoActive := False; 331 end else ProfilePhotoActive := False; 316 332 end; 317 333 … … 406 422 end; 407 423 408 procedure TFormContact.DefaultPhoto; 409 begin 410 ProfilePhotoActive := False; 411 ImagePhoto.Picture.Assign(Core.GetProfileImage.Picture); 424 procedure TFormContact.SetProfilePhotoActive(AValue: Boolean); 425 begin 426 if FProfilePhotoActive = AValue then Exit; 427 FProfilePhotoActive := AValue; 428 if not FProfilePhotoActive then begin 429 ImagePhoto.Picture.Assign(Core.GetProfileImage.Picture); 430 end; 431 UpdateInterface; 412 432 end; 413 433 … … 428 448 ); 429 449 begin 450 // Hide PageControl to fire TabSheet OnHide event on form close 451 PageControlContact.ActivePage.Hide; 452 453 Core.LastContactTabIndex := PageControlContact.TabIndex; 430 454 Core.PersistentForm1.Save(Self); 431 455 end; … … 440 464 if OpenPictureDialog1.Execute then begin 441 465 ImagePhoto.Picture.LoadFromFile(OpenPictureDialog1.FileName); 466 ProfilePhotoActive := True; 442 467 end; 468 end; 469 470 procedure TFormContact.APhotoClearExecute(Sender: TObject); 471 begin 472 ProfilePhotoActive := False; 443 473 end; 444 474 … … 471 501 begin 472 502 APhotoSave.Enabled := ProfilePhotoActive; 503 APhotoClear.Enabled := ProfilePhotoActive; 473 504 end; 474 505
Note:
See TracChangeset
for help on using the changeset viewer.