- .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
73 lines
2.0 KiB
C#
73 lines
2.0 KiB
C#
using System.Collections.ObjectModel;
|
||
using System.Windows.Input;
|
||
using Microsoft.Win32;
|
||
using SpdUp.Core;
|
||
using SpdUp.Models;
|
||
using SpdUp.Services;
|
||
|
||
namespace SpdUp.ViewModels;
|
||
|
||
/// <summary>
|
||
/// Game Library page – manage detected and manually-added games.
|
||
/// </summary>
|
||
public sealed class GameLibraryViewModel : ObservableObject
|
||
{
|
||
private readonly AppSettings _settings;
|
||
private readonly GameDetectionService _detectionService;
|
||
|
||
public ObservableCollection<GameEntry> Games { get; }
|
||
|
||
private GameEntry? _selectedGame;
|
||
public GameEntry? SelectedGame
|
||
{
|
||
get => _selectedGame;
|
||
set => SetProperty(ref _selectedGame, value);
|
||
}
|
||
|
||
public ICommand AddGameCommand { get; }
|
||
public ICommand RemoveGameCommand { get; }
|
||
|
||
public GameLibraryViewModel(AppSettings settings, GameDetectionService detectionService)
|
||
{
|
||
_settings = settings;
|
||
_detectionService = detectionService;
|
||
Games = new ObservableCollection<GameEntry>(_settings.Games);
|
||
|
||
AddGameCommand = new RelayCommand(AddGame);
|
||
RemoveGameCommand = new RelayCommand(RemoveGame, () => SelectedGame is not null);
|
||
}
|
||
|
||
private void AddGame()
|
||
{
|
||
var dlg = new OpenFileDialog
|
||
{
|
||
Filter = "Executables (*.exe)|*.exe",
|
||
Title = "Select Game Executable"
|
||
};
|
||
|
||
if (dlg.ShowDialog() == true)
|
||
{
|
||
var entry = new GameEntry
|
||
{
|
||
Name = System.IO.Path.GetFileNameWithoutExtension(dlg.FileName),
|
||
ExecutablePath = dlg.FileName,
|
||
ProcessName = GameEntry.ProcessNameFromPath(dlg.FileName),
|
||
LauncherSource = "Manual"
|
||
};
|
||
|
||
Games.Add(entry);
|
||
_settings.Games.Add(entry);
|
||
_detectionService.AddGameProcess(entry.ProcessName);
|
||
_settings.Save();
|
||
}
|
||
}
|
||
|
||
private void RemoveGame()
|
||
{
|
||
if (SelectedGame is null) return;
|
||
_settings.Games.Remove(SelectedGame);
|
||
Games.Remove(SelectedGame);
|
||
_settings.Save();
|
||
}
|
||
}
|