Trace Logger - remember window size, implement floating window and restore default settings, refactor, also clean up some ToolDialogSettings logic

This commit is contained in:
adelikat 2014-01-30 15:28:05 +00:00
parent dead076979
commit 003156d28e
6 changed files with 83 additions and 17 deletions

View File

@ -1,4 +1,6 @@
namespace BizHawk.Client.Common using System.Drawing;
namespace BizHawk.Client.Common
{ {
public class ToolDialogSettings public class ToolDialogSettings
{ {
@ -31,5 +33,21 @@
return SaveWindowPosition && Width.HasValue && Height.HasValue; return SaveWindowPosition && Width.HasValue && Height.HasValue;
} }
} }
public Point WindowPosition
{
get
{
return new Point(Wndx ?? 0, Wndy ?? 0);
}
}
public Size WindowSize
{
get
{
return new Size(Width ?? 0, Height ?? 0);
}
}
} }
} }

View File

@ -1498,7 +1498,10 @@ namespace BizHawk.Client.EmuHawk
Global.Config.HexEditorSettings.TopMost = false; Global.Config.HexEditorSettings.TopMost = false;
Global.Config.HexEditorSettings.SaveWindowPosition = true; Global.Config.HexEditorSettings.SaveWindowPosition = true;
Global.Config.HexEditorSettings.FloatingWindow = false;
Global.Config.AutoLoadHexEditor = false; Global.Config.AutoLoadHexEditor = false;
RefreshFloatingWindowControl();
} }
#endregion #endregion

View File

