File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -192,14 +192,18 @@ private void LoadGlobals()
192192 PowerPlanCurrentText . Text = $ "Current: { activeName } ";
193193 PowerPlanMonitorCheck . IsChecked = g . PowerPlan . Monitor ;
194194 PowerPlanAutoApplyCheck . IsChecked = g . PowerPlan . AutoApply ;
195- var availableChoices = Enum . GetValues < PowerPlanChoice > ( )
196- . Where ( c => planNames . ContainsKey ( PowerPlanMonitor . ToGuid ( c ) ) )
195+
196+ var planItems = planNames
197+ . OrderBy ( kv => kv . Value , StringComparer . OrdinalIgnoreCase )
198+ . Select ( kv => new PowerPlanItem ( kv . Key , kv . Value ) )
197199 . ToList ( ) ;
198- if ( availableChoices . Count == 0 ) availableChoices = Enum . GetValues < PowerPlanChoice > ( ) . ToList ( ) ;
199- PowerPlanCombo . ItemsSource = availableChoices ;
200- PowerPlanCombo . SelectedItem = availableChoices . Contains ( g . PowerPlan . Desired )
201- ? g . PowerPlan . Desired
202- : availableChoices [ 0 ] ;
200+ PowerPlanCombo . ItemsSource = planItems ;
201+ PowerPlanCombo . DisplayMemberPath = nameof ( PowerPlanItem . Name ) ;
202+
203+ var savedGuid = PowerPlanMonitor . ResolveDesiredGuid ( g . PowerPlan ) ;
204+ PowerPlanCombo . SelectedItem = planItems . FirstOrDefault ( p => p . Guid == savedGuid )
205+ ?? ( active is Guid a ? planItems . FirstOrDefault ( p => p . Guid == a ) : null )
206+ ?? planItems . FirstOrDefault ( ) ;
203207 }
204208
205209 private static bool ? SafeRead ( Func < bool ? > f )
You can’t perform that action at this time.
0 commit comments