cleanup LogWindow

This commit is contained in:
adelikat 2019-12-17 11:19:34 -06:00
parent d780b1c898
commit 35ff30cc01
2 changed files with 41 additions and 40 deletions

View File

@ -93,7 +93,7 @@ namespace BizHawk.Client.EmuHawk
this.buttonCopy.TabIndex = 3; this.buttonCopy.TabIndex = 3;
this.buttonCopy.Text = "Copy Sel."; this.buttonCopy.Text = "Copy Sel.";
this.buttonCopy.UseVisualStyleBackColor = true; this.buttonCopy.UseVisualStyleBackColor = true;
this.buttonCopy.Click += new System.EventHandler(this.buttonCopy_Click); this.buttonCopy.Click += new System.EventHandler(this.ButtonCopy_Click);
// //
// buttonCopyAll // buttonCopyAll
// //
@ -103,7 +103,7 @@ namespace BizHawk.Client.EmuHawk
this.buttonCopyAll.TabIndex = 4; this.buttonCopyAll.TabIndex = 4;
this.buttonCopyAll.Text = "Copy All"; this.buttonCopyAll.Text = "Copy All";
this.buttonCopyAll.UseVisualStyleBackColor = true; this.buttonCopyAll.UseVisualStyleBackColor = true;
this.buttonCopyAll.Click += new System.EventHandler(this.buttonCopyAll_Click); this.buttonCopyAll.Click += new System.EventHandler(this.ButtonCopyAll_Click);
// //
// AddToGameDbBtn // AddToGameDbBtn
// //
@ -133,9 +133,9 @@ namespace BizHawk.Client.EmuHawk
this.virtualListView1.UseCompatibleStateImageBehavior = false; this.virtualListView1.UseCompatibleStateImageBehavior = false;
this.virtualListView1.View = System.Windows.Forms.View.Details; this.virtualListView1.View = System.Windows.Forms.View.Details;
this.virtualListView1.VirtualMode = true; this.virtualListView1.VirtualMode = true;
this.virtualListView1.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(this.virtualListView1_QueryItemText); this.virtualListView1.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(this.ListView_QueryItemText);
this.virtualListView1.ClientSizeChanged += new System.EventHandler(this.virtualListView1_ClientSizeChanged); this.virtualListView1.ClientSizeChanged += new System.EventHandler(this.ListView_ClientSizeChanged);
this.virtualListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.virtualListView1_KeyDown); this.virtualListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListView_KeyDown);
// //
// LogWindow // LogWindow
// //

View File

@ -17,7 +17,7 @@ namespace BizHawk.Client.EmuHawk
{ {
//TODO: only show add to game db when this is a Rom details dialog //TODO: only show add to game db when this is a Rom details dialog
//Let user decide what type (instead of always adding it as a good dump) //Let user decide what type (instead of always adding it as a good dump)
private readonly List<string> Lines = new List<string>(); private readonly List<string> _lines = new List<string>();
public LogWindow() public LogWindow()
{ {
@ -29,21 +29,22 @@ namespace BizHawk.Client.EmuHawk
LogConsole.notifyLogWindowClosing(); LogConsole.notifyLogWindowClosing();
SaveConfigSettings(); SaveConfigSettings();
}; };
virtualListView1_ClientSizeChanged(null, null); ListView_ClientSizeChanged(null, null);
} }
public static void ShowReport(string title, string report, IWin32Window parent) public static void ShowReport(string title, string report, IWin32Window parent)
{ {
using (var dlg = new LogWindow()) using var dlg = new LogWindow();
var ss = report.Split('\n');
foreach (var s in ss)
{ {
var ss = report.Split('\n'); dlg._lines.Add(s.TrimEnd('\r'));
foreach (var s in ss)
dlg.Lines.Add(s.TrimEnd('\r'));
dlg.virtualListView1.VirtualListSize = ss.Length;
dlg.Text = title;
dlg.btnClear.Visible = false;
dlg.ShowDialog(parent);
} }
dlg.virtualListView1.VirtualListSize = ss.Length;
dlg.Text = title;
dlg.btnClear.Visible = false;
dlg.ShowDialog(parent);
} }
public void Append(string str) public void Append(string str)
@ -53,7 +54,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (!string.IsNullOrWhiteSpace(s)) if (!string.IsNullOrWhiteSpace(s))
{ {
Lines.Add(s.TrimEnd('\r')); _lines.Add(s.TrimEnd('\r'));
virtualListView1.VirtualListSize++; virtualListView1.VirtualListSize++;
} }
} }
@ -61,7 +62,7 @@ namespace BizHawk.Client.EmuHawk
private void btnClear_Click(object sender, EventArgs e) private void btnClear_Click(object sender, EventArgs e)
{ {
Lines.Clear(); _lines.Clear();
virtualListView1.VirtualListSize = 0; virtualListView1.VirtualListSize = 0;
virtualListView1.SelectedIndices.Clear(); virtualListView1.SelectedIndices.Clear();
} }
@ -98,42 +99,42 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void virtualListView1_QueryItemText(object sender, RetrieveVirtualItemEventArgs e) private void ListView_QueryItemText(object sender, RetrieveVirtualItemEventArgs e)
{ {
e.Item = new ListViewItem(Lines[e.ItemIndex]); e.Item = new ListViewItem(_lines[e.ItemIndex]);
} }
private void virtualListView1_ClientSizeChanged(object sender, EventArgs e) private void ListView_ClientSizeChanged(object sender, EventArgs e)
{ {
virtualListView1.Columns[0].Width = virtualListView1.ClientSize.Width; virtualListView1.Columns[0].Width = virtualListView1.ClientSize.Width;
} }
private void buttonCopy_Click(object sender, EventArgs e) private void ListView_KeyDown(object sender, KeyEventArgs e)
{
var sb = new StringBuilder();
foreach (int i in virtualListView1.SelectedIndices)
sb.AppendLine(Lines[i]);
if (sb.Length > 0)
Clipboard.SetText(sb.ToString(), TextDataFormat.Text);
}
private void buttonCopyAll_Click(object sender, EventArgs e)
{
var sb = new StringBuilder();
foreach (var s in Lines)
sb.AppendLine(s);
if (sb.Length > 0)
Clipboard.SetText(sb.ToString(), TextDataFormat.Text);
}
private void virtualListView1_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift) if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift)
{ {
buttonCopy_Click(null, null); ButtonCopy_Click(null, null);
} }
} }
private void ButtonCopy_Click(object sender, EventArgs e)
{
var sb = new StringBuilder();
foreach (int i in virtualListView1.SelectedIndices)
sb.AppendLine(_lines[i]);
if (sb.Length > 0)
Clipboard.SetText(sb.ToString(), TextDataFormat.Text);
}
private void ButtonCopyAll_Click(object sender, EventArgs e)
{
var sb = new StringBuilder();
foreach (var s in _lines)
sb.AppendLine(s);
if (sb.Length > 0)
Clipboard.SetText(sb.ToString(), TextDataFormat.Text);
}
private void HideShowGameDbButton() private void HideShowGameDbButton()
{ {
AddToGameDbBtn.Visible = Global.Emulator.CanGenerateGameDBEntries() AddToGameDbBtn.Visible = Global.Emulator.CanGenerateGameDBEntries()