Hex Editor - fix so context menu items dependent on addresses don't if no address is highlighted (prevents some exceptions being thrown when user attempts to use them)

This commit is contained in:
adelikat 2013-11-07 23:14:04 +00:00
parent 9dbcfdffd1
commit 10b609cb6e
2 changed files with 585 additions and 572 deletions

View File

@ -71,17 +71,17 @@
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.resetToDefaultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.resetToDefaultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ViewerContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.ViewerContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.copyToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.CopyContextItem = new System.Windows.Forms.ToolStripMenuItem();
this.pasteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.PasteContextItem = new System.Windows.Forms.ToolStripMenuItem();
this.freezeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.FreezeContextItem = new System.Windows.Forms.ToolStripMenuItem();
this.addToRamWatchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AddToRamWatchContextItem = new System.Windows.Forms.ToolStripMenuItem();
this.unfreezeAllToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.UnfreezeAllContextItem = new System.Windows.Forms.ToolStripMenuItem();
this.pokeAddressToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.PokeContextItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); this.ContextSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.incrementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.IncrementContextItem = new System.Windows.Forms.ToolStripMenuItem();
this.decrementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.DecrementContextItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); this.ContextSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.gotoAddressToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.GoToContextItem = new System.Windows.Forms.ToolStripMenuItem();
this.MemoryViewerBox = new System.Windows.Forms.GroupBox(); this.MemoryViewerBox = new System.Windows.Forms.GroupBox();
this.AddressLabel = new System.Windows.Forms.Label(); this.AddressLabel = new System.Windows.Forms.Label();
this.vScrollBar1 = new System.Windows.Forms.VScrollBar(); this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
@ -426,108 +426,108 @@
// ViewerContextMenuStrip // ViewerContextMenuStrip
// //
this.ViewerContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.ViewerContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.copyToolStripMenuItem1, this.CopyContextItem,
this.pasteToolStripMenuItem1, this.PasteContextItem,
this.freezeToolStripMenuItem, this.FreezeContextItem,
this.addToRamWatchToolStripMenuItem, this.AddToRamWatchContextItem,
this.unfreezeAllToolStripMenuItem1, this.UnfreezeAllContextItem,
this.pokeAddressToolStripMenuItem1, this.PokeContextItem,
this.toolStripSeparator4, this.ContextSeparator1,
this.incrementToolStripMenuItem, this.IncrementContextItem,
this.decrementToolStripMenuItem, this.DecrementContextItem,
this.toolStripSeparator5, this.ContextSeparator2,
this.gotoAddressToolStripMenuItem1}); this.GoToContextItem});
this.ViewerContextMenuStrip.Name = "ViewerContextMenuStrip"; this.ViewerContextMenuStrip.Name = "ViewerContextMenuStrip";
this.ViewerContextMenuStrip.Size = new System.Drawing.Size(220, 236); this.ViewerContextMenuStrip.Size = new System.Drawing.Size(220, 214);
this.ViewerContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.ViewerContextMenuStrip_Opening); this.ViewerContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.ViewerContextMenuStrip_Opening);
// //
// copyToolStripMenuItem1 // CopyContextItem
// //
this.copyToolStripMenuItem1.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Duplicate; this.CopyContextItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Duplicate;
this.copyToolStripMenuItem1.Name = "copyToolStripMenuItem1"; this.CopyContextItem.Name = "CopyContextItem";
this.copyToolStripMenuItem1.ShortcutKeyDisplayString = "Ctrl+C"; this.CopyContextItem.ShortcutKeyDisplayString = "Ctrl+C";
this.copyToolStripMenuItem1.Size = new System.Drawing.Size(219, 22); this.CopyContextItem.Size = new System.Drawing.Size(219, 22);
this.copyToolStripMenuItem1.Text = "&Copy"; this.CopyContextItem.Text = "&Copy";
this.copyToolStripMenuItem1.Click += new System.EventHandler(this.copyToolStripMenuItem1_Click); this.CopyContextItem.Click += new System.EventHandler(this.copyToolStripMenuItem1_Click);
// //
// pasteToolStripMenuItem1 // PasteContextItem
// //
this.pasteToolStripMenuItem1.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Paste; this.PasteContextItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Paste;
this.pasteToolStripMenuItem1.Name = "pasteToolStripMenuItem1"; this.PasteContextItem.Name = "PasteContextItem";
this.pasteToolStripMenuItem1.ShortcutKeyDisplayString = "Ctrl+V"; this.PasteContextItem.ShortcutKeyDisplayString = "Ctrl+V";
this.pasteToolStripMenuItem1.Size = new System.Drawing.Size(219, 22); this.PasteContextItem.Size = new System.Drawing.Size(219, 22);
this.pasteToolStripMenuItem1.Text = "&Paste"; this.PasteContextItem.Text = "&Paste";
this.pasteToolStripMenuItem1.Click += new System.EventHandler(this.pasteToolStripMenuItem1_Click); this.PasteContextItem.Click += new System.EventHandler(this.pasteToolStripMenuItem1_Click);
// //
// freezeToolStripMenuItem // FreezeContextItem
// //
this.freezeToolStripMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Freeze; this.FreezeContextItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Freeze;
this.freezeToolStripMenuItem.Name = "freezeToolStripMenuItem"; this.FreezeContextItem.Name = "FreezeContextItem";
this.freezeToolStripMenuItem.ShortcutKeyDisplayString = "Space"; this.FreezeContextItem.ShortcutKeyDisplayString = "Space";
this.freezeToolStripMenuItem.Size = new System.Drawing.Size(219, 22); this.FreezeContextItem.Size = new System.Drawing.Size(219, 22);
this.freezeToolStripMenuItem.Text = "&Freeze"; this.FreezeContextItem.Text = "&Freeze";
this.freezeToolStripMenuItem.Click += new System.EventHandler(this.freezeToolStripMenuItem_Click); this.FreezeContextItem.Click += new System.EventHandler(this.freezeToolStripMenuItem_Click);
// //
// addToRamWatchToolStripMenuItem // AddToRamWatchContextItem
// //
this.addToRamWatchToolStripMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.FindHS; this.AddToRamWatchContextItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.FindHS;
this.addToRamWatchToolStripMenuItem.Name = "addToRamWatchToolStripMenuItem"; this.AddToRamWatchContextItem.Name = "AddToRamWatchContextItem";
this.addToRamWatchToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+W"; this.AddToRamWatchContextItem.ShortcutKeyDisplayString = "Ctrl+W";
this.addToRamWatchToolStripMenuItem.Size = new System.Drawing.Size(219, 22); this.AddToRamWatchContextItem.Size = new System.Drawing.Size(219, 22);
this.addToRamWatchToolStripMenuItem.Text = "&Add to Ram Watch"; this.AddToRamWatchContextItem.Text = "&Add to Ram Watch";
this.addToRamWatchToolStripMenuItem.Click += new System.EventHandler(this.addToRamWatchToolStripMenuItem_Click); this.AddToRamWatchContextItem.Click += new System.EventHandler(this.addToRamWatchToolStripMenuItem_Click);
// //
// unfreezeAllToolStripMenuItem1 // UnfreezeAllContextItem
// //
this.unfreezeAllToolStripMenuItem1.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Unfreeze; this.UnfreezeAllContextItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Unfreeze;
this.unfreezeAllToolStripMenuItem1.Name = "unfreezeAllToolStripMenuItem1"; this.UnfreezeAllContextItem.Name = "UnfreezeAllContextItem";
this.unfreezeAllToolStripMenuItem1.ShortcutKeyDisplayString = "Shift+Del"; this.UnfreezeAllContextItem.ShortcutKeyDisplayString = "Shift+Del";
this.unfreezeAllToolStripMenuItem1.Size = new System.Drawing.Size(219, 22); this.UnfreezeAllContextItem.Size = new System.Drawing.Size(219, 22);
this.unfreezeAllToolStripMenuItem1.Text = "&Unfreeze All"; this.UnfreezeAllContextItem.Text = "&Unfreeze All";
this.unfreezeAllToolStripMenuItem1.Click += new System.EventHandler(this.unfreezeAllToolStripMenuItem1_Click); this.UnfreezeAllContextItem.Click += new System.EventHandler(this.unfreezeAllToolStripMenuItem1_Click);
// //
// pokeAddressToolStripMenuItem1 // PokeContextItem
// //
this.pokeAddressToolStripMenuItem1.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.poke; this.PokeContextItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.poke;
this.pokeAddressToolStripMenuItem1.Name = "pokeAddressToolStripMenuItem1"; this.PokeContextItem.Name = "PokeContextItem";
this.pokeAddressToolStripMenuItem1.ShortcutKeyDisplayString = "Ctrl+P"; this.PokeContextItem.ShortcutKeyDisplayString = "Ctrl+P";
this.pokeAddressToolStripMenuItem1.Size = new System.Drawing.Size(219, 22); this.PokeContextItem.Size = new System.Drawing.Size(219, 22);
this.pokeAddressToolStripMenuItem1.Text = "&Poke Address"; this.PokeContextItem.Text = "&Poke Address";
this.pokeAddressToolStripMenuItem1.Click += new System.EventHandler(this.pokeAddressToolStripMenuItem1_Click); this.PokeContextItem.Click += new System.EventHandler(this.pokeAddressToolStripMenuItem1_Click);
// //
// toolStripSeparator4 // ContextSeparator1
// //
this.toolStripSeparator4.Name = "toolStripSeparator4"; this.ContextSeparator1.Name = "ContextSeparator1";
this.toolStripSeparator4.Size = new System.Drawing.Size(216, 6); this.ContextSeparator1.Size = new System.Drawing.Size(216, 6);
// //
// incrementToolStripMenuItem // IncrementContextItem
// //
this.incrementToolStripMenuItem.Name = "incrementToolStripMenuItem"; this.IncrementContextItem.Name = "IncrementContextItem";
this.incrementToolStripMenuItem.ShortcutKeyDisplayString = "+"; this.IncrementContextItem.ShortcutKeyDisplayString = "+";
this.incrementToolStripMenuItem.Size = new System.Drawing.Size(219, 22); this.IncrementContextItem.Size = new System.Drawing.Size(219, 22);
this.incrementToolStripMenuItem.Text = "&Increment"; this.IncrementContextItem.Text = "&Increment";
this.incrementToolStripMenuItem.Click += new System.EventHandler(this.incrementToolStripMenuItem_Click); this.IncrementContextItem.Click += new System.EventHandler(this.incrementToolStripMenuItem_Click);
// //
// decrementToolStripMenuItem // DecrementContextItem
// //
this.decrementToolStripMenuItem.Name = "decrementToolStripMenuItem"; this.DecrementContextItem.Name = "DecrementContextItem";
this.decrementToolStripMenuItem.ShortcutKeyDisplayString = "-"; this.DecrementContextItem.ShortcutKeyDisplayString = "-";
this.decrementToolStripMenuItem.Size = new System.Drawing.Size(219, 22); this.DecrementContextItem.Size = new System.Drawing.Size(219, 22);
this.decrementToolStripMenuItem.Text = "&Decrement"; this.DecrementContextItem.Text = "&Decrement";
this.decrementToolStripMenuItem.Click += new System.EventHandler(this.decrementToolStripMenuItem_Click); this.DecrementContextItem.Click += new System.EventHandler(this.decrementToolStripMenuItem_Click);
// //
// toolStripSeparator5 // ContextSeparator2
// //
this.toolStripSeparator5.Name = "toolStripSeparator5"; this.ContextSeparator2.Name = "ContextSeparator2";
this.toolStripSeparator5.Size = new System.Drawing.Size(216, 6); this.ContextSeparator2.Size = new System.Drawing.Size(216, 6);
// //
// gotoAddressToolStripMenuItem1 // GoToContextItem
// //
this.gotoAddressToolStripMenuItem1.Name = "gotoAddressToolStripMenuItem1"; this.GoToContextItem.Name = "GoToContextItem";
this.gotoAddressToolStripMenuItem1.ShortcutKeyDisplayString = "Ctrl+G"; this.GoToContextItem.ShortcutKeyDisplayString = "Ctrl+G";
this.gotoAddressToolStripMenuItem1.Size = new System.Drawing.Size(219, 22); this.GoToContextItem.Size = new System.Drawing.Size(219, 22);
this.gotoAddressToolStripMenuItem1.Text = "&Go to Address..."; this.GoToContextItem.Text = "&Go to Address...";
this.gotoAddressToolStripMenuItem1.Click += new System.EventHandler(this.gotoAddressToolStripMenuItem1_Click); this.GoToContextItem.Click += new System.EventHandler(this.gotoAddressToolStripMenuItem1_Click);
// //
// MemoryViewerBox // MemoryViewerBox
// //
@ -644,8 +644,8 @@
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem enToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem enToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip ViewerContextMenuStrip; private System.Windows.Forms.ContextMenuStrip ViewerContextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem freezeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem FreezeContextItem;
private System.Windows.Forms.ToolStripMenuItem addToRamWatchToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem AddToRamWatchContextItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem addToRamWatchToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem addToRamWatchToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem saveWindowsSettingsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem saveWindowsSettingsToolStripMenuItem;
@ -655,12 +655,12 @@
private System.Windows.Forms.Label AddressesLabel; private System.Windows.Forms.Label AddressesLabel;
private System.Windows.Forms.VScrollBar vScrollBar1; private System.Windows.Forms.VScrollBar vScrollBar1;
private System.Windows.Forms.ToolStripMenuItem unfreezeAllToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem unfreezeAllToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem unfreezeAllToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem UnfreezeAllContextItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; private System.Windows.Forms.ToolStripSeparator ContextSeparator1;
private System.Windows.Forms.ToolStripMenuItem incrementToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem IncrementContextItem;
private System.Windows.Forms.ToolStripMenuItem decrementToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem DecrementContextItem;
private System.Windows.Forms.ToolStripMenuItem gotoAddressToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem GoToContextItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; private System.Windows.Forms.ToolStripSeparator ContextSeparator2;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem;
@ -676,13 +676,13 @@
private System.Windows.Forms.ToolStripMenuItem resetToDefaultToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem resetToDefaultToolStripMenuItem1;
public System.Windows.Forms.Label Header; public System.Windows.Forms.Label Header;
private System.Windows.Forms.Label AddressLabel; private System.Windows.Forms.Label AddressLabel;
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem CopyContextItem;
private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem PasteContextItem;
private System.Windows.Forms.ToolStripMenuItem findNextToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem findNextToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem findPrevToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem findPrevToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem pokeAddressToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem pokeAddressToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem pokeAddressToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem PokeContextItem;
private System.Windows.Forms.ToolStripMenuItem alwaysOnTopToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem alwaysOnTopToolStripMenuItem;
} }
} }

