3074/OverlayWindow.xaml.cs

53 lines
1.7 KiB
C#

using System;
using System.ComponentModel;
using System.Windows;
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)));
}
}
}