From 203c855e6651f115f16af528a8cdd16d86f5c480 Mon Sep 17 00:00:00 2001 From: Nikolaj Pedersen Date: Wed, 29 May 2019 13:15:59 +0200 Subject: [PATCH] Now show a dialog with the content of the line when double-clicking a line. The text in the dialog can be selected and copied to clipboard. --- SnakeTail/LogLineDialog.Designer.cs | 66 +++++++++++++++ SnakeTail/LogLineDialog.cs | 28 +++++++ SnakeTail/LogLineDialog.resx | 120 ++++++++++++++++++++++++++++ SnakeTail/SnakeTail.csproj | 10 +++ SnakeTail/TailForm.Designer.cs | 1 + SnakeTail/TailForm.cs | 11 +++ 6 files changed, 236 insertions(+) create mode 100644 SnakeTail/LogLineDialog.Designer.cs create mode 100644 SnakeTail/LogLineDialog.cs create mode 100644 SnakeTail/LogLineDialog.resx diff --git a/SnakeTail/LogLineDialog.Designer.cs b/SnakeTail/LogLineDialog.Designer.cs new file mode 100644 index 0000000..e3fabe0 --- /dev/null +++ b/SnakeTail/LogLineDialog.Designer.cs @@ -0,0 +1,66 @@ +namespace SnakeTail +{ + partial class LogLineDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lineText = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // lineText + // + this.lineText.Dock = System.Windows.Forms.DockStyle.Fill; + this.lineText.Location = new System.Drawing.Point(0, 0); + this.lineText.Multiline = true; + this.lineText.Name = "lineText"; + this.lineText.ReadOnly = true; + this.lineText.Size = new System.Drawing.Size(808, 60); + this.lineText.TabIndex = 0; + // + // LogLineDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(808, 60); + this.Controls.Add(this.lineText); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "LogLineDialog"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + public System.Windows.Forms.TextBox lineText; + } +} \ No newline at end of file diff --git a/SnakeTail/LogLineDialog.cs b/SnakeTail/LogLineDialog.cs new file mode 100644 index 0000000..e30a2d9 --- /dev/null +++ b/SnakeTail/LogLineDialog.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace SnakeTail +{ + public partial class LogLineDialog : Form + { + public LogLineDialog() + { + InitializeComponent(); + } + + protected override bool ProcessDialogKey(Keys keyData) + { + if (Form.ModifierKeys == Keys.None && keyData == Keys.Escape) + { + Hide(); + return true; + } + return base.ProcessDialogKey(keyData); + } + } +} diff --git a/SnakeTail/LogLineDialog.resx b/SnakeTail/LogLineDialog.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/SnakeTail/LogLineDialog.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SnakeTail/SnakeTail.csproj b/SnakeTail/SnakeTail.csproj index ada174e..5c766b0 100644 --- a/SnakeTail/SnakeTail.csproj +++ b/SnakeTail/SnakeTail.csproj @@ -62,6 +62,7 @@ + @@ -84,6 +85,12 @@ ExternalToolConfigForm.cs + + Form + + + LogLineDialog.cs + @@ -133,6 +140,9 @@ KeywordConfigForm.cs + + LogLineDialog.cs + MainForm.cs Designer diff --git a/SnakeTail/TailForm.Designer.cs b/SnakeTail/TailForm.Designer.cs index 1949c30..0215cd7 100644 --- a/SnakeTail/TailForm.Designer.cs +++ b/SnakeTail/TailForm.Designer.cs @@ -389,6 +389,7 @@ private void InitializeComponent() this._tailListView.CacheVirtualItems += new System.Windows.Forms.CacheVirtualItemsEventHandler(this._tailListView_CacheVirtualItems); this._tailListView.DrawItem += new System.Windows.Forms.DrawListViewItemEventHandler(this._tailListView_DrawItem); this._tailListView.DrawSubItem += new System.Windows.Forms.DrawListViewSubItemEventHandler(this._tailListView_DrawSubItem); + this._tailListView.ItemActivate += new System.EventHandler(this._tailListView_ItemActivate); this._tailListView.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this._tailListView_RetrieveVirtualItem); this._tailListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this._tailListView_KeyDown); // diff --git a/SnakeTail/TailForm.cs b/SnakeTail/TailForm.cs index 3fd1435..100bbc1 100644 --- a/SnakeTail/TailForm.cs +++ b/SnakeTail/TailForm.cs @@ -101,6 +101,7 @@ partial class TailForm : Form, ITailForm Color _bookmarkBackColor = Color.Green; // Default bookmark background color List _bookmarks = new List(); ThreadPoolQueue _threadPoolQueue = null; + LogLineDialog _logLineDialog = new LogLineDialog(); public TailForm() { @@ -1738,6 +1739,16 @@ public void OpenExplorer() MessageBox.Show(this, "Failed to open Windows Explorer.\n\n" + ex.Message); } } + + private void _tailListView_ItemActivate(object sender, EventArgs e) + { + ListView.SelectedIndexCollection selectedIndexCollection = _tailListView.SelectedIndices; + if (selectedIndexCollection.Count == 1) + { + _logLineDialog.lineText.Text = _tailListView.Items[selectedIndexCollection[0]].Text; + _logLineDialog.ShowDialog(); + } + } } class LogFileListView : ListView