mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #3310 from Jack251970/welcome_backspace_issue
Fix Welcome Backspace Issue & Fix Hotkey Control Settings Null Exception
This commit is contained in:
commit
9b2816192e
16 changed files with 287 additions and 140 deletions
|
|
@ -64,6 +64,7 @@ namespace Flow.Launcher
|
|||
.AddSingleton<IPublicAPI, PublicAPIInstance>()
|
||||
.AddSingleton<MainViewModel>()
|
||||
.AddSingleton<Theme>()
|
||||
.AddSingleton<WelcomeViewModel>()
|
||||
).Build();
|
||||
Ioc.Default.ConfigureServices(host.Services);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@
|
|||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalContentAlignment="Left"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
DefaultHotkey="" />
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
|
|
|
|||
|
|
@ -4,25 +4,16 @@ using System.Collections.ObjectModel;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Helper;
|
||||
using Flow.Launcher.Infrastructure.Hotkey;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
|
||||
namespace Flow.Launcher
|
||||
{
|
||||
public partial class HotkeyControl
|
||||
{
|
||||
public IHotkeySettings HotkeySettings {
|
||||
get { return (IHotkeySettings)GetValue(HotkeySettingsProperty); }
|
||||
set { SetValue(HotkeySettingsProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HotkeySettingsProperty = DependencyProperty.Register(
|
||||
nameof(HotkeySettings),
|
||||
typeof(IHotkeySettings),
|
||||
typeof(HotkeyControl),
|
||||
new PropertyMetadata()
|
||||
);
|
||||
public string WindowTitle {
|
||||
get { return (string)GetValue(WindowTitleProperty); }
|
||||
set { SetValue(WindowTitleProperty, value); }
|
||||
|
|
@ -71,8 +62,7 @@ namespace Flow.Launcher
|
|||
return;
|
||||
}
|
||||
|
||||
hotkeyControl.SetKeysToDisplay(new HotkeyModel(hotkeyControl.Hotkey));
|
||||
hotkeyControl.CurrentHotkey = new HotkeyModel(hotkeyControl.Hotkey);
|
||||
hotkeyControl.RefreshHotkeyInterface(hotkeyControl.Hotkey);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -90,17 +80,117 @@ namespace Flow.Launcher
|
|||
}
|
||||
|
||||
|
||||
public static readonly DependencyProperty HotkeyProperty = DependencyProperty.Register(
|
||||
nameof(Hotkey),
|
||||
typeof(string),
|
||||
public static readonly DependencyProperty TypeProperty = DependencyProperty.Register(
|
||||
nameof(Type),
|
||||
typeof(HotkeyType),
|
||||
typeof(HotkeyControl),
|
||||
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnHotkeyChanged)
|
||||
new FrameworkPropertyMetadata(HotkeyType.Hotkey, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnHotkeyChanged)
|
||||
);
|
||||
|
||||
public HotkeyType Type
|
||||
{
|
||||
get { return (HotkeyType)GetValue(TypeProperty); }
|
||||
set { SetValue(TypeProperty, value); }
|
||||
}
|
||||
|
||||
public enum HotkeyType
|
||||
{
|
||||
Hotkey,
|
||||
PreviewHotkey,
|
||||
OpenContextMenuHotkey,
|
||||
SettingWindowHotkey,
|
||||
CycleHistoryUpHotkey,
|
||||
CycleHistoryDownHotkey,
|
||||
SelectPrevPageHotkey,
|
||||
SelectNextPageHotkey,
|
||||
AutoCompleteHotkey,
|
||||
AutoCompleteHotkey2,
|
||||
SelectPrevItemHotkey,
|
||||
SelectPrevItemHotkey2,
|
||||
SelectNextItemHotkey,
|
||||
SelectNextItemHotkey2
|
||||
}
|
||||
|
||||
// We can initialize settings in static field because it has been constructed in App constuctor
|
||||
// and it will not construct settings instances twice
|
||||
private static readonly Settings _settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
|
||||
public string Hotkey
|
||||
{
|
||||
get { return (string)GetValue(HotkeyProperty); }
|
||||
set { SetValue(HotkeyProperty, value); }
|
||||
get
|
||||
{
|
||||
return Type switch
|
||||
{
|
||||
HotkeyType.Hotkey => _settings.Hotkey,
|
||||
HotkeyType.PreviewHotkey => _settings.PreviewHotkey,
|
||||
HotkeyType.OpenContextMenuHotkey => _settings.OpenContextMenuHotkey,
|
||||
HotkeyType.SettingWindowHotkey => _settings.SettingWindowHotkey,
|
||||
HotkeyType.CycleHistoryUpHotkey => _settings.CycleHistoryUpHotkey,
|
||||
HotkeyType.CycleHistoryDownHotkey => _settings.CycleHistoryDownHotkey,
|
||||
HotkeyType.SelectPrevPageHotkey => _settings.SelectPrevPageHotkey,
|
||||
HotkeyType.SelectNextPageHotkey => _settings.SelectNextPageHotkey,
|
||||
HotkeyType.AutoCompleteHotkey => _settings.AutoCompleteHotkey,
|
||||
HotkeyType.AutoCompleteHotkey2 => _settings.AutoCompleteHotkey2,
|
||||
HotkeyType.SelectPrevItemHotkey => _settings.SelectPrevItemHotkey,
|
||||
HotkeyType.SelectPrevItemHotkey2 => _settings.SelectPrevItemHotkey2,
|
||||
HotkeyType.SelectNextItemHotkey => _settings.SelectNextItemHotkey,
|
||||
HotkeyType.SelectNextItemHotkey2 => _settings.SelectNextItemHotkey2,
|
||||
_ => string.Empty
|
||||
};
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case HotkeyType.Hotkey:
|
||||
_settings.Hotkey = value;
|
||||
break;
|
||||
case HotkeyType.PreviewHotkey:
|
||||
_settings.PreviewHotkey = value;
|
||||
break;
|
||||
case HotkeyType.OpenContextMenuHotkey:
|
||||
_settings.OpenContextMenuHotkey = value;
|
||||
break;
|
||||
case HotkeyType.SettingWindowHotkey:
|
||||
_settings.SettingWindowHotkey = value;
|
||||
break;
|
||||
case HotkeyType.CycleHistoryUpHotkey:
|
||||
_settings.CycleHistoryUpHotkey = value;
|
||||
break;
|
||||
case HotkeyType.CycleHistoryDownHotkey:
|
||||
_settings.CycleHistoryDownHotkey = value;
|
||||
break;
|
||||
case HotkeyType.SelectPrevPageHotkey:
|
||||
_settings.SelectPrevPageHotkey = value;
|
||||
break;
|
||||
case HotkeyType.SelectNextPageHotkey:
|
||||
_settings.SelectNextPageHotkey = value;
|
||||
break;
|
||||
case HotkeyType.AutoCompleteHotkey:
|
||||
_settings.AutoCompleteHotkey = value;
|
||||
break;
|
||||
case HotkeyType.AutoCompleteHotkey2:
|
||||
_settings.AutoCompleteHotkey2 = value;
|
||||
break;
|
||||
case HotkeyType.SelectPrevItemHotkey:
|
||||
_settings.SelectPrevItemHotkey = value;
|
||||
break;
|
||||
case HotkeyType.SelectNextItemHotkey:
|
||||
_settings.SelectNextItemHotkey = value;
|
||||
break;
|
||||
case HotkeyType.SelectPrevItemHotkey2:
|
||||
_settings.SelectPrevItemHotkey2 = value;
|
||||
break;
|
||||
case HotkeyType.SelectNextItemHotkey2:
|
||||
_settings.SelectNextItemHotkey2 = value;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// After setting the hotkey, we need to refresh the interface
|
||||
RefreshHotkeyInterface(Hotkey);
|
||||
}
|
||||
}
|
||||
|
||||
public HotkeyControl()
|
||||
|
|
@ -108,7 +198,14 @@ namespace Flow.Launcher
|
|||
InitializeComponent();
|
||||
|
||||
HotkeyList.ItemsSource = KeysToDisplay;
|
||||
SetKeysToDisplay(CurrentHotkey);
|
||||
|
||||
RefreshHotkeyInterface(Hotkey);
|
||||
}
|
||||
|
||||
private void RefreshHotkeyInterface(string hotkey)
|
||||
{
|
||||
SetKeysToDisplay(new HotkeyModel(Hotkey));
|
||||
CurrentHotkey = new HotkeyModel(Hotkey);
|
||||
}
|
||||
|
||||
private static bool CheckHotkeyAvailability(HotkeyModel hotkey, bool validateKeyGesture) =>
|
||||
|
|
@ -133,7 +230,7 @@ namespace Flow.Launcher
|
|||
HotKeyMapper.RemoveHotkey(Hotkey);
|
||||
}
|
||||
|
||||
var dialog = new HotkeyControlDialog(Hotkey, DefaultHotkey, HotkeySettings, WindowTitle);
|
||||
var dialog = new HotkeyControlDialog(Hotkey, DefaultHotkey, WindowTitle);
|
||||
await dialog.ShowAsync();
|
||||
switch (dialog.ResultType)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@ using System.Linq;
|
|||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using ChefKeys;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Helper;
|
||||
using Flow.Launcher.Infrastructure.Hotkey;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Plugin;
|
||||
using ModernWpf.Controls;
|
||||
|
||||
|
|
@ -16,7 +18,7 @@ namespace Flow.Launcher;
|
|||
|
||||
public partial class HotkeyControlDialog : ContentDialog
|
||||
{
|
||||
private IHotkeySettings _hotkeySettings;
|
||||
private static readonly IHotkeySettings _hotkeySettings = Ioc.Default.GetRequiredService<Settings>();
|
||||
private Action? _overwriteOtherHotkey;
|
||||
private string DefaultHotkey { get; }
|
||||
public string WindowTitle { get; }
|
||||
|
|
@ -36,7 +38,7 @@ public partial class HotkeyControlDialog : ContentDialog
|
|||
|
||||
private static bool isOpenFlowHotkey;
|
||||
|
||||
public HotkeyControlDialog(string hotkey, string defaultHotkey, IHotkeySettings hotkeySettings, string windowTitle = "")
|
||||
public HotkeyControlDialog(string hotkey, string defaultHotkey, string windowTitle = "")
|
||||
{
|
||||
WindowTitle = windowTitle switch
|
||||
{
|
||||
|
|
@ -45,7 +47,6 @@ public partial class HotkeyControlDialog : ContentDialog
|
|||
};
|
||||
DefaultHotkey = defaultHotkey;
|
||||
CurrentHotkey = new HotkeyModel(hotkey);
|
||||
_hotkeySettings = hotkeySettings;
|
||||
SetKeysToDisplay(CurrentHotkey);
|
||||
|
||||
InitializeComponent();
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ namespace Flow.Launcher
|
|||
|
||||
private void OpenWelcomeWindow()
|
||||
{
|
||||
var WelcomeWindow = new WelcomeWindow(_settings);
|
||||
var WelcomeWindow = new WelcomeWindow();
|
||||
WelcomeWindow.Show();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
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;
|
||||
using Flow.Launcher.ViewModel;
|
||||
|
||||
namespace Flow.Launcher.Resources.Pages
|
||||
{
|
||||
|
|
@ -10,10 +11,10 @@ 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<Settings>();
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
Ioc.Default.GetRequiredService<WelcomeViewModel>().PageNum = 1;
|
||||
InitializeComponent();
|
||||
}
|
||||
private Internationalization _translater => InternationalizationManager.Instance;
|
||||
|
|
@ -37,4 +38,4 @@ namespace Flow.Launcher.Resources.Pages
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,8 +114,7 @@
|
|||
Margin="0,8,0,0"
|
||||
ChangeHotkey="{Binding SetTogglingHotkeyCommand}"
|
||||
DefaultHotkey="Alt+Space"
|
||||
Hotkey="{Binding Settings.Hotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="Hotkey"
|
||||
ValidateKeyGesture="True"
|
||||
WindowTitle="{DynamicResource flowlauncherHotkey}" />
|
||||
</StackPanel>
|
||||
|
|
|
|||
|
|
@ -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,10 @@ 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<Settings>();
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
Ioc.Default.GetRequiredService<WelcomeViewModel>().PageNum = 2;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Navigation;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.ViewModel;
|
||||
|
||||
namespace Flow.Launcher.Resources.Pages
|
||||
{
|
||||
|
|
@ -8,10 +9,10 @@ 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<Settings>();
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
Ioc.Default.GetRequiredService<WelcomeViewModel>().PageNum = 3;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using System;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.ViewModel;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Flow.Launcher.Resources.Pages
|
||||
|
|
@ -8,10 +9,10 @@ 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<Settings>();
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
Ioc.Default.GetRequiredService<WelcomeViewModel>().PageNum = 4;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
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;
|
||||
using Flow.Launcher.ViewModel;
|
||||
|
||||
namespace Flow.Launcher.Resources.Pages
|
||||
{
|
||||
|
|
@ -15,10 +16,10 @@ 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<Settings>();
|
||||
// Sometimes the navigation is not triggered by button click,
|
||||
// so we need to reset the page number
|
||||
Ioc.Default.GetRequiredService<WelcomeViewModel>().PageNum = 5;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ public partial class SettingsPaneAboutViewModel : BaseModel
|
|||
[RelayCommand]
|
||||
private void OpenWelcomeWindow()
|
||||
{
|
||||
var window = new WelcomeWindow(_settings);
|
||||
var window = new WelcomeWindow();
|
||||
window.ShowDialog();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@
|
|||
<flowlauncher:HotkeyControl
|
||||
ChangeHotkey="{Binding SetTogglingHotkeyCommand}"
|
||||
DefaultHotkey="Alt+Space"
|
||||
Hotkey="{Binding Settings.Hotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="Hotkey"
|
||||
ValidateKeyGesture="True"
|
||||
WindowTitle="{DynamicResource flowlauncherHotkey}" />
|
||||
</cc:Card>
|
||||
|
|
@ -46,8 +45,7 @@
|
|||
Sub="{DynamicResource previewHotkeyToolTip}">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey="F1"
|
||||
Hotkey="{Binding Settings.PreviewHotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="PreviewHotkey"
|
||||
ValidateKeyGesture="False"
|
||||
WindowTitle="{DynamicResource previewHotkey}" />
|
||||
</cc:Card>
|
||||
|
|
@ -105,8 +103,7 @@
|
|||
Type="Inside">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey="Ctrl+I"
|
||||
Hotkey="{Binding Settings.OpenContextMenuHotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="OpenContextMenuHotkey"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:Card>
|
||||
<cc:Card
|
||||
|
|
@ -127,8 +124,7 @@
|
|||
Type="Inside">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey="Ctrl+I"
|
||||
Hotkey="{Binding Settings.SettingWindowHotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="SettingWindowHotkey"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:Card>
|
||||
<cc:Card
|
||||
|
|
@ -149,8 +145,7 @@
|
|||
Type="Inside">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey="Alt+Up"
|
||||
Hotkey="{Binding Settings.CycleHistoryUpHotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="CycleHistoryUpHotkey"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:Card>
|
||||
<cc:Card
|
||||
|
|
@ -159,8 +154,7 @@
|
|||
Type="Inside">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey="Alt+Down"
|
||||
Hotkey="{Binding Settings.CycleHistoryDownHotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="CycleHistoryDownHotkey"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:Card>
|
||||
<cc:Card
|
||||
|
|
@ -176,8 +170,7 @@
|
|||
Type="Inside">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey=""
|
||||
Hotkey="{Binding Settings.SelectPrevPageHotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="SelectPrevPageHotkey"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:Card>
|
||||
<cc:Card
|
||||
|
|
@ -186,8 +179,7 @@
|
|||
Type="Inside">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey=""
|
||||
Hotkey="{Binding Settings.SelectNextPageHotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="SelectNextPageHotkey"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:Card>
|
||||
|
||||
|
|
@ -221,8 +213,7 @@
|
|||
<cc:ExCard.SideContent>
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey="Ctrl+Tab"
|
||||
Hotkey="{Binding Settings.AutoCompleteHotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="AutoCompleteHotkey"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:ExCard.SideContent>
|
||||
<cc:Card
|
||||
|
|
@ -231,8 +222,7 @@
|
|||
Type="InsideFit">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey=""
|
||||
Hotkey="{Binding Settings.AutoCompleteHotkey2}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="AutoCompleteHotkey2"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:Card>
|
||||
</cc:ExCard>
|
||||
|
|
@ -244,8 +234,7 @@
|
|||
<cc:ExCard.SideContent>
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey="Shift+Tab"
|
||||
Hotkey="{Binding Settings.SelectPrevItemHotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="SelectPrevItemHotkey"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:ExCard.SideContent>
|
||||
<cc:Card
|
||||
|
|
@ -254,8 +243,7 @@
|
|||
Type="InsideFit">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey=""
|
||||
Hotkey="{Binding Settings.SelectPrevItemHotkey2}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="SelectPrevItemHotkey2"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:Card>
|
||||
</cc:ExCard>
|
||||
|
|
@ -267,8 +255,7 @@
|
|||
<cc:ExCard.SideContent>
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey="Tab"
|
||||
Hotkey="{Binding Settings.SelectNextItemHotkey}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="SelectNextItemHotkey"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:ExCard.SideContent>
|
||||
<cc:Card
|
||||
|
|
@ -277,8 +264,7 @@
|
|||
Type="InsideFit">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey=""
|
||||
Hotkey="{Binding Settings.SelectNextItemHotkey2}"
|
||||
HotkeySettings="{Binding Settings}"
|
||||
Type="SelectNextItemHotkey2"
|
||||
ValidateKeyGesture="False" />
|
||||
</cc:Card>
|
||||
</cc:ExCard>
|
||||
|
|
|
|||
68
Flow.Launcher/ViewModel/WelcomeViewModel.cs
Normal file
68
Flow.Launcher/ViewModel/WelcomeViewModel.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
using Flow.Launcher.Plugin;
|
||||
|
||||
namespace Flow.Launcher.ViewModel
|
||||
{
|
||||
public partial class WelcomeViewModel : BaseModel
|
||||
{
|
||||
public const int MaxPageNum = 5;
|
||||
|
||||
public string PageDisplay => $"{PageNum}/5";
|
||||
|
||||
private int _pageNum = 1;
|
||||
public int PageNum
|
||||
{
|
||||
get => _pageNum;
|
||||
set
|
||||
{
|
||||
if (_pageNum != value)
|
||||
{
|
||||
_pageNum = value;
|
||||
OnPropertyChanged();
|
||||
UpdateView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _backEnabled = false;
|
||||
public bool BackEnabled
|
||||
{
|
||||
get => _backEnabled;
|
||||
set
|
||||
{
|
||||
_backEnabled = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private bool _nextEnabled = true;
|
||||
public bool NextEnabled
|
||||
{
|
||||
get => _nextEnabled;
|
||||
set
|
||||
{
|
||||
_nextEnabled = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateView()
|
||||
{
|
||||
OnPropertyChanged(nameof(PageDisplay));
|
||||
if (PageNum == 1)
|
||||
{
|
||||
BackEnabled = false;
|
||||
NextEnabled = true;
|
||||
}
|
||||
else if (PageNum == MaxPageNum)
|
||||
{
|
||||
BackEnabled = true;
|
||||
NextEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
BackEnabled = true;
|
||||
NextEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
xmlns:local="clr-namespace:Flow.Launcher"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
|
||||
Name="FlowWelcomeWindow"
|
||||
Title="{DynamicResource Welcome_Page1_Title}"
|
||||
Width="550"
|
||||
|
|
@ -14,8 +15,10 @@
|
|||
MinHeight="650"
|
||||
MaxWidth="550"
|
||||
MaxHeight="650"
|
||||
d:DataContext="{d:DesignInstance Type=vm:WelcomeViewModel}"
|
||||
Activated="OnActivated"
|
||||
Background="{DynamicResource Color00B}"
|
||||
Closed="Window_Closed"
|
||||
Foreground="{DynamicResource PopupTextColor}"
|
||||
MouseDown="window_MouseDown"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
|
|
@ -41,12 +44,12 @@
|
|||
Grid.Column="0"
|
||||
Width="16"
|
||||
Height="16"
|
||||
Margin="10,4,4,4"
|
||||
Margin="10 4 4 4"
|
||||
RenderOptions.BitmapScalingMode="HighQuality"
|
||||
Source="/Images/app.png" />
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Margin="4,0,0,0"
|
||||
Margin="4 0 0 0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource Color05B}"
|
||||
|
|
@ -95,7 +98,7 @@
|
|||
Grid.Row="1"
|
||||
Background="{DynamicResource Color00B}"
|
||||
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
|
||||
BorderThickness="0,1,0,0">
|
||||
BorderThickness="0 1 0 0">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="130" />
|
||||
|
|
@ -109,11 +112,11 @@
|
|||
VerticalAlignment="Center">
|
||||
<TextBlock
|
||||
Name="PageNavigation"
|
||||
Margin="0,2,0,0"
|
||||
Margin="0 2 0 0"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="{Binding PageDisplay, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
||||
Text="{Binding PageDisplay, Mode=OneWay}"
|
||||
TextAlignment="Center" />
|
||||
</StackPanel>
|
||||
|
||||
|
|
@ -122,25 +125,26 @@
|
|||
Grid.Column="0"
|
||||
Width="100"
|
||||
Height="40"
|
||||
Margin="20,5,0,5"
|
||||
Margin="20 5 0 5"
|
||||
Click="BtnCancel_OnClick"
|
||||
Content="{DynamicResource Skip}"
|
||||
DockPanel.Dock="Right"
|
||||
FontSize="14" />
|
||||
<DockPanel
|
||||
Grid.Column="2"
|
||||
Margin="0,0,20,0"
|
||||
Margin="0 0 20 0"
|
||||
VerticalAlignment="Stretch">
|
||||
<Button
|
||||
x:Name="NextButton"
|
||||
Width="40"
|
||||
Height="40"
|
||||
Margin="8,5,0,5"
|
||||
Margin="8 5 0 5"
|
||||
Click="ForwardButton_Click"
|
||||
Content=""
|
||||
DockPanel.Dock="Right"
|
||||
FontFamily="/Resources/#Segoe Fluent Icons"
|
||||
FontSize="18" />
|
||||
FontSize="18"
|
||||
IsEnabled="{Binding NextEnabled, Mode=OneWay}" />
|
||||
<Button
|
||||
x:Name="BackButton"
|
||||
Width="40"
|
||||
|
|
@ -149,7 +153,8 @@
|
|||
Content=""
|
||||
DockPanel.Dock="Right"
|
||||
FontFamily="/Resources/#Segoe Fluent Icons"
|
||||
FontSize="18" />
|
||||
FontSize="18"
|
||||
IsEnabled="{Binding BackEnabled, Mode=OneWay}" />
|
||||
<StackPanel />
|
||||
</DockPanel>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,75 +2,57 @@
|
|||
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;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.ViewModel;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
|
||||
namespace Flow.Launcher
|
||||
{
|
||||
public partial class WelcomeWindow : Window
|
||||
{
|
||||
private readonly Settings settings;
|
||||
private readonly WelcomeViewModel _viewModel;
|
||||
|
||||
public WelcomeWindow(Settings settings)
|
||||
{
|
||||
InitializeComponent();
|
||||
BackButton.IsEnabled = false;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
private NavigationTransitionInfo _transitionInfo = new SlideNavigationTransitionInfo()
|
||||
private readonly NavigationTransitionInfo _forwardTransitionInfo = new SlideNavigationTransitionInfo()
|
||||
{
|
||||
Effect = SlideNavigationTransitionEffect.FromRight
|
||||
};
|
||||
private NavigationTransitionInfo _backTransitionInfo = new SlideNavigationTransitionInfo()
|
||||
private readonly NavigationTransitionInfo _backTransitionInfo = new SlideNavigationTransitionInfo()
|
||||
{
|
||||
Effect = SlideNavigationTransitionEffect.FromLeft
|
||||
};
|
||||
|
||||
private int pageNum = 1;
|
||||
private int MaxPage = 5;
|
||||
public string PageDisplay => $"{pageNum}/5";
|
||||
|
||||
private void UpdateView()
|
||||
public WelcomeWindow()
|
||||
{
|
||||
PageNavigation.Text = PageDisplay;
|
||||
if (pageNum == 1)
|
||||
{
|
||||
BackButton.IsEnabled = false;
|
||||
NextButton.IsEnabled = true;
|
||||
}
|
||||
else if (pageNum == MaxPage)
|
||||
{
|
||||
BackButton.IsEnabled = true;
|
||||
NextButton.IsEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
BackButton.IsEnabled = true;
|
||||
NextButton.IsEnabled = true;
|
||||
}
|
||||
_viewModel = Ioc.Default.GetRequiredService<WelcomeViewModel>();
|
||||
DataContext = _viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ForwardButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
pageNum++;
|
||||
UpdateView();
|
||||
|
||||
ContentFrame.Navigate(PageTypeSelector(pageNum), settings, _transitionInfo);
|
||||
if (_viewModel.PageNum < WelcomeViewModel.MaxPageNum)
|
||||
{
|
||||
_viewModel.PageNum++;
|
||||
ContentFrame.Navigate(PageTypeSelector(_viewModel.PageNum), null, _forwardTransitionInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
_viewModel.NextEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void BackwardButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (pageNum > 1)
|
||||
if (_viewModel.PageNum > 1)
|
||||
{
|
||||
pageNum--;
|
||||
UpdateView();
|
||||
ContentFrame.Navigate(PageTypeSelector(pageNum), settings, _backTransitionInfo);
|
||||
_viewModel.PageNum--;
|
||||
ContentFrame.Navigate(PageTypeSelector(_viewModel.PageNum), null, _backTransitionInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
BackButton.IsEnabled = false;
|
||||
_viewModel.BackEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +91,13 @@ 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 */
|
||||
}
|
||||
|
||||
private void Window_Closed(object sender, EventArgs e)
|
||||
{
|
||||
// Save settings when window is closed
|
||||
Ioc.Default.GetRequiredService<Settings>().Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue