Add checks for enabling certain content menus
This commit is contained in:
parent
7e8cfcd16c
commit
6c38b46ad4
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -94,7 +94,7 @@ namespace Switch_Toolbox.Library.Forms
|
|||||||
stPanel1.Controls.Add(ObjectTree);
|
stPanel1.Controls.Add(ObjectTree);
|
||||||
|
|
||||||
TreeNode FileRoot = new TreeNode(FileFormat.FileName);
|
TreeNode FileRoot = new TreeNode(FileFormat.FileName);
|
||||||
FillTreeNodes(FileRoot, ((IArchiveFile)FileFormat).Files);
|
FillTreeNodes(FileRoot, (IArchiveFile)FileFormat);
|
||||||
AddNode(FileRoot);
|
AddNode(FileRoot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -106,11 +106,11 @@ namespace Switch_Toolbox.Library.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FillTreeNodes(TreeNode root, IEnumerable<ArchiveFileInfo> files)
|
void FillTreeNodes(TreeNode root, IArchiveFile archiveFile)
|
||||||
{
|
{
|
||||||
var rootText = root.Text;
|
var rootText = root.Text;
|
||||||
var rootTextLength = rootText.Length;
|
var rootTextLength = rootText.Length;
|
||||||
var nodeStrings = files;
|
var nodeStrings = archiveFile.Files;
|
||||||
foreach (var node in nodeStrings)
|
foreach (var node in nodeStrings)
|
||||||
{
|
{
|
||||||
string nodeString = node.FileName;
|
string nodeString = node.FileName;
|
||||||
@ -136,9 +136,17 @@ namespace Switch_Toolbox.Library.Forms
|
|||||||
// Node was not found, add it
|
// Node was not found, add it
|
||||||
|
|
||||||
var folder = new ArchiveFolderNodeWrapper(parentName);
|
var folder = new ArchiveFolderNodeWrapper(parentName);
|
||||||
|
folder.CanReplace = archiveFile.CanReplaceFiles;
|
||||||
|
folder.CanDelete = archiveFile.CanDeleteFiles;
|
||||||
|
folder.CanRename = archiveFile.CanRenameFiles;
|
||||||
|
|
||||||
if (rootIndex == roots.Length - 1)
|
if (rootIndex == roots.Length - 1)
|
||||||
{
|
{
|
||||||
ArchiveNodeWrapper wrapperFile = new ArchiveNodeWrapper(parentName);
|
ArchiveNodeWrapper wrapperFile = new ArchiveNodeWrapper(parentName);
|
||||||
|
wrapperFile.CanReplace = archiveFile.CanReplaceFiles;
|
||||||
|
wrapperFile.CanDelete = archiveFile.CanDeleteFiles;
|
||||||
|
wrapperFile.CanRename = archiveFile.CanRenameFiles;
|
||||||
|
|
||||||
wrapperFile.ArchiveFileInfo = node;
|
wrapperFile.ArchiveFileInfo = node;
|
||||||
wrapperFile.Name = nodeName;
|
wrapperFile.Name = nodeName;
|
||||||
parentNode.Nodes.Add(wrapperFile);
|
parentNode.Nodes.Add(wrapperFile);
|
||||||
|
@ -66,6 +66,28 @@ namespace Switch_Toolbox.Library
|
|||||||
|
|
||||||
public class ArchiveFolderNodeWrapper : TreeNodeCustom
|
public class ArchiveFolderNodeWrapper : TreeNodeCustom
|
||||||
{
|
{
|
||||||
|
public bool CanReplace
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
ContextMenuStrip.Items[1].Enabled = true;
|
||||||
|
else
|
||||||
|
ContextMenuStrip.Items[1].Enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool CanRename = false;
|
||||||
|
public bool CanDelete
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
ContextMenuStrip.Items[2].Enabled = true;
|
||||||
|
else
|
||||||
|
ContextMenuStrip.Items[2].Enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ArchiveFolderNodeWrapper(string text)
|
public ArchiveFolderNodeWrapper(string text)
|
||||||
{
|
{
|
||||||
Text = text;
|
Text = text;
|
||||||
@ -73,6 +95,7 @@ namespace Switch_Toolbox.Library
|
|||||||
ContextMenuStrip = new STContextMenuStrip();
|
ContextMenuStrip = new STContextMenuStrip();
|
||||||
ContextMenuStrip.Items.Add(new STToolStripItem("Extract Folder", ExtractAction));
|
ContextMenuStrip.Items.Add(new STToolStripItem("Extract Folder", ExtractAction));
|
||||||
ContextMenuStrip.Items.Add(new STToolStripItem("Replace Folder", ReplaceAction));
|
ContextMenuStrip.Items.Add(new STToolStripItem("Replace Folder", ReplaceAction));
|
||||||
|
ContextMenuStrip.Items.Add(new STToolStripItem("Delete Folder", DeleteAction));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExtractAction(object sender, EventArgs args)
|
private void ExtractAction(object sender, EventArgs args)
|
||||||
@ -126,6 +149,12 @@ namespace Switch_Toolbox.Library
|
|||||||
|
|
||||||
private void ReplaceAction(object sender, EventArgs args)
|
private void ReplaceAction(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteAction(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateDirectoryIfExists(string Dir)
|
private void CreateDirectoryIfExists(string Dir)
|
||||||
@ -146,6 +175,28 @@ namespace Switch_Toolbox.Library
|
|||||||
|
|
||||||
public class ArchiveNodeWrapper : TreeNodeCustom
|
public class ArchiveNodeWrapper : TreeNodeCustom
|
||||||
{
|
{
|
||||||
|
public bool CanReplace
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
ContextMenuStrip.Items[1].Enabled = true;
|
||||||
|
else
|
||||||
|
ContextMenuStrip.Items[1].Enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool CanRename = false;
|
||||||
|
public bool CanDelete
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
ContextMenuStrip.Items[2].Enabled = true;
|
||||||
|
else
|
||||||
|
ContextMenuStrip.Items[2].Enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ArchiveNodeWrapper(string text)
|
public ArchiveNodeWrapper(string text)
|
||||||
{
|
{
|
||||||
Text = text;
|
Text = text;
|
||||||
@ -153,6 +204,7 @@ namespace Switch_Toolbox.Library
|
|||||||
ContextMenuStrip = new STContextMenuStrip();
|
ContextMenuStrip = new STContextMenuStrip();
|
||||||
ContextMenuStrip.Items.Add(new STToolStripItem("Extract", ExtractAction));
|
ContextMenuStrip.Items.Add(new STToolStripItem("Extract", ExtractAction));
|
||||||
ContextMenuStrip.Items.Add(new STToolStripItem("Replace", ReplaceAction));
|
ContextMenuStrip.Items.Add(new STToolStripItem("Replace", ReplaceAction));
|
||||||
|
ContextMenuStrip.Items.Add(new STToolStripItem("Delete", DeleteAction));
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual ArchiveFileInfo ArchiveFileInfo { get; set; }
|
public virtual ArchiveFileInfo ArchiveFileInfo { get; set; }
|
||||||
@ -162,6 +214,10 @@ namespace Switch_Toolbox.Library
|
|||||||
ArchiveFileInfo.Export();
|
ArchiveFileInfo.Export();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DeleteAction(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
private void ReplaceAction(object sender, EventArgs args)
|
private void ReplaceAction(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
ArchiveFileInfo.Replace();
|
ArchiveFileInfo.Replace();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user