@ -47,6 +47,7 @@
this.AutoloadMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AutoloadMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.BrowseBox = new System.Windows.Forms.Button(); this.BrowseBox = new System.Windows.Forms.Button();
this.FileBox = new System.Windows.Forms.TextBox(); this.FileBox = new System.Windows.Forms.TextBox();
@ -54,7 +55,8 @@
this.ToWindowRadio = new System.Windows.Forms.RadioButton(); this.ToWindowRadio = new System.Windows.Forms.RadioButton();
this.ClearButton = new System.Windows.Forms.Button(); this.ClearButton = new System.Windows.Forms.Button();
this.LoggingEnabled = new System.Windows.Forms.CheckBox(); this.LoggingEnabled = new System.Windows.Forms.CheckBox();
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.RestoreDefaultSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.TracerBox.SuspendLayout(); this.TracerBox.SuspendLayout();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
@ -186,7 +188,9 @@
this.AutoloadMenuItem, this.AutoloadMenuItem,
this.SaveWindowPositionMenuItem, this.SaveWindowPositionMenuItem,
this.AlwaysOnTopMenuItem, this.AlwaysOnTopMenuItem,
this.FloatingWindowMenuItem}); this.FloatingWindowMenuItem,
this.toolStripSeparator3,
this.RestoreDefaultSettingsMenuItem});
this.OptionsSubMenu.Name = "OptionsSubMenu"; this.OptionsSubMenu.Name = "OptionsSubMenu";
this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20); this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20);
this.OptionsSubMenu.Text = "&Options"; this.OptionsSubMenu.Text = "&Options";
@ -195,36 +199,43 @@
// MaxLinesMenuItem // MaxLinesMenuItem
// //
this.MaxLinesMenuItem.Name = "MaxLinesMenuItem"; this.MaxLinesMenuItem.Name = "MaxLinesMenuItem";
this.MaxLinesMenuItem.Size = new System.Drawing.Size(191, 22); this.MaxLinesMenuItem.Size = new System.Drawing.Size(199, 22);
this.MaxLinesMenuItem.Text = "&Set Max Lines..."; this.MaxLinesMenuItem.Text = "&Set Max Lines...";
this.MaxLinesMenuItem.Click += new System.EventHandler(this.MaxLinesMenuItem_Click); this.MaxLinesMenuItem.Click += new System.EventHandler(this.MaxLinesMenuItem_Click);
// //
// toolStripSeparator2 // toolStripSeparator2
// //
this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(188, 6); this.toolStripSeparator2.Size = new System.Drawing.Size(196, 6);
// //
// AutoloadMenuItem // AutoloadMenuItem
// //
this.AutoloadMenuItem.Name = "AutoloadMenuItem"; this.AutoloadMenuItem.Name = "AutoloadMenuItem";
this.AutoloadMenuItem.Size = new System.Drawing.Size(191, 22); this.AutoloadMenuItem.Size = new System.Drawing.Size(199, 22);
this.AutoloadMenuItem.Text = "&Autoload"; this.AutoloadMenuItem.Text = "&Autoload";
this.AutoloadMenuItem.Click += new System.EventHandler(this.AutoloadMenuItem_Click); this.AutoloadMenuItem.Click += new System.EventHandler(this.AutoloadMenuItem_Click);
// //
// SaveWindowPositionMenuItem // SaveWindowPositionMenuItem
// //
this.SaveWindowPositionMenuItem.Name = "SaveWindowPositionMenuItem"; this.SaveWindowPositionMenuItem.Name = "SaveWindowPositionMenuItem";
this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(191, 22); this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(199, 22);
this.SaveWindowPositionMenuItem.Text = "&Save Window Position"; this.SaveWindowPositionMenuItem.Text = "&Save Window Position";
this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click); this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click);
// //
// AlwaysOnTopMenuItem // AlwaysOnTopMenuItem
// //
this.AlwaysOnTopMenuItem.Name = "AlwaysOnTopMenuItem"; this.AlwaysOnTopMenuItem.Name = "AlwaysOnTopMenuItem";
this.AlwaysOnTopMenuItem.Size = new System.Drawing.Size(191, 22); this.AlwaysOnTopMenuItem.Size = new System.Drawing.Size(199, 22);
this.AlwaysOnTopMenuItem.Text = "&Always on Top"; this.AlwaysOnTopMenuItem.Text = "&Always on Top";
this.AlwaysOnTopMenuItem.Click += new System.EventHandler(this.AlwaysOnTopMenuItem_Click); this.AlwaysOnTopMenuItem.Click += new System.EventHandler(this.AlwaysOnTopMenuItem_Click);
// //
// FloatingWindowMenuItem
//
this.FloatingWindowMenuItem.Name = "FloatingWindowMenuItem";
this.FloatingWindowMenuItem.Size = new System.Drawing.Size(199, 22);
this.FloatingWindowMenuItem.Text = "&Floating Window";
this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click);
//
// groupBox2 // groupBox2
// //
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
@ -312,12 +323,17 @@
this.LoggingEnabled.UseVisualStyleBackColor = true; this.LoggingEnabled.UseVisualStyleBackColor = true;
this.LoggingEnabled.CheckedChanged += new System.EventHandler(this.LoggingEnabled_CheckedChanged); this.LoggingEnabled.CheckedChanged += new System.EventHandler(this.LoggingEnabled_CheckedChanged);
// //
// FloatingWindowMenuItem // toolStripSeparator3
// //
this.FloatingWindowMenuItem.Name = "FloatingWindowMenuItem"; this.toolStripSeparator3.Name = "toolStripSeparator3";
this.FloatingWindowMenuItem.Size = new System.Drawing.Size(191, 22); this.toolStripSeparator3.Size = new System.Drawing.Size(196, 6);
this.FloatingWindowMenuItem.Text = "&Floating Window"; //
this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click); // RestoreDefaultSettingsMenuItem
//
this.RestoreDefaultSettingsMenuItem.Name = "RestoreDefaultSettingsMenuItem";
this.RestoreDefaultSettingsMenuItem.Size = new System.Drawing.Size(199, 22);
this.RestoreDefaultSettingsMenuItem.Text = "Restore Default Settings";
this.RestoreDefaultSettingsMenuItem.Click += new System.EventHandler(this.RestoreDefaultSettingsMenuItem_Click);
// //
// TraceLogger // TraceLogger
// //
@ -373,5 +389,7 @@
private System.Windows.Forms.ToolStripMenuItem SelectAllMenuItem; private System.Windows.Forms.ToolStripMenuItem SelectAllMenuItem;
private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem; private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem;
private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem; private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem RestoreDefaultSettingsMenuItem;
} }
} }

View File

