18,11 → 18,14 |
ImageList1: TImageList; |
CheckBox2: TCheckBox; |
Button3: TButton; |
Button4: TButton; |
SaveDialog1: TSaveDialog; |
procedure Button1Click(Sender: TObject); |
procedure Button2Click(Sender: TObject); |
procedure FormShow(Sender: TObject); |
procedure TreeView1DblClick(Sender: TObject); |
procedure Button3Click(Sender: TObject); |
procedure Button4Click(Sender: TObject); |
private |
localRecyclersNode: TTreeNode; |
individualRecyclersNode: TTreeNode; |
50,6 → 53,9 |
ICON_UNKNOWN = 8; |
ICON_FOLDER = 10; |
|
resourcestring |
S_PLEASE_WAIT = 'Please wait'; |
|
procedure TRecyclerListingMainForm.Button1Click(Sender: TObject); |
var |
drives: TObjectList{TRbDrive}; |
67,74 → 73,82 |
item: TRbRecycleBinItem; |
nItem: TTreeNode; |
sCaption: string; |
|
bakCaption: string; |
resourcestring |
S_DRIVE = 'Drive %s'; |
begin |
localRecyclersNode.DeleteChildren; // TODO: Will the objects be freed? This is important to avoid memory leaks. |
|
TreeView1.Items.BeginUpdate; |
drives := TObjectList.Create(false); |
bins := TObjectList.Create(false); |
items := TObjectList.Create(false); |
bakCaption := Button1.Caption; |
Button1.Caption := S_PLEASE_WAIT; |
try |
drives.Clear; |
TRecycleBinManager.ListDrives(drives); |
for iDrive := 0 to drives.Count - 1 do |
begin |
drive := drives.Items[iDrive] as TRbDrive; |
localRecyclersNode.DeleteChildren; // TODO: Will the objects be freed? This is important to avoid memory leaks. |
|
if drive.VolumeGUIDAvailable then |
nDrive := TreeView1.Items.AddChildObject(localRecyclersNode, Format(S_DRIVE, [drive.DriveLetter])+': ' + GUIDToString(drive.VolumeGUID), drive) |
else |
nDrive := TreeView1.Items.AddChildObject(localRecyclersNode, Format(S_DRIVE, [drive.DriveLetter])+':', drive); |
nDrive.ImageIndex := ICON_DRIVE; |
nDrive.SelectedIndex := nDrive.ImageIndex; |
|
bins.Clear; |
if CheckBox1.Checked then |
drive.ListRecycleBins(bins, GetMySID) |
else |
drive.ListRecycleBins(bins); |
for iBin := 0 to bins.Count - 1 do |
TreeView1.Items.BeginUpdate; |
drives := TObjectList.Create(false); |
bins := TObjectList.Create(false); |
items := TObjectList.Create(false); |
try |
drives.Clear; |
TRecycleBinManager.ListDrives(drives); |
for iDrive := 0 to drives.Count - 1 do |
begin |
bin := bins.Items[iBin] as TRbRecycleBin; |
drive := drives.Items[iDrive] as TRbDrive; |
|
nBin := TreeView1.Items.AddChildObject(nDrive, bin.FileOrDirectory, bin); |
nBin.ImageIndex := ICON_BIN; |
nBin.SelectedIndex := nBin.ImageIndex; |
if drive.VolumeGUIDAvailable then |
nDrive := TreeView1.Items.AddChildObject(localRecyclersNode, Format(S_DRIVE, [drive.DriveLetter])+': ' + GUIDToString(drive.VolumeGUID), drive) |
else |
nDrive := TreeView1.Items.AddChildObject(localRecyclersNode, Format(S_DRIVE, [drive.DriveLetter])+':', drive); |
nDrive.ImageIndex := ICON_DRIVE; |
nDrive.SelectedIndex := nDrive.ImageIndex; |
|
items.Clear; |
bin.ListItems(items); |
for iItem := 0 to items.Count - 1 do |
bins.Clear; |
if CheckBox1.Checked then |
drive.ListRecycleBins(bins, GetMySID) |
else |
drive.ListRecycleBins(bins); |
for iBin := 0 to bins.Count - 1 do |
begin |
item := items.Items[iItem] as TRbRecycleBinItem; |
bin := bins.Items[iBin] as TRbRecycleBin; |
|
if not FileExists(item.PhysicalFile) and |
not DirectoryExists(item.PhysicalFile) and |
CheckBox2.Checked then continue; |
nBin := TreeView1.Items.AddChildObject(nDrive, bin.FileOrDirectory, bin); |
nBin.ImageIndex := ICON_BIN; |
nBin.SelectedIndex := nBin.ImageIndex; |
|
sCaption := item.Source; |
if item is TRbVistaItem (*item.IndexFile <> ''*) then sCaption := sCaption + ' ('+ExtractFileName(item.IndexFile)+')'; |
nItem := TreeView1.Items.AddChildObject(nBin, sCaption, item); |
items.Clear; |
bin.ListItems(items); |
for iItem := 0 to items.Count - 1 do |
begin |
item := items.Items[iItem] as TRbRecycleBinItem; |
|
if FileExists(item.PhysicalFile) then |
nItem.ImageIndex := ICON_FILE |
else if DirectoryExists(item.PhysicalFile) then |
nItem.ImageIndex := ICON_FOLDER // TODO: Feature: Read folder contents and display them in this treeview. (Also change icon to "open folder") |
else |
nItem.ImageIndex := ICON_UNKNOWN; |
nItem.SelectedIndex := nItem.ImageIndex; |
if not FileExists(item.PhysicalFile) and |
not DirectoryExists(item.PhysicalFile) and |
CheckBox2.Checked then continue; |
|
sCaption := item.Source; |
if item is TRbVistaItem (*item.IndexFile <> ''*) then sCaption := sCaption + ' ('+ExtractFileName(item.IndexFile)+')'; |
nItem := TreeView1.Items.AddChildObject(nBin, sCaption, item); |
|
if FileExists(item.PhysicalFile) then |
nItem.ImageIndex := ICON_FILE |
else if DirectoryExists(item.PhysicalFile) then |
nItem.ImageIndex := ICON_FOLDER // TODO: Feature: Read folder contents and display them in this treeview. (Also change icon to "open folder") |
else |
nItem.ImageIndex := ICON_UNKNOWN; |
nItem.SelectedIndex := nItem.ImageIndex; |
end; |
end; |
end; |
finally |
drives.Free; |
bins.Free; |
items.Free; |
TreeView1.Items.EndUpdate; |
end; |
|
localRecyclersNode.Expand(false); |
finally |
drives.Free; |
bins.Free; |
items.Free; |
TreeView1.Items.EndUpdate; |
Button1.Caption := bakCaption; |
end; |
|
localRecyclersNode.Expand(false); |
end; |
|
procedure TRecyclerListingMainForm.Button2Click(Sender: TObject); |
147,43 → 161,50 |
item: TRbRecycleBinItem; |
nItem: TTreeNode; |
sCaption: string; |
bakCaption: string; |
begin |
bin := TRbRecycleBin.Create(LabeledEdit1.Text); |
bakCaption := Button2.Caption; |
Button2.Caption := S_PLEASE_WAIT; |
try |
bin := TRbRecycleBin.Create(LabeledEdit1.Text); |
|
nBin := TreeView1.Items.AddChildObject(individualRecyclersNode, bin.FileOrDirectory, bin); |
nBin.ImageIndex := ICON_BIN; |
nBin.SelectedIndex := nBin.ImageIndex; |
individualRecyclersNode.Expand(false); |
nBin := TreeView1.Items.AddChildObject(individualRecyclersNode, bin.FileOrDirectory, bin); |
nBin.ImageIndex := ICON_BIN; |
nBin.SelectedIndex := nBin.ImageIndex; |
individualRecyclersNode.Expand(false); |
|
items := TObjectList.Create(false); |
try |
items.Clear; |
bin.ListItems(items); |
for iItem := 0 to items.Count - 1 do |
begin |
item := items.Items[iItem] as TRbRecycleBinItem; |
items := TObjectList.Create(false); |
try |
items.Clear; |
bin.ListItems(items); |
for iItem := 0 to items.Count - 1 do |
begin |
item := items.Items[iItem] as TRbRecycleBinItem; |
|
if not FileExists(item.PhysicalFile) and |
not DirectoryExists(item.PhysicalFile) and |
CheckBox2.Checked then continue; |
if not FileExists(item.PhysicalFile) and |
not DirectoryExists(item.PhysicalFile) and |
CheckBox2.Checked then continue; |
|
sCaption := item.Source; |
if item is TRbVistaItem (*item.IndexFile <> ''*) then sCaption := sCaption + ' ('+ExtractFileName(item.IndexFile)+')'; |
nItem := TreeView1.Items.AddChildObject(nBin, sCaption, item); |
sCaption := item.Source; |
if item is TRbVistaItem (*item.IndexFile <> ''*) then sCaption := sCaption + ' ('+ExtractFileName(item.IndexFile)+')'; |
nItem := TreeView1.Items.AddChildObject(nBin, sCaption, item); |
|
if FileExists(item.PhysicalFile) then |
nItem.ImageIndex := ICON_FILE |
else if DirectoryExists(item.PhysicalFile) then |
nItem.ImageIndex := ICON_FOLDER // TODO: Feature: Read folder contents and display them in this treeview. (Also change icon to "open folder") |
else |
nItem.ImageIndex := ICON_UNKNOWN; |
nItem.SelectedIndex := nItem.ImageIndex; |
if FileExists(item.PhysicalFile) then |
nItem.ImageIndex := ICON_FILE |
else if DirectoryExists(item.PhysicalFile) then |
nItem.ImageIndex := ICON_FOLDER // TODO: Feature: Read folder contents and display them in this treeview. (Also change icon to "open folder") |
else |
nItem.ImageIndex := ICON_UNKNOWN; |
nItem.SelectedIndex := nItem.ImageIndex; |
end; |
finally |
items.Free; |
end; |
|
nBin.Expand(false); |
finally |
items.Free; |
Button2.Caption := bakCaption; |
end; |
|
nBin.Expand(false); |
end; |
|
procedure TRecyclerListingMainForm.Button3Click(Sender: TObject); |
192,6 → 213,14 |
LabeledEdit1.Text := OpenDialog1.FileName; |
end; |
|
procedure TRecyclerListingMainForm.Button4Click(Sender: TObject); |
begin |
if SaveDialog1.Execute then |
begin |
TreeView1.SaveToFile(SaveDialog1.FileName); |
end; |
end; |
|
procedure TRecyclerListingMainForm.FormShow(Sender: TObject); |
resourcestring |
S_LOCAL_RECYCLE_BINS = 'Local recycle bins'; |