2018-02-28 20:06:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using Eto.Forms;
|
|
|
|
|
|
using Eto.Serialization.Xaml;
|
|
|
|
|
|
|
|
|
|
|
|
namespace exeinfogui.GEM
|
|
|
|
|
|
{
|
|
|
|
|
|
public class TabGemResources : TabPage
|
|
|
|
|
|
{
|
2018-03-01 16:33:04 +00:00
|
|
|
|
libexeinfo.GEM.ColorIcon[] colorIcons;
|
|
|
|
|
|
PanelGemBox panelBox;
|
|
|
|
|
|
PanelGemColorIcon panelColorIcon;
|
|
|
|
|
|
PanelGemGeneric panelGeneric;
|
|
|
|
|
|
PanelGemIcon panelIcon;
|
|
|
|
|
|
PanelGemImage panelImage;
|
|
|
|
|
|
PanelGemString panelString;
|
|
|
|
|
|
PanelGemText panelText;
|
|
|
|
|
|
Panel pnlResource;
|
|
|
|
|
|
TreeGridItemCollection treeData;
|
|
|
|
|
|
TreeGridView treeResources;
|
2018-02-28 20:06:05 +00:00
|
|
|
|
|
|
|
|
|
|
public TabGemResources()
|
|
|
|
|
|
{
|
|
|
|
|
|
XamlReader.Load(this);
|
|
|
|
|
|
|
|
|
|
|
|
treeResources.Columns.Add(new GridColumn {HeaderText = "Type", DataCell = new TextBoxCell(0)});
|
|
|
|
|
|
|
|
|
|
|
|
treeResources.AllowMultipleSelection = false;
|
|
|
|
|
|
treeResources.SelectionChanged += TreeResourcesOnSelectionChanged;
|
|
|
|
|
|
|
2018-03-01 16:33:04 +00:00
|
|
|
|
panelGeneric = new PanelGemGeneric();
|
|
|
|
|
|
panelString = new PanelGemString();
|
|
|
|
|
|
panelText = new PanelGemText();
|
|
|
|
|
|
panelBox = new PanelGemBox();
|
|
|
|
|
|
panelImage = new PanelGemImage();
|
|
|
|
|
|
panelIcon = new PanelGemIcon();
|
|
|
|
|
|
panelColorIcon = new PanelGemColorIcon();
|
2018-02-28 20:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-01 16:33:04 +00:00
|
|
|
|
public void Update(libexeinfo.GEM.TreeObjectNode[] roots, libexeinfo.GEM.ColorIcon[] cicons)
|
2018-02-28 20:06:05 +00:00
|
|
|
|
{
|
|
|
|
|
|
treeData = new TreeGridItemCollection();
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < roots.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
TreeGridItem root = new TreeGridItem {Values = new object[] {$"Root {i}", null}};
|
|
|
|
|
|
|
|
|
|
|
|
AddObjectToTree(root, roots[i]);
|
|
|
|
|
|
|
|
|
|
|
|
treeData.Add(root);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
treeResources.DataStore = treeData;
|
2018-03-01 16:33:04 +00:00
|
|
|
|
colorIcons = cicons;
|
2018-02-28 20:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TreeResourcesOnSelectionChanged(object sender, EventArgs eventArgs)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!(((TreeGridItem)treeResources.SelectedItem)?.Values[1] is libexeinfo.GEM.TreeObjectNode node))
|
|
|
|
|
|
{
|
|
|
|
|
|
pnlResource.Content = null;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(node.type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_BUTTON:
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_STRING:
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_TITLE:
|
|
|
|
|
|
panelString.Update(node);
|
|
|
|
|
|
pnlResource.Content = panelString;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_TEXT:
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_BOXTEXT:
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_FTEXT:
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_FBOXTEXT:
|
|
|
|
|
|
panelText.Update(node);
|
|
|
|
|
|
pnlResource.Content = panelText;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_BOX:
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_IBOX:
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_BOXCHAR:
|
|
|
|
|
|
panelBox.Update(node);
|
|
|
|
|
|
pnlResource.Content = panelBox;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_IMAGE:
|
|
|
|
|
|
panelImage.Update(node);
|
|
|
|
|
|
pnlResource.Content = panelImage;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_ICON:
|
|
|
|
|
|
panelIcon.Update(node);
|
|
|
|
|
|
pnlResource.Content = panelIcon;
|
|
|
|
|
|
break;
|
2018-03-01 16:33:04 +00:00
|
|
|
|
/* case libexeinfo.GEM.ObjectTypes.G_USERDEF: break;*/
|
|
|
|
|
|
case libexeinfo.GEM.ObjectTypes.G_CICON:
|
|
|
|
|
|
if(colorIcons == null || node.data >= colorIcons.Length || colorIcons[node.data] == null)
|
|
|
|
|
|
goto default;
|
|
|
|
|
|
|
|
|
|
|
|
panelColorIcon.Update(node, colorIcons[node.data]);
|
|
|
|
|
|
pnlResource.Content = panelColorIcon;
|
|
|
|
|
|
break;
|
2018-02-28 20:06:05 +00:00
|
|
|
|
default:
|
|
|
|
|
|
panelGeneric.Update(node);
|
|
|
|
|
|
pnlResource.Content = panelGeneric;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void AddObjectToTree(TreeGridItem parent, libexeinfo.GEM.TreeObjectNode node)
|
|
|
|
|
|
{
|
|
|
|
|
|
while(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
TreeGridItem item = new TreeGridItem {Values = new object[] {$"{node.type}", node}};
|
|
|
|
|
|
|
|
|
|
|
|
if(node.child != null) AddObjectToTree(item, node.child);
|
|
|
|
|
|
|
|
|
|
|
|
parent.Children.Add(item);
|
|
|
|
|
|
|
|
|
|
|
|
if(node.sibling != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
node = node.sibling;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|