Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ComboBoxItem Tag="Default" IsSelected="True">Default</ComboBoxItem>
<ComboBoxItem Tag="Name">Name</ComboBoxItem>
<ComboBoxItem Tag="Pid">Process ID</ComboBoxItem>
<ComboBoxItem Tag="Uptime">Uptime</ComboBoxItem>
<!-- <ComboBoxItem Tag="Uptime">Uptime</ComboBoxItem> -->
<ComboBoxItem Tag="State">State</ComboBoxItem>
</ComboBox>
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<ComboBoxItem Tag="Default" IsSelected="True">Default</ComboBoxItem>
<ComboBoxItem Tag="Name">Name</ComboBoxItem>
<ComboBoxItem Tag="State">State</ComboBoxItem>
<ComboBoxItem Tag="ActiveState">Active State</ComboBoxItem>
</ComboBox>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="8" Grid.Row="0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -549,8 +549,41 @@ private void Order_Services()

List<ServiceInfo> 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 =>
{
Expand All @@ -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)
Expand Down
Loading