mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Revise the parameter assigning process & change navigation transition
This commit is contained in:
parent
a6f1e7ff52
commit
0d6a9c763f
11 changed files with 98 additions and 74 deletions
|
|
@ -1,10 +1,11 @@
|
|||
<Page
|
||||
<ui:Page
|
||||
x:Class="Flow.Launcher.Resources.Pages.WelcomePage1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
Title="WelcomePage1"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||
mc:Ignorable="d">
|
||||
|
|
@ -148,4 +149,4 @@
|
|||
</StackPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Page>
|
||||
</ui:Page>
|
||||
|
|
|
|||
|
|
@ -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
|
|||
/// </summary>
|
||||
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<Language> Languages => _translater.LoadAvailableLanguages();
|
||||
|
||||
public Settings Settings { get; }
|
||||
public Settings Settings { get; set; }
|
||||
|
||||
public string CustomLanguage
|
||||
{
|
||||
|
|
@ -54,4 +61,4 @@ namespace Flow.Launcher.Resources.Pages
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<Page
|
||||
<ui:Page
|
||||
x:Class="Flow.Launcher.Resources.Pages.WelcomePage2"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
|
|
@ -119,4 +119,4 @@
|
|||
</StackPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Page>
|
||||
</ui:Page>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// WelcomePage2.xaml에 대한 상호 작용 논리
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
<Page
|
||||
<ui:Page
|
||||
x:Class="Flow.Launcher.Resources.Pages.WelcomePage3"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="WelcomePage3"
|
||||
mc:Ignorable="d">
|
||||
|
|
@ -303,4 +304,4 @@
|
|||
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Page>
|
||||
</ui:Page>
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
<Page
|
||||
<ui:Page
|
||||
x:Class="Flow.Launcher.Resources.Pages.WelcomePage4"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="WelcomePage4"
|
||||
d:DesignHeight="450"
|
||||
|
|
@ -132,4 +133,4 @@
|
|||
</StackPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Page>
|
||||
</ui:Page>
|
||||
|
|
|
|||
|
|
@ -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
|
|||
/// <summary>
|
||||
/// WelcomePage4.xaml에 대한 상호 작용 논리
|
||||
/// </summary>
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
<Page
|
||||
<ui:Page
|
||||
x:Class="Flow.Launcher.Resources.Pages.WelcomePage5"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure"
|
||||
Title="WelcomePage5"
|
||||
|
|
@ -118,4 +119,4 @@
|
|||
</StackPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Page>
|
||||
</ui:Page>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ namespace Flow.Launcher
|
|||
{
|
||||
public partial class WelcomeWindow : Window
|
||||
{
|
||||
private readonly List<Page> 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")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue