forked from ThePacielloGroup/CCA-Win
-
Notifications
You must be signed in to change notification settings - Fork 0
/
about.pas
165 lines (144 loc) · 6.23 KB
/
about.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
unit about;
(*
CCA is a tool to evaluate the color visibility and contrast of foreground/background color combinations.
Copyright (C) 2014 The Paciello Group
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons, ShellAPI, IniFIles, OleCtrls,
SHDocVw, MSHTML_TLB, Activex;
type
TAboutForm = class(TForm)
Panel1: TPanel;
BitBtn1: TBitBtn;
Panel2: TPanel;
WB1: TWebBrowser;
procedure WB1BeforeNavigate2(Sender: TObject; const pDisp: IDispatch;
var URL, Flags, TargetFrameName, PostData, Headers: OleVariant;
var Cancel: WordBool);
private
{ Private 錾 }
public
{ Public 錾 }
TransPath: string;
procedure LoadINI;
end;
var
AboutForm: TAboutForm;
implementation
uses Main;
{$R *.dfm}
procedure TAboutForm.LoadINI;
var
ini: TMemIniFile;
Charset, Lang, EN, JP, s, WATC, EN_Mail, EN_Address, JP_Mail, JP_Address: widestring;
T_Site, T_Mail, T_Name: widestring;
VTxt, Add, Note: widestring;
List: TStringList;
RS:TResourceStream;
bTrans: Boolean;
v: Variant;
iDoc: IHTMLDocument2;
begin
WB1.Navigate('about:blank');
ini := TMemIniFile.Create(TransPath, TEncoding.UTF8);
List := TStringList.Create;
try
Charset := ini.ReadString('HTML', 'Charset', 'utf-8');
Lang := ini.ReadString('HTML', 'Lang', 'en');
EN := ini.ReadString('Translations', 'en_ver', 'Steven Faulkner (English version):');
JP := ini.ReadString('Translations', 'jp_ver', '');
EN_Mail := ini.ReadString('Translations', 'en_mail', '[email protected]');
JP_Mail := ini.ReadString('Translations', 'jp_mail', '');
EN_Address := ini.ReadString('Translations', 'en_website', 'https://www.paciellogroup.com/resources/contrastanalyser/');
JP_Address := ini.ReadString('Translations', 'jp_website', '');
Caption := ini.ReadString('Translations', 'aboutwnd', 'About');
T_Name := ini.ReadString('Translations', 'translator_name', '');
T_Site := ini.ReadString('Translations', 'translator_site', '');
T_Mail := ini.ReadString('Translations', 'translator_mail', '');
VTxt := ini.ReadString('Translations', 'versiontext', 'Colour Contrast Analyser version 2.4');
Add := ini.ReadString('Translations', 'address_group', 'E-Mail & Web site address');
Note := ini.ReadString('Translations', 'abouttext', 'The Colour Contrast Analyser was developed by Jun in collaboration with Steve Faulkner.');
RS := TResourceStream.Create(hInstance,'ABOUT',PChar('TEXT'));
WATC := ini.ReadString('Translations', 'WATC', 'http://www.wat-c.org/');
try
List.LoadFromStream(RS);
List.Text := StringReplace(List.Text, '%charset%', Charset, [rfReplaceAll, rfIgnoreCase]);
List.Text := StringReplace(List.Text, '%lang%', Lang, [rfReplaceAll, rfIgnoreCase]);
s := List.Text;
//s := s + #13#10 + '<h1><img src="' + IconPath + '" height="32" width="32" alt="CCA Icon" />' + VTxt + '</h1>';
s := s + #13#10 + '<h1><img src="res://' + Application.ExeName + '/CCA" height="32" width="32" alt="CCA Icon" />' + VTxt + '</h1>';
//s := '<h1>' + VTxt + '</h1>';
s := s + #13#10 + '<hr />';
s := s + #13#10 + '<p>' + Note + '</p>';
s := s + #13#10 + '<h2>' + Add + '</h2>';
s := s + #13#10 + '<dl>';
s := s + #13#10 + '<dt>' + EN + '</dt><dd>' + 'Mail: <a href="mailto:' + EN_Mail + '">' + EN_Mail + '</a></dd>';
s := s + '<dd>' + 'Website: <a href="' + EN_Address + '">' + EN_Address + '</a></dd>';
{s := s + #13#10 + '<dt>' + JP + '</dt>';
if JP_Mail <> '' then
s := s + '<dd>' + 'Mail: <a href="mailto:' + JP_Mail + '">' + JP_Mail + '</a></dd>';
if JP_Address <> '' then
s := s + '<dd>' + 'Website: <a href="' + JP_Address + '">' + JP_Address + '</a></dd>'; }
s := s + #13#10 + '<dt>WAT-C</dt>';
s := s + '<dd>' + 'Website: <a href="' + WATC + '">' + WATC + '</a></dd>';
bTrans := False;
if T_Name <> '' then
begin
s := s + #13#10 + '<dt>' + T_Name + '</dt>';
bTrans := True;
end;
if T_Mail <> '' then
begin
s := s + '<dd>' + 'Mail: <a href="mailto:' + T_Mail + '">' + T_Mail + '</a></dd>';
bTrans := True;
end;
if T_Site <> '' then
begin
s := s + '<dd>' + 'Website: <a href="' + T_Site + '">' + T_Site + '</a></dd>';
bTrans := True;
end;
if bTrans then s := s + '</dt>';
s := s + #13#10 + '</dl></body></html>';
List.Add(s);
if SUCCEEDED(WB1.Document.QueryInterface(IID_IHTMLDocument2, iDoc)) then
begin
v := VarArrayCreate([0, 0], varVariant);
v[0] := s;//List.Text;
iDoc.write(PSafeArray(TVarData(v).VArray));
iDoc.close;
end;
finally
RS.Free;
end;
finally
ini.Free;
List.Free;
end;
end;
procedure TAboutForm.WB1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
var
s: string;
begin
if LowerCase(URL) <> 'about:blank' then
begin
Cancel := True;
s := URl;
ShellExecute(Handle, 'open', PChar(s), nil, nil, SW_SHOW);
end;
end;
end.