Rev 73 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
68 | daniel-mar | 1 | unit UD2_TaskProperties; |
2 | |||
3 | interface |
||
4 | |||
5 | uses |
||
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
||
7 | Dialogs, UD2_Obj, StdCtrls, ExtCtrls, Grids, ValEdit; |
||
8 | |||
9 | type |
||
10 | TUD2TaskPropertiesForm = class(TForm) |
||
11 | ValueListEditor1: TValueListEditor; |
||
12 | LabeledEdit1: TLabeledEdit; |
||
13 | Image1: TImage; |
||
14 | ListBox1: TListBox; |
||
15 | Label1: TLabel; |
||
16 | Button1: TButton; |
||
17 | Label2: TLabel; |
||
18 | Button2: TButton; |
||
19 | procedure Button2Click(Sender: TObject); |
||
20 | procedure Button1Click(Sender: TObject); |
||
21 | private |
||
22 | FUD2: TUD2; |
||
23 | FShortTaskName: string; |
||
24 | procedure LoadExecutableFilesList; |
||
25 | procedure LoadIcon; |
||
26 | public |
||
27 | constructor Create(AOwner: TComponent; AUD2: TUD2; AShortTaskName: string); reintroduce; |
||
28 | end; |
||
29 | |||
30 | (* |
||
31 | var |
||
32 | UD2TaskPropertiesForm: TTaskPropertiesForm; |
||
33 | *) |
||
34 | |||
35 | implementation |
||
36 | |||
37 | {$R *.dfm} |
||
38 | |||
39 | uses |
||
40 | UD2_Utils, UD2_Main, ShellAPI; |
||
41 | |||
42 | procedure TUD2TaskPropertiesForm.LoadExecutableFilesList; |
||
43 | resourcestring |
||
44 | LNG_RIOD = '%s [Run in own directory]'; |
||
45 | var |
||
46 | sl: TStringList; |
||
47 | i: integer; |
||
48 | s: string; |
||
49 | begin |
||
50 | //fud2.GetCommandList(AShortTaskName, ListBox1.Items); |
||
51 | |||
52 | ListBox1.Clear; |
||
53 | sl := TStringList.Create; |
||
54 | try |
||
55 | fud2.GetCommandList(FShortTaskName, sl); |
||
56 | for i := 0 to sl.Count-1 do |
||
57 | begin |
||
58 | s := sl.Strings[i]; |
||
59 | if Copy(s, 1, Length(UD2_RUN_IN_OWN_DIRECTORY_PREFIX)) = UD2_RUN_IN_OWN_DIRECTORY_PREFIX then |
||
60 | begin |
||
61 | s := Copy(s, 1+Length(UD2_RUN_IN_OWN_DIRECTORY_PREFIX), Length(s)-Length(UD2_RUN_IN_OWN_DIRECTORY_PREFIX)); |
||
62 | s := Format(LNG_RIOD, [s]); |
||
63 | end; |
||
64 | ListBox1.Items.Add(s); |
||
65 | end; |
||
66 | finally |
||
67 | sl.Free; |
||
68 | end; |
||
69 | end; |
||
70 | |||
71 | procedure TUD2TaskPropertiesForm.LoadIcon; |
||
72 | var |
||
73 | ico: TIcon; |
||
74 | icoSplit: TIconFileIdx; |
||
75 | iconString: string; |
||
76 | begin |
||
77 | iconString := fud2.ReadMetatagString(FShortTaskName, UD2_Main.TagIcon, ''); |
||
78 | if iconString <> '' then |
||
79 | begin |
||
80 | icoSplit := SplitIconString(iconString); |
||
81 | ico := TIcon.Create; |
||
82 | try |
||
83 | ico.Handle := ExtractIcon(Application.Handle, PChar(icoSplit.FileName), icoSplit.IconIndex); |
||
84 | Image1.Picture.Icon.Assign(ico); |
||
85 | finally |
||
86 | ico.Free; |
||
87 | end; |
||
88 | end |
||
89 | else |
||
90 | begin |
||
91 | UD2MainForm.ImageList1.GetIcon(0, Image1.Picture.Icon); |
||
92 | end; |
||
93 | end; |
||
94 | |||
95 | constructor TUD2TaskPropertiesForm.Create(AOwner: TComponent; AUD2: TUD2; AShortTaskName: string); |
||
96 | resourcestring |
||
97 | LNG_TASK_PROPS = 'Task properties of "%s"'; |
||
98 | var |
||
99 | Description: string; |
||
100 | begin |
||
101 | inherited Create(AOwner); |
||
102 | FUD2 := AUD2; |
||
103 | FShortTaskName := AShortTaskName; |
||
104 | |||
105 | FUD2.IniFile.ReadSectionValues(AShortTaskName, ValueListEditor1.Strings); |
||
106 | |||
107 | Description := FUD2.GetTaskName(AShortTaskName); |
||
108 | Caption := Format(LNG_TASK_PROPS, [Description]); |
||
109 | LabeledEdit1.Text := AShortTaskName; |
||
110 | LoadExecutableFilesList; |
||
111 | LoadIcon; |
||
112 | end; |
||
113 | |||
114 | procedure TUD2TaskPropertiesForm.Button2Click(Sender: TObject); |
||
115 | begin |
||
116 | Close; |
||
117 | end; |
||
118 | |||
119 | procedure TUD2TaskPropertiesForm.Button1Click(Sender: TObject); |
||
120 | begin |
||
121 | UD2_RunCMD(fud2.IniFileName, SW_NORMAL); |
||
122 | end; |
||
123 | |||
124 | end. |