From b3b174ed4b30d7bd42dfe79163f81f8a797e6edb Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Sun, 23 Jul 2023 18:17:34 +0100 Subject: [PATCH] Finalize placement of flag editor in menu --- Bloxstrap/UI/Elements/Menu/MainWindow.xaml | 4 +- .../Menu/Pages/FastFlagEditorPage.xaml | 37 ++++++++++--------- .../Menu/Pages/FastFlagEditorPage.xaml.cs | 8 ++++ .../UI/Elements/Menu/Pages/FastFlagsPage.xaml | 30 ++------------- .../Elements/Menu/Pages/FastFlagsPage.xaml.cs | 4 +- .../UI/ViewModels/Menu/FastFlagsViewModel.cs | 20 +++++++++- 6 files changed, 53 insertions(+), 50 deletions(-) diff --git a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml index 013d1ee..73260ad 100644 --- a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml +++ b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml @@ -43,9 +43,9 @@ - + + - diff --git a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml index e19a729..03cb28b 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml @@ -12,13 +12,30 @@ - + - + + + + + + + + + + + + - - - - diff --git a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs index 68e76ec..3d4c3ba 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs +++ b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs @@ -3,6 +3,8 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; +using Wpf.Ui.Mvvm.Contracts; + using Bloxstrap.UI.Elements.Dialogs; namespace Bloxstrap.UI.Elements.Menu.Pages @@ -67,6 +69,12 @@ namespace Bloxstrap.UI.Elements.Menu.Pages } } + private void BackButton_Click(object sender, RoutedEventArgs e) + { + if (Window.GetWindow(this) is INavigationWindow window) + window.Navigate(typeof(FastFlagsPage)); + } + private void AddButton_Click(object sender, RoutedEventArgs e) { var dialog = new AddFastFlagDialog(); diff --git a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml index b7c2491..e6940ef 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml @@ -15,36 +15,14 @@ - + - + - - - - - - - - - - - + + diff --git a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml.cs b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml.cs index ee3c53e..d6c8f5b 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml.cs +++ b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml.cs @@ -14,7 +14,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages public FastFlagsPage() { - DataContext = new FastFlagsViewModel(); + DataContext = new FastFlagsViewModel(this); InitializeComponent(); } @@ -28,7 +28,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages return; } - DataContext = new FastFlagsViewModel(); + DataContext = new FastFlagsViewModel(this); } private void ValidateInt32(object sender, TextCompositionEventArgs e) => e.Handled = !Int32.TryParse(e.Text, out int _); diff --git a/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs b/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs index ca32a4f..3412a30 100644 --- a/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs @@ -1,15 +1,31 @@ using System.Windows; +using System.Windows.Controls; using System.Windows.Input; +using Wpf.Ui.Mvvm.Contracts; + using CommunityToolkit.Mvvm.Input; +using Bloxstrap.UI.Elements.Menu.Pages; + namespace Bloxstrap.UI.ViewModels.Menu { public class FastFlagsViewModel : NotifyPropertyChangedViewModel { - public ICommand OpenClientSettingsCommand => new RelayCommand(OpenClientSettings); + private readonly Page _page; - private void OpenClientSettings() => Utilities.ShellExecute(Path.Combine(Directories.Modifications, "ClientSettings\\ClientAppSettings.json")); + public FastFlagsViewModel(Page page) + { + _page = page; + } + + private void OpenFastFlagEditor() + { + if (Window.GetWindow(_page) is INavigationWindow window) + window.Navigate(typeof(FastFlagEditorPage)); + } + + public ICommand OpenFastFlagEditorCommand => new RelayCommand(OpenFastFlagEditor); public Visibility ShowDebugFlags => App.Settings.Prop.OhHeyYouFoundMe ? Visibility.Visible : Visibility.Collapsed;