Slight improvements to Executable editor enabling section deletion

This commit is contained in:
Michael Becker 2015-05-11 22:02:02 -04:00
parent f829623f79
commit 41cd7d8202
2 changed files with 53 additions and 19 deletions

View File

@ -30,15 +30,17 @@
{
this.components = new System.ComponentModel.Container();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.pnlSections = new System.Windows.Forms.Panel();
this.tv = new System.Windows.Forms.TreeView();
this.pnlSections = new System.Windows.Forms.Panel();
this.lvSections = new System.Windows.Forms.ListView();
this.chSectionName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chSectionOffset = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chSectionLength = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.mnuContextListViewSections = new AwesomeControls.CommandBars.CBContextMenu(this.components);
this.mnuContextListViewSectionsExport = new System.Windows.Forms.ToolStripMenuItem();
this.mnuContextListViewSectionsImport = new System.Windows.Forms.ToolStripMenuItem();
this.mnuContextListViewSectionsExport = new System.Windows.Forms.ToolStripMenuItem();
this.mnuContextListViewSectionsDelete = new System.Windows.Forms.ToolStripMenuItem();
this.mnuContextListViewSectionsSep1 = new System.Windows.Forms.ToolStripSeparator();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
@ -64,15 +66,6 @@
this.splitContainer1.SplitterDistance = 167;
this.splitContainer1.TabIndex = 0;
//
// pnlSections
//
this.pnlSections.Controls.Add(this.lvSections);
this.pnlSections.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlSections.Location = new System.Drawing.Point(0, 0);
this.pnlSections.Name = "pnlSections";
this.pnlSections.Size = new System.Drawing.Size(331, 247);
this.pnlSections.TabIndex = 0;
//
// tv
//
this.tv.Dock = System.Windows.Forms.DockStyle.Fill;
@ -82,6 +75,15 @@
this.tv.Size = new System.Drawing.Size(167, 247);
this.tv.TabIndex = 0;
//
// pnlSections
//
this.pnlSections.Controls.Add(this.lvSections);
this.pnlSections.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlSections.Location = new System.Drawing.Point(0, 0);
this.pnlSections.Name = "pnlSections";
this.pnlSections.Size = new System.Drawing.Size(331, 247);
this.pnlSections.TabIndex = 0;
//
// lvSections
//
this.lvSections.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
@ -116,12 +118,21 @@
// mnuContextListViewSections
//
this.mnuContextListViewSections.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuContextListViewSectionsDelete,
this.mnuContextListViewSectionsSep1,
this.mnuContextListViewSectionsImport,
this.mnuContextListViewSectionsExport});
this.mnuContextListViewSections.Name = "mnuContextListViewSections";
this.mnuContextListViewSections.Size = new System.Drawing.Size(153, 70);
this.mnuContextListViewSections.Size = new System.Drawing.Size(153, 98);
this.mnuContextListViewSections.Opening += new System.ComponentModel.CancelEventHandler(this.mnuContextListViewSections_Opening);
//
// mnuContextListViewSectionsImport
//
this.mnuContextListViewSectionsImport.Name = "mnuContextListViewSectionsImport";
this.mnuContextListViewSectionsImport.Size = new System.Drawing.Size(152, 22);
this.mnuContextListViewSectionsImport.Text = "&Import...";
this.mnuContextListViewSectionsImport.Click += new System.EventHandler(this.mnuContextListViewSectionsImport_Click);
//
// mnuContextListViewSectionsExport
//
this.mnuContextListViewSectionsExport.Enabled = false;
@ -130,12 +141,17 @@
this.mnuContextListViewSectionsExport.Text = "&Export...";
this.mnuContextListViewSectionsExport.Click += new System.EventHandler(this.mnuContextListViewSectionsExport_Click);
//
// mnuContextListViewSectionsImport
// mnuContextListViewSectionsDelete
//
this.mnuContextListViewSectionsImport.Name = "mnuContextListViewSectionsImport";
this.mnuContextListViewSectionsImport.Size = new System.Drawing.Size(152, 22);
this.mnuContextListViewSectionsImport.Text = "&Import...";
this.mnuContextListViewSectionsImport.Click += new System.EventHandler(this.mnuContextListViewSectionsImport_Click);
this.mnuContextListViewSectionsDelete.Name = "mnuContextListViewSectionsDelete";
this.mnuContextListViewSectionsDelete.Size = new System.Drawing.Size(152, 22);
this.mnuContextListViewSectionsDelete.Text = "&Delete";
this.mnuContextListViewSectionsDelete.Click += new System.EventHandler(this.mnuContextListViewSectionsDelete_Click);
//
// mnuContextListViewSectionsSep1
//
this.mnuContextListViewSectionsSep1.Name = "mnuContextListViewSectionsSep1";
this.mnuContextListViewSectionsSep1.Size = new System.Drawing.Size(149, 6);
//
// ExecutableEditor
//
@ -165,5 +181,7 @@
private AwesomeControls.CommandBars.CBContextMenu mnuContextListViewSections;
private System.Windows.Forms.ToolStripMenuItem mnuContextListViewSectionsExport;
private System.Windows.Forms.ToolStripMenuItem mnuContextListViewSectionsImport;
private System.Windows.Forms.ToolStripMenuItem mnuContextListViewSectionsDelete;
private System.Windows.Forms.ToolStripSeparator mnuContextListViewSectionsSep1;
}
}

View File

@ -93,7 +93,7 @@ namespace UniversalEditor.Editors.Executable
if (ofd.ShowDialog() == DialogResult.OK)
{
ExecutableSection section = new ExecutableSection();
section.Name = ofd.FileName;
section.Name = System.IO.Path.GetFileName(ofd.FileName);
section.Load(ofd.FileName);
BeginEdit();
@ -102,12 +102,28 @@ namespace UniversalEditor.Editors.Executable
ListViewItem lvi = new ListViewItem();
lvi.Tag = section;
lvi.Text = section.Name;
lvi.Text = System.IO.Path.GetFileName(section.Name);
lvi.SubItems.Add((0).ToString());
lvi.SubItems.Add((0).ToString());
lvSections.Items.Add(lvi);
}
}
private void mnuContextListViewSectionsDelete_Click(object sender, EventArgs e)
{
ExecutableObjectModel executable = (ObjectModel as ExecutableObjectModel);
if (executable == null) return;
if (lvSections.SelectedItems.Count == 0) return;
if (MessageBox.Show("Are you sure you want to delete the selected sections?", "Delete Sections", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
while (lvSections.SelectedItems.Count > 0)
{
ExecutableSection section = (lvSections.SelectedItems[0].Tag as ExecutableSection);
if (section != null) executable.Sections.Remove(section);
lvSections.SelectedItems[0].Remove();
}
}
}
}