diff --git a/BizHawk.MultiClient/LogWindow.Designer.cs b/BizHawk.MultiClient/LogWindow.Designer.cs index ebe7011ff3..86c7d628be 100644 --- a/BizHawk.MultiClient/LogWindow.Designer.cs +++ b/BizHawk.MultiClient/LogWindow.Designer.cs @@ -31,14 +31,17 @@ this.btnClose = new System.Windows.Forms.Button(); this.btnClear = new System.Windows.Forms.Button(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.textBox1 = new System.Windows.Forms.TextBox(); + this.buttonCopy = new System.Windows.Forms.Button(); + this.virtualListView1 = new BizHawk.VirtualListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.buttonCopyAll = new System.Windows.Forms.Button(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // btnClose // this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnClose.Location = new System.Drawing.Point(453, 3); + this.btnClose.Location = new System.Drawing.Point(597, 3); this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(75, 23); this.btnClose.TabIndex = 2; @@ -60,40 +63,70 @@ // this.tableLayoutPanel1.AutoSize = true; this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnCount = 5; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.Controls.Add(this.btnClear, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.btnClose, 2, 0); + this.tableLayoutPanel1.Controls.Add(this.btnClose, 4, 0); + this.tableLayoutPanel1.Controls.Add(this.buttonCopy, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.buttonCopyAll, 2, 0); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 273); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 368); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 1; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(531, 29); + this.tableLayoutPanel1.Size = new System.Drawing.Size(675, 29); this.tableLayoutPanel1.TabIndex = 5; // - // textBox1 + // buttonCopy // - this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.textBox1.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox1.Location = new System.Drawing.Point(0, 0); - this.textBox1.Multiline = true; - this.textBox1.Name = "textBox1"; - this.textBox1.ReadOnly = true; - this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBox1.Size = new System.Drawing.Size(531, 273); - this.textBox1.TabIndex = 6; - this.textBox1.TabStop = false; + this.buttonCopy.Location = new System.Drawing.Point(84, 3); + this.buttonCopy.Name = "buttonCopy"; + this.buttonCopy.Size = new System.Drawing.Size(75, 23); + this.buttonCopy.TabIndex = 3; + this.buttonCopy.Text = "Copy Sel."; + this.buttonCopy.UseVisualStyleBackColor = true; + this.buttonCopy.Click += new System.EventHandler(this.buttonCopy_Click); + // + // virtualListView1 + // + this.virtualListView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1}); + this.virtualListView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.virtualListView1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.virtualListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.virtualListView1.ItemCount = 0; + this.virtualListView1.Location = new System.Drawing.Point(0, 0); + this.virtualListView1.Name = "virtualListView1"; + this.virtualListView1.selectedItem = -1; + this.virtualListView1.Size = new System.Drawing.Size(675, 368); + this.virtualListView1.TabIndex = 8; + this.virtualListView1.UseCompatibleStateImageBehavior = false; + this.virtualListView1.View = System.Windows.Forms.View.Details; + this.virtualListView1.VirtualMode = true; + this.virtualListView1.QueryItemText += new BizHawk.QueryItemTextHandler(this.virtualListView1_QueryItemText); + this.virtualListView1.ClientSizeChanged += new System.EventHandler(this.virtualListView1_ClientSizeChanged); + // + // buttonCopyAll + // + this.buttonCopyAll.Location = new System.Drawing.Point(165, 3); + this.buttonCopyAll.Name = "buttonCopyAll"; + this.buttonCopyAll.Size = new System.Drawing.Size(75, 23); + this.buttonCopyAll.TabIndex = 4; + this.buttonCopyAll.Text = "Copy All"; + this.buttonCopyAll.UseVisualStyleBackColor = true; + this.buttonCopyAll.Click += new System.EventHandler(this.buttonCopyAll_Click); // // LogWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnClose; - this.ClientSize = new System.Drawing.Size(531, 302); - this.Controls.Add(this.textBox1); + this.ClientSize = new System.Drawing.Size(675, 397); + this.Controls.Add(this.virtualListView1); this.Controls.Add(this.tableLayoutPanel1); this.MinimumSize = new System.Drawing.Size(171, 97); this.Name = "LogWindow"; @@ -111,6 +144,9 @@ private System.Windows.Forms.Button btnClose; private System.Windows.Forms.Button btnClear; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.TextBox textBox1; + private VirtualListView virtualListView1; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.Button buttonCopy; + private System.Windows.Forms.Button buttonCopyAll; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/LogWindow.cs b/BizHawk.MultiClient/LogWindow.cs index f971544650..067dc77cd1 100644 --- a/BizHawk.MultiClient/LogWindow.cs +++ b/BizHawk.MultiClient/LogWindow.cs @@ -16,6 +16,8 @@ namespace BizHawk.MultiClient int defaultWidth; int defaultHeight; + List Lines = new List(); + public LogWindow() { InitializeComponent(); @@ -26,36 +28,35 @@ namespace BizHawk.MultiClient LogConsole.notifyLogWindowClosing(); SaveConfigSettings(); }; + virtualListView1_ClientSizeChanged(null, null); } - public void ShowReport(string title, string report) + public static void ShowReport(string title, string report, IWin32Window parent) { - Text = title; - textBox1.Text = report; - btnClear.Visible = false; - ShowDialog(); - } - - public void SetLogText(string str) - { - textBox1.Text = str; - textBox1.SelectionStart = str.Length; - textBox1.ScrollToCaret(); - Refresh(); + using (var dlg = new LogWindow()) + { + var ss = report.Split('\n'); + foreach (var s in ss) + dlg.Lines.Add(s); + dlg.virtualListView1.ItemCount = ss.Length; + dlg.Text = title; + dlg.btnClear.Visible = false; + dlg.ShowDialog(parent); + } } StringBuilder sbLog = new StringBuilder(); public void Append(string str) { - sbLog.Append(str); - SetLogText(sbLog.ToString()); + Lines.Add(str); + virtualListView1.ItemCount++; } private void btnClear_Click(object sender, EventArgs e) { - sbLog.Length = 0; - SetLogText(""); - Refresh(); + Lines.Clear(); + virtualListView1.ItemCount = 0; + virtualListView1.SelectedIndices.Clear(); } private void btnClose_Click(object sender, EventArgs e) @@ -90,5 +91,33 @@ namespace BizHawk.MultiClient Global.Config.LogWindowHeight = this.Bottom - this.Top; } } + + private void virtualListView1_QueryItemText(int item, int subItem, out string text) + { + text = Lines[item]; + } + + private void virtualListView1_ClientSizeChanged(object sender, EventArgs e) + { + virtualListView1.Columns[0].Width = virtualListView1.ClientSize.Width; + } + + 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.Append(s); + if (sb.Length > 0) + Clipboard.SetText(sb.ToString(), TextDataFormat.Text); + } } } diff --git a/BizHawk.MultiClient/MainForm.MenuItems.cs b/BizHawk.MultiClient/MainForm.MenuItems.cs index d738f3d96f..74136aae70 100644 --- a/BizHawk.MultiClient/MainForm.MenuItems.cs +++ b/BizHawk.MultiClient/MainForm.MenuItems.cs @@ -24,10 +24,9 @@ namespace BizHawk.MultiClient private void DumpStatus_Click(object sender, EventArgs e) { string details = Global.Emulator.CoreOutputComm.RomStatusDetails; - if(string.IsNullOrEmpty(details)) return; - var lw = new LogWindow(); + if (string.IsNullOrEmpty(details)) return; Global.Sound.StopSound(); - lw.ShowReport("Dump Status Report",details); + LogWindow.ShowReport("Dump Status Report", details, this); Global.Sound.StartSound(); }