From 53e907d1454bbcae944bc4d4645d4a7d5c8b096b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com> Date: Tue, 2 Nov 2021 14:34:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B3=E9=94=AE=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.UI/LogListBox.xaml | 9 ++++++++- FastGithub.UI/LogListBox.xaml.cs | 13 +++++++++++++ FastGithub.UI/UdpLog.cs | 8 +++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/FastGithub.UI/LogListBox.xaml b/FastGithub.UI/LogListBox.xaml index 7f10abc..9a241c7 100644 --- a/FastGithub.UI/LogListBox.xaml +++ b/FastGithub.UI/LogListBox.xaml @@ -8,6 +8,7 @@ d:DesignHeight="450" d:DesignWidth="800"> - + + + + + + + diff --git a/FastGithub.UI/LogListBox.xaml.cs b/FastGithub.UI/LogListBox.xaml.cs index 7e0b51c..8835fb8 100644 --- a/FastGithub.UI/LogListBox.xaml.cs +++ b/FastGithub.UI/LogListBox.xaml.cs @@ -41,5 +41,18 @@ namespace FastGithub.UI this.Dispatcher.Invoke(() => this.LogList.Add(log)); this.BeginReceiveFrom(); } + + private void MenuItem_Copy_Click(object sender, System.Windows.RoutedEventArgs e) + { + if (this.listBox.SelectedValue is UdpLog udpLog) + { + udpLog.SetToClipboard(); + } + } + + private void MenuItem_Clear_Click(object sender, System.Windows.RoutedEventArgs e) + { + this.LogList.Clear(); + } } } diff --git a/FastGithub.UI/UdpLog.cs b/FastGithub.UI/UdpLog.cs index 34d7e0d..5fa54fe 100644 --- a/FastGithub.UI/UdpLog.cs +++ b/FastGithub.UI/UdpLog.cs @@ -1,4 +1,5 @@ using System; +using System.Windows; using System.Windows.Media; namespace FastGithub.UI @@ -14,5 +15,10 @@ namespace FastGithub.UI public string SourceContext { get; set; } public string Color => this.Level == "Information" ? "#333" : "IndianRed"; - } + + public void SetToClipboard() + { + Clipboard.SetText($"{this.Timestamp.ToString("yyyy-MM-dd HH:mm:ss.fff")}\r\n{this.SourceContext}\r\n{this.Message}"); + } + } }