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
3 changes: 3 additions & 0 deletions src/Core/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public class Settings
public bool TaskbarSingleLine { get; set; } = false;// 单行显示
public bool TaskbarHoverShowAll { get; set; } = true; // [新增] 悬浮显示所有监控项
public int TaskbarManualOffset { get; set; } = 0;// 手动偏移量 (像素)

// ★★★ [新增] Win11 任务栏修正高度 ★★★
public int Win11TaskbarHeight { get; set; } = 48; // 默认 48px (96dpi)

// ====== 任务栏:高级自定义外观 ======
public bool TaskbarCustomStyle { get; set; } = false; // 总开关
Expand Down
12 changes: 10 additions & 2 deletions src/UI/Helpers/TaskbarWinHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public struct RECT { public int left, top, right, bottom; }
public class TaskbarWinHelper
{
private readonly Form _form;
private readonly Settings _cfg;
private readonly ITaskbarStrategy _strategy;

// ★★★ 性能优化缓存 ★★★
Expand All @@ -104,9 +105,10 @@ public class TaskbarWinHelper

public bool UsesInternalLayout => _strategy.HasInternalLayout;

public TaskbarWinHelper(Form form)
public TaskbarWinHelper(Form form, Settings cfg)
{
_form = form;
_cfg = cfg;
// 策略工厂模式:根据系统版本选择合适的集成策略
if (_isWin11)
{
Expand Down Expand Up @@ -181,6 +183,11 @@ public void RestoreTaskbar()
_strategy.Restore();
}

public void InvalidateCache()
{
_isCacheValid = false;
}

// =================================================================
// 句柄与信息获取 (通用逻辑)
// =================================================================
Expand Down Expand Up @@ -265,7 +272,8 @@ public Rectangle GetTaskbarRect(IntPtr hTaskbar, string targetDevice)
if (!isVertical)
{
int dpi = GetTaskbarDpi();
int standardHeight = (int)Math.Round(48.0 * dpi / 96.0);
int baseHeight = _cfg?.Win11TaskbarHeight ?? 48;
int standardHeight = (int)Math.Round((double)baseHeight * dpi / 96.0);

if (rectPhys.Height > (standardHeight * 0.8))
{
Expand Down
10 changes: 9 additions & 1 deletion src/UI/Settings/TaskbarPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ private void CreateGeneralGroup()
() => Config?.TaskbarManualOffset ?? 0,
v => { if(Config!=null) Config.TaskbarManualOffset = v; });

// [新增] Win11 高度修正
if (Environment.OSVersion.Version.Major == 10 && Environment.OSVersion.Version.Build >= 22000)
{
group.AddInt(this, "Win11 任务栏高度", "px",
() => Config?.Win11TaskbarHeight ?? 48,
v => { if(Config!=null) Config.Win11TaskbarHeight = v; });
}

group.AddHint(LanguageManager.T("Menu.TaskbarAlignTip"));
AddGroupToPage(group);
}
Expand Down Expand Up @@ -290,4 +298,4 @@ private void AddGroupToPage(LiteSettingsGroup group)
_container.Controls.SetChildIndex(wrapper, 0);
}
}
}
}
3 changes: 2 additions & 1 deletion src/UI/TaskbarForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public TaskbarForm(Settings cfg, UIController ui, MainForm mainForm)
_isWin11 = Environment.OSVersion.Version >= new Version(10, 0, 22000);

// 初始化组件
_winHelper = new TaskbarWinHelper(this);
_winHelper = new TaskbarWinHelper(this, _cfg);
_bizHelper = new TaskbarBizHelper(this, _cfg, _winHelper);

// 窗体属性
Expand Down Expand Up @@ -77,6 +77,7 @@ public TaskbarForm(Settings cfg, UIController ui, MainForm mainForm)

public void ReloadLayout()
{
_winHelper?.InvalidateCache(); // 强制清除位置缓存,确保高度设置立即生效
_layout = new HorizontalLayout(ThemeManager.Current, 300, LayoutMode.Taskbar, _cfg);
_lastLayoutSignature = ""; // 重置签名,强制重算
_winHelper.ApplyLayeredStyle(_bizHelper.TransparentKey, _cfg.TaskbarClickThrough);
Expand Down