-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathUFrm.pas
176 lines (136 loc) · 3.96 KB
/
UFrm.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
166
167
168
169
170
171
172
173
174
175
176
{------------------------------------------------------------------------------
Component Installer app
Developed by Rodrigo Depine Dalpiaz (digao dalpiaz)
Delphi utility app to auto-install component packages into IDE
https://github.com/digao-dalpiaz/CompInstall
Please, read the documentation at GitHub link.
------------------------------------------------------------------------------}
unit UFrm;
interface
uses Vcl.Forms, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.Buttons,
Vcl.Controls, System.Classes,
//
Vcl.Graphics, UDefinitions;
type
TFrm = class(TForm)
LbComponentName: TLabel;
EdCompName: TEdit;
LbDelphiVersion: TLabel;
EdDV: TComboBox;
Ck64bit: TCheckBox;
LbInstallLog: TLabel;
BtnInstall: TBitBtn;
BtnExit: TBitBtn;
M: TRichEdit;
LbVersion: TLabel;
LbDigaoDalpiaz: TLinkLabel;
LbComponentVersion: TLabel;
EdCompVersion: TEdit;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure BtnExitClick(Sender: TObject);
procedure BtnInstallClick(Sender: TObject);
procedure LbDigaoDalpiazLinkClick(Sender: TObject; const Link: string;
LinkType: TSysLinkType);
procedure FormShow(Sender: TObject);
private
D: TDefinitions;
DefLoaded: Boolean;
public
procedure LoadDefinitions;
procedure SetButtons(bEnabled: Boolean);
procedure Log(const A: string; bBold: Boolean = True; Color: TColor = clBlack);
end;
var
Frm: TFrm;
implementation
{$R *.dfm}
uses System.SysUtils, Vcl.Dialogs, System.UITypes,
Winapi.Windows, Winapi.Messages, Winapi.ShellAPI,
UCommon, UProcess, UGitHub, UDelphiVersionCombo;
procedure TFrm.Log(const A: string; bBold: Boolean = True; Color: TColor = clBlack);
begin
//log text at RichEdit control, with some formatted rules
M.SelStart := Length(M.Text);
if bBold then
M.SelAttributes.Style := [fsBold]
else
M.SelAttributes.Style := [];
M.SelAttributes.Color := Color;
M.SelText := A+#13#10;
SendMessage(M.Handle, WM_VSCROLL, SB_BOTTOM, 0); //scroll to bottom
end;
procedure TFrm.LoadDefinitions;
begin
if Assigned(D) then D.Free;
DefLoaded := False;
D := TDefinitions.Create;
try
D.LoadIniFile(AppDir+INI_FILE_NAME);
EdCompName.Text := D.CompName;
EdCompVersion.Text := D.CompVersion;
TDelphiVersionComboLoader.Load(EdDV, D.DelphiVersions);
Ck64bit.Visible := D.HasAny64bit;
DefLoaded := True;
except
on E: Exception do
Log('Error loading component definitions: '+E.Message, True, clRed);
end;
end;
procedure TFrm.FormCreate(Sender: TObject);
begin
ReportMemoryLeaksOnShutdown := True;
AppDir := ExtractFilePath(Application.ExeName);
LoadDefinitions;
end;
procedure TFrm.FormDestroy(Sender: TObject);
begin
D.Free;
TDelphiVersionComboLoader.Clear(EdDV);
end;
procedure TFrm.FormShow(Sender: TObject);
begin
if DefLoaded then
CheckGitHubUpdate(D.GitHubRepository, D.CompVersion);
end;
procedure TFrm.LbDigaoDalpiazLinkClick(Sender: TObject; const Link: string;
LinkType: TSysLinkType);
begin
ShellExecute(0, '', PChar(Link), '', '', SW_SHOWNORMAL);
end;
procedure TFrm.BtnExitClick(Sender: TObject);
begin
Close;
end;
procedure TFrm.BtnInstallClick(Sender: TObject);
var
P: TProcess;
begin
if not DefLoaded then
raise Exception.Create('Component definitions are not loaded');
M.Clear; //clear log
if EdDV.ItemIndex=-1 then
begin
MessageDlg('Select one Delphi version', mtError, [mbOK], 0);
EdDV.SetFocus;
Exit;
end;
//check if Delphi IDE is running
if FindWindow('TAppBuilder', nil)<>0 then
begin
MessageDlg('Please, close Delphi IDE first!', mtError, [mbOK], 0);
Exit;
end;
SetButtons(False);
Refresh;
P := TProcess.Create(D,
TDelphiVersionItem(EdDV.Items.Objects[EdDV.ItemIndex]).InternalNumber,
Ck64bit.Checked and Ck64bit.Visible);
P.Start;
end;
procedure TFrm.SetButtons(bEnabled: Boolean);
begin
BtnInstall.Enabled := bEnabled;
BtnExit.Enabled := bEnabled;
end;
end.