Add decoding RT_ACCELERATOR (Windows) and RT_ACCELTABLE (OS/2) resources from NE, and appropriate GUI.

This commit is contained in:
2018-03-03 18:58:47 +00:00
parent 18464bacff
commit b78157bf4d
5 changed files with 459 additions and 7 deletions

View File

@@ -0,0 +1,78 @@
using System.Collections.Generic;
using System.Linq;
using Eto.Forms;
using Eto.Serialization.Xaml;
namespace exeinfogui.NE
{
public class PanelNeAccelerators : Panel
{
GridView grdAccelerators;
Label lblCodepage;
TextBox txtCodepage;
public PanelNeAccelerators()
{
XamlReader.Load(this);
grdAccelerators.Columns.Add(new GridColumn
{
DataCell = new TextBoxCell {Binding = Binding.Property<Accelerator, string>(a => $"{a.Type}")},
HeaderText = "Type"
});
grdAccelerators.Columns.Add(new GridColumn
{
DataCell = new TextBoxCell {Binding = Binding.Property<Accelerator, string>(a => $"{a.Key}")},
HeaderText = "Key"
});
grdAccelerators.Columns.Add(new GridColumn
{
DataCell = new TextBoxCell {Binding = Binding.Property<Accelerator, string>(a => $"{a.Command}")},
HeaderText = "Command"
});
}
public void Update(byte[] data, libexeinfo.NE.TargetOS targetOs)
{
grdAccelerators.DataStore = null;
List<Accelerator> accelerators = new List<Accelerator>();
if(targetOs == libexeinfo.NE.TargetOS.OS2)
{
libexeinfo.NE.Os2AcceleratorTable table = libexeinfo.NE.GetOs2Accelerators(data);
lblCodepage.Visible = true;
txtCodepage.Visible = true;
txtCodepage.Text = $"{table.CodePage}";
accelerators.AddRange(table.Accelerators.Select(accel => new Accelerator
{
Type = $"{accel.Type}",
Key = $"{accel.Key}",
Command = accel.Command
}));
}
else
{
lblCodepage.Visible = false;
txtCodepage.Visible = false;
accelerators.AddRange(libexeinfo.NE.GetWinAccelerators(data)
.Select(accel => new Accelerator
{
Type = $"{accel.Flags}",
Key = $"{accel.Key}",
Command = accel.Command
}));
}
if(accelerators.Count > 0) grdAccelerators.DataStore = accelerators;
}
class Accelerator
{
public ushort Command;
public string Key;
public string Type;
}
}
}