Files
SpdUp/ViewModels/GameLibraryViewModel.cs
Phil-icyou 19ba425e79 Initial commit: SpdUp Windows Gaming Booster v1.0.0
- .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
2026-03-08 17:34:45 +01:00

73 lines
2.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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();
}
}