- .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
87 lines
3.5 KiB
C#
87 lines
3.5 KiB
C#
using System.Globalization;
|
||
using System.Windows;
|
||
using System.Windows.Data;
|
||
using System.Windows.Media;
|
||
|
||
namespace SpdUp.Converters;
|
||
|
||
/// <summary>Bool → Visibility converter.</summary>
|
||
public sealed class BoolToVisibilityConverter : IValueConverter
|
||
{
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> value is true ? Visibility.Visible : Visibility.Collapsed;
|
||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> value is Visibility.Visible;
|
||
}
|
||
|
||
/// <summary>Inverted Bool → Visibility converter.</summary>
|
||
public sealed class InverseBoolToVisibilityConverter : IValueConverter
|
||
{
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> value is true ? Visibility.Collapsed : Visibility.Visible;
|
||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> value is Visibility.Collapsed;
|
||
}
|
||
|
||
/// <summary>Float percentage (0–100) to a progress bar width or colour.</summary>
|
||
public sealed class PercentToColorConverter : IValueConverter
|
||
{
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||
{
|
||
var pct = System.Convert.ToSingle(value);
|
||
if (pct > 90) return new SolidColorBrush(Color.FromRgb(255, 69, 58)); // red
|
||
if (pct > 70) return new SolidColorBrush(Color.FromRgb(255, 159, 10)); // orange
|
||
return new SolidColorBrush(Color.FromRgb(48, 209, 88)); // green
|
||
}
|
||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> throw new NotSupportedException();
|
||
}
|
||
|
||
/// <summary>Null → Visibility (collapsed when null).</summary>
|
||
public sealed class NullToVisibilityConverter : IValueConverter
|
||
{
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> value is null ? Visibility.Collapsed : Visibility.Visible;
|
||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> throw new NotSupportedException();
|
||
}
|
||
|
||
/// <summary>Format float to one decimal.</summary>
|
||
public sealed class FloatFormatConverter : IValueConverter
|
||
{
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||
{
|
||
var fmt = parameter as string ?? "F1";
|
||
return System.Convert.ToSingle(value).ToString(fmt);
|
||
}
|
||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> throw new NotSupportedException();
|
||
}
|
||
|
||
/// <summary>Bool to boost button text.</summary>
|
||
public sealed class BoostButtonTextConverter : IValueConverter
|
||
{
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> value is true ? "⏹ STOP BOOST" : "🚀 BOOST GAME";
|
||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> throw new NotSupportedException();
|
||
}
|
||
|
||
/// <summary>Bool to brush (boost active colour).</summary>
|
||
public sealed class BoostButtonColorConverter : IValueConverter
|
||
{
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> value is true
|
||
? new SolidColorBrush(Color.FromRgb(255, 69, 58))
|
||
: new SolidColorBrush(Color.FromRgb(48, 209, 88));
|
||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||
=> throw new NotSupportedException();
|
||
}
|