Skip to content

Commit 0d6a9c7

Browse files
committed
Revise the parameter assigning process & change navigation transition
1 parent a6f1e7f commit 0d6a9c7

11 files changed

+98
-74
lines changed

Flow.Launcher/Resources/Pages/WelcomePage1.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
<Page
1+
<ui:Page
22
x:Class="Flow.Launcher.Resources.Pages.WelcomePage1"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:ui="http://schemas.modernwpf.com/2019"
89
Title="WelcomePage1"
910
DataContext="{Binding RelativeSource={RelativeSource Self}}"
1011
mc:Ignorable="d">
@@ -148,4 +149,4 @@
148149
</StackPanel>
149150
</Grid>
150151
</ScrollViewer>
151-
</Page>
152+
</ui:Page>

Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
using Flow.Launcher.Infrastructure;
2020
using Flow.Launcher.ViewModel;
2121
using Flow.Launcher.Core.Resource;
22+
using ModernWpf.Navigation;
23+
using Page = ModernWpf.Controls.Page;
2224

2325
namespace Flow.Launcher.Resources.Pages
2426
{
@@ -27,16 +29,21 @@ namespace Flow.Launcher.Resources.Pages
2729
/// </summary>
2830
public partial class WelcomePage1 : Page
2931
{
30-
31-
public WelcomePage1(Settings settings)
32+
private bool initialize = false;
33+
34+
protected override void OnNavigatedTo(NavigationEventArgs e)
3235
{
33-
Settings = settings;
36+
37+
if (e.ExtraData is Settings settings)
38+
Settings = settings;
39+
else
40+
throw new ArgumentException("Unexpected Navigation Parameter for Settings");
3441
InitializeComponent();
3542
}
3643
private Internationalization _translater => InternationalizationManager.Instance;
3744
public List<Language> Languages => _translater.LoadAvailableLanguages();
3845

39-
public Settings Settings { get; }
46+
public Settings Settings { get; set; }
4047

4148
public string CustomLanguage
4249
{
@@ -54,4 +61,4 @@ public string CustomLanguage
5461
}
5562

5663
}
57-
}
64+
}

Flow.Launcher/Resources/Pages/WelcomePage2.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Page
1+
<ui:Page
22
x:Class="Flow.Launcher.Resources.Pages.WelcomePage2"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -119,4 +119,4 @@
119119
</StackPanel>
120120
</Grid>
121121
</ScrollViewer>
122-
</Page>
122+
</ui:Page>

Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,33 @@
11
using Flow.Launcher.Helper;
22
using Flow.Launcher.Infrastructure.UserSettings;
33
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
8-
using System.Windows;
9-
using System.Windows.Controls;
10-
using System.Windows.Data;
11-
using System.Windows.Documents;
12-
using System.Windows.Input;
13-
using System.Windows.Media;
14-
using System.Windows.Media.Imaging;
154
using System.Windows.Navigation;
16-
using System.Windows.Shapes;
175

