1 | unit FormNormalize;
|
---|
2 |
|
---|
3 | {$mode Delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, RegistryEx,
|
---|
9 | FormEx;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormNormalize }
|
---|
14 |
|
---|
15 | TFormNormalize = class(TFormEx)
|
---|
16 | ButtonCancel: TButton;
|
---|
17 | ButtonProcess: TButton;
|
---|
18 | CheckBoxAddPhonePrefix: TCheckBox;
|
---|
19 | CheckBoxRemoveExactDuplicates: TCheckBox;
|
---|
20 | CheckBoxRemovePhotos: TCheckBox;
|
---|
21 | CheckBoxRemovePhoneSpaces: TCheckBox;
|
---|
22 | CheckBoxConvertInternationaCallPrefixToCountryCode: TCheckBox;
|
---|
23 | EditPhoneCountryCode: TEdit;
|
---|
24 | EditPhoneInternationalCallPrefix: TEdit;
|
---|
25 | ScrollBox1: TScrollBox;
|
---|
26 | procedure ButtonProcessClick(Sender: TObject);
|
---|
27 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
28 | procedure FormShow(Sender: TObject);
|
---|
29 | private
|
---|
30 | procedure LoadConfig;
|
---|
31 | procedure SaveConfig;
|
---|
32 | end;
|
---|
33 |
|
---|
34 | implementation
|
---|
35 |
|
---|
36 | {$R *.lfm}
|
---|
37 |
|
---|
38 | uses
|
---|
39 | Core, VCardFile, VCardProcessor;
|
---|
40 |
|
---|
41 | { TFormNormalize }
|
---|
42 |
|
---|
43 | procedure TFormNormalize.FormClose(Sender: TObject;
|
---|
44 | var CloseAction: TCloseAction);
|
---|
45 | begin
|
---|
46 | SaveConfig;
|
---|
47 | end;
|
---|
48 |
|
---|
49 | procedure TFormNormalize.ButtonProcessClick(Sender: TObject);
|
---|
50 | var
|
---|
51 | VCardProcessor: TVCardProcessor;
|
---|
52 | begin
|
---|
53 | VCardProcessor := TVCardProcessor.Create(nil);
|
---|
54 | with VCardProcessor do
|
---|
55 | try
|
---|
56 | RemovePhoneSpaces := CheckBoxRemovePhoneSpaces.Checked;
|
---|
57 | AddDefaultPhoneCountryPrefix := CheckBoxAddPhonePrefix.Checked;
|
---|
58 | DefaultPhoneCountryCode := Core.Core.DefaultPhoneCountryCode;
|
---|
59 | ConvertInternationalCallPrefixToCountryCode := CheckBoxConvertInternationaCallPrefixToCountryCode.Checked;
|
---|
60 | DefaultInternationalCallPrefix := Core.Core.DefaultInternationalCallPrefix;
|
---|
61 | RemoveExactDuplicates := CheckBoxRemoveExactDuplicates.Checked;
|
---|
62 | RemovePhotos := CheckBoxRemovePhotos.Checked;
|
---|
63 | Process(TVCardFile(Core.Core.DataFile).VCard);
|
---|
64 | finally
|
---|
65 | Free;
|
---|
66 | end;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | procedure TFormNormalize.FormShow(Sender: TObject);
|
---|
70 | begin
|
---|
71 | LoadConfig;
|
---|
72 | end;
|
---|
73 |
|
---|
74 | procedure TFormNormalize.LoadConfig;
|
---|
75 | begin
|
---|
76 | EditPhoneCountryCode.Text := Core.Core.DefaultPhoneCountryCode;
|
---|
77 | EditPhoneInternationalCallPrefix.Text := Core.Core.DefaultInternationalCallPrefix;
|
---|
78 | with TRegistryEx.Create do
|
---|
79 | try
|
---|
80 | CurrentContext := Core.Core.ApplicationInfo1.GetRegistryContext;
|
---|
81 | CheckBoxAddPhonePrefix.Checked := ReadBoolWithDefault('AddPhonePrefix', False);
|
---|
82 | CheckBoxRemovePhoneSpaces.Checked := ReadBoolWithDefault('RemovePhoneSpaces', False);
|
---|
83 | CheckBoxRemoveExactDuplicates.Checked := ReadBoolWithDefault('RemoveExactDuplicates', False);
|
---|
84 | CheckBoxRemovePhotos.Checked := ReadBoolWithDefault('RemovePhotos', False);
|
---|
85 | CheckBoxConvertInternationaCallPrefixToCountryCode.Checked := ReadBoolWithDefault('ConvertInternationaCallPrefixToCountryCode', False);
|
---|
86 | finally
|
---|
87 | Free;
|
---|
88 | end;
|
---|
89 | end;
|
---|
90 |
|
---|
91 | procedure TFormNormalize.SaveConfig;
|
---|
92 | begin
|
---|
93 | Core.Core.DefaultPhoneCountryCode := EditPhoneCountryCode.Text;
|
---|
94 | Core.Core.DefaultInternationalCallPrefix := EditPhoneInternationalCallPrefix.Text;
|
---|
95 | with TRegistryEx.Create do
|
---|
96 | try
|
---|
97 | CurrentContext := Core.Core.ApplicationInfo1.GetRegistryContext;
|
---|
98 | WriteBool('AddPhonePrefix', CheckBoxAddPhonePrefix.Checked);
|
---|
99 | WriteBool('RemovePhoneSpaces', CheckBoxRemovePhoneSpaces.Checked);
|
---|
100 | WriteBool('RemoveExactDuplicates', CheckBoxRemoveExactDuplicates.Checked);
|
---|
101 | WriteBool('RemovePhotos', CheckBoxRemovePhotos.Checked);
|
---|
102 | WriteBool('ConvertInternationaCallPrefixToCountryCode', CheckBoxConvertInternationaCallPrefixToCountryCode.Checked);
|
---|
103 | finally
|
---|
104 | Free;
|
---|
105 | end;
|
---|
106 | end;
|
---|
107 |
|
---|
108 |
|
---|
109 | end.
|
---|
110 |
|
---|