Archive editing improvements.
Add file/folder clearing on folders and archive. Add folder replacing.
This commit is contained in:
parent
2a62ad98ab
commit
5518ea598d
@ -308,6 +308,7 @@ namespace Toolbox.Library
|
|||||||
new STToolStripSeparator(),
|
new STToolStripSeparator(),
|
||||||
new STToolStripItem("Add Folder", AddFolderAction) { Enabled = ArchiveFile.CanAddFiles},
|
new STToolStripItem("Add Folder", AddFolderAction) { Enabled = ArchiveFile.CanAddFiles},
|
||||||
new STToolStripItem("Add File", AddFileAction) { Enabled = ArchiveFile.CanAddFiles},
|
new STToolStripItem("Add File", AddFileAction) { Enabled = ArchiveFile.CanAddFiles},
|
||||||
|
new STToolStripItem("Clear Files", ClearAction) { Enabled = ArchiveFile.CanDeleteFiles},
|
||||||
};
|
};
|
||||||
|
|
||||||
var toolStripList = ToolStrips.ToList();
|
var toolStripList = ToolStrips.ToList();
|
||||||
@ -319,6 +320,16 @@ namespace Toolbox.Library
|
|||||||
return toolStripList.ToArray();
|
return toolStripList.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ClearAction(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
//Clear all nodes
|
||||||
|
for (int i = 0; i < FileNodes.Count; i++)
|
||||||
|
ArchiveFile.DeleteFile(FileNodes[i].Item1);
|
||||||
|
|
||||||
|
Nodes.Clear();
|
||||||
|
FileNodes.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
private void AddFolderAction(object sender, EventArgs args)
|
private void AddFolderAction(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
Nodes.Add(new ArchiveFolderNodeWrapper("NewFolder", ArchiveFile, this));
|
Nodes.Add(new ArchiveFolderNodeWrapper("NewFolder", ArchiveFile, this));
|
||||||
@ -669,6 +680,7 @@ namespace Toolbox.Library
|
|||||||
new STToolStripSeparator(),
|
new STToolStripSeparator(),
|
||||||
new STToolStripItem("Add Folder", AddFolderAction) { Enabled = ArchiveFile.CanAddFiles },
|
new STToolStripItem("Add Folder", AddFolderAction) { Enabled = ArchiveFile.CanAddFiles },
|
||||||
new STToolStripItem("Add File", AddFileAction) { Enabled = ArchiveFile.CanAddFiles },
|
new STToolStripItem("Add File", AddFileAction) { Enabled = ArchiveFile.CanAddFiles },
|
||||||
|
new STToolStripItem("Clear Files", ClearAction) { Enabled = ArchiveFile.CanDeleteFiles },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -688,6 +700,17 @@ namespace Toolbox.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ClearAction(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
foreach (var node in TreeViewExtensions.Collect(Nodes))
|
||||||
|
{
|
||||||
|
if (node is ArchiveFileWrapper)
|
||||||
|
ArchiveFile.DeleteFile(((ArchiveFileWrapper)node).ArchiveFileInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
Nodes.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnClick(TreeView treeView)
|
public override void OnClick(TreeView treeView)
|
||||||
{
|
{
|
||||||
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.GetActiveContent(typeof(STPropertyGrid));
|
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.GetActiveContent(typeof(STPropertyGrid));
|
||||||
@ -733,8 +756,21 @@ namespace Toolbox.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReplaceAction(object sender, EventArgs args)
|
private void ReplaceAction(object sender, EventArgs args) {
|
||||||
{
|
//Add folders and files from selected path
|
||||||
|
FolderSelectDialog ofd = new FolderSelectDialog();
|
||||||
|
if (ofd.ShowDialog() == DialogResult.OK) {
|
||||||
|
//Clear all nodes
|
||||||
|
foreach (var node in TreeViewExtensions.Collect(Nodes))
|
||||||
|
{
|
||||||
|
if (node is ArchiveFileWrapper)
|
||||||
|
ArchiveFile.DeleteFile(((ArchiveFileWrapper)node).ArchiveFileInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
Nodes.Clear();
|
||||||
|
|
||||||
|
TreeHelper.AddFiles(this, RootNode, Directory.GetFiles(ofd.SelectedPath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteAction(object sender, EventArgs args) {
|
private void DeleteAction(object sender, EventArgs args) {
|
||||||
|
Loading…
Reference in New Issue
Block a user