Debug log links will be clickable

This commit is contained in:
Jaex 2013-11-24 21:38:39 +02:00
parent dc29123c01
commit 27eed97243
3 changed files with 30 additions and 31 deletions

View file

@ -28,30 +28,15 @@ protected override void Dispose(bool disposing)
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.txtDebugLog = new System.Windows.Forms.TextBox();
this.btnLoadedAssemblies = new System.Windows.Forms.Button(); this.btnLoadedAssemblies = new System.Windows.Forms.Button();
this.btnCopyAll = new System.Windows.Forms.Button(); this.btnCopyAll = new System.Windows.Forms.Button();
this.rtbDebug = new System.Windows.Forms.RichTextBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// txtDebugLog
//
this.txtDebugLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtDebugLog.BackColor = System.Drawing.Color.White;
this.txtDebugLog.Location = new System.Drawing.Point(8, 8);
this.txtDebugLog.Multiline = true;
this.txtDebugLog.Name = "txtDebugLog";
this.txtDebugLog.ReadOnly = true;
this.txtDebugLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtDebugLog.Size = new System.Drawing.Size(744, 472);
this.txtDebugLog.TabIndex = 2;
this.txtDebugLog.WordWrap = false;
//
// btnLoadedAssemblies // btnLoadedAssemblies
// //
this.btnLoadedAssemblies.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnLoadedAssemblies.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnLoadedAssemblies.Location = new System.Drawing.Point(96, 488); this.btnLoadedAssemblies.Location = new System.Drawing.Point(96, 511);
this.btnLoadedAssemblies.Name = "btnLoadedAssemblies"; this.btnLoadedAssemblies.Name = "btnLoadedAssemblies";
this.btnLoadedAssemblies.Size = new System.Drawing.Size(136, 23); this.btnLoadedAssemblies.Size = new System.Drawing.Size(136, 23);
this.btnLoadedAssemblies.TabIndex = 1; this.btnLoadedAssemblies.TabIndex = 1;
@ -62,7 +47,7 @@ private void InitializeComponent()
// btnCopyAll // btnCopyAll
// //
this.btnCopyAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnCopyAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCopyAll.Location = new System.Drawing.Point(8, 488); this.btnCopyAll.Location = new System.Drawing.Point(8, 511);
this.btnCopyAll.Name = "btnCopyAll"; this.btnCopyAll.Name = "btnCopyAll";
this.btnCopyAll.Size = new System.Drawing.Size(80, 23); this.btnCopyAll.Size = new System.Drawing.Size(80, 23);
this.btnCopyAll.TabIndex = 0; this.btnCopyAll.TabIndex = 0;
@ -70,28 +55,37 @@ private void InitializeComponent()
this.btnCopyAll.UseVisualStyleBackColor = true; this.btnCopyAll.UseVisualStyleBackColor = true;
this.btnCopyAll.Click += new System.EventHandler(this.btnCopyAll_Click); this.btnCopyAll.Click += new System.EventHandler(this.btnCopyAll_Click);
// //
// rtbDebug
//
this.rtbDebug.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.rtbDebug.Location = new System.Drawing.Point(8, 8);
this.rtbDebug.Name = "rtbDebug";
this.rtbDebug.Size = new System.Drawing.Size(744, 496);
this.rtbDebug.TabIndex = 3;
this.rtbDebug.Text = "";
this.rtbDebug.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.rtbDebug_LinkClicked);
//
// DebugForm // DebugForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(760, 518); this.ClientSize = new System.Drawing.Size(760, 541);
this.Controls.Add(this.rtbDebug);
this.Controls.Add(this.btnCopyAll); this.Controls.Add(this.btnCopyAll);
this.Controls.Add(this.btnLoadedAssemblies); this.Controls.Add(this.btnLoadedAssemblies);
this.Controls.Add(this.txtDebugLog);
this.MinimumSize = new System.Drawing.Size(400, 400); this.MinimumSize = new System.Drawing.Size(400, 400);
this.Name = "DebugForm"; this.Name = "DebugForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ShareX - Debug log"; this.Text = "ShareX - Debug log";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DebugForm_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DebugForm_FormClosing);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
private System.Windows.Forms.TextBox txtDebugLog;
private System.Windows.Forms.Button btnLoadedAssemblies; private System.Windows.Forms.Button btnLoadedAssemblies;
private System.Windows.Forms.Button btnCopyAll; private System.Windows.Forms.Button btnCopyAll;
private System.Windows.Forms.RichTextBox rtbDebug;
} }
} }

View file

@ -42,9 +42,9 @@ public DebugForm(Logger logger)
Icon = ShareXResources.Icon; Icon = ShareXResources.Icon;
this.logger = logger; this.logger = logger;
txtDebugLog.Text = logger.ToString(); rtbDebug.Text = logger.ToString();
txtDebugLog.SelectionStart = txtDebugLog.TextLength; rtbDebug.SelectionStart = rtbDebug.TextLength;
txtDebugLog.ScrollToCaret(); rtbDebug.ScrollToCaret();
logger.MessageAdded += logger_MessageAdded; logger.MessageAdded += logger_MessageAdded;
} }
@ -63,19 +63,19 @@ private void AppendMessage(string message)
{ {
if (!string.IsNullOrEmpty(message)) if (!string.IsNullOrEmpty(message))
{ {
int start = txtDebugLog.SelectionStart; int start = rtbDebug.SelectionStart;
int len = txtDebugLog.SelectionLength; int len = rtbDebug.SelectionLength;
txtDebugLog.AppendText(message + Environment.NewLine); rtbDebug.AppendText(message + Environment.NewLine);
if (len > 0) if (len > 0)
{ {
txtDebugLog.Select(start, len); rtbDebug.Select(start, len);
} }
} }
} }
private void btnCopyAll_Click(object sender, EventArgs e) private void btnCopyAll_Click(object sender, EventArgs e)
{ {
string text = txtDebugLog.Text.Trim(); string text = rtbDebug.Text.Trim();
ClipboardHelpers.CopyText(text); ClipboardHelpers.CopyText(text);
} }
@ -94,5 +94,10 @@ private void btnLoadedAssemblies_Click(object sender, EventArgs e)
MessageBox.Show(assemblies, "ShareX - Loaded assemblies", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show(assemblies, "ShareX - Loaded assemblies", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
private void rtbDebug_LinkClicked(object sender, LinkClickedEventArgs e)
{
Helpers.LoadBrowserAsync(e.LinkText);
}
} }
} }

View file

@ -465,7 +465,7 @@ public static void LoadBrowserAsync(string url)
} }
catch (Exception e) catch (Exception e)
{ {
DebugHelper.WriteException(e, "LoadBrowserAsync failed"); DebugHelper.WriteException(e, "LoadBrowserAsync(" + url + ") failed");
} }
}); });
} }