From 3471ae0ff193f445705f137ccc8b37afa2ea790a Mon Sep 17 00:00:00 2001 From: clover_yan <56215525+clover-yan@users.noreply.github.com> Date: Fri, 12 May 2023 11:40:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=E9=BC=A0=E6=A0=87=E7=A9=BF?= =?UTF-8?q?=E9=80=8F=EF=BC=8C=E4=BC=98=E5=8C=96=E5=A4=96=E8=A7=82=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DateCountdown/MainWindow.xaml.cs | 33 ++++++++++++++++++++++-- DateCountdown/Properties/AssemblyInfo.cs | 4 +-- README.md | 5 ++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/DateCountdown/MainWindow.xaml.cs b/DateCountdown/MainWindow.xaml.cs index 8972194..c618e07 100644 --- a/DateCountdown/MainWindow.xaml.cs +++ b/DateCountdown/MainWindow.xaml.cs @@ -39,6 +39,32 @@ public MainWindow() dispatcherTimer.Start(); } + // 利用 win32 接口实现窗体鼠标事件穿透 + const int WS_EX_TRANSPARENT = 0x20; + const int GWL_EXSTYLE = -20; + + [DllImport("user32.dll")] + static extern int GetWindowLong(IntPtr hwnd, int index); + + [DllImport("user32.dll")] + static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle); + + protected override void OnSourceInitialized(EventArgs e) + { + base.OnSourceInitialized(e); + + if (App.StartArgs.Contains("-k")) + { + + // Get this window's handle + IntPtr hwnd = new WindowInteropHelper(this).Handle; + + // Change the extended window style to include WS_EX_TRANSPARENT + int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE); + SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT); + } + } + private void DispatcherTimer_Tick(object sender, EventArgs e) { // int year = getYear(); @@ -110,6 +136,9 @@ private void Window_Loaded(object sender, RoutedEventArgs e) try { TextBlockTitle.Text = App.StartArgs[0]; + if (TextBlockTitle.Text == "") { + TextBlockTitle.Text = "距离高考还有"; + } } catch { @@ -164,8 +193,8 @@ private void Window_Loaded(object sender, RoutedEventArgs e) if (App.StartArgs.Contains("-b")) { - TextBlockTitle.Effect = AfterText.Effect = TextBlockCopyright.Effect = new DropShadowEffect { Color = light ? Colors.Black : Colors.White, Direction = 320, ShadowDepth = 0, BlurRadius = alpha ? 10 : 5 }; - TextBlockDays.Effect = TextBlockDaysDetails.Effect = new DropShadowEffect { Color = light ? Colors.White : Colors.Black, Direction = 320, ShadowDepth = 0, BlurRadius = alpha ? 10 : 5 }; + TextBlockTitle.Effect = AfterText.Effect = TextBlockCopyright.Effect = new DropShadowEffect { Color = light ? Colors.Black : Colors.White, Direction = 320, ShadowDepth = 0, BlurRadius = alpha ? 15 : 5 }; + TextBlockDays.Effect = TextBlockDaysDetails.Effect = new DropShadowEffect { Color = light ? Colors.White : Colors.Black, Direction = 320, ShadowDepth = 0, BlurRadius = alpha ? 15 : 5 }; } if (App.StartArgs.Contains("-p")) diff --git a/DateCountdown/Properties/AssemblyInfo.cs b/DateCountdown/Properties/AssemblyInfo.cs index c9923ba..db333b7 100644 --- a/DateCountdown/Properties/AssemblyInfo.cs +++ b/DateCountdown/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.0.0")] -[assembly: AssemblyFileVersion("1.3.0.0")] +[assembly: AssemblyVersion("1.4.0.0")] +[assembly: AssemblyFileVersion("1.4.0.0")] diff --git a/README.md b/README.md index f800f44..b9b9173 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ 默认值为 `距离高考还有`。 +> **请注意:如果想要不传递此参数,而传递之后的参数,请将此参数留空(设为 `""`)。** + ### 参数 2 ~ 7 指定**目标年、月、日、时、分和秒**。 @@ -51,3 +53,6 @@ #### `-a` 将文字设为半透明。 + +#### `-k` +启用鼠标穿透。