Skip to content

Commit 05c1466

Browse files
committed
Assign Setting to Welcome Page
1 parent 7e2a3bc commit 05c1466

File tree

9 files changed

+109
-90
lines changed

9 files changed

+109
-90
lines changed

Flow.Launcher/HotkeyControl.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void TbHotkey_OnPreviewKeyDown(object sender, KeyEventArgs e)
3131
tbMsg.Visibility = Visibility.Hidden;
3232

3333
//when alt is pressed, the real key should be e.SystemKey
34-
Key key = (e.Key == Key.System ? e.SystemKey : e.Key);
34+
Key key = e.Key == Key.System ? e.SystemKey : e.Key;
3535

3636
SpecialKeyState specialKeyState = GlobalHotkey.Instance.CheckModifiers();
3737

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private void InitializeNotifyIcon()
241241

242242
private void OpenWelcomeWindow()
243243
{
244-
Flow.Launcher.WelcomeWindow WelcomeWindow = new Flow.Launcher.WelcomeWindow();
244+
Flow.Launcher.WelcomeWindow WelcomeWindow = new WelcomeWindow(_settings);
245245
WelcomeWindow.Show();
246246
}
247247
private void ToggleGameMode()

Flow.Launcher/Resources/Pages/WelcomePage1.xaml

Lines changed: 38 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<Page
2-
x:Class="Flow.Launcher.Resources.Pages.WelcomePage1"
3-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
7-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8-
Title="WelcomePage1"
9-
mc:Ignorable="d">
1+
<Page x:Class="Flow.Launcher.Resources.Pages.WelcomePage1"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
Title="WelcomePage1"
8+
DataContext="{Binding RelativeSource={RelativeSource Self}}"
9+
mc:Ignorable="d">
1010
<Page.Resources>
1111
<Style x:Key="StyleImageFadeIn" TargetType="{x:Type Image}">
1212
<Setter Property="Opacity" Value="0" />
@@ -17,10 +17,7 @@
1717
<BeginStoryboard>
1818
<BeginStoryboard.Storyboard>
1919
<Storyboard x:Name="FadeIn">
20-
<DoubleAnimation
21-
Storyboard.TargetProperty="Opacity"
22-
To="1"
23-
Duration="0:0:2" />
20+
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:2" />
2421
</Storyboard>
2522
</BeginStoryboard.Storyboard>
2623
</BeginStoryboard>
@@ -47,50 +44,41 @@
4744
</Border.Background>
4845

4946
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
50-
<Image
51-
Name="Logo"
52-
Width="60"
53-
Height="60"
54-
Source="../../images/app.png"
55-
Style="{DynamicResource StyleImageFadeIn}" />
56-
<TextBlock
57-
Margin="12,0,0,0"
58-
VerticalAlignment="Center"
59-
FontSize="30"
60-
Foreground="White">
47+
<Image Name="Logo"
48+
Width="60"
49+
Height="60"
50+
Source="../../images/app.png"
51+
Style="{DynamicResource StyleImageFadeIn}" />
52+
<TextBlock Margin="12,0,0,0"
53+
VerticalAlignment="Center"
54+
FontSize="30"
55+
Foreground="White">
6156
Flow Launcher
6257
</TextBlock>
6358
</StackPanel>
6459
</Border>
6560

6661
<StackPanel Grid.Row="1" Margin="24,20,24,20">
6762
<StackPanel>
68-
<TextBlock
69-
FontSize="20"
70-
FontWeight="SemiBold"
71-
Text="{DynamicResource Welcome_Page1_Title}" />
72-
<TextBlock
73-
Margin="0,10,0,0"
74-
FontSize="14"
75-
Text="{DynamicResource Welcome_Page1_Text01}"
76-
TextWrapping="WrapWithOverflow" />
77-
<TextBlock
78-
Margin="0,10,0,0"
79-
FontSize="14"
80-
Text="{DynamicResource Welcome_Page1_Text02}"
81-
TextWrapping="WrapWithOverflow" />
82-
<TextBlock
83-
Margin="0,30,0,0"
84-
FontSize="14"
85-
FontWeight="SemiBold"
86-
Text="{DynamicResource language}" />
87-
<ComboBox
88-
Width="200"
89-
Margin="0,10,0,0"
90-
DisplayMemberPath="Display"
91-
ItemsSource="{Binding Languages}"
92-
SelectedValue="{Binding Language}"
93-
SelectedValuePath="LanguageCode" />
63+
<TextBlock FontSize="20" FontWeight="SemiBold" Text="{DynamicResource Welcome_Page1_Title}" />
64+
<TextBlock Margin="0,10,0,0"
65+
FontSize="14"
66+
Text="{DynamicResource Welcome_Page1_Text01}"
67+
TextWrapping="WrapWithOverflow" />
68+
<TextBlock Margin="0,10,0,0"
69+
FontSize="14"
70+
Text="{DynamicResource Welcome_Page1_Text02}"
71+
TextWrapping="WrapWithOverflow" />
72+
<TextBlock Margin="0,30,0,0"
73+
FontSize="14"
74+
FontWeight="SemiBold"
75+
Text="{DynamicResource language}" />
76+
<ComboBox Width="200"
77+
Margin="0,10,0,0"
78+
DisplayMemberPath="Display"
79+
ItemsSource="{Binding Languages}"
80+
SelectedValue="{Binding CustomLanguage, Mode=TwoWay}"
81+
SelectedValuePath="LanguageCode" />
9482
</StackPanel>
9583

