- .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
75 lines
2.0 KiB
C#
75 lines
2.0 KiB
C#
using System.Collections.ObjectModel;
|
||
using System.Windows.Input;
|
||
using System.Windows.Threading;
|
||
using SpdUp.Core;
|
||
|
||
namespace SpdUp.ViewModels;
|
||
|
||
/// <summary>
|
||
/// Debug Log page – live scrolling log of every action the application performs.
|
||
/// </summary>
|
||
public sealed class DebugLogViewModel : ObservableObject
|
||
{
|
||
private const int MaxLines = 2000;
|
||
private readonly Dispatcher _dispatcher;
|
||
|
||
public ObservableCollection<string> LogLines { get; } = new();
|
||
|
||
private string _filterText = string.Empty;
|
||
public string FilterText
|
||
{
|
||
get => _filterText;
|
||
set
|
||
{
|
||
if (SetProperty(ref _filterText, value))
|
||
OnPropertyChanged(nameof(FilteredLogLines));
|
||
}
|
||
}
|
||
|
||
public IEnumerable<string> FilteredLogLines =>
|
||
string.IsNullOrWhiteSpace(_filterText)
|
||
? LogLines
|
||
: LogLines.Where(l => l.Contains(_filterText, StringComparison.OrdinalIgnoreCase));
|
||
|
||
private bool _autoScroll = true;
|
||
public bool AutoScroll
|
||
{
|
||
get => _autoScroll;
|
||
set => SetProperty(ref _autoScroll, value);
|
||
}
|
||
|
||
public ICommand ClearCommand { get; }
|
||
public ICommand CopyAllCommand { get; }
|
||
|
||
public DebugLogViewModel()
|
||
{
|
||
_dispatcher = Dispatcher.CurrentDispatcher;
|
||
|
||
ClearCommand = new RelayCommand(() => { LogLines.Clear(); OnPropertyChanged(nameof(FilteredLogLines)); });
|
||
CopyAllCommand = new RelayCommand(() =>
|
||
{
|
||
try
|
||
{
|
||
var text = string.Join(Environment.NewLine, LogLines);
|
||
System.Windows.Clipboard.SetText(text);
|
||
}
|
||
catch { }
|
||
});
|
||
|
||
// Subscribe to all log events
|
||
Logger.LogWritten += OnLogWritten;
|
||
}
|
||
|
||
private void OnLogWritten(string line)
|
||
{
|
||
_dispatcher.BeginInvoke(() =>
|
||
{
|
||
LogLines.Add(line);
|
||
while (LogLines.Count > MaxLines)
|
||
LogLines.RemoveAt(0);
|
||
|
||
OnPropertyChanged(nameof(FilteredLogLines));
|
||
});
|
||
}
|
||
}
|