78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Globalization;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
using System.Windows.Media;
|
|
|
|
namespace _3074
|
|
{
|
|
public partial class OverlayWindow : Window
|
|
{
|
|
internal readonly HotkeyManager _hotkey;
|
|
|
|
public OverlayWindow()
|
|
{
|
|
InitializeComponent();
|
|
DataContext = new OverlayViewModel();
|
|
_hotkey = new HotkeyManager(this);
|
|
}
|
|
|
|
protected override void OnSourceInitialized(EventArgs e)
|
|
{
|
|
base.OnSourceInitialized(e);
|
|
TsfFilter.AllFilters.ForEach(f => f.RegisterHotkey(_hotkey));
|
|
_hotkey.OnSourceInitialized();
|
|
}
|
|
|
|
protected override void OnClosed(EventArgs e)
|
|
{
|
|
_hotkey.OnClosed();
|
|
base.OnClosed(e);
|
|
}
|
|
}
|
|
|
|
public class OverlayViewModel : INotifyPropertyChanged
|
|
{
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
public string F3074 => Tsf.F3074.GetState();
|
|
public string F3074UL => Tsf.F3074UL.GetState();
|
|
public string F7500 => Tsf.F7500.GetState();
|
|
public string F27K => Tsf.F27K.GetState();
|
|
public string F30K => Tsf.F30K.GetState();
|
|
public string FFullGame => Tsf.FFullGame.GetState();
|
|
|
|
public OverlayViewModel()
|
|
{
|
|
Tsf.F3074.OnStateChanged += () => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(F3074)));
|
|
Tsf.F3074UL.OnStateChanged += () => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(F3074UL)));
|
|
Tsf.F7500.OnStateChanged += () => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(F7500)));
|
|
Tsf.F27K.OnStateChanged += () => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(F27K)));
|
|
Tsf.F30K.OnStateChanged += () => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(F30K)));
|
|
Tsf.FFullGame.OnStateChanged += () => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FFullGame)));
|
|
}
|
|
}
|
|
|
|
public class OnOrOffColorSelector : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (!(value is string str)) return Colors.Orange;
|
|
switch (str.ToLower())
|
|
{
|
|
case "on":
|
|
return Colors.GreenYellow;
|
|
case "off":
|
|
return Colors.Red;
|
|
default:
|
|
return Colors.BlueViolet;
|
|
}
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new Exception();
|
|
}
|
|
}
|
|
} |