Rev 95 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 95 | Rev 96 | ||
---|---|---|---|
1 | unit UD2_Main; |
1 | unit UD2_Main; |
2 | 2 | ||
3 | interface |
3 | interface |
4 | 4 | ||
5 | {$IF CompilerVersion >= 25.0} |
5 | {$IF CompilerVersion >= 25.0} |
6 | {$LEGACYIFEND ON} |
6 | {$LEGACYIFEND ON} |
7 | {$IFEND} |
7 | {$IFEND} |
8 | 8 | ||
9 | {$INCLUDE 'UserDetect2.inc'} |
9 | {$INCLUDE 'UserDetect2.inc'} |
10 | 10 | ||
11 | uses |
11 | uses |
12 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
12 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
13 | Dialogs, StdCtrls, Grids, ValEdit, UD2_Obj, ComCtrls, ImgList, ExtCtrls, |
13 | Dialogs, StdCtrls, Grids, ValEdit, UD2_Obj, ComCtrls, ImgList, ExtCtrls, |
14 | CommCtrl, Menus, VTSListView, VTSCompat, UD2_PluginStatus, Contnrs, |
14 | CommCtrl, Menus, VTSListView, VTSCompat, UD2_PluginStatus, Contnrs, |
15 | System.ImageList; |
15 | System.ImageList; |
16 | 16 | ||
17 | const |
17 | const |
18 | DefaultIniFile = 'UserDetect2.ini'; |
18 | DefaultIniFile = 'UserDetect2.ini'; |
19 | DefaultWarnIfNothingMatchesGUI = 'true'; |
19 | DefaultWarnIfNothingMatchesGUI = 'true'; |
20 | TagWarnIfNothingMatchesGUI = 'WarnIfNothingMatches.GUI'; |
20 | TagWarnIfNothingMatchesGUI = 'WarnIfNothingMatches.GUI'; |
21 | DefaultWarnIfNothingMatchesCLI = 'false'; |
21 | DefaultWarnIfNothingMatchesCLI = 'false'; |
22 | TagWarnIfNothingMatchesCLI = 'WarnIfNothingMatches.CLI'; |
22 | TagWarnIfNothingMatchesCLI = 'WarnIfNothingMatches.CLI'; |
23 | DefaultCloseAfterLaunching = 'false'; |
23 | DefaultCloseAfterLaunching = 'false'; |
24 | TagCloseAfterLaunching = 'CloseAfterLaunching'; |
24 | TagCloseAfterLaunching = 'CloseAfterLaunching'; |
25 | TagIcon = 'Icon'; |
25 | TagIcon = 'Icon'; |
26 | 26 | ||
27 | type |
27 | type |
28 | TUD2MainForm = class(TForm) |
28 | TUD2MainForm = class(TForm) |
29 | OpenDialog1: TOpenDialog; |
29 | OpenDialog1: TOpenDialog; |
30 | PageControl1: TPageControl; |
30 | PageControl1: TPageControl; |
31 | TasksTabSheet: TTabSheet; |
31 | TasksTabSheet: TTabSheet; |
32 | TabSheet2: TTabSheet; |
32 | TabSheet2: TTabSheet; |
33 | TabSheet3: TTabSheet; |
33 | TabSheet3: TTabSheet; |
34 | IniTemplateMemo: TMemo; |
34 | IniTemplateMemo: TMemo; |
35 | TabSheet4: TTabSheet; |
35 | TabSheet4: TTabSheet; |
36 | TasksListView: TVTSListView; |
36 | TasksListView: TVTSListView; |
37 | TasksImageList: TImageList; |
37 | TasksImageList: TImageList; |
38 | SaveDialog1: TSaveDialog; |
38 | SaveDialog1: TSaveDialog; |
39 | TabSheet5: TTabSheet; |
39 | TabSheet5: TTabSheet; |
40 | Image1: TImage; |
40 | Image1: TImage; |
41 | Label1: TLabel; |
41 | Label1: TLabel; |
42 | Label2: TLabel; |
42 | Label2: TLabel; |
43 | Label3: TLabel; |
43 | Label3: TLabel; |
44 | Label4: TLabel; |
44 | Label4: TLabel; |
45 | Label5: TLabel; |
45 | Label5: TLabel; |
46 | Label6: TLabel; |
46 | Label6: TLabel; |
47 | Label7: TLabel; |
47 | Label7: TLabel; |
48 | Label8: TLabel; |
48 | Label8: TLabel; |
49 | LoadedPluginsListView: TVTSListView; |
49 | LoadedPluginsListView: TVTSListView; |
50 | IdentificationsListView: TVTSListView; |
50 | IdentificationsListView: TVTSListView; |
51 | ErrorsTabSheet: TTabSheet; |
51 | ErrorsTabSheet: TTabSheet; |
52 | ErrorsMemo: TMemo; |
52 | ErrorsMemo: TMemo; |
53 | Memo1: TMemo; |
53 | Memo1: TMemo; |
54 | Panel1: TPanel; |
54 | Panel1: TPanel; |
55 | OpenTDFButton: TButton; |
55 | OpenTDFButton: TButton; |
56 | SaveTDFButton: TButton; |
56 | SaveTDFButton: TButton; |
57 | TasksPopupMenu: TPopupMenu; |
57 | TasksPopupMenu: TPopupMenu; |
58 | Run1: TMenuItem; |
58 | Run1: TMenuItem; |
59 | Properties1: TMenuItem; |
59 | Properties1: TMenuItem; |
60 | IdentificationsPopupMenu: TPopupMenu; |
60 | IdentificationsPopupMenu: TPopupMenu; |
61 | CopyTaskDefinitionExample1: TMenuItem; |
61 | CopyTaskDefinitionExample1: TMenuItem; |
62 | Button3: TButton; |
62 | Button3: TButton; |
63 | VersionLabel: TLabel; |
63 | VersionLabel: TLabel; |
64 | LoadedPluginsPopupMenu: TPopupMenu; |
64 | LoadedPluginsPopupMenu: TPopupMenu; |
65 | CopyStatusCodeToClipboard: TMenuItem; |
65 | CopyStatusCodeToClipboard: TMenuItem; |
66 | Panel2: TPanel; |
66 | Panel2: TPanel; |
67 | Image2: TImage; |
67 | Image2: TImage; |
68 | DynamicTestGroupbox: TGroupBox; |
68 | DynamicTestGroupbox: TGroupBox; |
69 | DynamicTestPluginComboBox: TComboBox; |
69 | DynamicTestPluginComboBox: TComboBox; |
70 | DynamicTestPluginLabel: TLabel; |
70 | DynamicTestPluginLabel: TLabel; |
71 | DynamicTestDataLabel: TLabel; |
71 | DynamicTestDataLabel: TLabel; |
72 | DynamicTestDataEdit: TEdit; |
72 | DynamicTestDataEdit: TEdit; |
73 | DynamicTestButton: TButton; |
73 | DynamicTestButton: TButton; |
74 | procedure FormDestroy(Sender: TObject); |
74 | procedure FormDestroy(Sender: TObject); |
75 | procedure TasksListViewDblClick(Sender: TObject); |
75 | procedure TasksListViewDblClick(Sender: TObject); |
76 | procedure TasksListViewKeyPress(Sender: TObject; var Key: Char); |
76 | procedure TasksListViewKeyPress(Sender: TObject; var Key: Char); |
77 | procedure OpenTDFButtonClick(Sender: TObject); |
77 | procedure OpenTDFButtonClick(Sender: TObject); |
78 | procedure SaveTDFButtonClick(Sender: TObject); |
78 | procedure SaveTDFButtonClick(Sender: TObject); |
79 | procedure URLLabelClick(Sender: TObject); |
79 | procedure URLLabelClick(Sender: TObject); |
80 | procedure TasksPopupMenuPopup(Sender: TObject); |
80 | procedure TasksPopupMenuPopup(Sender: TObject); |
81 | procedure Run1Click(Sender: TObject); |
81 | procedure Run1Click(Sender: TObject); |
82 | procedure Properties1Click(Sender: TObject); |
82 | procedure Properties1Click(Sender: TObject); |
83 | procedure IdentificationsPopupMenuPopup(Sender: TObject); |
83 | procedure IdentificationsPopupMenuPopup(Sender: TObject); |
84 | procedure CopyTaskDefinitionExample1Click(Sender: TObject); |
84 | procedure CopyTaskDefinitionExample1Click(Sender: TObject); |
85 | procedure ListViewCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer); |
85 | procedure ListViewCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer); |
86 | procedure Button3Click(Sender: TObject); |
86 | procedure Button3Click(Sender: TObject); |
87 | procedure LoadedPluginsPopupMenuPopup(Sender: TObject); |
87 | procedure LoadedPluginsPopupMenuPopup(Sender: TObject); |
88 | procedure CopyStatusCodeToClipboardClick(Sender: TObject); |
88 | procedure CopyStatusCodeToClipboardClick(Sender: TObject); |
89 | procedure FormCreate(Sender: TObject); |
89 | procedure FormCreate(Sender: TObject); |
90 | procedure DynamicTestButtonClick(Sender: TObject); |
90 | procedure DynamicTestButtonClick(Sender: TObject); |
- | 91 | private |
|
- | 92 | procedure ConvertFirstIconToGray; |
|
91 | protected |
93 | protected |
92 | ud2: TUD2; |
94 | ud2: TUD2; |
93 | procedure LoadTaskList; |
95 | procedure LoadTaskList; |
94 | procedure LoadDetectedIDs; |
96 | procedure LoadDetectedIDs; |
95 | procedure LoadINITemplate; |
97 | procedure LoadINITemplate; |
96 | procedure LoadLoadedPluginList; |
98 | procedure LoadLoadedPluginList; |
97 | procedure LoadDynamicPluginList; |
99 | procedure LoadDynamicPluginList; |
98 | function GetIniFileName: string; |
100 | function GetIniFileName: string; |
99 | procedure DoRun(ShortTaskName: string; gui: boolean); |
101 | procedure DoRun(ShortTaskName: string; gui: boolean); |
100 | procedure CheckForErrors; |
102 | procedure CheckForErrors; |
101 | public |
103 | public |
102 | procedure Run; |
104 | procedure Run; |
103 | end; |
105 | end; |
104 | 106 | ||
105 | var |
107 | var |
106 | UD2MainForm: TUD2MainForm; |
108 | UD2MainForm: TUD2MainForm; |
107 | 109 | ||
108 | implementation |
110 | implementation |
109 | 111 | ||
110 | {$R *.dfm} |
112 | {$R *.dfm} |
111 | 113 | ||
112 | uses |
114 | uses |
113 | ShellAPI, Clipbrd, Math, AlphaNumSort, UD2_Utils, UD2_TaskProperties, UD2_Parsing; |
115 | ShellAPI, Clipbrd, Math, AlphaNumSort, UD2_Utils, UD2_TaskProperties, UD2_Parsing; |
114 | 116 | ||
115 | type |
117 | type |
116 | TUD2ListViewEntry = class(TObject) |
118 | TUD2ListViewEntry = class(TObject) |
117 | ShortTaskName: string; |
119 | ShortTaskName: string; |
118 | CloseAfterLaunching: boolean; |
120 | CloseAfterLaunching: boolean; |
119 | TaskPropertiesForm: TForm; |
121 | TaskPropertiesForm: TForm; |
120 | end; |
122 | end; |
121 | 123 | ||
122 | function AddIconRecToImageList(rec: TIconFileIdx; ImageList: TImageList): integer; |
124 | function AddIconRecToImageList(rec: TIconFileIdx; ImageList: TImageList): integer; |
123 | var |
125 | var |
124 | icon: TIcon; |
126 | icon: TIcon; |
125 | begin |
127 | begin |
126 | icon := TIcon.Create; |
128 | icon := TIcon.Create; |
127 | try |
129 | try |
128 | icon.Handle := ExtractIcon(Application.Handle, PChar(rec.FileName), rec.IconIndex); |
130 | icon.Handle := ExtractIcon(Application.Handle, PChar(rec.FileName), rec.IconIndex); |
129 | 131 | ||
130 | // result := ImageList.AddIcon(ico); |
132 | // result := ImageList.AddIcon(ico); |
131 | result := AddTransparentIconToImageList(ImageList, icon); |
133 | result := AddTransparentIconToImageList(ImageList, icon); |
- | 134 | AddTransparentIconToImageList(ImageList, icon, true) |
|
132 | finally |
135 | finally |
133 | icon.Free; |
136 | icon.Free; |
134 | end; |
137 | end; |
135 | end; |
138 | end; |
136 | 139 | ||
137 | { TUD2MainForm } |
140 | { TUD2MainForm } |
138 | 141 | ||
139 | function TUD2MainForm.GetIniFileName: string; |
142 | function TUD2MainForm.GetIniFileName: string; |
140 | resourcestring |
143 | resourcestring |
141 | LNG_FILE_NOT_FOUND = 'File "%s" not found.'; |
144 | LNG_FILE_NOT_FOUND = 'File "%s" not found.'; |
142 | begin |
145 | begin |
143 | if (ParamCount >= 1) and not CheckBoolParam(1, 'C') then |
146 | if (ParamCount >= 1) and not CheckBoolParam(1, 'C') then |
144 | begin |
147 | begin |
145 | if FileExists(ParamStr(1)) then |
148 | if FileExists(ParamStr(1)) then |
146 | begin |
149 | begin |
147 | result := ParamStr(1); |
150 | result := ParamStr(1); |
148 | end |
151 | end |
149 | else |
152 | else |
150 | begin |
153 | begin |
151 | ExitCode := EXITCODE_INI_NOT_FOUND; |
154 | ExitCode := EXITCODE_INI_NOT_FOUND; |
152 | MessageDlg(Format(LNG_FILE_NOT_FOUND, [ParamStr(1)]), mtError, [mbOK], 0); |
155 | MessageDlg(Format(LNG_FILE_NOT_FOUND, [ParamStr(1)]), mtError, [mbOK], 0); |
153 | result := ''; |
156 | result := ''; |
154 | end; |
157 | end; |
155 | Exit; |
158 | Exit; |
156 | end |
159 | end |
157 | else |
160 | else |
158 | begin |
161 | begin |
159 | if FileExists(DefaultIniFile) then |
162 | if FileExists(DefaultIniFile) then |
160 | begin |
163 | begin |
161 | result := DefaultIniFile; |
164 | result := DefaultIniFile; |
162 | Exit; |
165 | Exit; |
163 | end; |
166 | end; |
164 | 167 | ||
165 | if FileExists(GetOwnCmdName + '.ini') then |
168 | if FileExists(GetOwnCmdName + '.ini') then |
166 | begin |
169 | begin |
167 | result := GetOwnCmdName + '.ini'; |
170 | result := GetOwnCmdName + '.ini'; |
168 | Exit; |
171 | Exit; |
169 | end; |
172 | end; |
170 | 173 | ||
171 | if CompatOpenDialogExecute(OpenDialog1) then |
174 | if CompatOpenDialogExecute(OpenDialog1) then |
172 | begin |
175 | begin |
173 | result := OpenDialog1.FileName; |
176 | result := OpenDialog1.FileName; |
174 | Exit; |
177 | Exit; |
175 | end; |
178 | end; |
176 | 179 | ||
177 | result := ''; |
180 | result := ''; |
178 | Exit; |
181 | Exit; |
179 | end; |
182 | end; |
180 | end; |
183 | end; |
181 | 184 | ||
182 | procedure TUD2MainForm.LoadTaskList; |
185 | procedure TUD2MainForm.LoadTaskList; |
183 | var |
186 | var |
184 | sl: TStringList; |
187 | sl: TStringList; |
185 | i: integer; |
188 | i: integer; |
186 | ShortTaskName, iconString: string; |
189 | ShortTaskName, iconString: string; |
187 | iconIndex: integer; |
190 | iconIndex: integer; |
188 | obj: TUD2ListViewEntry; |
191 | obj: TUD2ListViewEntry; |
- | 192 | cmds: TUD2CommandArray; |
|
189 | begin |
193 | begin |
190 | for i := 0 to TasksListView.Items.Count-1 do |
194 | for i := 0 to TasksListView.Items.Count-1 do |
191 | begin |
195 | begin |
192 | TUD2ListViewEntry(TasksListView.Items.Item[i].Data).Free; |
196 | TUD2ListViewEntry(TasksListView.Items.Item[i].Data).Free; |
193 | end; |
197 | end; |
194 | TasksListView.Clear; |
198 | TasksListView.Clear; |
195 | 199 | ||
196 | sl := TStringList.Create; |
200 | sl := TStringList.Create; |
197 | try |
201 | try |
198 | ud2.GetTaskListing(sl); |
202 | ud2.GetTaskListing(sl); |
199 | for i := 0 to sl.Count-1 do |
203 | for i := 0 to sl.Count-1 do |
200 | begin |
204 | begin |
201 | ShortTaskName := sl.Names[i]; |
205 | ShortTaskName := sl.Names[i]; |
202 | 206 | ||
203 | Obj := TUD2ListViewEntry.Create; |
207 | Obj := TUD2ListViewEntry.Create; |
204 | Obj.ShortTaskName := ShortTaskName; |
208 | Obj.ShortTaskName := ShortTaskName; |
205 | Obj.CloseAfterLaunching := ud2.ReadMetatagBool(ShortTaskName, TagCloseAfterLaunching, DefaultCloseAfterLaunching); |
209 | Obj.CloseAfterLaunching := ud2.ReadMetatagBool(ShortTaskName, TagCloseAfterLaunching, DefaultCloseAfterLaunching); |
206 | 210 | ||
207 | TasksListView.AddItem(sl.Values[ShortTaskName], TObject(Obj)); |
211 | TasksListView.AddItem(sl.Values[ShortTaskName], TObject(Obj)); |
208 | 212 | ||
209 | iconString := ud2.ReadMetatagString(ShortTaskName, TagIcon, ''); |
213 | iconString := ud2.ReadMetatagString(ShortTaskName, TagIcon, ''); |
210 | if iconString <> '' then |
214 | if iconString <> '' then |
211 | begin |
215 | begin |
212 | iconIndex := AddIconRecToImageList(SplitIconString(iconString), TasksImageList); |
216 | iconIndex := AddIconRecToImageList(SplitIconString(iconString), TasksImageList); |
213 | if iconIndex <> -1 then |
217 | if iconIndex <> -1 then |
214 | begin |
218 | begin |
215 | TasksListView.Items.Item[TasksListView.Items.Count-1].ImageIndex := iconIndex; |
219 | TasksListView.Items.Item[TasksListView.Items.Count-1].ImageIndex := iconIndex; |
216 | end; |
220 | end; |
217 | end; |
221 | end; |
- | 222 | ||
- | 223 | SetLength(cmds, 0); |
|
- | 224 | cmds := ud2.GetCommandList(obj.ShortTaskName); |
|
- | 225 | if Length(cmds) = 0 then |
|
- | 226 | begin |
|
- | 227 | TasksListView.Items.Item[TasksListView.Items.Count-1].ImageIndex := TasksListView.Items.Item[TasksListView.Items.Count-1].ImageIndex + 1; |
|
- | 228 | end; |
|
218 | end; |
229 | end; |
219 | finally |
230 | finally |
220 | sl.Free; |
231 | sl.Free; |
221 | end; |
232 | end; |
222 | end; |
233 | end; |
223 | 234 | ||
224 | procedure TUD2MainForm.DoRun(ShortTaskName: string; gui: boolean); |
235 | procedure TUD2MainForm.DoRun(ShortTaskName: string; gui: boolean); |
225 | resourcestring |
236 | resourcestring |
226 | LNG_TASK_NOT_EXISTS = 'The task "%s" does not exist in the INI file.'; |
237 | LNG_TASK_NOT_EXISTS = 'The task "%s" does not exist in the INI file.'; |
227 | LNG_NOTHING_MATCHES = 'No identification string matches to your environment. No application was launched. Please check the Task Definition File.'; |
238 | LNG_NOTHING_MATCHES = 'No identification string matches to your environment. No application was launched. Please check the Task Definition File.'; |
228 | var |
239 | var |
229 | i: integer; |
240 | i: integer; |
230 | cmds: TUD2CommandArray; |
241 | cmds: TUD2CommandArray; |
231 | showMismatchError: boolean; |
242 | showMismatchError: boolean; |
232 | begin |
243 | begin |
233 | if not ud2.TaskExists(ShortTaskName) then |
244 | if not ud2.TaskExists(ShortTaskName) then |
234 | begin |
245 | begin |
235 | // This can happen if the task name is taken from command line |
246 | // This can happen if the task name is taken from command line |
236 | MessageDlg(Format(LNG_TASK_NOT_EXISTS, [ShortTaskName]), mtError, [mbOK], 0); |
247 | MessageDlg(Format(LNG_TASK_NOT_EXISTS, [ShortTaskName]), mtError, [mbOK], 0); |
237 | ExitCode := EXITCODE_TASK_NOT_EXISTS; |
248 | ExitCode := EXITCODE_TASK_NOT_EXISTS; |
238 | Exit; |
249 | Exit; |
239 | end; |
250 | end; |
240 | 251 | ||
241 | SetLength(cmds, 0); |
252 | SetLength(cmds, 0); |
242 | cmds := ud2.GetCommandList(ShortTaskName); // TODO: What to do with AErrorOut (errors from dynamic queries?) |
253 | cmds := ud2.GetCommandList(ShortTaskName); // TODO: What to do with AErrorOut (errors from dynamic queries?) |
243 | 254 | ||
244 | if gui then |
255 | if gui then |
245 | showMismatchError := ud2.ReadMetatagBool(ShortTaskName, TagWarnIfNothingMatchesGUI, DefaultWarnIfNothingMatchesGUI) |
256 | showMismatchError := ud2.ReadMetatagBool(ShortTaskName, TagWarnIfNothingMatchesGUI, DefaultWarnIfNothingMatchesGUI) |
246 | else |
257 | else |
247 | showMismatchError := ud2.ReadMetatagBool(ShortTaskName, TagWarnIfNothingMatchesCLI, DefaultWarnIfNothingMatchesCLI); |
258 | showMismatchError := ud2.ReadMetatagBool(ShortTaskName, TagWarnIfNothingMatchesCLI, DefaultWarnIfNothingMatchesCLI); |
248 | 259 | ||
249 | if (Length(cmds) = 0) and showMismatchError then |
260 | if (Length(cmds) = 0) and showMismatchError then |
250 | begin |
261 | begin |
251 | MessageDlg(LNG_NOTHING_MATCHES, mtWarning, [mbOK], 0); |
262 | MessageDlg(LNG_NOTHING_MATCHES, mtWarning, [mbOK], 0); |
252 | ExitCode := EXITCODE_TASK_NOTHING_MATCHES; |
263 | ExitCode := EXITCODE_TASK_NOTHING_MATCHES; |
253 | end; |
264 | end; |
254 | 265 | ||
255 | for i := Low(cmds) to High(cmds) do |
266 | for i := Low(cmds) to High(cmds) do |
256 | begin |
267 | begin |
257 | UD2_RunCMD(cmds[i]); |
268 | UD2_RunCMD(cmds[i]); |
258 | end; |
269 | end; |
259 | end; |
270 | end; |
260 | 271 | ||
261 | procedure TUD2MainForm.FormDestroy(Sender: TObject); |
272 | procedure TUD2MainForm.FormDestroy(Sender: TObject); |
262 | var |
273 | var |
263 | i: integer; |
274 | i: integer; |
264 | begin |
275 | begin |
265 | if Assigned(ud2) then FreeAndNil(ud2); |
276 | if Assigned(ud2) then FreeAndNil(ud2); |
266 | 277 | ||
267 | for i := 0 to TasksListView.Items.Count-1 do |
278 | for i := 0 to TasksListView.Items.Count-1 do |
268 | begin |
279 | begin |
269 | TUD2ListViewEntry(TasksListView.Items.Item[i].Data).Free; |
280 | TUD2ListViewEntry(TasksListView.Items.Item[i].Data).Free; |
270 | end; |
281 | end; |
271 | TasksListView.Clear; |
282 | TasksListView.Clear; |
272 | end; |
283 | end; |
273 | 284 | ||
274 | procedure TUD2MainForm.CheckForErrors; |
285 | procedure TUD2MainForm.CheckForErrors; |
275 | begin |
286 | begin |
276 | ErrorsTabSheet.TabVisible := ud2.Errors.Count > 0; |
287 | ErrorsTabSheet.TabVisible := ud2.Errors.Count > 0; |
277 | if ErrorsTabSheet.TabVisible then |
288 | if ErrorsTabSheet.TabVisible then |
278 | begin |
289 | begin |
279 | ErrorsMemo.Lines.Assign(ud2.Errors); |
290 | ErrorsMemo.Lines.Assign(ud2.Errors); |
280 | PageControl1.ActivePage := ErrorsTabSheet; |
291 | PageControl1.ActivePage := ErrorsTabSheet; |
281 | end; |
292 | end; |
282 | end; |
293 | end; |
283 | 294 | ||
284 | procedure TUD2MainForm.LoadDetectedIDs; |
295 | procedure TUD2MainForm.LoadDetectedIDs; |
285 | var |
296 | var |
286 | i, j: integer; |
297 | i, j: integer; |
287 | pl: TUD2Plugin; |
298 | pl: TUD2Plugin; |
288 | ude: TUD2IdentificationEntry; |
299 | ude: TUD2IdentificationEntry; |
289 | begin |
300 | begin |
290 | IdentificationsListView.Clear; |
301 | IdentificationsListView.Clear; |
291 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
302 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
292 | begin |
303 | begin |
293 | pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
304 | pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
294 | for j := 0 to pl.DetectedIdentifications.Count-1 do |
305 | for j := 0 to pl.DetectedIdentifications.Count-1 do |
295 | begin |
306 | begin |
296 | ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry; |
307 | ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry; |
297 | 308 | ||
298 | with IdentificationsListView.Items.Add do |
309 | with IdentificationsListView.Items.Add do |
299 | begin |
310 | begin |
300 | Data := ude; |
311 | Data := ude; |
301 | Caption := pl.PluginName; |
312 | Caption := pl.PluginName; |
302 | if ude.DynamicDataUsed then |
313 | if ude.DynamicDataUsed then |
303 | SubItems.Add(ude.DynamicData) |
314 | SubItems.Add(ude.DynamicData) |
304 | else |
315 | else |
305 | SubItems.Add(''); |
316 | SubItems.Add(''); |
306 | SubItems.Add(pl.IdentificationMethodName); |
317 | SubItems.Add(pl.IdentificationMethodName); |
307 | SubItems.Add(ude.IdentificationString); |
318 | SubItems.Add(ude.IdentificationString); |
308 | SubItems.Add(pl.PluginGUIDString) |
319 | SubItems.Add(pl.PluginGUIDString) |
309 | end; |
320 | end; |
310 | end; |
321 | end; |
311 | end; |
322 | end; |
312 | 323 | ||
313 | for i := 0 to IdentificationsListView.Columns.Count-1 do |
324 | for i := 0 to IdentificationsListView.Columns.Count-1 do |
314 | begin |
325 | begin |
315 | IdentificationsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER; |
326 | IdentificationsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER; |
316 | end; |
327 | end; |
317 | end; |
328 | end; |
318 | 329 | ||
319 | procedure TUD2MainForm.LoadINITemplate; |
330 | procedure TUD2MainForm.LoadINITemplate; |
320 | var |
331 | var |
321 | i, j: integer; |
332 | i, j: integer; |
322 | pl: TUD2Plugin; |
333 | pl: TUD2Plugin; |
323 | ude: TUD2IdentificationEntry; |
334 | ude: TUD2IdentificationEntry; |
324 | idNames: TStringList; |
335 | idNames: TStringList; |
325 | begin |
336 | begin |
326 | IniTemplateMemo.Clear; |
337 | IniTemplateMemo.Clear; |
327 | IniTemplateMemo.Lines.Add('[ExampleTask1]'); |
338 | IniTemplateMemo.Lines.Add('[ExampleTask1]'); |
328 | IniTemplateMemo.Lines.Add('; Optional but recommended'); |
339 | IniTemplateMemo.Lines.Add('; Optional but recommended'); |
329 | IniTemplateMemo.Lines.Add(UD2_TagDescription+'=Run Task #1'); |
340 | IniTemplateMemo.Lines.Add(UD2_TagDescription+'=Run Task #1'); |
330 | IniTemplateMemo.Lines.Add('; Warns when no application was launched. Default: false.'); |
341 | IniTemplateMemo.Lines.Add('; Warns when no application was launched. Default: false.'); |
331 | IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesGUI+'='+DefaultWarnIfNothingMatchesGUI); |
342 | IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesGUI+'='+DefaultWarnIfNothingMatchesGUI); |
332 | IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesCLI+'='+DefaultWarnIfNothingMatchesCLI); |
343 | IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesCLI+'='+DefaultWarnIfNothingMatchesCLI); |
333 | IniTemplateMemo.Lines.Add('; Optional: IconDLL + IconIndex'); |
344 | IniTemplateMemo.Lines.Add('; Optional: IconDLL + IconIndex'); |
334 | IniTemplateMemo.Lines.Add(TagIcon+'=%SystemRoot%\system32\Shell32.dll,3'); |
345 | IniTemplateMemo.Lines.Add(TagIcon+'=%SystemRoot%\system32\Shell32.dll,3'); |
335 | IniTemplateMemo.Lines.Add('; Optional: Can be true or false'); |
346 | IniTemplateMemo.Lines.Add('; Optional: Can be true or false'); |
336 | IniTemplateMemo.Lines.Add(TagCloseAfterLaunching+'='+DefaultCloseAfterLaunching); |
347 | IniTemplateMemo.Lines.Add(TagCloseAfterLaunching+'='+DefaultCloseAfterLaunching); |
337 | 348 | ||
338 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
349 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
339 | begin |
350 | begin |
340 | pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
351 | pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
341 | for j := 0 to pl.DetectedIdentifications.Count-1 do |
352 | for j := 0 to pl.DetectedIdentifications.Count-1 do |
342 | begin |
353 | begin |
343 | ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry; |
354 | ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry; |
344 | IniTemplateMemo.Lines.Add(Format('; %s', [ude.Plugin.PluginName])); |
355 | IniTemplateMemo.Lines.Add(Format('; %s', [ude.Plugin.PluginName])); |
345 | 356 | ||
346 | idNames := TStringList.Create; |
357 | idNames := TStringList.Create; |
347 | try |
358 | try |
348 | ude.GetIdNames(idNames); |
359 | ude.GetIdNames(idNames); |
349 | if idNames.Count >= 1 then |
360 | if idNames.Count >= 1 then |
350 | IniTemplateMemo.Lines.Add(idNames.Strings[0]+'=calc.exe'); |
361 | IniTemplateMemo.Lines.Add(idNames.Strings[0]+'=calc.exe'); |
351 | finally |
362 | finally |
352 | idNames.Free; |
363 | idNames.Free; |
353 | end; |
364 | end; |
354 | 365 | ||
355 | end; |
366 | end; |
356 | end; |
367 | end; |
357 | end; |
368 | end; |
358 | 369 | ||
359 | procedure TUD2MainForm.LoadLoadedPluginList; |
370 | procedure TUD2MainForm.LoadLoadedPluginList; |
360 | resourcestring |
371 | resourcestring |
361 | LNG_MS = '%dms'; |
372 | LNG_MS = '%dms'; |
362 | var |
373 | var |
363 | i: integer; |
374 | i: integer; |
364 | pl: TUD2Plugin; |
375 | pl: TUD2Plugin; |
365 | begin |
376 | begin |
366 | LoadedPluginsListView.Clear; |
377 | LoadedPluginsListView.Clear; |
367 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
378 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
368 | begin |
379 | begin |
369 | pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
380 | pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
370 | with LoadedPluginsListView.Items.Add do |
381 | with LoadedPluginsListView.Items.Add do |
371 | begin |
382 | begin |
372 | Data := pl; |
383 | Data := pl; |
373 | Caption := pl.PluginDLL; |
384 | Caption := pl.PluginDLL; |
374 | SubItems.Add(pl.PluginVendor); |
385 | SubItems.Add(pl.PluginVendor); |
375 | SubItems.Add(pl.PluginName); |
386 | SubItems.Add(pl.PluginName); |
376 | SubItems.Add(pl.PluginVersion); |
387 | SubItems.Add(pl.PluginVersion); |
377 | SubItems.Add(pl.IdentificationMethodName); |
388 | SubItems.Add(pl.IdentificationMethodName); |
378 | if pl.AcceptsDynamicRequests then |
389 | if pl.AcceptsDynamicRequests then |
379 | SubItems.Add('Yes') |
390 | SubItems.Add('Yes') |
380 | else |
391 | else |
381 | SubItems.Add('No'); |
392 | SubItems.Add('No'); |
382 | SubItems.Add(IntToStr(pl.DetectedIdentifications.Count)); |
393 | SubItems.Add(IntToStr(pl.DetectedIdentifications.Count)); |
383 | SubItems.Add(Format(LNG_MS, [Max(1,pl.LoadingTime)])); // at least show 1ms, otherwise it would look unloggical |
394 | SubItems.Add(Format(LNG_MS, [Max(1,pl.LoadingTime)])); // at least show 1ms, otherwise it would look unloggical |
384 | SubItems.Add(pl.IdentificationProcedureStatusCodeDescribed); |
395 | SubItems.Add(pl.IdentificationProcedureStatusCodeDescribed); |
385 | SubItems.Add(pl.PluginGUIDString); |
396 | SubItems.Add(pl.PluginGUIDString); |
386 | end; |
397 | end; |
387 | end; |
398 | end; |
388 | 399 | ||
389 | for i := 0 to LoadedPluginsListView.Columns.Count-1 do |
400 | for i := 0 to LoadedPluginsListView.Columns.Count-1 do |
390 | begin |
401 | begin |
391 | LoadedPluginsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER; |
402 | LoadedPluginsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER; |
392 | end; |
403 | end; |
393 | end; |
404 | end; |
394 | 405 | ||
395 | procedure TUD2MainForm.TasksListViewDblClick(Sender: TObject); |
406 | procedure TUD2MainForm.TasksListViewDblClick(Sender: TObject); |
396 | var |
407 | var |
397 | obj: TUD2ListViewEntry; |
408 | obj: TUD2ListViewEntry; |
398 | begin |
409 | begin |
399 | if TasksListView.ItemIndex = -1 then exit; |
410 | if TasksListView.ItemIndex = -1 then exit; |
400 | obj := TUD2ListViewEntry(TasksListView.Selected.Data); |
411 | obj := TUD2ListViewEntry(TasksListView.Selected.Data); |
401 | DoRun(obj.ShortTaskName, true); |
412 | DoRun(obj.ShortTaskName, true); |
402 | if obj.CloseAfterLaunching then Close; |
413 | if obj.CloseAfterLaunching then Close; |
403 | end; |
414 | end; |
404 | 415 | ||
405 | procedure TUD2MainForm.TasksListViewKeyPress(Sender: TObject; var Key: Char); |
416 | procedure TUD2MainForm.TasksListViewKeyPress(Sender: TObject; var Key: Char); |
406 | begin |
417 | begin |
407 | if Key = #13 then |
418 | if Key = #13 then |
408 | begin |
419 | begin |
409 | TasksListViewDblClick(Sender); |
420 | TasksListViewDblClick(Sender); |
410 | end; |
421 | end; |
411 | end; |
422 | end; |
412 | 423 | ||
413 | procedure TUD2MainForm.OpenTDFButtonClick(Sender: TObject); |
424 | procedure TUD2MainForm.OpenTDFButtonClick(Sender: TObject); |
414 | var |
425 | var |
415 | cmd: TUD2Command; |
426 | cmd: TUD2Command; |
416 | begin |
427 | begin |
417 | cmd.executable := ud2.IniFileName; |
428 | cmd.executable := ud2.IniFileName; |
418 | cmd.runAsAdmin := false; |
429 | cmd.runAsAdmin := false; |
419 | cmd.runInOwnDirectory := false; |
430 | cmd.runInOwnDirectory := false; |
420 | cmd.windowMode := SW_NORMAL; |
431 | cmd.windowMode := SW_NORMAL; |
421 | UD2_RunCMD(cmd); |
432 | UD2_RunCMD(cmd); |
422 | end; |
433 | end; |
423 | 434 | ||
424 | procedure TUD2MainForm.SaveTDFButtonClick(Sender: TObject); |
435 | procedure TUD2MainForm.SaveTDFButtonClick(Sender: TObject); |
425 | begin |
436 | begin |
426 | if CompatSaveDialogExecute(SaveDialog1) then |
437 | if CompatSaveDialogExecute(SaveDialog1) then |
427 | begin |
438 | begin |
428 | IniTemplateMemo.Lines.SaveToFile(SaveDialog1.FileName); |
439 | IniTemplateMemo.Lines.SaveToFile(SaveDialog1.FileName); |
429 | end; |
440 | end; |
430 | end; |
441 | end; |
431 | 442 | ||
432 | procedure TUD2MainForm.URLLabelClick(Sender: TObject); |
443 | procedure TUD2MainForm.URLLabelClick(Sender: TObject); |
433 | var |
444 | var |
434 | cmd: TUD2Command; |
445 | cmd: TUD2Command; |
435 | begin |
446 | begin |
436 | cmd.executable := TLabel(Sender).Caption; |
447 | cmd.executable := TLabel(Sender).Caption; |
437 | if Pos('@', cmd.executable) > 0 then |
448 | if Pos('@', cmd.executable) > 0 then |
438 | cmd.executable := 'mailto:' + cmd.executable |
449 | cmd.executable := 'mailto:' + cmd.executable |
439 | else |
450 | else |
440 | cmd.executable := 'http://' + cmd.executable; |
451 | cmd.executable := 'http://' + cmd.executable; |
441 | 452 | ||
442 | cmd.runAsAdmin := false; |
453 | cmd.runAsAdmin := false; |
443 | cmd.runInOwnDirectory := false; |
454 | cmd.runInOwnDirectory := false; |
444 | cmd.windowMode := SW_NORMAL; |
455 | cmd.windowMode := SW_NORMAL; |
445 | 456 | ||
446 | UD2_RunCMD(cmd); |
457 | UD2_RunCMD(cmd); |
447 | end; |
458 | end; |
448 | 459 | ||
449 | procedure TUD2MainForm.TasksPopupMenuPopup(Sender: TObject); |
460 | procedure TUD2MainForm.TasksPopupMenuPopup(Sender: TObject); |
450 | begin |
461 | begin |
451 | Run1.Enabled := TasksListView.ItemIndex <> -1; |
462 | Run1.Enabled := TasksListView.ItemIndex <> -1; |
452 | Properties1.Enabled := TasksListView.ItemIndex <> -1; |
463 | Properties1.Enabled := TasksListView.ItemIndex <> -1; |
453 | end; |
464 | end; |
454 | 465 | ||
455 | procedure TUD2MainForm.Run1Click(Sender: TObject); |
466 | procedure TUD2MainForm.Run1Click(Sender: TObject); |
456 | begin |
467 | begin |
457 | TasksListViewDblClick(Sender); |
468 | TasksListViewDblClick(Sender); |
458 | end; |
469 | end; |
459 | 470 | ||
460 | procedure TUD2MainForm.Properties1Click(Sender: TObject); |
471 | procedure TUD2MainForm.Properties1Click(Sender: TObject); |
461 | var |
472 | var |
462 | obj: TUD2ListViewEntry; |
473 | obj: TUD2ListViewEntry; |
463 | begin |
474 | begin |
464 | if TasksListView.ItemIndex = -1 then exit; |
475 | if TasksListView.ItemIndex = -1 then exit; |
465 | obj := TUD2ListViewEntry(TasksListView.Selected.Data); |
476 | obj := TUD2ListViewEntry(TasksListView.Selected.Data); |
466 | if obj.TaskPropertiesForm = nil then |
477 | if obj.TaskPropertiesForm = nil then |
467 | begin |
478 | begin |
468 | obj.TaskPropertiesForm := TUD2TaskPropertiesForm.Create(Self, ud2, obj.ShortTaskName); |
479 | obj.TaskPropertiesForm := TUD2TaskPropertiesForm.Create(Self, ud2, obj.ShortTaskName); |
469 | end; |
480 | end; |
470 | obj.TaskPropertiesForm.Show; |
481 | obj.TaskPropertiesForm.Show; |
471 | end; |
482 | end; |
472 | 483 | ||
473 | procedure TUD2MainForm.IdentificationsPopupMenuPopup(Sender: TObject); |
484 | procedure TUD2MainForm.IdentificationsPopupMenuPopup(Sender: TObject); |
474 | begin |
485 | begin |
475 | CopyTaskDefinitionExample1.Enabled := IdentificationsListView.ItemIndex <> -1; |
486 | CopyTaskDefinitionExample1.Enabled := IdentificationsListView.ItemIndex <> -1; |
476 | end; |
487 | end; |
477 | 488 | ||
478 | procedure TUD2MainForm.CopyTaskDefinitionExample1Click(Sender: TObject); |
489 | procedure TUD2MainForm.CopyTaskDefinitionExample1Click(Sender: TObject); |
479 | var |
490 | var |
480 | s: string; |
491 | s: string; |
481 | ude: TUD2IdentificationEntry; |
492 | ude: TUD2IdentificationEntry; |
482 | begin |
493 | begin |
483 | if IdentificationsListView.ItemIndex = -1 then exit; |
494 | if IdentificationsListView.ItemIndex = -1 then exit; |
484 | 495 | ||
485 | ude := TUD2IdentificationEntry(IdentificationsListView.Selected.Data); |
496 | ude := TUD2IdentificationEntry(IdentificationsListView.Selected.Data); |
486 | s := '; ' + ude.Plugin.PluginName + #13#10 + |
497 | s := '; ' + ude.Plugin.PluginName + #13#10 + |
487 | UD2_CondToStr(ude.GetConditionString(false))+'=calc.exe'+#13#10+ |
498 | UD2_CondToStr(ude.GetConditionString(false))+'=calc.exe'+#13#10+ |
488 | #13#10+ |
499 | #13#10+ |
489 | '; Alternatively:'+#13#10+ |
500 | '; Alternatively:'+#13#10+ |
490 | UD2_CondToStr(ude.GetConditionString(true))+'=calc.exe'+#13#10; |
501 | UD2_CondToStr(ude.GetConditionString(true))+'=calc.exe'+#13#10; |
491 | 502 | ||
492 | Clipboard.AsText := s; |
503 | Clipboard.AsText := s; |
493 | end; |
504 | end; |
494 | 505 | ||
495 | procedure TUD2MainForm.ListViewCompare(Sender: TObject; Item1, |
506 | procedure TUD2MainForm.ListViewCompare(Sender: TObject; Item1, |
496 | Item2: TListItem; Data: Integer; var Compare: Integer); |
507 | Item2: TListItem; Data: Integer; var Compare: Integer); |
497 | var |
508 | var |
498 | ListView: TVTSListView; |
509 | ListView: TVTSListView; |
499 | begin |
510 | begin |
500 | ListView := Sender as TVTSListView; |
511 | ListView := Sender as TVTSListView; |
501 | if ListView.CurSortedColumn = 0 then |
512 | if ListView.CurSortedColumn = 0 then |
502 | begin |
513 | begin |
503 | Compare := AlphaNumCompare(Item1.Caption, Item2.Caption); |
514 | Compare := AlphaNumCompare(Item1.Caption, Item2.Caption); |
504 | end |
515 | end |
505 | else |
516 | else |
506 | begin |
517 | begin |
507 | Compare := AlphaNumCompare(Item1.SubItems[ListView.CurSortedColumn-1], |
518 | Compare := AlphaNumCompare(Item1.SubItems[ListView.CurSortedColumn-1], |
508 | Item2.SubItems[ListView.CurSortedColumn-1]); |
519 | Item2.SubItems[ListView.CurSortedColumn-1]); |
509 | end; |
520 | end; |
510 | if ListView.CurSortedDesc then Compare := -Compare; |
521 | if ListView.CurSortedDesc then Compare := -Compare; |
511 | end; |
522 | end; |
512 | 523 | ||
- | 524 | procedure TUD2MainForm.ConvertFirstIconToGray; |
|
- | 525 | var |
|
- | 526 | buffer, mask: TBitmap; |
|
- | 527 | x, y: integer; |
|
- | 528 | begin |
|
- | 529 | buffer := TBitmap.Create; |
|
- | 530 | mask := TBitmap.Create; |
|
- | 531 | try |
|
- | 532 | TasksImageList.GetBitmap(0, buffer); |
|
- | 533 | for x := 0 to buffer.Width - 1 do |
|
- | 534 | begin |
|
- | 535 | for y := 0 to buffer.Height - 1 do |
|
- | 536 | begin |
|
- | 537 | buffer.Canvas.Pixels[x, y] := ToGray(buffer.Canvas.Pixels[x, y]); |
|
- | 538 | end; |
|
- | 539 | end; |
|
- | 540 | ||
- | 541 | // create a mask for the icon. |
|
- | 542 | mask.Assign(buffer); |
|
- | 543 | mask.Canvas.Brush.Color := buffer.Canvas.Pixels[0, buffer.Height -1]; |
|
- | 544 | mask.Monochrome := true; |
|
- | 545 | ||
- | 546 | TasksImageList.Add(buffer, mask); |
|
- | 547 | finally |
|
- | 548 | buffer.Free; |
|
- | 549 | mask.Free; |
|
- | 550 | end; |
|
- | 551 | end; |
|
- | 552 | ||
513 | procedure TUD2MainForm.Button3Click(Sender: TObject); |
553 | procedure TUD2MainForm.Button3Click(Sender: TObject); |
514 | begin |
554 | begin |
515 | VTS_CheckUpdates('userdetect2', VersionLabel.Caption); |
555 | VTS_CheckUpdates('userdetect2', VersionLabel.Caption); |
516 | end; |
556 | end; |
517 | 557 | ||
518 | procedure TUD2MainForm.LoadedPluginsPopupMenuPopup(Sender: TObject); |
558 | procedure TUD2MainForm.LoadedPluginsPopupMenuPopup(Sender: TObject); |
519 | begin |
559 | begin |
520 | CopyStatusCodeToClipboard.Enabled := LoadedPluginsListView.ItemIndex <> -1; |
560 | CopyStatusCodeToClipboard.Enabled := LoadedPluginsListView.ItemIndex <> -1; |
521 | end; |
561 | end; |
522 | 562 | ||
523 | procedure TUD2MainForm.CopyStatusCodeToClipboardClick(Sender: TObject); |
563 | procedure TUD2MainForm.CopyStatusCodeToClipboardClick(Sender: TObject); |
524 | var |
564 | var |
525 | s: string; |
565 | s: string; |
526 | pl: TUD2Plugin; |
566 | pl: TUD2Plugin; |
527 | begin |
567 | begin |
528 | if LoadedPluginsListView.ItemIndex = -1 then exit; |
568 | if LoadedPluginsListView.ItemIndex = -1 then exit; |
529 | pl := TUD2Plugin(LoadedPluginsListView.Selected.Data); |
569 | pl := TUD2Plugin(LoadedPluginsListView.Selected.Data); |
530 | s := (*'; ' +*) pl.IdentificationProcedureStatusCodeDescribed; |
570 | s := (*'; ' +*) pl.IdentificationProcedureStatusCodeDescribed; |
531 | Clipboard.AsText := s; |
571 | Clipboard.AsText := s; |
532 | end; |
572 | end; |
533 | 573 | ||
534 | procedure TUD2MainForm.Run; |
574 | procedure TUD2MainForm.Run; |
535 | resourcestring |
575 | resourcestring |
536 | LNG_SYNTAX = 'Syntax: %s [TaskDefinitionFile [/T TaskName] | /C IdentificationTerm [Command] | /?]'; |
576 | LNG_SYNTAX = 'Syntax: %s [TaskDefinitionFile [/T TaskName] | /C IdentificationTerm [Command] | /?]'; |
537 | var |
577 | var |
538 | LoadedIniFile: string; |
578 | LoadedIniFile: string; |
539 | begin |
579 | begin |
540 | ExitCode := EXITCODE_OK; |
580 | ExitCode := EXITCODE_OK; |
541 | 581 | ||
542 | if ((ParamCount = 1) and CheckBoolParam(1, '?')) or |
582 | if ((ParamCount = 1) and CheckBoolParam(1, '?')) or |
543 | (CheckBoolParam(2, 'T') and (ParamCount > 3)) or |
583 | (CheckBoolParam(2, 'T') and (ParamCount > 3)) or |
544 | (CheckBoolParam(1, 'C') and (ParamCount > 3)) or |
584 | (CheckBoolParam(1, 'C') and (ParamCount > 3)) or |
545 | (not CheckBoolParam(2, 'T') and not CheckBoolParam(1, 'C') and (ParamCount > 1)) then |
585 | (not CheckBoolParam(2, 'T') and not CheckBoolParam(1, 'C') and (ParamCount > 1)) then |
546 | begin |
586 | begin |
547 | ExitCode := EXITCODE_SYNTAX_ERROR; |
587 | ExitCode := EXITCODE_SYNTAX_ERROR; |
548 | MessageDlg(Format(LNG_SYNTAX, [GetOwnCmdName]), mtInformation, [mbOK], 0); |
588 | MessageDlg(Format(LNG_SYNTAX, [GetOwnCmdName]), mtInformation, [mbOK], 0); |
549 | 589 | ||
550 | Visible := false; |
590 | Visible := false; |
551 | Close; |
591 | Close; |
552 | Exit; |
592 | Exit; |
553 | end; |
593 | end; |
554 | 594 | ||
555 | LoadedIniFile := GetIniFileName; |
595 | LoadedIniFile := GetIniFileName; |
556 | if LoadedIniFile = '' then |
596 | if LoadedIniFile = '' then |
557 | begin |
597 | begin |
558 | Visible := false; |
598 | Visible := false; |
559 | Close; |
599 | Close; |
560 | Exit; |
600 | Exit; |
561 | end; |
601 | end; |
562 | ud2 := TUD2.Create(LoadedIniFile); |
602 | ud2 := TUD2.Create(LoadedIniFile); |
563 | 603 | ||
564 | ud2.HandlePluginDir('', '*.udp'); |
604 | ud2.HandlePluginDir('', '*.udp'); |
565 | ud2.HandlePluginDir('Plugins', '*.udp'); |
605 | ud2.HandlePluginDir('Plugins', '*.udp'); |
566 | ud2.HandlePluginDir('Plugins', '*.dll'); |
606 | ud2.HandlePluginDir('Plugins', '*.dll'); |
567 | 607 | ||
568 | if CheckBoolParam(1, 'C') then |
608 | if CheckBoolParam(1, 'C') then |
569 | begin |
609 | begin |
570 | if ud2.FulfilsEverySubterm(ParamStr(2)) then |
610 | if ud2.FulfilsEverySubterm(ParamStr(2)) then |
571 | begin |
611 | begin |
572 | ExitCode := EXITCODE_OK; |
612 | ExitCode := EXITCODE_OK; |
573 | 613 | ||
574 | if ParamStr(3) <> '' then |
614 | if ParamStr(3) <> '' then |
575 | begin |
615 | begin |
576 | UD2_RunCMD(UD2P_DecodeCommand(ParamStr(3))); |
616 | UD2_RunCMD(UD2P_DecodeCommand(ParamStr(3))); |
577 | end; |
617 | end; |
578 | end |
618 | end |
579 | else |
619 | else |
580 | begin |
620 | begin |
581 | ExitCode := EXITCODE_TASK_NOTHING_MATCHES; |
621 | ExitCode := EXITCODE_TASK_NOTHING_MATCHES; |
582 | end; |
622 | end; |
583 | 623 | ||
584 | Visible := false; |
624 | Visible := false; |
585 | Close; |
625 | Close; |
586 | Exit; |
626 | Exit; |
587 | end |
627 | end |
588 | else if CheckBoolParam(2, 'T') then |
628 | else if CheckBoolParam(2, 'T') then |
589 | begin |
629 | begin |
590 | DoRun(ParamStr(3), false); |
630 | DoRun(ParamStr(3), false); |
591 | 631 | ||
592 | Visible := false; |
632 | Visible := false; |
593 | Close; |
633 | Close; |
594 | Exit; |
634 | Exit; |
595 | end |
635 | end |
596 | else |
636 | else |
597 | begin |
637 | begin |
598 | LoadTaskList; |
638 | LoadTaskList; |
599 | LoadDetectedIDs; |
639 | LoadDetectedIDs; |
600 | LoadINITemplate; |
640 | LoadINITemplate; |
601 | LoadLoadedPluginList; |
641 | LoadLoadedPluginList; |
602 | LoadDynamicPluginList; |
642 | LoadDynamicPluginList; |
603 | CheckForErrors; |
643 | CheckForErrors; |
604 | 644 | ||
605 | Visible := true; |
645 | Visible := true; |
606 | Exit; |
646 | Exit; |
607 | end; |
647 | end; |
608 | end; |
648 | end; |
609 | 649 | ||
610 | procedure TUD2MainForm.FormCreate(Sender: TObject); |
650 | procedure TUD2MainForm.FormCreate(Sender: TObject); |
611 | begin |
651 | begin |
612 | // To avoid accidental change of the default tab from the IDE VCL Designer |
652 | // To avoid accidental change of the default tab from the IDE VCL Designer |
613 | PageControl1.ActivePage := TasksTabSheet; |
653 | PageControl1.ActivePage := TasksTabSheet; |
614 | 654 | ||
615 | VersionLabel.Caption := GetFileVersion(ParamStr(0)); |
655 | VersionLabel.Caption := GetFileVersion(ParamStr(0)); |
- | 656 | ||
- | 657 | ConvertFirstIconToGray; |
|
616 | end; |
658 | end; |
617 | 659 | ||
618 | procedure TUD2MainForm.DynamicTestButtonClick(Sender: TObject); |
660 | procedure TUD2MainForm.DynamicTestButtonClick(Sender: TObject); |
619 | var |
661 | var |
620 | p: TUD2Plugin; |
662 | p: TUD2Plugin; |
621 | x: TArrayOfString; |
663 | x: TArrayOfString; |
622 | newStuff: boolean; |
664 | newStuff: boolean; |
623 | errors: TStrings; |
665 | errors: TStrings; |
624 | resourcestring |
666 | resourcestring |
625 | LNG_DETECTED_DYNAMICS = 'The plugin returned following identification strings:'; |
667 | LNG_DETECTED_DYNAMICS = 'The plugin returned following identification strings:'; |
626 | LNG_NOTHING_DETECTED = 'The plugin did not send any identification strings.'; |
668 | LNG_NOTHING_DETECTED = 'The plugin did not send any identification strings.'; |
627 | LNG_STATUS_RETURNED = 'The plugin sent following status in reply to your request:'; |
669 | LNG_STATUS_RETURNED = 'The plugin sent following status in reply to your request:'; |
628 | LNG_ERROR_RETURNED = 'The dynamic plugin could not load. The plugin sent following error messages:'; |
670 | LNG_ERROR_RETURNED = 'The dynamic plugin could not load. The plugin sent following error messages:'; |
629 | begin |
671 | begin |
630 | if DynamicTestPluginComboBox.ItemIndex = -1 then |
672 | if DynamicTestPluginComboBox.ItemIndex = -1 then |
631 | begin |
673 | begin |
632 | ShowMessage('Please select a plugin that is accepting dynamic requests.'); |
674 | ShowMessage('Please select a plugin that is accepting dynamic requests.'); |
633 | Exit; |
675 | Exit; |
634 | end; |
676 | end; |
635 | 677 | ||
636 | p := DynamicTestPluginComboBox.Items.Objects[DynamicTestPluginComboBox.ItemIndex] as TUD2Plugin; |
678 | p := DynamicTestPluginComboBox.Items.Objects[DynamicTestPluginComboBox.ItemIndex] as TUD2Plugin; |
637 | 679 | ||
638 | errors := TStringList.Create; |
680 | errors := TStringList.Create; |
639 | try |
681 | try |
640 | newStuff := p.InvokeDynamicCheck(DynamicTestDataEdit.Text, errors, x); |
682 | newStuff := p.InvokeDynamicCheck(DynamicTestDataEdit.Text, errors, x); |
641 | if errors.Count > 0 then |
683 | if errors.Count > 0 then |
642 | begin |
684 | begin |
643 | ShowMessage(LNG_ERROR_RETURNED + #13#10#13#10 + errors.Text); |
685 | ShowMessage(LNG_ERROR_RETURNED + #13#10#13#10 + errors.Text); |
644 | Exit; |
686 | Exit; |
645 | end; |
687 | end; |
646 | finally |
688 | finally |
647 | FreeAndNil(errors); |
689 | FreeAndNil(errors); |
648 | end; |
690 | end; |
649 | 691 | ||
650 | if p.IdentificationProcedureStatusCode.wCategory <> UD2_STATUSCAT_SUCCESS then |
692 | if p.IdentificationProcedureStatusCode.wCategory <> UD2_STATUSCAT_SUCCESS then |
651 | begin |
693 | begin |
652 | // e.g. "Not available" because of invalid dynamic input data |
694 | // e.g. "Not available" because of invalid dynamic input data |
653 | ShowMessage(LNG_STATUS_RETURNED + #13#10#13#10 + p.IdentificationProcedureStatusCodeDescribed); |
695 | ShowMessage(LNG_STATUS_RETURNED + #13#10#13#10 + p.IdentificationProcedureStatusCodeDescribed); |
654 | Exit; |
696 | Exit; |
655 | end; |
697 | end; |
656 | 698 | ||
657 | if Length(x) > 0 then |
699 | if Length(x) > 0 then |
658 | ShowMessage(LNG_DETECTED_DYNAMICS + #13#10#13#10 + MergeString(x, #13#10)) |
700 | ShowMessage(LNG_DETECTED_DYNAMICS + #13#10#13#10 + MergeString(x, #13#10)) |
659 | else |
701 | else |
660 | ShowMessage(LNG_NOTHING_DETECTED); |
702 | ShowMessage(LNG_NOTHING_DETECTED); |
661 | 703 | ||
662 | if newStuff then |
704 | if newStuff then |
663 | begin |
705 | begin |
664 | LoadDetectedIDs; |
706 | LoadDetectedIDs; |
665 | LoadINITemplate; |
707 | LoadINITemplate; |
666 | LoadLoadedPluginList; // To update the "Detected IDs" column |
708 | LoadLoadedPluginList; // To update the "Detected IDs" column |
667 | end; |
709 | end; |
668 | end; |
710 | end; |
669 | 711 | ||
670 | procedure TUD2MainForm.LoadDynamicPluginList; |
712 | procedure TUD2MainForm.LoadDynamicPluginList; |
671 | var |
713 | var |
672 | i: integer; |
714 | i: integer; |
673 | p: TUD2Plugin; |
715 | p: TUD2Plugin; |
674 | begin |
716 | begin |
675 | DynamicTestPluginComboBox.Clear; |
717 | DynamicTestPluginComboBox.Clear; |
676 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
718 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
677 | begin |
719 | begin |
678 | p := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
720 | p := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
679 | if p.AcceptsDynamicRequests then |
721 | if p.AcceptsDynamicRequests then |
680 | begin |
722 | begin |
681 | // TODO: PROBLEM!! Beim Dynamic Check (Dynamic Query) wird der plugin status überschrieben!!! |
723 | // TODO: PROBLEM!! Beim Dynamic Check (Dynamic Query) wird der plugin status überschrieben!!! |
682 | DynamicTestPluginComboBox.Items.AddObject(p.PluginName, p); |
724 | DynamicTestPluginComboBox.Items.AddObject(p.PluginName, p); |
683 | end; |
725 | end; |
684 | end; |
726 | end; |
685 | end; |
727 | end; |
686 | 728 | ||
687 | end. |
729 | end. |
688 | 730 |