186
namespace Flow.Launcher.Resources.Pages
197
{
208
/// <summary>
219
/// WelcomePage2.xaml에 대한 상호 작용 논리
2210
/// </summary>
23-
public partial class WelcomePage2 : Page
11+
public partial class WelcomePage2
2412
{
25-
private readonly Settings settings;
13+
private Settings Settings { get; set; }
2614

27-
public WelcomePage2(Settings settings)
15+
protected override void OnNavigatedTo(NavigationEventArgs e)
2816
{
17+
if (e.ExtraData is Settings settings)
18+
Settings = settings;
19+
else
20+
throw new ArgumentException("Unexpected Parameter setting.");
2921
InitializeComponent();
30-
this.settings = settings;
31-
HotkeyControl.SetHotkey(new Infrastructure.Hotkey.HotkeyModel(settings.Hotkey));
22+
23+
HotkeyControl.SetHotkey(new Infrastructure.Hotkey.HotkeyModel(Settings.Hotkey));
3224
HotkeyControl.HotkeyChanged += (_, _) =>
3325
{
3426
if (HotkeyControl.CurrentHotkeyAvailable)
3527
{
3628
HotKeyMapper.SetHotkey(HotkeyControl.CurrentHotkey, HotKeyMapper.OnToggleHotkey);
37-
HotKeyMapper.RemoveHotkey(settings.Hotkey);
38-
settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
29+
HotKeyMapper.RemoveHotkey(Settings.Hotkey);
30+
Settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
3931
}
4032
};
4133
}

Flow.Launcher/Resources/Pages/WelcomePage3.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Page
1+
<ui:Page
22
x:Class="Flow.Launcher.Resources.Pages.WelcomePage3"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
7+
xmlns:ui="http://schemas.modernwpf.com/2019"
78
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
89
Title="WelcomePage3"
910
mc:Ignorable="d">
@@ -303,4 +304,4 @@
303304

304305
</Grid>
305306
</ScrollViewer>
306-
</Page>
307+
</ui:Page>

Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@
1313
using System.Windows.Media.Imaging;
1414
using System.Windows.Navigation;
1515
using System.Windows.Shapes;
16+
using Flow.Launcher.Infrastructure.UserSettings;
1617

1718
namespace Flow.Launcher.Resources.Pages
1819
{
1920

20-
public partial class WelcomePage3 : Page
21+
public partial class WelcomePage3
2122
{
22-
public WelcomePage3()
23+
protected override void OnNavigatedTo(NavigationEventArgs e)
2324
{
25+
if (e.ExtraData is Settings settings)
26+
Settings = settings;
27+
else if(Settings is null)
28+
throw new ArgumentException("Unexpected Navigation Parameter for Settings");
2429
InitializeComponent();
25-
2630
}
2731

28-
32+
public Settings Settings { get; set; }
2933
}
3034
}

Flow.Launcher/Resources/Pages/WelcomePage4.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Page
1+
<ui:Page
22
x:Class="Flow.Launcher.Resources.Pages.WelcomePage4"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
7+
xmlns:ui="http://schemas.modernwpf.com/2019"
78
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
89
Title="WelcomePage4"
910
d:DesignHeight="450"
@@ -132,4 +133,4 @@
132133
</StackPanel>
133134
</Grid>
134135
</ScrollViewer>
135-
</Page>
136+
</ui:Page>

Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Flow.Launcher.Infrastructure.UserSettings;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
@@ -18,11 +19,17 @@ namespace Flow.Launcher.Resources.Pages
1819
/// <summary>
1920
/// WelcomePage4.xaml에 대한 상호 작용 논리
2021
/// </summary>
21-
public partial class WelcomePage4 : Page
22+
public partial class WelcomePage4
2223
{
23-
public WelcomePage4()
24+
protected override void OnNavigatedTo(NavigationEventArgs e)
2425
{
26+
if (e.ExtraData is Settings settings)
27+
Settings = settings;
28+
else
29+
throw new ArgumentException("Unexpected Navigation Parameter for Settings");
2530
InitializeComponent();
2631
}
32+
33+
public Settings Settings { get; set; }
2734
}
2835
}

Flow.Launcher/Resources/Pages/WelcomePage5.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Page
1+
<ui:Page
22
x:Class="Flow.Launcher.Resources.Pages.WelcomePage5"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
7+
xmlns:ui="http://schemas.modernwpf.com/2019"
78
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
89
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure"
910
Title="WelcomePage5"
@@ -118,4 +119,4 @@
118119
</StackPanel>
119120
</Grid>
120121
</ScrollViewer>
121-
</Page>
122+
</ui:Page>

Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@
2121

2222
namespace Flow.Launcher.Resources.Pages
2323
{
24-
public partial class WelcomePage5 : Page
24+
public partial class WelcomePage5
2525
{
2626
private const string StartupPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
27-
private readonly Settings settings;
27+
public Settings Settings { get; set; }
2828
public bool HideOnStartup { get; set; }
29-
public WelcomePage5(Settings settings)
29+
30+
protected override void OnNavigatedTo(NavigationEventArgs e)
3031
{
32+
if (e.ExtraData is Settings settings)
33+
Settings = settings;
34+
else
35+
throw new ArgumentException("Unexpected Navigation Parameter for Settings");
3136
InitializeComponent();
32-
this.settings = settings;
3337
}
3438

3539
private void OnAutoStartupChecked(object sender, RoutedEventArgs e)
@@ -46,23 +50,23 @@ private void RemoveStartup()
4650
{
4751
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
4852
key?.DeleteValue(Constant.FlowLauncher, false);
49-
settings.StartFlowLauncherOnSystemStartup = false;
53+
Settings.StartFlowLauncherOnSystemStartup = false;
5054
}
51-
public void SetStartup()
55+
private void SetStartup()
5256
{
5357
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
5458
key?.SetValue(Constant.FlowLauncher, Constant.ExecutablePath);
55-
settings.StartFlowLauncherOnSystemStartup = true;
59+
Settings.StartFlowLauncherOnSystemStartup = true;
5660
}
5761

5862
private void OnHideOnStartupChecked(object sender, RoutedEventArgs e)
5963
{
60-
settings.HideOnStartup = true;
64+
Settings.HideOnStartup = true;
6165

6266
}
6367
private void OnHideOnStartupUnchecked(object sender, RoutedEventArgs e)
6468
{
65-
settings.HideOnStartup = false;
69+
Settings.HideOnStartup = false;
6670
}
6771

6872
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)