From 81a841057cf8cf4c6e94c61dc4217cd4472dd4b4 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 4 May 2014 16:01:46 +0000 Subject: [PATCH] Ram Watch - convert message label into a Status bar with a error icon with similar functionality as ram search --- .../tools/Watch/RamSearch.cs | 15 ++---- .../tools/Watch/RamWatch.Designer.cs | 54 ++++++++++++++----- .../tools/Watch/RamWatch.cs | 42 ++++++++++----- .../tools/Watch/RamWatch.resx | 3 ++ 4 files changed, 77 insertions(+), 37 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs index dc707bc067..45cb1f2396 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs @@ -139,14 +139,7 @@ namespace BizHawk.Client.EmuHawk private void OutOfRangeCheck() { - if (_searches.OutOfRangeAddress.Any()) - { - ErrorIconButton.Visible = true; - } - else - { - ErrorIconButton.Visible = false; - } + ErrorIconButton.Visible = _searches.OutOfRangeAddress.Any(); } private void ListView_QueryItemBkColor(int index, int column, ref Color color) @@ -1476,11 +1469,11 @@ namespace BizHawk.Client.EmuHawk private void ErrorIconButton_Click(object sender, EventArgs e) { - var _outOfRangeAddresses = _searches.OutOfRangeAddress.ToList(); + var outOfRangeAddresses = _searches.OutOfRangeAddress.ToList(); - SetRemovedMessage(_outOfRangeAddresses.Count); + SetRemovedMessage(outOfRangeAddresses.Count); - _searches.RemoveRange(_outOfRangeAddresses); + _searches.RemoveRange(outOfRangeAddresses); WatchListView.ItemCount = _searches.Count; SetTotal(); diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs index 3b83c9c065..eafbb221f0 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs @@ -31,7 +31,6 @@ this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RamWatch)); this.WatchCountLabel = new System.Windows.Forms.Label(); - this.MessageLabel = new System.Windows.Forms.Label(); this.MemDomainLabel = new System.Windows.Forms.Label(); this.ListViewContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.EditContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -50,6 +49,8 @@ this.ShowChangeCountsContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ShowDiffContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ShowDomainContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.MessageLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStrip1 = new ToolStripEx(); this.newToolStripButton = new System.Windows.Forms.ToolStripButton(); this.openToolStripButton = new System.Windows.Forms.ToolStripButton(); @@ -117,7 +118,9 @@ this.DiffColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.DomainColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.NotesColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.ErrorIconButton = new System.Windows.Forms.ToolStripButton(); this.ListViewContextMenu.SuspendLayout(); + this.statusStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -131,16 +134,6 @@ this.WatchCountLabel.TabIndex = 5; this.WatchCountLabel.Text = "0 watches"; // - // MessageLabel - // - this.MessageLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.MessageLabel.AutoSize = true; - this.MessageLabel.Location = new System.Drawing.Point(18, 362); - this.MessageLabel.Name = "MessageLabel"; - this.MessageLabel.Size = new System.Drawing.Size(187, 13); - this.MessageLabel.TabIndex = 6; - this.MessageLabel.Text = " "; - // // MemDomainLabel // this.MemDomainLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -299,6 +292,23 @@ this.ShowDomainContextMenuItem.Text = "Show Domain"; this.ShowDomainContextMenuItem.Click += new System.EventHandler(this.ShowDomainMenuItem_Click); // + // statusStrip1 + // + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ErrorIconButton, + this.MessageLabel}); + this.statusStrip1.Location = new System.Drawing.Point(0, 356); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(359, 22); + this.statusStrip1.TabIndex = 8; + this.statusStrip1.Text = "statusStrip1"; + // + // MessageLabel + // + this.MessageLabel.Name = "MessageLabel"; + this.MessageLabel.Size = new System.Drawing.Size(31, 17); + this.MessageLabel.Text = " "; + // // toolStrip1 // this.toolStrip1.ClickThrough = true; @@ -868,6 +878,7 @@ this.WatchListView.ItemCount = 0; this.WatchListView.Location = new System.Drawing.Point(16, 76); this.WatchListView.Name = "WatchListView"; + this.WatchListView.SelectAllInProgress = false; this.WatchListView.selectedItem = -1; this.WatchListView.Size = new System.Drawing.Size(327, 281); this.WatchListView.TabIndex = 2; @@ -925,13 +936,24 @@ this.NotesColumn.Text = "Notes"; this.NotesColumn.Width = 128; // + // ErrorIconButton + // + this.ErrorIconButton.BackColor = System.Drawing.Color.NavajoWhite; + this.ErrorIconButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.ErrorIconButton.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.ExclamationRed; + this.ErrorIconButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.ErrorIconButton.Name = "ErrorIconButton"; + this.ErrorIconButton.Size = new System.Drawing.Size(23, 20); + this.ErrorIconButton.Text = "Warning! Out of Range Addresses in list, click to remove them"; + this.ErrorIconButton.Click += new System.EventHandler(this.ErrorIconButton_Click); + // // RamWatch // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(359, 378); + this.Controls.Add(this.statusStrip1); this.Controls.Add(this.MemDomainLabel); - this.Controls.Add(this.MessageLabel); this.Controls.Add(this.WatchCountLabel); this.Controls.Add(this.toolStrip1); this.Controls.Add(this.menuStrip1); @@ -946,6 +968,8 @@ this.DragEnter += new System.Windows.Forms.DragEventHandler(this.NewRamWatch_DragEnter); this.Enter += new System.EventHandler(this.NewRamWatch_Enter); this.ListViewContextMenu.ResumeLayout(false); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); this.menuStrip1.ResumeLayout(false); @@ -1020,8 +1044,7 @@ private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; private System.Windows.Forms.ToolStripButton MoveUpStripButton1; private System.Windows.Forms.ToolStripButton MoveDownStripButton1; - private System.Windows.Forms.Label WatchCountLabel; - private System.Windows.Forms.Label MessageLabel; + private System.Windows.Forms.Label WatchCountLabel; private System.Windows.Forms.Label MemDomainLabel; private System.Windows.Forms.ToolStripSeparator Separator2; private System.Windows.Forms.ToolStripMenuItem OriginalMenuItem; @@ -1044,5 +1067,8 @@ private System.Windows.Forms.ToolStripMenuItem ShowDomainContextMenuItem; private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem; private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel MessageLabel; + private System.Windows.Forms.ToolStripButton ErrorIconButton; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index 8209cf0192..6f880c1da5 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -150,7 +150,7 @@ namespace BizHawk.Client.EmuHawk Global.Config.RecentWatches.Add(path); WatchListView.ItemCount = _watches.ItemCount; UpdateWatchCount(); - UpdateMessageLabel(); + UpdateStatusBar(); _watches.Changes = false; } } @@ -170,10 +170,10 @@ namespace BizHawk.Client.EmuHawk { _watches.Load(file.FullName, append); WatchListView.ItemCount = _watches.ItemCount; - UpdateMessageLabel(); UpdateWatchCount(); Global.Config.RecentWatches.Add(_watches.CurrentFileName); SetMemoryDomain(_watches.Domain.ToString()); + UpdateStatusBar(); } } } @@ -188,7 +188,7 @@ namespace BizHawk.Client.EmuHawk if (!string.IsNullOrWhiteSpace(_watches.CurrentFileName)) { _watches.Reload(); - UpdateMessageLabel(); + UpdateStatusBar(); } else { @@ -241,7 +241,7 @@ namespace BizHawk.Client.EmuHawk private void Changes() { _watches.Changes = true; - UpdateMessageLabel(); + UpdateStatusBar(); } private void ColumnPositions() @@ -405,7 +405,7 @@ namespace BizHawk.Client.EmuHawk _watches.Clear(); WatchListView.ItemCount = _watches.ItemCount; UpdateWatchCount(); - UpdateMessageLabel(); + UpdateStatusBar(); _sortReverse = false; _sortedColumn = string.Empty; } @@ -431,7 +431,7 @@ namespace BizHawk.Client.EmuHawk var result = _watches.SaveAs(ToolHelpers.GetWatchSaveFileFromUser(_watches.CurrentFileName)); if (result) { - UpdateMessageLabel(saved: true); + UpdateStatusBar(saved: true); Global.Config.RecentWatches.Add(_watches.CurrentFileName); } } @@ -502,7 +502,7 @@ namespace BizHawk.Client.EmuHawk MemDomainLabel.Text = Global.Emulator.SystemId + " " + _watches.Domain.Name; } - private void UpdateMessageLabel(bool saved = false) + private void UpdateStatusBar(bool saved = false) { var message = string.Empty; if (!string.IsNullOrWhiteSpace(_watches.CurrentFileName)) @@ -517,10 +517,9 @@ namespace BizHawk.Client.EmuHawk } } - if (_watches.Any(watch => (watch.Address ?? 0) >= watch.Domain.Size)) - { - message += " WARNING! Out of range addresses"; - } + var test1 = _watches.Any(watch => (watch.Address ?? 0) >= watch.Domain.Size); + + ErrorIconButton.Visible = _watches.Any(watch => (watch.Address ?? 0) >= watch.Domain.Size); MessageLabel.Text = message; } @@ -628,7 +627,7 @@ namespace BizHawk.Client.EmuHawk { if (_watches.Save()) { - UpdateMessageLabel(saved: true); + UpdateStatusBar(saved: true); } } else @@ -988,7 +987,9 @@ namespace BizHawk.Client.EmuHawk private void NewRamWatch_Load(object sender, EventArgs e) { + LoadConfigSettings(); + UpdateStatusBar(); } private void NewRamWatch_Activated(object sender, EventArgs e) @@ -1122,6 +1123,23 @@ namespace BizHawk.Client.EmuHawk base.OnShown(e); } + private void ErrorIconButton_Click(object sender, EventArgs e) + { + var items = _watches + .Where(watch => (watch.Address ?? 0) >= watch.Domain.Size) + .ToList(); + + foreach (var item in items) + { + _watches.Remove(item); + } + + WatchListView.ItemCount = _watches.ItemCount; + UpdateValues(); + UpdateWatchCount(); + UpdateStatusBar(); + } + #endregion #endregion diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.resx b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.resx index 8aa260f851..9840def06a 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.resx +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.resx @@ -120,6 +120,9 @@ 336, 17 + + 506, 17 + 231, 17