diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 3f1bae090..3616e4c59 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -445,7 +445,7 @@ namespace Flow.Launcher private void OpenWelcomeWindow() { - var WelcomeWindow = new WelcomeWindow(_settings); + var WelcomeWindow = new WelcomeWindow(); WelcomeWindow.Show(); } diff --git a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs index 98fb47288..8d4312ba5 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs @@ -1,8 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Windows.Navigation; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Core.Resource; +using CommunityToolkit.Mvvm.DependencyInjection; namespace Flow.Launcher.Resources.Pages { @@ -10,10 +10,7 @@ namespace Flow.Launcher.Resources.Pages { protected override void OnNavigatedTo(NavigationEventArgs e) { - if (e.ExtraData is Settings settings) - Settings = settings; - else - throw new ArgumentException("Unexpected Navigation Parameter for Settings"); + Settings = Ioc.Default.GetRequiredService(); InitializeComponent(); } private Internationalization _translater => InternationalizationManager.Instance; @@ -37,4 +34,4 @@ namespace Flow.Launcher.Resources.Pages } } -} \ No newline at end of file +} diff --git a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs index 1ed5747cd..4a4679a4a 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs @@ -1,11 +1,11 @@ using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Infrastructure.UserSettings; -using System; using System.Windows.Navigation; using CommunityToolkit.Mvvm.Input; using Flow.Launcher.ViewModel; using System.Windows.Media; +using CommunityToolkit.Mvvm.DependencyInjection; namespace Flow.Launcher.Resources.Pages { @@ -15,11 +15,7 @@ namespace Flow.Launcher.Resources.Pages protected override void OnNavigatedTo(NavigationEventArgs e) { - if (e.ExtraData is Settings settings) - Settings = settings; - else - throw new ArgumentException("Unexpected Parameter setting."); - + Settings = Ioc.Default.GetRequiredService(); InitializeComponent(); } diff --git a/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs index 9051e7c27..38cb8642a 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs @@ -1,5 +1,5 @@ -using System; -using System.Windows.Navigation; +using System.Windows.Navigation; +using CommunityToolkit.Mvvm.DependencyInjection; using Flow.Launcher.Infrastructure.UserSettings; namespace Flow.Launcher.Resources.Pages @@ -8,10 +8,7 @@ namespace Flow.Launcher.Resources.Pages { protected override void OnNavigatedTo(NavigationEventArgs e) { - if (e.ExtraData is Settings settings) - Settings = settings; - else if(Settings is null) - throw new ArgumentException("Unexpected Navigation Parameter for Settings"); + Settings = Ioc.Default.GetRequiredService(); InitializeComponent(); } diff --git a/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs index 11bbcd6ed..fc6568935 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs @@ -1,5 +1,5 @@ -using Flow.Launcher.Infrastructure.UserSettings; -using System; +using CommunityToolkit.Mvvm.DependencyInjection; +using Flow.Launcher.Infrastructure.UserSettings; using System.Windows.Navigation; namespace Flow.Launcher.Resources.Pages @@ -8,10 +8,7 @@ namespace Flow.Launcher.Resources.Pages { protected override void OnNavigatedTo(NavigationEventArgs e) { - if (e.ExtraData is Settings settings) - Settings = settings; - else - throw new ArgumentException("Unexpected Navigation Parameter for Settings"); + Settings = Ioc.Default.GetRequiredService(); InitializeComponent(); } diff --git a/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs index abb805303..5327eb5c8 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs @@ -1,9 +1,9 @@ -using System; -using System.Windows; +using System.Windows; using System.Windows.Navigation; using Flow.Launcher.Infrastructure.UserSettings; using Microsoft.Win32; using Flow.Launcher.Infrastructure; +using CommunityToolkit.Mvvm.DependencyInjection; namespace Flow.Launcher.Resources.Pages { @@ -15,10 +15,7 @@ namespace Flow.Launcher.Resources.Pages protected override void OnNavigatedTo(NavigationEventArgs e) { - if (e.ExtraData is Settings settings) - Settings = settings; - else - throw new ArgumentException("Unexpected Navigation Parameter for Settings"); + Settings = Ioc.Default.GetRequiredService(); InitializeComponent(); } diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs index ade650284..6606b00f0 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs @@ -54,7 +54,7 @@ public partial class SettingsPaneAboutViewModel : BaseModel [RelayCommand] private void OpenWelcomeWindow() { - var window = new WelcomeWindow(_settings); + var window = new WelcomeWindow(); window.ShowDialog(); } diff --git a/Flow.Launcher/WelcomeWindow.xaml.cs b/Flow.Launcher/WelcomeWindow.xaml.cs index c3723a8c5..1d55b5741 100644 --- a/Flow.Launcher/WelcomeWindow.xaml.cs +++ b/Flow.Launcher/WelcomeWindow.xaml.cs @@ -2,7 +2,6 @@ using System.Windows; using System.Windows.Input; using System.Windows.Controls; -using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Resources.Pages; using ModernWpf.Media.Animation; @@ -10,13 +9,10 @@ namespace Flow.Launcher { public partial class WelcomeWindow : Window { - private readonly Settings settings; - - public WelcomeWindow(Settings settings) + public WelcomeWindow() { InitializeComponent(); BackButton.IsEnabled = false; - this.settings = settings; } private NavigationTransitionInfo _transitionInfo = new SlideNavigationTransitionInfo() @@ -57,7 +53,7 @@ namespace Flow.Launcher pageNum++; UpdateView(); - ContentFrame.Navigate(PageTypeSelector(pageNum), settings, _transitionInfo); + ContentFrame.Navigate(PageTypeSelector(pageNum), null, _transitionInfo); } private void BackwardButton_Click(object sender, RoutedEventArgs e) @@ -66,7 +62,7 @@ namespace Flow.Launcher { pageNum--; UpdateView(); - ContentFrame.Navigate(PageTypeSelector(pageNum), settings, _backTransitionInfo); + ContentFrame.Navigate(PageTypeSelector(pageNum), null, _backTransitionInfo); } else { @@ -109,7 +105,7 @@ namespace Flow.Launcher private void ContentFrame_Loaded(object sender, RoutedEventArgs e) { - ContentFrame.Navigate(PageTypeSelector(1), settings); /* Set First Page */ + ContentFrame.Navigate(PageTypeSelector(1)); /* Set First Page */ } } }