9684
</StackPanel>

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
using Microsoft.Win32;
1919
using Flow.Launcher.Infrastructure;
2020
using Flow.Launcher.ViewModel;
21-
21+
using Flow.Launcher.Core.Resource;
2222

2323
namespace Flow.Launcher.Resources.Pages
2424
{
@@ -27,10 +27,31 @@ namespace Flow.Launcher.Resources.Pages
2727
/// </summary>
2828
public partial class WelcomePage1 : Page
2929
{
30-
public WelcomePage1()
31-
{
3230

31+
public WelcomePage1(Settings settings)
32+
{
33+
Settings = settings;
3334
InitializeComponent();
3435
}
36+
private Internationalization _translater => InternationalizationManager.Instance;
37+
public List<Language> Languages => _translater.LoadAvailableLanguages();
38+
39+
public Settings Settings { get; }
40+
41+
public string CustomLanguage
42+
{
43+
get
44+
{
45+
return Settings.Language;
46+
}
47+
set
48+
{
49+
InternationalizationManager.Instance.ChangeLanguage(value);
50+
51+
if (InternationalizationManager.Instance.PromptShouldUsePinyin(value))
52+
Settings.ShouldUsePinyin = true;
53+
}
54+
}
55+
3556
}
3657
}

Flow.Launcher/Resources/Pages/WelcomePage2.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
1010
xmlns:ui="http://schemas.modernwpf.com/2019"
1111
Title="WelcomePage2"
12-
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}"
1312
mc:Ignorable="d">
1413
<Page.Resources>
1514
<converters:BorderClipConverter x:Key="BorderClipConverter" />

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
using Flow.Launcher.Helper;
2+
using Flow.Launcher.Infrastructure.UserSettings;
3+
using System;
24
using System.Collections.Generic;
35
using System.Linq;
46
using System.Text;
@@ -20,9 +22,21 @@ namespace Flow.Launcher.Resources.Pages
2022
/// </summary>
2123
public partial class WelcomePage2 : Page
2224
{
23-
public WelcomePage2()
25+
private readonly Settings settings;
26+
27+
public WelcomePage2(Settings settings)
2428
{
2529
InitializeComponent();
30+
this.settings = settings;
31+
HotkeyControl.HotkeyChanged += (_, _) =>
32+
{
33+
if (HotkeyControl.CurrentHotkeyAvailable)
34+
{
35+
HotKeyMapper.SetHotkey(HotkeyControl.CurrentHotkey, HotKeyMapper.OnToggleHotkey);
36+
HotKeyMapper.RemoveHotkey(settings.Hotkey);
37+
settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
38+
}
39+
};
2640
}
2741
}
2842
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ namespace Flow.Launcher.Resources.Pages
2727
public partial class WelcomePage5 : Page
2828
{
2929
private const string StartupPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
30-
public WelcomePage5()
30+
private readonly Settings settings;
31+
32+
public WelcomePage5(Settings settings)
3133
{
3234
InitializeComponent();
35+
this.settings = settings;
3336
}
3437

3538
private void OnAutoStartupChecked(object sender, RoutedEventArgs e)
@@ -46,11 +49,13 @@ private void RemoveStartup()
4649
{
4750
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
4851
key?.DeleteValue(Constant.FlowLauncher, false);
52+
settings.StartFlowLauncherOnSystemStartup = false;
4953
}
50-
public static void SetStartup()
54+
public void SetStartup()
5155
{
5256
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
5357
key?.SetValue(Constant.FlowLauncher, Constant.ExecutablePath);
58+
settings.StartFlowLauncherOnSystemStartup = true;
5459
}
5560

5661

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ void OnHotkeyChanged(object sender, EventArgs e)
132132
{
133133
if (HotkeyControl.CurrentHotkeyAvailable)
134134
{
135-
136135
HotKeyMapper.SetHotkey(HotkeyControl.CurrentHotkey, HotKeyMapper.OnToggleHotkey);
137136
HotKeyMapper.RemoveHotkey(settings.Hotkey);
138137
settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
@@ -277,7 +276,7 @@ private void OpenSettingFolder(object sender, RoutedEventArgs e)
277276

278277
private void OpenWelcomeWindow(object sender, RoutedEventArgs e)
279278
{
280-
Flow.Launcher.WelcomeWindow WelcomeWindow = new Flow.Launcher.WelcomeWindow();
279+
Flow.Launcher.WelcomeWindow WelcomeWindow = new Flow.Launcher.WelcomeWindow(settings);
281280
WelcomeWindow.Show();
282281
}
283282
private void OpenLogFolder(object sender, RoutedEventArgs e)

Flow.Launcher/WelcomeWindow.xaml.cs

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,31 @@
1212
using System.Windows.Media.Animation;
1313
using System.Windows.Media.Imaging;
1414
using System.Windows.Shapes;
15+
using Flow.Launcher.Infrastructure.UserSettings;
16+
using Flow.Launcher.Resources.Pages;
1517
using ModernWpf.Media.Animation;
16-
using Page = ModernWpf.Controls.Page;
17-
using WelcomePages = Flow.Launcher.Resources.Pages;
1818

1919
namespace Flow.Launcher
2020
{
2121
public partial class WelcomeWindow : Window
2222
{
23-
public WelcomeWindow()
23+
private readonly List<Page> pages;
24+
private readonly Settings settings;
25+
26+
public WelcomeWindow(Settings settings)
2427
{
2528
InitializeComponent();
26-
ContentFrame.Navigate(typeof(WelcomePages.WelcomePage1));
2729
BackButton.IsEnabled = false;
30+
this.settings = settings;
31+
pages = new()
32+
{
33+
new WelcomePage1(settings),
34+
new WelcomePage2(settings),
35+
new WelcomePage3(),
36+
new WelcomePage4(),
37+
new WelcomePage5(settings),
38+
};
39+
ContentFrame.Navigate(pages[0]);
2840
}
2941
private int page;
3042
private int MaxPage = 5;
@@ -41,47 +53,28 @@ private void ButtonDisabler()
4153
BackButton.IsEnabled = true;
4254
NextButton.IsEnabled = false;
4355
}
44-
else
56+
else
4557
{
4658
BackButton.IsEnabled = true;
4759
NextButton.IsEnabled = true;
4860
}
4961
}
5062
private NavigationTransitionInfo _transitionInfo = new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight };
5163
Storyboard sb = new Storyboard();
52-
53-
private static Type PageSelector(int a)
54-
{
55-
56-
switch (a)
57-
{
58-
case 0:
59-
return typeof(WelcomePages.WelcomePage1);
60-
case 1:
61-
return typeof(WelcomePages.WelcomePage2);
62-
case 2:
63-
return typeof(WelcomePages.WelcomePage3);
64-
case 3:
65-
return typeof(WelcomePages.WelcomePage4);
66-
case 4:
67-
return typeof(WelcomePages.WelcomePage5);
68-
default:
69-
return typeof(WelcomePages.WelcomePage1);
70-
}
71-
}
7264
private void ForwardButton_Click(object sender, RoutedEventArgs e)
7365
{
7466
page = page + 1;
7567
ButtonDisabler();
76-
var pageToNavigateTo = PageSelector(page);
77-
ContentFrame.Navigate(pageToNavigateTo, null, _transitionInfo);
68+
var pageToNavigateTo = pages[page];
69+
70+
ContentFrame.Navigate(pageToNavigateTo, _transitionInfo);
7871
}
7972

8073
private void BackwardButton_Click(object sender, RoutedEventArgs e)
8174
{
8275
if (page > 0)
8376
{
84-
page = page - 1;
77+
page--;
8578
ButtonDisabler();
8679
ContentFrame.GoBack();
8780
}

0 commit comments

Comments
 (0)