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