@ -14,9 +14,11 @@ namespace BizHawk.Client.EmuHawk
{ {
// Refresh rate slider // Refresh rate slider
// Make faster, such as not saving to disk until the logging is stopped, dont' add to Instructions list every frame, etc // Make faster, such as not saving to disk until the logging is stopped, dont' add to Instructions list every frame, etc
// Remember window size
private readonly List<string> _instructions = new List<string>(); private readonly List<string> _instructions = new List<string>();
private FileInfo _logFile; private FileInfo _logFile;
private int _defaultWidth;
private int _defaultHeight;
public TraceLogger() public TraceLogger()
{ {
@ -44,6 +46,8 @@ namespace BizHawk.Client.EmuHawk
Global.CoreComm.Tracer.Enabled = false; Global.CoreComm.Tracer.Enabled = false;
Global.Config.TraceLoggerSettings.Wndx = Location.X; Global.Config.TraceLoggerSettings.Wndx = Location.X;
Global.Config.TraceLoggerSettings.Wndy = Location.Y; Global.Config.TraceLoggerSettings.Wndy = Location.Y;
Global.Config.TraceLoggerSettings.Width = Size.Width;
Global.Config.TraceLoggerSettings.Height = Size.Height;
} }
private void TraceView_QueryItemText(int index, int column, out string text) private void TraceView_QueryItemText(int index, int column, out string text)
@ -53,9 +57,17 @@ namespace BizHawk.Client.EmuHawk
private void TraceLogger_Load(object sender, EventArgs e) private void TraceLogger_Load(object sender, EventArgs e)
{ {
_defaultWidth = Size.Width;
_defaultHeight = Size.Height;
if (Global.Config.TraceLoggerSettings.UseWindowPosition) if (Global.Config.TraceLoggerSettings.UseWindowPosition)
{ {
Location = new Point(Global.Config.TraceLoggerSettings.Wndx.Value, Global.Config.TraceLoggerSettings.Wndy.Value); Location = Global.Config.TraceLoggerSettings.WindowPosition;
}
if (Global.Config.TraceLoggerSettings.UseWindowSize)
{
Size = Global.Config.TraceLoggerSettings.WindowSize;
} }
ClearList(); ClearList();
@ -311,6 +323,17 @@ namespace BizHawk.Client.EmuHawk
RefreshFloatingWindowControl(); RefreshFloatingWindowControl();
} }
private void RestoreDefaultSettingsMenuItem_Click(object sender, EventArgs e)
{
Size = new Size(_defaultWidth, _defaultHeight);
Global.Config.TraceLoggerSettings.SaveWindowPosition = true;
Global.Config.TraceLoggerSettings.TopMost = false;
Global.Config.TraceLoggerSettings.FloatingWindow = false;
RefreshFloatingWindowControl();
}
#endregion #endregion
#region Dialog and ListView Events #region Dialog and ListView Events

View File

@ -198,12 +198,12 @@ namespace BizHawk.Client.EmuHawk
if (Global.Config.RamSearchSettings.UseWindowPosition) if (Global.Config.RamSearchSettings.UseWindowPosition)
{ {
Location = new Point(Global.Config.RamSearchSettings.Wndx.Value, Global.Config.RamSearchSettings.Wndy.Value); Location = Global.Config.RamSearchSettings.WindowPosition;
} }
if (Global.Config.RamSearchSettings.UseWindowSize) if (Global.Config.RamSearchSettings.UseWindowSize)
{ {
Size = new Size(Global.Config.RamSearchSettings.Width.Value, Global.Config.RamSearchSettings.Height.Value); Size = Global.Config.RamSearchSettings.WindowSize;
} }
TopMost = Global.Config.RamSearchSettings.TopMost; TopMost = Global.Config.RamSearchSettings.TopMost;
@ -1288,6 +1288,8 @@ namespace BizHawk.Client.EmuHawk
{ {
SetToFastMode(); SetToFastMode();
} }
RefreshFloatingWindowControl();
} }
#endregion #endregion

View File

@ -923,7 +923,9 @@ namespace BizHawk.Client.EmuHawk
Global.Config.DisplayRamWatch = false; Global.Config.DisplayRamWatch = false;
Global.Config.RamWatchSettings.SaveWindowPosition = true; Global.Config.RamWatchSettings.SaveWindowPosition = true;
Global.Config.RamWatchSettings.TopMost = TopMost = false; Global.Config.RamWatchSettings.TopMost = TopMost = false;
Global.Config.RamWatchSettings.FloatingWindow = false;
RefreshFloatingWindowControl();
LoadColumnInfo(); LoadColumnInfo();
} }