Changeset 45 for trunk/Forms
- Timestamp:
- Dec 2, 2021, 3:19:57 PM (3 years ago)
- Location:
- trunk/Forms
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormContact.lfm
r43 r45 25 25 object TabSheetGeneral: TTabSheet 26 26 Caption = 'General' 27 ClientHeight = 74 228 ClientWidth = 9 2927 ClientHeight = 744 28 ClientWidth = 931 29 29 OnShow = TabSheetGeneralShow 30 30 ParentFont = False 31 31 object Label1: TLabel 32 32 Left = 240 33 Height = 2 433 Height = 25 34 34 Top = 80 35 Width = 9435 Width = 86 36 36 Caption = 'First name:' 37 37 ParentColor = False … … 40 40 object EditFirstName: TEdit 41 41 Left = 360 42 Height = 4242 Height = 33 43 43 Top = 72 44 44 Width = 155 … … 48 48 object Label2: TLabel 49 49 Left = 16 50 Height = 2 450 Height = 25 51 51 Top = 250 52 Width = 6352 Width = 59 53 53 Caption = 'Mobile:' 54 54 ParentColor = False … … 57 57 object EditMobile: TEdit 58 58 Left = 144 59 Height = 4259 Height = 33 60 60 Top = 240 61 61 Width = 254 … … 65 65 object EditPhone: TEdit 66 66 Left = 144 67 Height = 4267 Height = 33 68 68 Top = 286 69 69 Width = 254 … … 73 73 object Label3: TLabel 74 74 Left = 16 75 Height = 2 475 Height = 25 76 76 Top = 290 77 Width = 5 977 Width = 54 78 78 Caption = 'Phone:' 79 79 ParentColor = False … … 82 82 object EditEmail: TEdit 83 83 Left = 144 84 Height = 4284 Height = 33 85 85 Top = 328 86 86 Width = 254 … … 90 90 object Label4: TLabel 91 91 Left = 16 92 Height = 2 492 Height = 25 93 93 Top = 336 94 Width = 5 894 Width = 53 95 95 Caption = 'E-mail:' 96 96 ParentColor = False … … 99 99 object EditLastName: TEdit 100 100 Left = 671 101 Height = 42101 Height = 33 102 102 Top = 72 103 103 Width = 155 … … 107 107 object Label5: TLabel 108 108 Left = 536 109 Height = 2 4109 Height = 25 110 110 Top = 80 111 Width = 8 7111 Width = 80 112 112 Caption = 'Last name' 113 113 ParentColor = False … … 116 116 object EditBirthday: TEdit 117 117 Left = 144 118 Height = 42118 Height = 33 119 119 Top = 424 120 120 Width = 254 … … 124 124 object Label22: TLabel 125 125 Left = 16 126 Height = 2 4126 Height = 25 127 127 Top = 432 128 Width = 76128 Width = 69 129 129 Caption = 'Birthday:' 130 130 ParentColor = False … … 136 136 Top = 16 137 137 Width = 207 138 PopupMenu = PopupMenuPhoto 138 139 Proportional = True 139 140 Stretch = True … … 141 142 object Label24: TLabel 142 143 Left = 240 143 Height = 2 4144 Height = 25 144 145 Top = 32 145 Width = 8 8146 Width = 80 146 147 Caption = 'Full name:' 147 148 ParentColor = False … … 150 151 object EditFullName: TEdit 151 152 Left = 360 152 Height = 42153 Height = 33 153 154 Top = 24 154 155 Width = 467 … … 158 159 object Label25: TLabel 159 160 Left = 536 160 Height = 2 4161 Height = 25 161 162 Top = 128 162 Width = 1 16163 Width = 108 163 164 Caption = 'Middle name:' 164 165 ParentColor = False … … 167 168 object EditMiddleName: TEdit 168 169 Left = 671 169 Height = 42170 Height = 33 170 171 Top = 120 171 172 Width = 155 … … 175 176 object Label26: TLabel 176 177 Left = 240 177 Height = 2 4178 Height = 25 178 179 Top = 176 179 Width = 101180 Width = 93 180 181 Caption = 'Title before:' 181 182 ParentColor = False … … 184 185 object EditTitleBefore: TEdit 185 186 Left = 360 186 Height = 42187 Height = 33 187 188 Top = 168 188 189 Width = 155 … … 192 193 object Label27: TLabel 193 194 Left = 536 194 Height = 2 4195 Height = 25 195 196 Top = 176 196 Width = 85197 Width = 77 197 198 Caption = 'Title after:' 198 199 ParentColor = False … … 201 202 object EditTitleAfter: TEdit 202 203 Left = 671 203 Height = 42204 Height = 33 204 205 Top = 168 205 206 Width = 155 … … 209 210 object Label44: TLabel 210 211 Left = 240 211 Height = 2 4212 Height = 25 212 213 Top = 128 213 Width = 91214 Width = 82 214 215 Caption = 'Nickname:' 215 216 ParentColor = False … … 218 219 object EditNickName: TEdit 219 220 Left = 360 220 Height = 42221 Height = 33 221 222 Top = 120 222 223 Width = 155 … … 226 227 object Label45: TLabel 227 228 Left = 432 228 Height = 2 4229 Height = 25 229 230 Top = 432 230 Width = 105231 Width = 96 231 232 Caption = 'Anniversary:' 232 233 ParentColor = False … … 235 236 object EditAniversary: TEdit 236 237 Left = 575 237 Height = 42238 Height = 33 238 239 Top = 424 239 240 Width = 254 … … 243 244 object Label9: TLabel 244 245 Left = 432 245 Height = 2 4246 Height = 25 246 247 Top = 248 247 Width = 34248 Width = 29 248 249 Caption = 'Fax:' 249 250 ParentColor = False … … 252 253 object EditFax: TEdit 253 254 Left = 575 254 Height = 42255 Height = 33 255 256 Top = 240 256 257 Width = 254 … … 260 261 object EditPager: TEdit 261 262 Left = 575 262 Height = 42263 Height = 33 263 264 Top = 286 264 265 Width = 254 … … 268 269 object Label10: TLabel 269 270 Left = 432 270 Height = 2 4271 Height = 25 271 272 Top = 290 272 Width = 54273 Width = 48 273 274 Caption = 'Pager:' 274 275 ParentColor = False … … 277 278 object Label46: TLabel 278 279 Left = 16 279 Height = 2 4280 Height = 25 280 281 Top = 384 281 Width = 1 14282 Width = 107 282 283 Caption = 'Web address:' 283 284 ParentColor = False … … 286 287 object EditWeb: TEdit 287 288 Left = 144 288 Height = 42289 Height = 33 289 290 Top = 376 290 291 Width = 683 … … 390 391 Anchors = [akTop, akLeft, akRight] 391 392 Caption = 'Address' 392 ClientHeight = 21 5393 ClientWidth = 88 8393 ClientHeight = 212 394 ClientWidth = 886 394 395 TabOrder = 6 395 396 object Label36: TLabel … … 611 612 Width = 911 612 613 Caption = 'Address' 613 ClientHeight = 2 20614 ClientWidth = 90 9614 ClientHeight = 217 615 ClientWidth = 907 615 616 TabOrder = 4 616 617 object Label31: TLabel … … 900 901 object ActionList1: TActionList 901 902 Images = Core.ImageList1 902 Left = 848 903 Top = 488 904 object AEditField: TAction 905 Caption = 'Edit' 903 Left = 592 904 Top = 528 905 object APhotoLoad: TAction 906 Caption = 'Load from file' 907 OnExecute = APhotoLoadExecute 908 end 909 object APhotoSave: TAction 910 Caption = 'Save to file' 911 OnExecute = APhotoSaveExecute 906 912 end 907 913 end 908 object PopupMenu 1: TPopupMenu914 object PopupMenuPhoto: TPopupMenu 909 915 Images = Core.ImageList1 910 Left = 856911 Top = 368916 Left = 408 917 Top = 528 912 918 object MenuItem1: TMenuItem 913 Action = AEditField 919 Action = APhotoLoad 920 end 921 object MenuItem2: TMenuItem 922 Action = APhotoSave 914 923 end 915 924 end 925 object OpenPictureDialog1: TOpenPictureDialog 926 Left = 197 927 Top = 535 928 end 929 object SavePictureDialog1: TSavePictureDialog 930 Left = 197 931 Top = 617 932 end 916 933 end -
trunk/Forms/UFormContact.lrj
r43 r45 57 57 {"hash":147653555,"name":"tformcontact.buttonprevious.caption","sourcebytes":[80,114,101,118,105,111,117,115],"value":"Previous"}, 58 58 {"hash":347380,"name":"tformcontact.buttonnext.caption","sourcebytes":[78,101,120,116],"value":"Next"}, 59 {"hash":310020,"name":"tformcontact.aeditfield.caption","sourcebytes":[69,100,105,116],"value":"Edit"} 59 {"hash":8431845,"name":"tformcontact.aphotoload.caption","sourcebytes":[76,111,97,100,32,102,114,111,109,32,102,105,108,101],"value":"Load from file"}, 60 {"hash":9308581,"name":"tformcontact.aphotosave.caption","sourcebytes":[83,97,118,101,32,116,111,32,102,105,108,101],"value":"Save to file"} 60 61 ]} -
trunk/Forms/UFormContact.pas
r43 r45 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, ActnList, Menus, ExtCtrls, UContact, UFormProperties;9 ComCtrls, ActnList, Menus, ExtCtrls, ExtDlgs, UContact, UFormProperties; 10 10 11 11 type … … 14 14 15 15 TFormContact = class(TForm) 16 AEditField: TAction; 16 APhotoSave: TAction; 17 APhotoLoad: TAction; 17 18 ActionList1: TActionList; 18 19 ButtonCancel: TButton; … … 114 115 MemoNotes: TMemo; 115 116 MenuItem1: TMenuItem; 117 MenuItem2: TMenuItem; 118 OpenPictureDialog1: TOpenPictureDialog; 116 119 PageControlContact: TPageControl; 117 PopupMenu1: TPopupMenu; 120 PopupMenuPhoto: TPopupMenu; 121 SavePictureDialog1: TSavePictureDialog; 118 122 TabSheetOthers: TTabSheet; 119 123 TabSheetHome: TTabSheet; … … 121 125 TabSheetGeneral: TTabSheet; 122 126 TabSheetAll: TTabSheet; 127 procedure APhotoLoadExecute(Sender: TObject); 128 procedure APhotoSaveExecute(Sender: TObject); 123 129 procedure ButtonNextClick(Sender: TObject); 124 130 procedure ButtonOkClick(Sender: TObject); … … 140 146 procedure LoadData; 141 147 procedure SaveData; 148 procedure UpdateInterface; 142 149 property Contact: TContact read FContact write SetContact; 143 150 property OnPrevious: TNotifyEvent read FOnPrevious write FOnPrevious; … … 166 173 FormProperties.Align := alClient; 167 174 FormProperties.Show; 175 UpdateInterface; 168 176 end; 169 177 … … 195 203 if FContact = AValue then Exit; 196 204 FContact := AValue; 197 LoadData;205 if Visible then LoadData; 198 206 end; 199 207 … … 212 220 begin 213 221 if Assigned(FOnNext) then FOnNext(Self); 222 end; 223 224 procedure TFormContact.APhotoLoadExecute(Sender: TObject); 225 begin 226 if OpenPictureDialog1.Execute then begin 227 ImagePhoto.Picture.LoadFromFile(OpenPictureDialog1.FileName); 228 end; 229 end; 230 231 procedure TFormContact.APhotoSaveExecute(Sender: TObject); 232 begin 233 if SavePictureDialog1.Execute then begin 234 ImagePhoto.Picture.SaveToFile(SavePictureDialog1.FileName); 235 end; 214 236 end; 215 237 … … 294 316 MemoNotes.Lines.Text := Contact.Fields[cfNote]; 295 317 318 // Photo 296 319 ImagePhoto.Picture.Bitmap.Clear; 297 320 PhotoProperty := Contact.GetProperty(cfPhoto); … … 326 349 end; 327 350 end; 351 UpdateInterface; 328 352 end; 329 353 330 354 procedure TFormContact.SaveData; 355 var 356 Photo: string; 357 PhotoProperty: TContactProperty; 358 Stream: TMemoryStream; 359 JpegImage: TJpegImage; 331 360 begin 332 361 // General … … 382 411 // Others 383 412 Contact.Fields[cfNote] := MemoNotes.Lines.Text; 413 414 // Photo 415 if (ImagePhoto.Picture.Bitmap.Width <> 0) and (ImagePhoto.Picture.Bitmap.Height <> 0) then begin 416 PhotoProperty := Contact.GetProperty(cfPhoto); 417 if not Assigned(PhotoProperty) then begin 418 PhotoProperty := TContactProperty.Create; 419 PhotoProperty.Name := 'PHOTO'; 420 PhotoProperty.Attributes.DelimitedText := 'JPEG'; 421 Contact.Properties.Add(PhotoProperty); 422 end; 423 PhotoProperty.Encoding := 'BASE64'; 424 Stream := TMemoryStream.Create; 425 try 426 if PhotoProperty.Attributes.IndexOf('JPEG') <> -1 then begin 427 JpegImage := TJPEGImage.Create; 428 try 429 try 430 JpegImage.SetSize(ImagePhoto.Picture.Bitmap.Width, ImagePhoto.Picture.Bitmap.Height); 431 JpegImage.Canvas.Draw(0, 0, ImagePhoto.Picture.Bitmap); 432 JpegImage.SaveToStream(Stream); 433 except 434 end; 435 finally 436 JpegImage.Free; 437 end; 438 end else begin 439 try 440 ImagePhoto.Picture.SaveToStream(Stream); 441 except 442 end; 443 end; 444 445 SetLength(Photo, Stream.Size); 446 Stream.Position := 0; 447 Stream.Read(Photo[1], Length(Photo)); 448 Contact.Fields[cfPhoto] := Photo; 449 finally 450 Stream.Free; 451 end; 452 end; 453 end; 454 455 procedure TFormContact.UpdateInterface; 456 begin 457 APhotoSave.Enabled := (ImagePhoto.Picture.Bitmap.Width <> 0) and 458 (ImagePhoto.Picture.Bitmap.Height <> 0); 384 459 end; 385 460
Note:
See TracChangeset
for help on using the changeset viewer.