Revision | 10 (tree) |
---|---|
Zeit | 2014-06-29 04:50:06 |
Autor | twm |
display the template as well as the original and output
@@ -1,6 +1,6 @@ | ||
1 | 1 | [Version Info] |
2 | 2 | AutoIncBuild=0 |
3 | -Build=20 | |
3 | +Build=25 | |
4 | 4 | MajorVer=1 |
5 | 5 | MinorVer=0 |
6 | 6 | Release=0 |
@@ -7,7 +7,7 @@ | ||
7 | 7 | Revision=0 |
8 | 8 | |
9 | 9 | [Version Info Keys] |
10 | -FileVersion=1.0.0.20 | |
10 | +FileVersion=1.0.0.25 | |
11 | 11 | ProductVersion={today} |
12 | 12 | FileDescription=INI file formatter |
13 | 13 | OriginalFilename=IniFileFormatter |
@@ -12,7 +12,9 @@ | ||
12 | 12 | Controls, |
13 | 13 | Forms, |
14 | 14 | Dialogs, |
15 | - StdCtrls; | |
15 | + StdCtrls, | |
16 | + ComCtrls, | |
17 | + u_dzTranslator; | |
16 | 18 | |
17 | 19 | type |
18 | 20 | Tf_IniFileFormatter = class(TForm) |
@@ -20,9 +22,13 @@ | ||
20 | 22 | ed_Filename: TEdit; |
21 | 23 | od_Filename: TOpenDialog; |
22 | 24 | b_Filename: TButton; |
23 | - l_Original: TLabel; | |
25 | + pc_Input: TPageControl; | |
26 | + ts_Original: TTabSheet; | |
27 | + ts_Template: TTabSheet; | |
24 | 28 | m_Original: TMemo; |
25 | - l_Preview: TLabel; | |
29 | + m_Template: TMemo; | |
30 | + pc_Output: TPageControl; | |
31 | + ts_Preview: TTabSheet; | |
26 | 32 | m_Preview: TMemo; |
27 | 33 | gb_SortSections: TGroupBox; |
28 | 34 | rb_SectionsUnsorted: TRadioButton; |
@@ -47,13 +53,14 @@ | ||
47 | 53 | procedure b_TemplateClick(Sender: TObject); |
48 | 54 | private |
49 | 55 | procedure LoadAndSort(const _Filename: string); |
50 | - function FormatIni: boolean; | |
56 | + function FormatIni: Boolean; | |
51 | 57 | public |
58 | + constructor Create(_Owner: TComponent); override; | |
52 | 59 | procedure SetSrcFile(const _Value: string); |
53 | - procedure SetSortSections(_Idx: integer); | |
54 | - procedure SetSortItems(_Idx: integer); | |
60 | + procedure SetSortSections(_Idx: Integer); | |
61 | + procedure SetSortItems(_Idx: Integer); | |
55 | 62 | procedure SetTemplate(const _Value: string); |
56 | - function Execute(const _Value: string): boolean; | |
63 | + function Execute(const _Value: string): Boolean; | |
57 | 64 | end; |
58 | 65 | |
59 | 66 | implementation |
@@ -62,8 +69,19 @@ | ||
62 | 69 | |
63 | 70 | uses |
64 | 71 | u_dzIniFileFormatter, |
65 | - u_dzIniSections; | |
72 | + u_dzIniSections, | |
73 | + u_dzVclUtils; | |
66 | 74 | |
75 | +constructor Tf_IniFileFormatter.Create(_Owner: TComponent); | |
76 | +begin | |
77 | + inherited; | |
78 | + | |
79 | + TranslateComponent(Self); | |
80 | + TControl_SetMinConstraints(Self); | |
81 | + TForm_AppendVersion(Self); | |
82 | + pc_Input.ActivePage := ts_Original; | |
83 | +end; | |
84 | + | |
67 | 85 | procedure Tf_IniFileFormatter.b_CloseClick(Sender: TObject); |
68 | 86 | begin |
69 | 87 | Close; |
@@ -71,9 +89,9 @@ | ||
71 | 89 | |
72 | 90 | procedure Tf_IniFileFormatter.b_FilenameClick(Sender: TObject); |
73 | 91 | begin |
74 | - od_Filename.FileName := ed_Filename.Text; | |
92 | + od_Filename.Filename := ed_Filename.Text; | |
75 | 93 | if od_Filename.Execute then begin |
76 | - ed_Filename.Text := od_Filename.FileName; | |
94 | + ed_Filename.Text := od_Filename.Filename; | |
77 | 95 | LoadAndSort(ed_Filename.Text); |
78 | 96 | end; |
79 | 97 | end; |
@@ -80,9 +98,9 @@ | ||
80 | 98 | |
81 | 99 | procedure Tf_IniFileFormatter.b_TemplateClick(Sender: TObject); |
82 | 100 | begin |
83 | - od_Filename.FileName := ed_Template.Text; | |
101 | + od_Filename.Filename := ed_Template.Text; | |
84 | 102 | if od_Filename.Execute then begin |
85 | - ed_Template.Text := od_Filename.FileName; | |
103 | + ed_Template.Text := od_Filename.Filename; | |
86 | 104 | end; |
87 | 105 | FormatIni; |
88 | 106 | end; |
@@ -89,12 +107,12 @@ | ||
89 | 107 | |
90 | 108 | procedure Tf_IniFileFormatter.b_SaveAsClick(Sender: TObject); |
91 | 109 | begin |
92 | - sd_Filename.FileName := ed_Filename.Text; | |
110 | + sd_Filename.Filename := ed_Filename.Text; | |
93 | 111 | if sd_Filename.Execute then |
94 | - m_Preview.Lines.SaveToFile(sd_Filename.FileName); | |
112 | + m_Preview.Lines.SaveToFile(sd_Filename.Filename); | |
95 | 113 | end; |
96 | 114 | |
97 | -function Tf_IniFileFormatter.Execute(const _Value: string): boolean; | |
115 | +function Tf_IniFileFormatter.Execute(const _Value: string): Boolean; | |
98 | 116 | begin |
99 | 117 | Result := FormatIni; |
100 | 118 | if Result then |
@@ -101,23 +119,23 @@ | ||
101 | 119 | m_Preview.Lines.SaveToFile(_Value); |
102 | 120 | end; |
103 | 121 | |
104 | -procedure Tf_IniFileFormatter.SetSortItems(_Idx: integer); | |
122 | +procedure Tf_IniFileFormatter.SetSortItems(_Idx: Integer); | |
105 | 123 | begin |
106 | 124 | case _Idx of |
107 | - 0: rb_ItemsUnsorted.Checked := true; | |
108 | - 2: rb_ItemsByTemplate.Checked := true; | |
125 | + 0: rb_ItemsUnsorted.Checked := True; | |
126 | + 2: rb_ItemsByTemplate.Checked := True; | |
109 | 127 | else |
110 | - rb_ItemsAlpha.Checked := true; | |
128 | + rb_ItemsAlpha.Checked := True; | |
111 | 129 | end; |
112 | 130 | end; |
113 | 131 | |
114 | -procedure Tf_IniFileFormatter.SetSortSections(_Idx: integer); | |
132 | +procedure Tf_IniFileFormatter.SetSortSections(_Idx: Integer); | |
115 | 133 | begin |
116 | 134 | case _Idx of |
117 | - 0: rb_SectionsUnsorted.Checked := true; | |
118 | - 2: rb_SectionsByTemplate.Checked := true; | |
135 | + 0: rb_SectionsUnsorted.Checked := True; | |
136 | + 2: rb_SectionsByTemplate.Checked := True; | |
119 | 137 | else |
120 | - rb_SectionsAlpha.Checked := true; | |
138 | + rb_SectionsAlpha.Checked := True; | |
121 | 139 | end; |
122 | 140 | end; |
123 | 141 |
@@ -142,12 +160,11 @@ | ||
142 | 160 | w: Integer; |
143 | 161 | l: Integer; |
144 | 162 | begin |
145 | - w := (ClientWidth - m_Original.Left * 3) div 2; | |
146 | - m_Original.Width := w; | |
147 | - m_Preview.Width := w; | |
148 | - l := m_Original.Left * 2 + w; | |
149 | - m_Preview.Left := l; | |
150 | - l_Preview.Left := l; | |
163 | + w := (ClientWidth - pc_Input.Left * 3) div 2; | |
164 | + pc_Input.Width := w; | |
165 | + pc_Output.Width := w; | |
166 | + l := pc_Input.Left * 2 + w; | |
167 | + pc_Output.Left := l; | |
151 | 168 | end; |
152 | 169 | |
153 | 170 | procedure Tf_IniFileFormatter.LoadAndSort(const _Filename: string); |
@@ -156,9 +173,9 @@ | ||
156 | 173 | FormatIni; |
157 | 174 | end; |
158 | 175 | |
159 | -function Tf_IniFileFormatter.FormatIni: boolean; | |
176 | +function Tf_IniFileFormatter.FormatIni: Boolean; | |
160 | 177 | var |
161 | - b: boolean; | |
178 | + b: Boolean; | |
162 | 179 | Formatter: TIniFileFormatter; |
163 | 180 | Template: TIniFileFormatter; |
164 | 181 | SortTemplate: TStringList; |
@@ -165,15 +182,20 @@ | ||
165 | 182 | Sections: TStringList; |
166 | 183 | s: string; |
167 | 184 | begin |
168 | - Result := false; | |
185 | + Result := False; | |
169 | 186 | |
170 | 187 | Template := nil; |
171 | 188 | |
189 | + if ed_Template.Text = '' then | |
190 | + m_Template.Lines.Clear | |
191 | + else | |
192 | + m_Template.Lines.LoadFromFile(ed_Template.Text); | |
193 | + | |
172 | 194 | b := rb_SectionsByTemplate.Checked or rb_ItemsByTemplate.Checked; |
173 | 195 | if b then begin |
174 | 196 | if (ed_Template.Text = '') then begin |
175 | 197 | m_Preview.Lines.Clear; |
176 | - exit; | |
198 | + Exit; | |
177 | 199 | end; |
178 | 200 | Template := TIniFileFormatter.Create; |
179 | 201 | try |
@@ -229,7 +251,7 @@ | ||
229 | 251 | FreeAndNil(Formatter); |
230 | 252 | FreeAndNil(Template); |
231 | 253 | end; |
232 | - Result := true; | |
254 | + Result := True; | |
233 | 255 | end; |
234 | 256 | |
235 | 257 | end. |
@@ -56,7 +56,7 @@ | ||
56 | 56 | #. f_IniFileFormatter..gb_SortItems..rb_ItemsUnsorted..Caption |
57 | 57 | #: w_IniFileFormatter.dfm:138 w_IniFileFormatter.dfm:175 |
58 | 58 | msgid "Unsorted" |
59 | -msgstr "unsortiert" | |
59 | +msgstr "Unsortiert" | |
60 | 60 | |
61 | 61 | #. f_IniFileFormatter..gb_SortSections..rb_SectionsAlpha..Caption |
62 | 62 | #. f_IniFileFormatter..gb_SortItems..rb_ItemsAlpha..Caption |
@@ -68,7 +68,7 @@ | ||
68 | 68 | #. f_IniFileFormatter..gb_SortItems..rb_ItemsByTemplate..Caption |
69 | 69 | #: w_IniFileFormatter.dfm:158 w_IniFileFormatter.dfm:195 |
70 | 70 | msgid "By Template" |
71 | -msgstr "nach einer Vorlage" | |
71 | +msgstr "Nach einer Vorlage" | |
72 | 72 | |
73 | 73 | #. f_IniFileFormatter..gb_SortItems..Caption |
74 | 74 | #: w_IniFileFormatter.dfm:168 |