Subversion Repositories userdetect2

Rev

Rev 73 | Rev 81 | 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
 
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
80 daniel-mar 44
  LNG_RIOD = 'Run in own directory';
45
  LNG_ADMIN = 'Run as admin';
68 daniel-mar 46
var
47
  sl: TStringList;
48
  i: integer;
80 daniel-mar 49
  cmdLine, flags: string;
68 daniel-mar 50
begin
51
  //fud2.GetCommandList(AShortTaskName, ListBox1.Items);
52
 
53
  ListBox1.Clear;
54
  sl := TStringList.Create;
55
  try
56
    fud2.GetCommandList(FShortTaskName, sl);
57
    for i := 0 to sl.Count-1 do
58
    begin
80 daniel-mar 59
      cmdLine := sl.Strings[i];
60
      flags := '';
61
 
62
      if Pos(UD2_RUN_AS_ADMIN, cmdLine) >= 1 then
68 daniel-mar 63
      begin
80 daniel-mar 64
        cmdLine := StringReplace(cmdLine, UD2_RUN_AS_ADMIN, '', [rfReplaceAll]);
65
        if flags <> '' then flags := flags + ', ';
66
        flags := flags + LNG_ADMIN;
68 daniel-mar 67
      end;
80 daniel-mar 68
 
69
      if Pos(UD2_RUN_IN_OWN_DIRECTORY_PREFIX, cmdLine) >= 1 then
70
      begin
71
        cmdLine := StringReplace(cmdLine, UD2_RUN_IN_OWN_DIRECTORY_PREFIX, '', [rfReplaceAll]);
72
        if flags <> '' then flags := flags + ', ';
73
        flags := flags + LNG_RIOD;
74
      end;
75
 
76
      if flags <> '' then
77
      begin
78
        flags := ' [' + flags + ']';
79
      end;
80
 
81
      ListBox1.Items.Add(cmdLine + flags);
68 daniel-mar 82
    end;
83
  finally
84
    sl.Free;
85
  end;
86
end;
87
 
88
procedure TUD2TaskPropertiesForm.LoadIcon;
89
var
90
  ico: TIcon;
91
  icoSplit: TIconFileIdx;
92
  iconString: string;
93
begin
94
  iconString := fud2.ReadMetatagString(FShortTaskName, UD2_Main.TagIcon, '');
95
  if iconString <> '' then
96
  begin
97
    icoSplit := SplitIconString(iconString);
98
    ico := TIcon.Create;
99
    try
100
      ico.Handle := ExtractIcon(Application.Handle, PChar(icoSplit.FileName), icoSplit.IconIndex);
101
      Image1.Picture.Icon.Assign(ico);
102
    finally
103
      ico.Free;
104
    end;
105
  end
106
  else
107
  begin
73 daniel-mar 108
    UD2MainForm.TasksImageList.GetIcon(0, Image1.Picture.Icon);
68 daniel-mar 109
  end;
110
end;
111
 
112
constructor TUD2TaskPropertiesForm.Create(AOwner: TComponent; AUD2: TUD2; AShortTaskName: string);
113
resourcestring
114
  LNG_TASK_PROPS = 'Task properties of "%s"';
115
var
116
  Description: string;
117
begin
118
  inherited Create(AOwner);
119
  FUD2 := AUD2;
120
  FShortTaskName := AShortTaskName;
121
 
122
  FUD2.IniFile.ReadSectionValues(AShortTaskName, ValueListEditor1.Strings);
123
 
124
  Description := FUD2.GetTaskName(AShortTaskName);
125
  Caption := Format(LNG_TASK_PROPS, [Description]);
126
  LabeledEdit1.Text := AShortTaskName;
127
  LoadExecutableFilesList;
128
  LoadIcon;
129
end;
130
 
131
procedure TUD2TaskPropertiesForm.Button2Click(Sender: TObject);
132
begin
133
  Close;
134
end;
135
 
136
procedure TUD2TaskPropertiesForm.Button1Click(Sender: TObject);
137
begin
138
  UD2_RunCMD(fud2.IniFileName, SW_NORMAL);
139
end;
140
 
141
end.