Skip to content

Commit

Permalink
允许鼠标穿透,优化外观,更新版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
clover-yan authored May 12, 2023
1 parent 7e9cc8b commit 3471ae0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
33 changes: 31 additions & 2 deletions DateCountdown/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -110,6 +136,9 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
try
{
TextBlockTitle.Text = App.StartArgs[0];
if (TextBlockTitle.Text == "") {
TextBlockTitle.Text = "距离高考还有";
}
}
catch
{
Expand Down Expand Up @@ -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"))
Expand Down
4 changes: 2 additions & 2 deletions DateCountdown/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

默认值为 `距离高考还有`

> **请注意:如果想要不传递此参数,而传递之后的参数,请将此参数留空(设为 `""`)。**
### 参数 2 ~ 7
指定**目标年、月、日、时、分和秒**

Expand Down Expand Up @@ -51,3 +53,6 @@

#### `-a`
将文字设为半透明。

#### `-k`
启用鼠标穿透。

0 comments on commit 3471ae0

Please sign in to comment.