Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
################################################################################
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
################################################################################

/.dotnet_cli/.dotnet
/.vs
/bin/*
/obj/*
/LiteMonitor.Updater/*
3 changes: 2 additions & 1 deletion src/System/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static void Main()
try
{
// ★★★ 3. 启动应用 ★★★
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
ApplicationConfiguration.Initialize();
Application.Run(new MainForm());
}
Expand Down Expand Up @@ -148,4 +149,4 @@ static void LogCrash(Exception? ex, string source)
}
}
}
}
}
17 changes: 11 additions & 6 deletions src/UI/Helpers/TaskbarWinHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private IntPtr FindSecondaryTaskbar(Screen screen)
if (screen.Bounds.Contains(r.Location) || screen.Bounds.IntersectsWith(r))
return hWnd;
}
return FindWindow("Shell_TrayWnd", null);
return IntPtr.Zero;
}

public Rectangle GetTaskbarRect(IntPtr hTaskbar, string targetDevice)
Expand Down Expand Up @@ -264,7 +264,7 @@ public Rectangle GetTaskbarRect(IntPtr hTaskbar, string targetDevice)

if (!isVertical)
{
int dpi = GetTaskbarDpi();
int dpi = GetTaskbarDpi(hTaskbar);
int standardHeight = (int)Math.Round(48.0 * dpi / 96.0);

if (rectPhys.Height > (standardHeight * 0.8))
Expand Down Expand Up @@ -312,16 +312,21 @@ public static bool IsCenterAligned()
catch { return false; }
}

public static int GetTaskbarDpi()
public static int GetTaskbarDpi(IntPtr hWnd)
{
IntPtr taskbar = FindWindow("Shell_TrayWnd", null);
if (taskbar != IntPtr.Zero)
if (hWnd != IntPtr.Zero)
{
try { return (int)GetDpiForWindow(taskbar); } catch { }
try { return (int)GetDpiForWindow(hWnd); } catch { }
}
return 96;
}

public static int GetTaskbarDpi()
{
IntPtr taskbar = FindWindow("Shell_TrayWnd", null);
return GetTaskbarDpi(taskbar);
}

public static int GetWidgetsWidth()
{
int dpi = GetTaskbarDpi();
Expand Down
8 changes: 5 additions & 3 deletions src/UI/TaskbarForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ public TaskbarForm(Settings cfg, UIController ui, MainForm mainForm)
TopMost = false;
DoubleBuffered = true;

ReloadLayout();

_bizHelper.CheckTheme(true);
_bizHelper.FindHandles();

_bizHelper.AttachToTaskbar();
ReloadLayout();
_winHelper.ApplyLayeredStyle(_bizHelper.TransparentKey, _cfg.TaskbarClickThrough);

_timer.Interval = Math.Max(_cfg.RefreshMs, 60);
Expand All @@ -79,7 +78,10 @@ public void ReloadLayout()
{
_layout = new HorizontalLayout(ThemeManager.Current, 300, LayoutMode.Taskbar, _cfg);
_lastLayoutSignature = ""; // 重置签名,强制重算
_winHelper.ApplyLayeredStyle(_bizHelper.TransparentKey, _cfg.TaskbarClickThrough);
if (IsHandleCreated)
{
_winHelper.ApplyLayeredStyle(_bizHelper.TransparentKey, _cfg.TaskbarClickThrough);
}
_bizHelper.CheckTheme(true);

// 更新悬浮窗模式 (支持热切换)
Expand Down