diff --git a/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ProcessesPage.xaml b/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ProcessesPage.xaml index cbc3ec6..f7fea01 100644 --- a/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ProcessesPage.xaml +++ b/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ProcessesPage.xaml @@ -28,7 +28,7 @@ Default Name Process ID - Uptime + State diff --git a/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ServicesPage.xaml b/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ServicesPage.xaml index a225039..e3a0e6f 100644 --- a/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ServicesPage.xaml +++ b/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ServicesPage.xaml @@ -29,6 +29,7 @@ Default Name State + Active State diff --git a/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ServicesPage.xaml.cs b/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ServicesPage.xaml.cs index c7e8d66..76d2a18 100644 --- a/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ServicesPage.xaml.cs +++ b/src/paradigm-ehb.CommandCenter.WinUI/srvMgnt/Views/ServicesPage.xaml.cs @@ -429,7 +429,7 @@ private async Task LoadAllServices(CancellationToken cancellationToken = default SolidColorBrush activeStateFill = unit.ActiveState switch { "running" => (SolidColorBrush)Application.Current.Resources["SystemFillColorSuccessBrush"], - "exited" => (SolidColorBrush)Application.Current.Resources["SystemFillColorNeutralBrush"], + "exited" => (SolidColorBrush)Application.Current.Resources["SystemFillColorCriticalBackgroundBrush"], "dead" => (SolidColorBrush)Application.Current.Resources["SystemFillColorNeutralBrush"], "failed" => (SolidColorBrush)Application.Current.Resources["SystemFillColorCriticalBackgroundBrush"], _ => new SolidColorBrush(Colors.Goldenrod) @@ -549,8 +549,41 @@ private void Order_Services() List ordered = order switch { - "Name" => services.OrderBy(s => s.Name).ThenBy(s => s.Description).ToList(), - "State" => services.OrderBy(p => p.State).ThenBy(s => s.Name).ToList(), + "Name" => services.OrderBy(s => s.Name).ThenBy(s => + { + if (!string.IsNullOrEmpty(s.State) && s.State.Contains("enabled", StringComparison.InvariantCultureIgnoreCase)) + return 0; + if (!string.IsNullOrEmpty(s.State) && s.State.Contains("disabled", StringComparison.InvariantCultureIgnoreCase)) + return 1; + return 2; + }) + .ThenBy(s => s.State) + .ThenBy(s => s.ActiveState) + .ToList(), + "State" => services.OrderBy(p => + { + if (!string.IsNullOrEmpty(p.State) && p.State.Contains("enabled", StringComparison.InvariantCultureIgnoreCase)) + return 0; + if (!string.IsNullOrEmpty(p.State) && p.State.Contains("disabled", StringComparison.InvariantCultureIgnoreCase)) + return 1; + return 2; + + }) + .ThenBy(s => s.State) + .ThenBy(s => s.Name) + .ToList(), + "ActiveState" => services.OrderBy(s => + { + if (!string.IsNullOrEmpty(s.ActiveState) && s.ActiveState.Contains("running", StringComparison.InvariantCultureIgnoreCase)) + return 0; + if (!string.IsNullOrEmpty(s.ActiveState) && s.ActiveState.Contains("sleeping", StringComparison.InvariantCultureIgnoreCase)) + return 1; + return 2; + }) + .ThenBy(s => s.ActiveState) + .ThenBy(s => s.State, StringComparer.InvariantCultureIgnoreCase) + .ThenBy(s => s.Name, StringComparer.InvariantCultureIgnoreCase) + .ToList(), _ => services .OrderBy(s => { @@ -560,16 +593,27 @@ private void Order_Services() return 1; return 2; }) + .ThenBy(s => + { + if(!string.IsNullOrEmpty(s.ActiveState) && s.ActiveState.Contains("running", StringComparison.InvariantCultureIgnoreCase)) + return 0; + if (!string.IsNullOrEmpty(s.ActiveState) && s.ActiveState.Contains("sleeping", StringComparison.InvariantCultureIgnoreCase)) + return 1; + return 2; + }) .ThenBy(s => s.State, StringComparer.InvariantCultureIgnoreCase) .ThenBy(s => s.Name, StringComparer.InvariantCultureIgnoreCase) .ToList() }; - services.Clear(); - foreach (ServiceInfo process in ordered) + DispatcherQueue.EnqueueAsync(() => { - services.Add(process); - } + services.Clear(); + foreach (ServiceInfo process in ordered) + { + services.Add(process); + } + }); } private async Task ShowInfoBarAsync(string title, string message, InfoBarSeverity severity)