@@ -80,6 +80,8 @@ public partial class DellFanManagementGuiForm : Form
8080 private int _prevStartChargeIndex ;
8181 private int _prevStopChargeIndex ;
8282
83+ private Guid _activePlan ;
84+
8385 /// <summary>
8486 /// Constructor. Get everything set up before the window is displayed.
8587 /// </summary>
@@ -455,9 +457,7 @@ private void ApplyConfiguration()
455457 DCCpuFreqTextBox . Text = DCCpuFreq . ToString ( ) ;
456458 }
457459
458- // Power schemes
459460 /*
460- Guid activePlan = PowerManager.GetActivePlan();
461461 List<Guid> plans = PowerManager.ListPlans();
462462 for (int i = 0; i < plans.Count; i++)
463463 {
@@ -845,6 +845,23 @@ public void UpdateForm()
845845 }
846846 }
847847
848+ // Power schemes (Always monitoring current actived power scheme)
849+ Guid activePlan = PowerManager . GetActivePlan ( ) ;
850+ if ( activePlan != _activePlan )
851+ {
852+ _activePlan = activePlan ;
853+ activePowerPlanLabel . Text = "(当前电源计划:" + PowerManager . GetPlanName ( activePlan ) + ")" ;
854+ uint acFreqMax = PowerManager . GetPlanSetting ( activePlan , SettingSubgroup . PROCESSOR_SETTINGS_SUBGROUP , Setting . PROCFREQMAX , PowerMode . AC ) ;
855+ uint dcFreqMax = PowerManager . GetPlanSetting ( activePlan , SettingSubgroup . PROCESSOR_SETTINGS_SUBGROUP , Setting . PROCFREQMAX , PowerMode . DC ) ;
856+ uint acFreqMax1 = PowerManager . GetPlanSetting ( activePlan , SettingSubgroup . PROCESSOR_SETTINGS_SUBGROUP , Setting . PROCFREQMAX1 , PowerMode . AC ) ;
857+ uint dcFreqMax1 = PowerManager . GetPlanSetting ( activePlan , SettingSubgroup . PROCESSOR_SETTINGS_SUBGROUP , Setting . PROCFREQMAX1 , PowerMode . DC ) ;
858+
859+ ACCpuFreqTextBox . Text = acFreqMax . ToString ( ) ;
860+ ACCpuFreq1TextBox . Text = acFreqMax1 . ToString ( ) ;
861+ DCCpuFreqTextBox . Text = dcFreqMax . ToString ( ) ;
862+ DCCpuFreq1TextBox . Text = dcFreqMax1 . ToString ( ) ;
863+ }
864+
848865 _state . Release ( ) ;
849866
850867 if ( bringBackAudioDevice != null )
@@ -1279,6 +1296,7 @@ private void ApplyCpuFreqButtonClickedEventHandler(Object sender, EventArgs e)
12791296 try
12801297 {
12811298 // P-cores
1299+ /*
12821300 Process p = new Process();
12831301 p.StartInfo.FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "powercfg.exe");
12841302 p.StartInfo.Arguments = " /setDCvalueindex scheme_current SUB_PROCESSOR PROCFREQMAX1 " + (DCCpuFreq1TextBox.Text == "" ? "0" : DCCpuFreq1TextBox.Text);
@@ -1311,6 +1329,17 @@ private void ApplyCpuFreqButtonClickedEventHandler(Object sender, EventArgs e)
13111329 p.Start();
13121330 p.WaitForExit();
13131331 p.Close();
1332+ */
1333+ Guid activePlan = PowerManager . GetActivePlan ( ) ;
1334+ uint acFreq1 = ( ACCpuFreq1TextBox . Text == "" ) ? 0 : uint . Parse ( ACCpuFreq1TextBox . Text ) ;
1335+ uint dcFreq1 = ( DCCpuFreq1TextBox . Text == "" ) ? 0 : uint . Parse ( DCCpuFreq1TextBox . Text ) ;
1336+ uint acFreq = ( ACCpuFreqTextBox . Text == "" ) ? 0 : uint . Parse ( ACCpuFreqTextBox . Text ) ;
1337+ uint dcFreq = ( DCCpuFreqTextBox . Text == "" ) ? 0 : uint . Parse ( DCCpuFreqTextBox . Text ) ;
1338+ PowerManager . SetPlanSetting ( activePlan , SettingSubgroup . PROCESSOR_SETTINGS_SUBGROUP , Setting . PROCFREQMAX1 , PowerMode . AC , acFreq1 ) ;
1339+ PowerManager . SetPlanSetting ( activePlan , SettingSubgroup . PROCESSOR_SETTINGS_SUBGROUP , Setting . PROCFREQMAX1 , PowerMode . DC , dcFreq1 ) ;
1340+ PowerManager . SetPlanSetting ( activePlan , SettingSubgroup . PROCESSOR_SETTINGS_SUBGROUP , Setting . PROCFREQMAX , PowerMode . AC , acFreq ) ;
1341+ PowerManager . SetPlanSetting ( activePlan , SettingSubgroup . PROCESSOR_SETTINGS_SUBGROUP , Setting . PROCFREQMAX , PowerMode . DC , dcFreq ) ;
1342+ PowerManager . SetActivePlan ( activePlan ) ;
13141343
13151344 bool success = int . TryParse ( ACCpuFreq1TextBox . Text , out int ACCpuFreq1 ) ;
13161345 //if (success)
0 commit comments