diff --git a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml
index a7882568d..7010225f0 100644
--- a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml
+++ b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml
@@ -1,10 +1,11 @@
-
@@ -148,4 +149,4 @@
-
+
diff --git a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs
index 9cf1c53a7..e28a88c87 100644
--- a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs
+++ b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs
@@ -19,6 +19,8 @@ using Microsoft.Win32;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.ViewModel;
using Flow.Launcher.Core.Resource;
+using ModernWpf.Navigation;
+using Page = ModernWpf.Controls.Page;
namespace Flow.Launcher.Resources.Pages
{
@@ -27,16 +29,21 @@ namespace Flow.Launcher.Resources.Pages
///
public partial class WelcomePage1 : Page
{
-
- public WelcomePage1(Settings settings)
+ private bool initialize = false;
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
{
- Settings = settings;
+
+ if (e.ExtraData is Settings settings)
+ Settings = settings;
+ else
+ throw new ArgumentException("Unexpected Navigation Parameter for Settings");
InitializeComponent();
}
private Internationalization _translater => InternationalizationManager.Instance;
public List Languages => _translater.LoadAvailableLanguages();
- public Settings Settings { get; }
+ public Settings Settings { get; set; }
public string CustomLanguage
{
@@ -54,4 +61,4 @@ namespace Flow.Launcher.Resources.Pages
}
}
-}
+}
\ No newline at end of file
diff --git a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml b/Flow.Launcher/Resources/Pages/WelcomePage2.xaml
index f3202fd24..f8b30093b 100644
--- a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml
+++ b/Flow.Launcher/Resources/Pages/WelcomePage2.xaml
@@ -1,4 +1,4 @@
-
-
+
diff --git a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs
index ed606c6c7..f7ec0f270 100644
--- a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs
+++ b/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs
@@ -1,41 +1,33 @@
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure.UserSettings;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
using System.Windows.Navigation;
-using System.Windows.Shapes;
namespace Flow.Launcher.Resources.Pages
{
///
/// WelcomePage2.xaml에 대한 상호 작용 논리
///
- public partial class WelcomePage2 : Page
+ public partial class WelcomePage2
{
- private readonly Settings settings;
+ private Settings Settings { get; set; }
- public WelcomePage2(Settings settings)
+ protected override void OnNavigatedTo(NavigationEventArgs e)
{
+ if (e.ExtraData is Settings settings)
+ Settings = settings;
+ else
+ throw new ArgumentException("Unexpected Parameter setting.");
InitializeComponent();
- this.settings = settings;
- HotkeyControl.SetHotkey(new Infrastructure.Hotkey.HotkeyModel(settings.Hotkey));
+
+ HotkeyControl.SetHotkey(new Infrastructure.Hotkey.HotkeyModel(Settings.Hotkey));
HotkeyControl.HotkeyChanged += (_, _) =>
{
if (HotkeyControl.CurrentHotkeyAvailable)
{
HotKeyMapper.SetHotkey(HotkeyControl.CurrentHotkey, HotKeyMapper.OnToggleHotkey);
- HotKeyMapper.RemoveHotkey(settings.Hotkey);
- settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
+ HotKeyMapper.RemoveHotkey(Settings.Hotkey);
+ Settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
}
};
}
diff --git a/Flow.Launcher/Resources/Pages/WelcomePage3.xaml b/Flow.Launcher/Resources/Pages/WelcomePage3.xaml
index 97e431dc9..b424af3d8 100644
--- a/Flow.Launcher/Resources/Pages/WelcomePage3.xaml
+++ b/Flow.Launcher/Resources/Pages/WelcomePage3.xaml
@@ -1,9 +1,10 @@
-
@@ -303,4 +304,4 @@
-
+
diff --git a/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs
index 39c260b54..8c2b188ef 100644
--- a/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs
+++ b/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs
@@ -13,18 +13,22 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using Flow.Launcher.Infrastructure.UserSettings;
namespace Flow.Launcher.Resources.Pages
{
- public partial class WelcomePage3 : Page
+ public partial class WelcomePage3
{
- public WelcomePage3()
+ 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");
InitializeComponent();
-
}
-
+ public Settings Settings { get; set; }
}
}
diff --git a/Flow.Launcher/Resources/Pages/WelcomePage4.xaml b/Flow.Launcher/Resources/Pages/WelcomePage4.xaml
index e2062dcf2..13f003086 100644
--- a/Flow.Launcher/Resources/Pages/WelcomePage4.xaml
+++ b/Flow.Launcher/Resources/Pages/WelcomePage4.xaml
@@ -1,9 +1,10 @@
-
-
+
diff --git a/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs
index cd1a988a2..1c701b200 100644
--- a/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs
+++ b/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs
@@ -1,4 +1,5 @@
-using System;
+using Flow.Launcher.Infrastructure.UserSettings;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -18,11 +19,17 @@ namespace Flow.Launcher.Resources.Pages
///
/// WelcomePage4.xaml에 대한 상호 작용 논리
///
- public partial class WelcomePage4 : Page
+ public partial class WelcomePage4
{
- public WelcomePage4()
+ protected override void OnNavigatedTo(NavigationEventArgs e)
{
+ if (e.ExtraData is Settings settings)
+ Settings = settings;
+ else
+ throw new ArgumentException("Unexpected Navigation Parameter for Settings");
InitializeComponent();
}
+
+ public Settings Settings { get; set; }
}
}
diff --git a/Flow.Launcher/Resources/Pages/WelcomePage5.xaml b/Flow.Launcher/Resources/Pages/WelcomePage5.xaml
index 39090f81d..8bfd76478 100644
--- a/Flow.Launcher/Resources/Pages/WelcomePage5.xaml
+++ b/Flow.Launcher/Resources/Pages/WelcomePage5.xaml
@@ -1,9 +1,10 @@
-
-
+
diff --git a/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs
index 8a6a7d5c4..5d432bc16 100644
--- a/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs
+++ b/Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs
@@ -21,15 +21,19 @@ using Flow.Launcher.ViewModel;
namespace Flow.Launcher.Resources.Pages
{
- public partial class WelcomePage5 : Page
+ public partial class WelcomePage5
{
private const string StartupPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
- private readonly Settings settings;
+ public Settings Settings { get; set; }
public bool HideOnStartup { get; set; }
- public WelcomePage5(Settings settings)
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
{
+ if (e.ExtraData is Settings settings)
+ Settings = settings;
+ else
+ throw new ArgumentException("Unexpected Navigation Parameter for Settings");
InitializeComponent();
- this.settings = settings;
}
private void OnAutoStartupChecked(object sender, RoutedEventArgs e)
@@ -46,23 +50,23 @@ namespace Flow.Launcher.Resources.Pages
{
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
key?.DeleteValue(Constant.FlowLauncher, false);
- settings.StartFlowLauncherOnSystemStartup = false;
+ Settings.StartFlowLauncherOnSystemStartup = false;
}
- public void SetStartup()
+ private void SetStartup()
{
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
key?.SetValue(Constant.FlowLauncher, Constant.ExecutablePath);
- settings.StartFlowLauncherOnSystemStartup = true;
+ Settings.StartFlowLauncherOnSystemStartup = true;
}
private void OnHideOnStartupChecked(object sender, RoutedEventArgs e)
{
- settings.HideOnStartup = true;
+ Settings.HideOnStartup = true;
}
private void OnHideOnStartupUnchecked(object sender, RoutedEventArgs e)
{
- settings.HideOnStartup = false;
+ Settings.HideOnStartup = false;
}
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
diff --git a/Flow.Launcher/WelcomeWindow.xaml.cs b/Flow.Launcher/WelcomeWindow.xaml.cs
index 49406fbaa..f62f65531 100644
--- a/Flow.Launcher/WelcomeWindow.xaml.cs
+++ b/Flow.Launcher/WelcomeWindow.xaml.cs
@@ -20,7 +20,6 @@ namespace Flow.Launcher
{
public partial class WelcomeWindow : Window
{
- private readonly List pages;
private readonly Settings settings;
public WelcomeWindow(Settings settings)
@@ -28,35 +27,31 @@ namespace Flow.Launcher
InitializeComponent();
BackButton.IsEnabled = false;
this.settings = settings;
-
- pages = new()
- {
- new WelcomePage1(settings),
- new WelcomePage2(settings),
- new WelcomePage3(),
- new WelcomePage4(),
- new WelcomePage5(settings),
- };
- ContentFrame.Navigate(pages[0]);
+ ContentFrame.Navigate(PageTypeSelector(1), settings);
}
- private NavigationTransitionInfo _transitionInfo = new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight };
+ private NavigationTransitionInfo _transitionInfo = new SlideNavigationTransitionInfo()
+ {
+ Effect = SlideNavigationTransitionEffect.FromRight
+ };
+ private NavigationTransitionInfo _backTransitionInfo = new SlideNavigationTransitionInfo()
+ {
+ Effect = SlideNavigationTransitionEffect.FromLeft
+ };
Storyboard sb = new Storyboard();
- private int page;
private int pageNum = 1;
private int MaxPage = 5;
public string PageDisplay => $"{pageNum}/5";
private void UpdateView()
{
- pageNum = page + 1;
PageNavigation.Text = PageDisplay;
- if (page == 0)
+ if (pageNum == 1)
{
BackButton.IsEnabled = false;
NextButton.IsEnabled = true;
}
- else if (page == MaxPage - 1)
+ else if (pageNum == MaxPage)
{
BackButton.IsEnabled = true;
NextButton.IsEnabled = false;
@@ -70,20 +65,19 @@ namespace Flow.Launcher
private void ForwardButton_Click(object sender, RoutedEventArgs e)
{
- page = page + 1;
+ pageNum++;
UpdateView();
- var pageToNavigateTo = pages[page];
- ContentFrame.Navigate(pageToNavigateTo, _transitionInfo);
+ ContentFrame.Navigate(PageTypeSelector(pageNum), settings, _transitionInfo);
}
private void BackwardButton_Click(object sender, RoutedEventArgs e)
{
- if (page > 0)
+ if (pageNum > 1)
{
- page--;
+ pageNum--;
UpdateView();
- ContentFrame.GoBack();
+ ContentFrame.Navigate(PageTypeSelector(pageNum), settings, _backTransitionInfo);
}
else
{
@@ -95,6 +89,18 @@ namespace Flow.Launcher
{
Close();
}
- }
-}
+ private static Type PageTypeSelector(int pageNumber)
+ {
+ return pageNumber switch
+ {
+ 1 => typeof(WelcomePage1),
+ 2 => typeof(WelcomePage2),
+ 3 => typeof(WelcomePage3),
+ 4 => typeof(WelcomePage4),
+ 5 => typeof(WelcomePage5),
+ _ => throw new ArgumentOutOfRangeException(nameof(pageNumber), pageNumber, "Unexpected Page Number")
+ };
+ }
+ }
+}
\ No newline at end of file