From 10f5f0b44d8cccf7dc700e5600e87b492c76c6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com> Date: Fri, 19 Nov 2021 15:49:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=80=92=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.UI/UdpLogListBox.xaml.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/FastGithub.UI/UdpLogListBox.xaml.cs b/FastGithub.UI/UdpLogListBox.xaml.cs index 7aef0ac..554e44f 100644 --- a/FastGithub.UI/UdpLogListBox.xaml.cs +++ b/FastGithub.UI/UdpLogListBox.xaml.cs @@ -9,6 +9,7 @@ namespace FastGithub.UI /// public partial class UdpLogListBox : UserControl { + private readonly int maxLogCount = 100; public ObservableCollection LogList { get; } = new ObservableCollection(); public UdpLogListBox() @@ -28,7 +29,11 @@ namespace FastGithub.UI var log = await UdpLogger.GetUdpLogAsync(); if (log != null) { - this.LogList.Add(log); + this.LogList.Insert(0, log); + if (this.LogList.Count > this.maxLogCount) + { + this.LogList.RemoveAt(this.maxLogCount); + } } } catch (Exception)