From 7397d2e9ae1e7d52c97e95fadd7584c6f4b2854a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Mon, 18 Mar 2024 18:31:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95windows=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=B1=BBSystemEvents=EF=BC=8C=E8=AF=A5?= =?UTF-8?q?=E7=B1=BB=E9=9C=80=E8=A6=81=E7=94=A8=E6=88=B7=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E7=9A=84=E6=B6=88=E6=81=AF=E5=BE=AA=E7=8E=AF=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E8=BF=90=E8=A1=8C=E6=97=B6=E6=8B=BF=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E6=B6=88=E6=81=AF=EF=BC=8C=E4=B9=9F=E5=B0=B1=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E4=BA=8B=E4=BB=B6=E8=A7=A6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Test/Program.cs | 53 +++++++++++++++++++++++++++++++++++++++++++++++- Test/Test.csproj | 1 + 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/Test/Program.cs b/Test/Program.cs index 963b814b..361350d9 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -5,6 +5,7 @@ using System.Net; using System.Net.Sockets; using System.Threading; +using Microsoft.Win32; using NewLife; using NewLife.IO; using NewLife.Log; @@ -27,7 +28,7 @@ static void Main(String[] args) { XTrace.UseConsole(); - Test6(); + Test7(); Console.WriteLine("OK!"); Console.ReadKey(); @@ -193,6 +194,56 @@ static void Test6() } } + static void Test7() + { + XTrace.WriteLine("SystemEvents"); + + SystemEvents.PowerModeChanged += (s, e) => + { + XTrace.WriteLine("PowerModeChanged: {0}", e.Mode); + }; + SystemEvents.SessionSwitch += (s, e) => + { + XTrace.WriteLine("SessionSwitch: {0}", e.Reason); + }; + SystemEvents.SessionEnding += (s, e) => + { + XTrace.WriteLine("SessionEnding: {0}", e.Reason); + }; + SystemEvents.SessionEnded += (s, e) => + { + XTrace.WriteLine("SessionEnded: {0}", e.Reason); + }; + SystemEvents.UserPreferenceChanging += (s, e) => + { + XTrace.WriteLine("UserPreferenceChanging: {0}", e.Category); + }; + SystemEvents.UserPreferenceChanged += (s, e) => + { + XTrace.WriteLine("UserPreferenceChanged: {0}", e.Category); + }; + SystemEvents.DisplaySettingsChanged += (s, e) => + { + XTrace.WriteLine("DisplaySettingsChanged: {0}", e); + }; + SystemEvents.InstalledFontsChanged += (s, e) => + { + XTrace.WriteLine("InstalledFontsChanged: {0}", e); + }; + SystemEvents.TimeChanged += (s, e) => + { + XTrace.WriteLine("TimeChanged: {0}", e); + }; + SystemEvents.TimerElapsed += (s, e) => + { + XTrace.WriteLine("TimerElapsed: {0}", e); + }; + SystemEvents.LowMemory += (s, e) => + { + XTrace.WriteLine("LowMemory: {0}", e); + }; + } + static void Test8() { var str = "runtime=6.0;version>=1.0"; diff --git a/Test/Test.csproj b/Test/Test.csproj index aec76d9e..5dfd4057 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -29,6 +29,7 @@ +