@@ -36,7 +36,9 @@ static class Program {
3636 static int alreadyRead = 0 , alreadyReadCode = 1000 ;
3737 static string fanTable = "cool" , fanMode = "performance" , fanControl = "auto" , tempSensitivity = "high" , tppPower = "null" , iccMax = "null" , acLoadline = "null" , cpuPower = "null" , gpuPower = "max" , autoStart = "off" , customIcon = "original" , floatingBar = "off" , floatingBarLoc = "left" , omenKey = "default" , dataLocalize = "off" ;
3838 static volatile bool monitorFan = true ;
39+ static bool skipCheckedUpdate = false ; // action 内拦截时置 true,阻止 CreateMenuItem 覆盖勾选
3940 static bool monitorCPU = true , monitorGPU = true , isConnectedToNVIDIA = true , prevIsConnectedToNVIDIA = true , powerOnline = true , checkFloating = false , isTwoBytePL4 = false ;
41+ static bool hasAmdGpu ; // 启动时一次性检测,硬件状态不会改变
4042 static string monitorRefreshRate = "low" ; // 刷新频率:low=1s, high=0.25s
4143 static List < int > fanSpeedNow = new List < int > { 20 , 23 } ;
4244 static float respondSpeed = 0.4f ;
@@ -127,6 +129,7 @@ static void Main(string[] args) {
127129 alreadyReadCode = new Random ( int . Parse ( versionString ) ) . Next ( 1000 , 10000 ) ;
128130
129131 isTwoBytePL4 = IsTwoBytePL4Supported ( ) ;
132+ hasAmdGpu = HasAmdGpu ( ) ;
130133
131134 // Initialize tray icon
132135 platformSettings = LoadPlatformSettingsFromDll ( ) ;
@@ -231,7 +234,7 @@ private static object GetSAGHelper() {
231234 }
232235
233236 public static bool IsSupported ( ) {
234- if ( ! HasAmdGpu ( ) ) // ★ 先检查硬件,避免触发 ADL
237+ if ( ! hasAmdGpu ) // ★ 先检查硬件,避免触发 ADL
235238 return false ;
236239
237240 object helper = GetSAGHelper ( ) ;
@@ -888,7 +891,7 @@ static void InitTrayIcon() {
888891 performanceControlMenu . DropDownItems . Add ( new ToolStripSeparator ( ) ) ; // Separator between groups
889892 // 图形模式
890893 ToolStripMenuItem graphicsModeControlMenu = new ToolStripMenuItem ( "图形模式" ) ;
891- if ( HasAmdGpu ( ) ) {
894+ if ( hasAmdGpu ) {
892895 var initAmdMode = AmdGpuSwitcher . GetMode ( ) ;
893896 bool amdIsDiscrete = initAmdMode == AmdGpuSwitcher . LocalADLSmartMuxEnableState . ADL_MUXCONTROL_ENABLED ;
894897 graphicsModeControlMenu . DropDownItems . Add ( CreateMenuItem ( "独显直连" , "graphicsModeGroup" , ( s , e ) => {
@@ -908,7 +911,7 @@ static void InitTrayIcon() {
908911 }
909912 performanceControlMenu . DropDownItems . Add ( graphicsModeControlMenu ) ;
910913 graphicsModeControlMenu . DropDownOpening += ( s , e ) => {
911- if ( HasAmdGpu ( ) ) {
914+ if ( hasAmdGpu ) {
912915 var amdMode = AmdGpuSwitcher . GetMode ( ) ;
913916 bool isDisc = amdMode == AmdGpuSwitcher . LocalADLSmartMuxEnableState . ADL_MUXCONTROL_ENABLED ;
914917 UpdateCheckedState ( "graphicsModeGroup" , isDisc ? "独显直连" : "混合输出" ) ;
@@ -1143,6 +1146,7 @@ static void InitTrayIcon() {
11431146 if ( ! monitorGPU && fanControl == "auto" ) {
11441147 MessageBox . Show ( "当前为自动转速模式,若要关闭监控需切换为其他转速控制模式。" , "提示" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
11451148 UpdateCheckedState ( "monitorCPUGroup" , monitorCPU ? "开启CPU监控" : "关闭CPU监控" ) ;
1149+ skipCheckedUpdate = true ;
11461150 return ;
11471151 }
11481152 monitorCPU = false ;
@@ -1187,6 +1191,7 @@ static void InitTrayIcon() {
11871191 if ( ! monitorCPU && fanControl == "auto" ) {
11881192 MessageBox . Show ( "当前为自动转速模式,若要关闭监控需切换为其他转速控制模式。" , "提示" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
11891193 UpdateCheckedState ( "monitorGPUGroup" , monitorGPU ? "开启GPU监控" : "关闭GPU监控" ) ;
1194+ skipCheckedUpdate = true ;
11901195 return ;
11911196 }
11921197 monitorGPU = false ;
@@ -1755,7 +1760,11 @@ static ToolStripMenuItem CreateMenuItem(string text, string group, EventHandler
17551760
17561761 action ( s , e ) ; // Perform the original action
17571762 if ( group != null ) {
1758- UpdateCheckedState ( group , null , item ) ;
1763+ if ( skipCheckedUpdate ) {
1764+ skipCheckedUpdate = false ;
1765+ } else {
1766+ UpdateCheckedState ( group , null , item ) ;
1767+ }
17591768 }
17601769 } ;
17611770 return item ;
0 commit comments