View File

@ -1808,21 +1808,34 @@ namespace BizHawk.Client.EmuHawk
private void ViewerContextMenuStrip_Opening(object sender, CancelEventArgs e) private void ViewerContextMenuStrip_Opening(object sender, CancelEventArgs e)
{ {
copyToolStripMenuItem1.Visible = HighlightedAddress.HasValue || SecondaryHighlightedAddresses.Any(); var iData = Clipboard.GetDataObject();
IDataObject iData = Clipboard.GetDataObject(); CopyContextItem.Visible =
FreezeContextItem.Visible =
AddToRamWatchContextItem.Visible =
PokeContextItem.Visible =
IncrementContextItem.Visible =
DecrementContextItem.Visible =
ContextSeparator2.Visible =
HighlightedAddress.HasValue || SecondaryHighlightedAddresses.Any();
pasteToolStripMenuItem1.Visible = iData != null && iData.GetDataPresent(DataFormats.Text); UnfreezeAllContextItem.Visible = Global.CheatList.ActiveCount > 0;
PasteContextItem.Visible = (iData != null && iData.GetDataPresent(DataFormats.Text));
ContextSeparator1.Visible =
HighlightedAddress.HasValue ||
SecondaryHighlightedAddresses.Any() ||
(iData != null && iData.GetDataPresent(DataFormats.Text));
if (HighlightedAddress.HasValue && IsFrozen(HighlightedAddress.Value)) if (HighlightedAddress.HasValue && IsFrozen(HighlightedAddress.Value))
{ {
freezeToolStripMenuItem.Text = "Un&freeze"; FreezeContextItem.Text = "Un&freeze";
freezeToolStripMenuItem.Image = Properties.Resources.Unfreeze; FreezeContextItem.Image = Properties.Resources.Unfreeze;
} }
else else
{ {
freezeToolStripMenuItem.Text = "&Freeze"; FreezeContextItem.Text = "&Freeze";
freezeToolStripMenuItem.Image = Properties.Resources.Freeze; FreezeContextItem.Image = Properties.Resources.Freeze;
} }
} }