Changeset 47 for trunk/Forms


Ignore:
Timestamp:
Dec 3, 2021, 12:13:51 PM (3 years ago)
Author:
chronos
Message:
  • Modified: Optimize loading/saving values in contact form. Load/save only form fields from active tab.
Location:
trunk/Forms
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContact.lfm

    r45 r47  
    2525    object TabSheetGeneral: TTabSheet
    2626      Caption = 'General'
    27       ClientHeight = 744
    28       ClientWidth = 931
     27      ClientHeight = 742
     28      ClientWidth = 929
     29      OnHide = TabSheetGeneralHide
    2930      OnShow = TabSheetGeneralShow
    3031      ParentFont = False
    3132      object Label1: TLabel
    3233        Left = 240
    33         Height = 25
     34        Height = 24
    3435        Top = 80
    35         Width = 86
     36        Width = 94
    3637        Caption = 'First name:'
    3738        ParentColor = False
     
    4041      object EditFirstName: TEdit
    4142        Left = 360
    42         Height = 33
     43        Height = 42
    4344        Top = 72
    4445        Width = 155
     
    4849      object Label2: TLabel
    4950        Left = 16
    50         Height = 25
     51        Height = 24
    5152        Top = 250
    52         Width = 59
     53        Width = 63
    5354        Caption = 'Mobile:'
    5455        ParentColor = False
     
    5758      object EditMobile: TEdit
    5859        Left = 144
    59         Height = 33
     60        Height = 42
    6061        Top = 240
    6162        Width = 254
     
    6566      object EditPhone: TEdit
    6667        Left = 144
    67         Height = 33
     68        Height = 42
    6869        Top = 286
    6970        Width = 254
     
    7374      object Label3: TLabel
    7475        Left = 16
    75         Height = 25
     76        Height = 24
    7677        Top = 290
    77         Width = 54
     78        Width = 59
    7879        Caption = 'Phone:'
    7980        ParentColor = False
     
    8283      object EditEmail: TEdit
    8384        Left = 144
    84         Height = 33
     85        Height = 42
    8586        Top = 328
    8687        Width = 254
     
    9091      object Label4: TLabel
    9192        Left = 16
    92         Height = 25
     93        Height = 24
    9394        Top = 336
    94         Width = 53
     95        Width = 58
    9596        Caption = 'E-mail:'
    9697        ParentColor = False
     
    99100      object EditLastName: TEdit
    100101        Left = 671
    101         Height = 33
     102        Height = 42
    102103        Top = 72
    103104        Width = 155
     
    107108      object Label5: TLabel
    108109        Left = 536
    109         Height = 25
     110        Height = 24
    110111        Top = 80
    111         Width = 80
     112        Width = 87
    112113        Caption = 'Last name'
    113114        ParentColor = False
     
    116117      object EditBirthday: TEdit
    117118        Left = 144
    118         Height = 33
     119        Height = 42
    119120        Top = 424
    120121        Width = 254
     
    124125      object Label22: TLabel
    125126        Left = 16
    126         Height = 25
     127        Height = 24
    127128        Top = 432
    128         Width = 69
     129        Width = 76
    129130        Caption = 'Birthday:'
    130131        ParentColor = False
     
    142143      object Label24: TLabel
    143144        Left = 240
    144         Height = 25
     145        Height = 24
    145146        Top = 32
    146         Width = 80
     147        Width = 88
    147148        Caption = 'Full name:'
    148149        ParentColor = False
     
    151152      object EditFullName: TEdit
    152153        Left = 360
    153         Height = 33
     154        Height = 42
    154155        Top = 24
    155156        Width = 467
     
    159160      object Label25: TLabel
    160161        Left = 536
    161         Height = 25
     162        Height = 24
    162163        Top = 128
    163         Width = 108
     164        Width = 116
    164165        Caption = 'Middle name:'
    165166        ParentColor = False
     
    168169      object EditMiddleName: TEdit
    169170        Left = 671
    170         Height = 33
     171        Height = 42
    171172        Top = 120
    172173        Width = 155
     
    176177      object Label26: TLabel
    177178        Left = 240
    178         Height = 25
     179        Height = 24
    179180        Top = 176
    180         Width = 93
     181        Width = 101
    181182        Caption = 'Title before:'
    182183        ParentColor = False
     
    185186      object EditTitleBefore: TEdit
    186187        Left = 360
    187         Height = 33
     188        Height = 42
    188189        Top = 168
    189190        Width = 155
     
    193194      object Label27: TLabel
    194195        Left = 536
    195         Height = 25
     196        Height = 24
    196197        Top = 176
    197         Width = 77
     198        Width = 85
    198199        Caption = 'Title after:'
    199200        ParentColor = False
     
    202203      object EditTitleAfter: TEdit
    203204        Left = 671
    204         Height = 33
     205        Height = 42
    205206        Top = 168
    206207        Width = 155
     
    210211      object Label44: TLabel
    211212        Left = 240
    212         Height = 25
     213        Height = 24
    213214        Top = 128
    214         Width = 82
     215        Width = 91
    215216        Caption = 'Nickname:'
    216217        ParentColor = False
     
    219220      object EditNickName: TEdit
    220221        Left = 360
    221         Height = 33
     222        Height = 42
    222223        Top = 120
    223224        Width = 155
     
    227228      object Label45: TLabel
    228229        Left = 432
    229         Height = 25
     230        Height = 24
    230231        Top = 432
    231         Width = 96
     232        Width = 105
    232233        Caption = 'Anniversary:'
    233234        ParentColor = False
     
    236237      object EditAniversary: TEdit
    237238        Left = 575
    238         Height = 33
     239        Height = 42
    239240        Top = 424
    240241        Width = 254
     
    244245      object Label9: TLabel
    245246        Left = 432
    246         Height = 25
     247        Height = 24
    247248        Top = 248
    248         Width = 29
     249        Width = 34
    249250        Caption = 'Fax:'
    250251        ParentColor = False
     
    253254      object EditFax: TEdit
    254255        Left = 575
    255         Height = 33
     256        Height = 42
    256257        Top = 240
    257258        Width = 254
     
    261262      object EditPager: TEdit
    262263        Left = 575
    263         Height = 33
     264        Height = 42
    264265        Top = 286
    265266        Width = 254
     
    269270      object Label10: TLabel
    270271        Left = 432
    271         Height = 25
     272        Height = 24
    272273        Top = 290
    273         Width = 48
     274        Width = 54
    274275        Caption = 'Pager:'
    275276        ParentColor = False
     
    278279      object Label46: TLabel
    279280        Left = 16
    280         Height = 25
     281        Height = 24
    281282        Top = 384
    282         Width = 107
     283        Width = 114
    283284        Caption = 'Web address:'
    284285        ParentColor = False
     
    287288      object EditWeb: TEdit
    288289        Left = 144
    289         Height = 33
     290        Height = 42
    290291        Top = 376
    291292        Width = 683
     
    298299      ClientHeight = 742
    299300      ClientWidth = 929
    300       OnShow = TabSheetGeneralShow
     301      OnHide = TabSheetHomeHide
     302      OnShow = TabSheetHomeShow
    301303      ParentFont = False
    302304      object Label7: TLabel
     
    391393        Anchors = [akTop, akLeft, akRight]
    392394        Caption = 'Address'
    393         ClientHeight = 212
    394         ClientWidth = 886
     395        ClientHeight = 215
     396        ClientWidth = 888
    395397        TabOrder = 6
    396398        object Label36: TLabel
     
    537539      ClientHeight = 742
    538540      ClientWidth = 929
    539       OnShow = TabSheetGeneralShow
     541      OnHide = TabSheetWorkHide
     542      OnShow = TabSheetWorkShow
    540543      object EditOrganization: TEdit
    541544        Left = 173
     
    612615        Width = 911
    613616        Caption = 'Address'
    614         ClientHeight = 217
    615         ClientWidth = 907
     617        ClientHeight = 220
     618        ClientWidth = 909
    616619        TabOrder = 4
    617620        object Label31: TLabel
     
    825828      ClientHeight = 742
    826829      ClientWidth = 929
     830      OnHide = TabSheetOthersHide
     831      OnShow = TabSheetOthersShow
    827832      object MemoNotes: TMemo
    828833        Left = 16
     
    871876    Caption = 'OK'
    872877    ModalResult = 1
    873     OnClick = ButtonOkClick
    874878    ParentFont = False
    875879    TabOrder = 2
  • trunk/Forms/UFormContact.pas

    r45 r47  
    128128    procedure APhotoSaveExecute(Sender: TObject);
    129129    procedure ButtonNextClick(Sender: TObject);
    130     procedure ButtonOkClick(Sender: TObject);
    131130    procedure ButtonPreviousClick(Sender: TObject);
    132131    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     
    134133    procedure FormDestroy(Sender: TObject);
    135134    procedure FormShow(Sender: TObject);
    136     procedure ListView1Data(Sender: TObject; Item: TListItem);
    137135    procedure TabSheetAllShow(Sender: TObject);
     136    procedure TabSheetGeneralHide(Sender: TObject);
    138137    procedure TabSheetGeneralShow(Sender: TObject);
     138    procedure TabSheetHomeHide(Sender: TObject);
     139    procedure TabSheetHomeShow(Sender: TObject);
     140    procedure TabSheetOthersHide(Sender: TObject);
     141    procedure TabSheetOthersShow(Sender: TObject);
     142    procedure TabSheetWorkHide(Sender: TObject);
     143    procedure TabSheetWorkShow(Sender: TObject);
    139144  private
    140145    FContact: TContact;
     
    143148    FormProperties: TFormProperties;
    144149    procedure SetContact(AValue: TContact);
     150    procedure ReloadAllPropertiesTab;
    145151  public
    146     procedure LoadData;
    147     procedure SaveData;
    148152    procedure UpdateInterface;
    149153    property Contact: TContact read FContact write SetContact;
     
    168172begin
    169173  Core.PersistentForm1.Load(Self);
    170   PageControlContact.TabIndex := 0;
    171174
    172175  FormProperties.ManualDock(TabSheetAll, nil, alClient);
     
    176179end;
    177180
    178 procedure TFormContact.ListView1Data(Sender: TObject; Item: TListItem);
    179 begin
    180   if Item.Index < Contact.Properties.Count then
    181   with Contact.Properties[Item.Index] do begin
    182     Item.Caption := Contact.Properties[Item.Index].Name;
    183     Item.SubItems.Add(Attributes.DelimitedText);
    184     Item.SubItems.Add(Contact.Properties[Item.Index].Value);
    185     Item.Data := Contact.Properties[Item.Index];
    186   end;
    187 end;
    188 
    189181procedure TFormContact.TabSheetAllShow(Sender: TObject);
    190182begin
    191   SaveData;
     183  FormProperties.Properties := Contact.Properties;
    192184  FormProperties.ReloadList;
    193185  FormProperties.UpdateInterface;
    194186end;
    195187
     188procedure TFormContact.TabSheetGeneralHide(Sender: TObject);
     189var
     190  Photo: string;
     191  PhotoProperty: TContactProperty;
     192  Stream: TMemoryStream;
     193  JpegImage: TJpegImage;
     194begin
     195  Contact.Fields[cfFullName] := EditFullName.Text;
     196  Contact.Fields[cfMiddleName] := EditMiddleName.Text;
     197  Contact.Fields[cfFirstName] := EditFirstName.Text;
     198  Contact.Fields[cfLastName] := EditLastName.Text;
     199  Contact.Fields[cfTitleAfter] := EditTitleAfter.Text;
     200  Contact.Fields[cfTitleBefore] := EditTitleBefore.Text;
     201  Contact.Fields[cfNickName] := EditNickName.Text;
     202  Contact.Fields[cfEmail] := EditEmail.Text;
     203  Contact.Fields[cfTel] := EditPhone.Text;
     204  Contact.Fields[cfTelCell] := EditMobile.Text;
     205  Contact.Fields[cfTelFax] := EditFax.Text;
     206  Contact.Fields[cfTelPager] := EditPager.Text;
     207  Contact.Fields[cfDayOfBirth] := EditBirthday.Text;
     208  Contact.Fields[cfAnniversary] := EditAniversary.Text;
     209  Contact.Fields[cfUrl] := EditWeb.Text;
     210
     211  // Photo
     212  if (ImagePhoto.Picture.Bitmap.Width <> 0) and (ImagePhoto.Picture.Bitmap.Height <> 0) then begin
     213    PhotoProperty := Contact.GetProperty(cfPhoto);
     214    if not Assigned(PhotoProperty) then begin
     215      PhotoProperty := TContactProperty.Create;
     216      PhotoProperty.Name := 'PHOTO';
     217      PhotoProperty.Attributes.DelimitedText := 'JPEG';
     218      Contact.Properties.Add(PhotoProperty);
     219    end;
     220    PhotoProperty.Encoding := 'BASE64';
     221    Stream := TMemoryStream.Create;
     222    try
     223      if PhotoProperty.Attributes.IndexOf('JPEG') <> -1 then begin
     224        JpegImage := TJPEGImage.Create;
     225        try
     226          try
     227            JpegImage.SetSize(ImagePhoto.Picture.Bitmap.Width, ImagePhoto.Picture.Bitmap.Height);
     228            JpegImage.Canvas.Draw(0, 0, ImagePhoto.Picture.Bitmap);
     229            JpegImage.SaveToStream(Stream);
     230          except
     231          end;
     232        finally
     233          JpegImage.Free;
     234        end;
     235      end else begin
     236        try
     237          ImagePhoto.Picture.SaveToStream(Stream);
     238        except
     239        end;
     240      end;
     241
     242      SetLength(Photo, Stream.Size);
     243      Stream.Position := 0;
     244      Stream.Read(Photo[1], Length(Photo));
     245      Contact.Fields[cfPhoto] := Photo;
     246    finally
     247      Stream.Free;
     248    end;
     249  end;
     250
     251  ReloadAllPropertiesTab;
     252end;
     253
    196254procedure TFormContact.TabSheetGeneralShow(Sender: TObject);
    197 begin
    198   LoadData;
    199 end;
    200 
    201 procedure TFormContact.SetContact(AValue: TContact);
    202 begin
    203   if FContact = AValue then Exit;
    204   FContact := AValue;
    205   if Visible then LoadData;
    206 end;
    207 
    208 procedure TFormContact.FormClose(Sender: TObject; var CloseAction: TCloseAction
    209   );
    210 begin
    211   Core.PersistentForm1.Save(Self);
    212 end;
    213 
    214 procedure TFormContact.ButtonOkClick(Sender: TObject);
    215 begin
    216   SaveData;
    217 end;
    218 
    219 procedure TFormContact.ButtonNextClick(Sender: TObject);
    220 begin
    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;
    236 end;
    237 
    238 procedure TFormContact.ButtonPreviousClick(Sender: TObject);
    239 begin
    240   if Assigned(FOnPrevious) then FOnPrevious(Self);
    241 end;
    242 
    243 procedure TFormContact.FormCreate(Sender: TObject);
    244 begin
    245   Core.Translator.TranslateComponentRecursive(Self);
    246   Core.ThemeManager1.UseTheme(Self);
    247   FContact := nil;
    248   FormProperties := TFormProperties.Create(nil);
    249 end;
    250 
    251 procedure TFormContact.FormDestroy(Sender: TObject);
    252 begin
    253   FreeAndNil(FormProperties);
    254 end;
    255 
    256 procedure TFormContact.LoadData;
    257255var
    258256  Photo: string;
     
    261259  PhotoProperty: TContactProperty;
    262260begin
    263   FormProperties.Properties := Contact.Properties;
    264 
    265   // General
    266261  EditFullName.Text := Contact.Fields[cfFullName];
    267262  EditFirstName.Text := Contact.Fields[cfFirstName];
     
    279274  EditAniversary.Text := Contact.Fields[cfAnniversary];
    280275  EditWeb.Text := Contact.Fields[cfUrl];
    281 
    282   // Home
    283   EditHomeEmail.Text := Contact.Fields[cfEmailHome];
    284   EditHomePhone.Text := Contact.Fields[cfTelHome];
    285   EditHomeMobile.Text := Contact.Fields[cfTelCellHome];
    286   EditHomeFax.Text := Contact.Fields[cfTelFaxHome];
    287   EditHomePager.Text := Contact.Fields[cfTelPagerHome];
    288   EditHomeAddressPostOfficeBox.Text := Contact.Fields[cfHomeAddressPostOfficeBox];
    289   EditHomeAddressStreet.Text := Contact.Fields[cfHomeAddressStreet];
    290   EditHomeAddressStreetExtended.Text := Contact.Fields[cfHomeAddressStreetExtended];
    291   EditHomeAddressCity.Text := Contact.Fields[cfHomeAddressCity];
    292   EditHomeAddressRegion.Text := Contact.Fields[cfHomeAddressRegion];
    293   EditHomeAddressCountry.Text := Contact.Fields[cfHomeAddressCountry];
    294   EditHomeAddressPostalCode.Text := Contact.Fields[cfHomeAddressPostalCode];
    295   EditHomeWeb.Text := Contact.Fields[cfUrlHome];
    296 
    297   // Work
    298   EditWorkEmail.Text := Contact.Fields[cfEmailWork];
    299   EditWorkPhone.Text := Contact.Fields[cfTelWork];
    300   EditWorkMobile.Text := Contact.Fields[cfTelCellWork];
    301   EditWorkFax.Text := Contact.Fields[cfTelFaxWork];
    302   EditWorkPager.Text := Contact.Fields[cfTelPagerWork];
    303   EditTitle.Text := Contact.Fields[cfTitle];
    304   EditOrganization.Text := Contact.Fields[cfOrganization];
    305   EditDepartment.Text := Contact.Fields[cfDepartment];
    306   EditAddressWorkPostOfficeBox.Text := Contact.Fields[cfWorkAddressPostOfficeBox];
    307   EditAddressWorkStreet.Text := Contact.Fields[cfWorkAddressStreet];
    308   EditAddressWorkStreetExtended.Text := Contact.Fields[cfWorkAddressStreetExtended];
    309   EditAddressWorkCity.Text := Contact.Fields[cfWorkAddressCity];
    310   EditAddressWorkRegion.Text := Contact.Fields[cfWorkAddressRegion];
    311   EditAddressWorkCountry.Text := Contact.Fields[cfWorkAddressCountry];
    312   EditAddressWorkPostalCode.Text := Contact.Fields[cfWorkAddressPostalCode];
    313   EditWorkWeb.Text := Contact.Fields[cfUrlWork];
    314 
    315   // Others
    316   MemoNotes.Lines.Text := Contact.Fields[cfNote];
    317276
    318277  // Photo
     
    349308    end;
    350309  end;
    351   UpdateInterface;
    352 end;
    353 
    354 procedure TFormContact.SaveData;
    355 var
    356   Photo: string;
    357   PhotoProperty: TContactProperty;
    358   Stream: TMemoryStream;
    359   JpegImage: TJpegImage;
    360 begin
    361   // General
    362   Contact.Fields[cfFullName] := EditFullName.Text;
    363   Contact.Fields[cfMiddleName] := EditMiddleName.Text;
    364   Contact.Fields[cfFirstName] := EditFirstName.Text;
    365   Contact.Fields[cfLastName] := EditLastName.Text;
    366   Contact.Fields[cfTitleAfter] := EditTitleAfter.Text;
    367   Contact.Fields[cfTitleBefore] := EditTitleBefore.Text;
    368   Contact.Fields[cfNickName] := EditNickName.Text;
    369   Contact.Fields[cfEmail] := EditEmail.Text;
    370   Contact.Fields[cfTel] := EditPhone.Text;
    371   Contact.Fields[cfTelCell] := EditMobile.Text;
    372   Contact.Fields[cfTelFax] := EditFax.Text;
    373   Contact.Fields[cfTelPager] := EditPager.Text;
    374   Contact.Fields[cfDayOfBirth] := EditBirthday.Text;
    375   Contact.Fields[cfAnniversary] := EditAniversary.Text;
    376   Contact.Fields[cfUrl] := EditWeb.Text;
    377 
    378   // Home
     310end;
     311
     312procedure TFormContact.TabSheetHomeHide(Sender: TObject);
     313begin
    379314  Contact.Fields[cfEmailHome] := EditHomeEmail.Text;
    380315  Contact.Fields[cfTelHome] := EditHomePhone.Text;
     
    391326  Contact.Fields[cfUrlHome] := EditHomeWeb.Text;
    392327
    393   // Work
     328  ReloadAllPropertiesTab;
     329end;
     330
     331procedure TFormContact.TabSheetHomeShow(Sender: TObject);
     332begin
     333  EditHomeEmail.Text := Contact.Fields[cfEmailHome];
     334  EditHomePhone.Text := Contact.Fields[cfTelHome];
     335  EditHomeMobile.Text := Contact.Fields[cfTelCellHome];
     336  EditHomeFax.Text := Contact.Fields[cfTelFaxHome];
     337  EditHomePager.Text := Contact.Fields[cfTelPagerHome];
     338  EditHomeAddressPostOfficeBox.Text := Contact.Fields[cfHomeAddressPostOfficeBox];
     339  EditHomeAddressStreet.Text := Contact.Fields[cfHomeAddressStreet];
     340  EditHomeAddressStreetExtended.Text := Contact.Fields[cfHomeAddressStreetExtended];
     341  EditHomeAddressCity.Text := Contact.Fields[cfHomeAddressCity];
     342  EditHomeAddressRegion.Text := Contact.Fields[cfHomeAddressRegion];
     343  EditHomeAddressCountry.Text := Contact.Fields[cfHomeAddressCountry];
     344  EditHomeAddressPostalCode.Text := Contact.Fields[cfHomeAddressPostalCode];
     345  EditHomeWeb.Text := Contact.Fields[cfUrlHome];
     346end;
     347
     348procedure TFormContact.TabSheetOthersHide(Sender: TObject);
     349begin
     350  Contact.Fields[cfNote] := MemoNotes.Lines.Text;
     351
     352  ReloadAllPropertiesTab;
     353end;
     354
     355procedure TFormContact.TabSheetOthersShow(Sender: TObject);
     356begin
     357  MemoNotes.Lines.Text := Contact.Fields[cfNote];
     358end;
     359
     360procedure TFormContact.TabSheetWorkHide(Sender: TObject);
     361begin
    394362  Contact.Fields[cfEmailWork] := EditWorkEmail.Text;
    395363  Contact.Fields[cfTelWork] := EditWorkPhone.Text;
     
    409377  Contact.Fields[cfUrlWork] := EditWorkWeb.Text;
    410378
    411   // Others
    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;
     379  ReloadAllPropertiesTab;
     380end;
     381
     382procedure TFormContact.TabSheetWorkShow(Sender: TObject);
     383begin
     384  EditWorkEmail.Text := Contact.Fields[cfEmailWork];
     385  EditWorkPhone.Text := Contact.Fields[cfTelWork];
     386  EditWorkMobile.Text := Contact.Fields[cfTelCellWork];
     387  EditWorkFax.Text := Contact.Fields[cfTelFaxWork];
     388  EditWorkPager.Text := Contact.Fields[cfTelPagerWork];
     389  EditTitle.Text := Contact.Fields[cfTitle];
     390  EditOrganization.Text := Contact.Fields[cfOrganization];
     391  EditDepartment.Text := Contact.Fields[cfDepartment];
     392  EditAddressWorkPostOfficeBox.Text := Contact.Fields[cfWorkAddressPostOfficeBox];
     393  EditAddressWorkStreet.Text := Contact.Fields[cfWorkAddressStreet];
     394  EditAddressWorkStreetExtended.Text := Contact.Fields[cfWorkAddressStreetExtended];
     395  EditAddressWorkCity.Text := Contact.Fields[cfWorkAddressCity];
     396  EditAddressWorkRegion.Text := Contact.Fields[cfWorkAddressRegion];
     397  EditAddressWorkCountry.Text := Contact.Fields[cfWorkAddressCountry];
     398  EditAddressWorkPostalCode.Text := Contact.Fields[cfWorkAddressPostalCode];
     399  EditWorkWeb.Text := Contact.Fields[cfUrlWork];
     400end;
     401
     402procedure TFormContact.SetContact(AValue: TContact);
     403begin
     404  if FContact = AValue then Exit;
     405  FContact := AValue;
     406end;
     407
     408procedure TFormContact.ReloadAllPropertiesTab;
     409begin
     410  if TabSheetAll.Visible then begin
     411    TabSheetAllShow(nil);
     412  end;
     413end;
     414
     415procedure TFormContact.FormClose(Sender: TObject; var CloseAction: TCloseAction
     416  );
     417begin
     418  Core.PersistentForm1.Save(Self);
     419end;
     420
     421procedure TFormContact.ButtonNextClick(Sender: TObject);
     422begin
     423  if Assigned(FOnNext) then FOnNext(Self);
     424end;
     425
     426procedure TFormContact.APhotoLoadExecute(Sender: TObject);
     427begin
     428  if OpenPictureDialog1.Execute then begin
     429    ImagePhoto.Picture.LoadFromFile(OpenPictureDialog1.FileName);
     430  end;
     431end;
     432
     433procedure TFormContact.APhotoSaveExecute(Sender: TObject);
     434begin
     435  if SavePictureDialog1.Execute then begin
     436    ImagePhoto.Picture.SaveToFile(SavePictureDialog1.FileName);
     437  end;
     438end;
     439
     440procedure TFormContact.ButtonPreviousClick(Sender: TObject);
     441begin
     442  if Assigned(FOnPrevious) then FOnPrevious(Self);
     443end;
     444
     445procedure TFormContact.FormCreate(Sender: TObject);
     446begin
     447  Core.Translator.TranslateComponentRecursive(Self);
     448  Core.ThemeManager1.UseTheme(Self);
     449  FContact := nil;
     450  FormProperties := TFormProperties.Create(nil);
     451end;
     452
     453procedure TFormContact.FormDestroy(Sender: TObject);
     454begin
     455  FreeAndNil(FormProperties);
    453456end;
    454457
Note: See TracChangeset for help on using the changeset viewer.