- .NET 8 WPF app with full MVVM architecture - One-click boost: CPU, RAM, GPU, network, services, timer resolution - Real-time system monitor (LibreHardwareMonitor) - Auto game detection (30+ games) - RAM optimizer with kernel-level cleanup - Network optimizer (TCP registry tweaks) - Service manager, process manager, shader cache cleaner - Desktop widget overlay - Debug log viewer - Custom dark gaming theme with trans pride colors - 84 unit tests (xUnit) - Inno Setup installer script - Landing page website
68 lines
1.9 KiB
C#
68 lines
1.9 KiB
C#
using System.Collections.ObjectModel;
|
|
using System.ServiceProcess;
|
|
using System.Windows.Input;
|
|
using SpdUp.Core;
|
|
using SpdUp.Models;
|
|
using SpdUp.Services;
|
|
|
|
namespace SpdUp.ViewModels;
|
|
|
|
/// <summary>
|
|
/// Service Manager ViewModel.
|
|
/// </summary>
|
|
public sealed class ServiceManagerViewModel : ObservableObject
|
|
{
|
|
private readonly AppSettings _settings;
|
|
|
|
public ObservableCollection<ServiceEntry> Services { get; } = new();
|
|
|
|
private ServiceEntry? _selectedService;
|
|
public ServiceEntry? SelectedService
|
|
{
|
|
get => _selectedService;
|
|
set => SetProperty(ref _selectedService, value);
|
|
}
|
|
|
|
public ICommand RefreshCommand { get; }
|
|
public ICommand StopServiceCommand { get; }
|
|
public ICommand StartServiceCommand { get; }
|
|
|
|
public ServiceManagerViewModel(AppSettings settings)
|
|
{
|
|
_settings = settings;
|
|
|
|
RefreshCommand = new RelayCommand(Refresh);
|
|
StopServiceCommand = new RelayCommand(StopSelected, () => SelectedService is not null);
|
|
StartServiceCommand = new RelayCommand(StartSelected, () => SelectedService is not null);
|
|
|
|
Refresh();
|
|
}
|
|
|
|
private void Refresh()
|
|
{
|
|
Services.Clear();
|
|
|
|
// Show the configured services plus all known non-critical ones
|
|
var names = new HashSet<string>(_settings.ServicesToStop, StringComparer.OrdinalIgnoreCase);
|
|
foreach (var k in ServiceManagementService.KnownNonCriticalServices.Keys)
|
|
names.Add(k);
|
|
|
|
foreach (var entry in ServiceManagementService.GetServiceList(names))
|
|
Services.Add(entry);
|
|
}
|
|
|
|
private void StopSelected()
|
|
{
|
|
if (SelectedService is null) return;
|
|
ServiceManagementService.StopService(SelectedService.ServiceName);
|
|
Refresh();
|
|
}
|
|
|
|
private void StartSelected()
|
|
{
|
|
if (SelectedService is null) return;
|
|
ServiceManagementService.StartService(SelectedService.ServiceName);
|
|
Refresh();
|
|
}
|
|
}
|