diff --git a/src/HUDMerger/AboutWindow.xaml b/src/HUDMerger/AboutWindow.xaml index fd1c789..f65d0ab 100644 --- a/src/HUDMerger/AboutWindow.xaml +++ b/src/HUDMerger/AboutWindow.xaml @@ -1,19 +1,16 @@ - - - - - - - - - - - - - - - - + + + + diff --git a/src/HUDMerger/AboutWindow.xaml.cs b/src/HUDMerger/AboutWindow.xaml.cs index 6e5896d..8b29322 100644 --- a/src/HUDMerger/AboutWindow.xaml.cs +++ b/src/HUDMerger/AboutWindow.xaml.cs @@ -1,6 +1,5 @@ -using System.Diagnostics; +using System; using System.Windows; -using System.Windows.Input; namespace HUDMerger; @@ -13,14 +12,4 @@ public AboutWindow() { InitializeComponent(); } - - private void Open_Github(object sender, MouseButtonEventArgs e) - { - Process.Start("explorer", "https://github.com/cooolbros/hud-merger"); - } - - private void Open_TeamFortressTV(object sender, MouseButtonEventArgs e) - { - Process.Start("explorer", "https://www.teamfortress.tv/60220/hud-merger"); - } } diff --git a/src/HUDMerger/ViewModels/AboutWindowViewModel.cs b/src/HUDMerger/ViewModels/AboutWindowViewModel.cs new file mode 100644 index 0000000..a0cb492 --- /dev/null +++ b/src/HUDMerger/ViewModels/AboutWindowViewModel.cs @@ -0,0 +1,28 @@ +using System; +using System.Diagnostics; +using System.Windows.Input; +using Microsoft.Toolkit.Mvvm.Input; + +namespace HUDMerger.ViewModels; + +public class AboutWindowViewModel : ViewModelBase +{ + public ICommand OpenGithubCommand { get; } + public ICommand OpenTeamFortressTVCommand { get; } + + public AboutWindowViewModel() + { + OpenGithubCommand = new RelayCommand(OpenGithub); + OpenTeamFortressTVCommand = new RelayCommand(OpenTeamFortressTV); + } + + private void OpenGithub() + { + Process.Start("explorer", "https://github.com/cooolbros/hud-merger"); + } + + private void OpenTeamFortressTV() + { + Process.Start("explorer", "https://www.teamfortress.tv/60220/hud-merger"); + } +} diff --git a/src/HUDMerger/ViewModels/MainWindowViewModel.cs b/src/HUDMerger/ViewModels/MainWindowViewModel.cs index fd53745..b0cd0e6 100644 --- a/src/HUDMerger/ViewModels/MainWindowViewModel.cs +++ b/src/HUDMerger/ViewModels/MainWindowViewModel.cs @@ -85,7 +85,7 @@ public MainWindowViewModel() ShowSettingsWindowCommand = new RelayCommand(ShowSettingsWindow); QuitCommand = new RelayCommand(Application.Current.Shutdown); - ShowAboutWindowCommand = new RelayCommand(() => ShowWindow(new AboutWindow())); + ShowAboutWindowCommand = new RelayCommand(ShowAboutWindow); SourceHUDInfoViewModel = new HUDInfoViewModel("from", SourceHUD); TargetHUDInfoViewModel = new HUDInfoViewModel("to", TargetHUD); @@ -117,10 +117,17 @@ void OnClose(object? sender, EventArgs args) settingsWindow.Show(); } - private static void ShowWindow(Window window) + private void ShowAboutWindow() { - window.Owner ??= Application.Current.MainWindow; - window.Show(); + using AboutWindowViewModel aboutWindowViewModel = new(); + + AboutWindow aboutWindow = new() + { + DataContext = aboutWindowViewModel, + Owner = Application.Current.MainWindow + }; + + aboutWindow.Show(); } private void LoadSourceHUD() diff --git a/src/HUDMerger/Views/AboutWindowView.xaml b/src/HUDMerger/Views/AboutWindowView.xaml new file mode 100644 index 0000000..2d5fdeb --- /dev/null +++ b/src/HUDMerger/Views/AboutWindowView.xaml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/HUDMerger/Views/AboutWindowView.xaml.cs b/src/HUDMerger/Views/AboutWindowView.xaml.cs new file mode 100644 index 0000000..ce802d1 --- /dev/null +++ b/src/HUDMerger/Views/AboutWindowView.xaml.cs @@ -0,0 +1,15 @@ +using System; +using System.Windows.Controls; + +namespace HUDMerger.Views; + +/// +/// Interaction logic for AboutWindowView.xaml +/// +public partial class AboutWindowView : UserControl +{ + public AboutWindowView() + { + InitializeComponent(); + } +}