Files
SpdUp/ViewModels/DebugLogViewModel.cs
T
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

75 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 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));
});
}
}