From c48ecc86c97a444835a62b76de85a6ef65fe4e6a Mon Sep 17 00:00:00 2001
From: croire <1432593898@qq.com>
Date: Sun, 24 Oct 2021 15:38:47 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=9B=91=E5=90=AC=E5=89=AA?=
=?UTF-8?q?=E8=B4=B4=E6=9D=BF=E4=BA=8B=E4=BB=B6=E8=BF=9E=E7=BB=AD=E6=89=A7?=
=?UTF-8?q?=E8=A1=8C2=E6=AC=A1=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DownKyi/ViewModels/MainWindowViewModel.cs | 27 +++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/DownKyi/ViewModels/MainWindowViewModel.cs b/DownKyi/ViewModels/MainWindowViewModel.cs
index 22279ee..2f9f1fa 100644
--- a/DownKyi/ViewModels/MainWindowViewModel.cs
+++ b/DownKyi/ViewModels/MainWindowViewModel.cs
@@ -149,6 +149,7 @@ namespace DownKyi.ViewModels
clipboardHooker = new ClipboardHooker(Application.Current.MainWindow);
clipboardHooker.ClipboardUpdated += OnClipboardUpdated;
+ // 进入首页
var param = new NavigationParameters
{
{ "Parent", "" },
@@ -292,8 +293,32 @@ namespace DownKyi.ViewModels
icon.Fill = DictionaryResource.GetColor("ColorSystemBtnTintDark");
}
+ #region 剪贴板
+
+ private int times = 0;
+
+ ///
+ /// 监听剪贴板更新事件,会执行两遍以上
+ ///
+ ///
+ ///
private void OnClipboardUpdated(object sender, EventArgs e)
{
+ times += 1;
+ DispatcherTimer timer = new DispatcherTimer
+ {
+ Interval = new TimeSpan(0, 0, 0, 0, 300)
+ };
+ timer.Tick += (s, ex) => { timer.IsEnabled = false; times = 0; };
+ timer.IsEnabled = true;
+
+ if (times % 2 == 0)
+ {
+ timer.IsEnabled = false;
+ times = 0;
+ return;
+ }
+
AllowStatus isListenClipboard = SettingsManager.GetInstance().IsListenClipboard();
if (isListenClipboard != AllowStatus.YES)
{
@@ -381,5 +406,7 @@ namespace DownKyi.ViewModels
}
}
+ #endregion
+
}
}