From 4c7b5921e65d2335db45fba93bc59da0f8f09851 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 18 Jan 2024 21:46:21 -0600 Subject: [PATCH] Welcome Page Port Part 1 --- .../Hotkey/HotkeyModel.cs | 83 +++++++- .../Image/ImageCache.cs | 14 +- Flow.Launcher/App.axaml | 5 +- Flow.Launcher/Flow.Launcher.csproj | 16 ++ Flow.Launcher/Helper/HotKeyMapper.cs | 12 +- ...HotkeyControl.xaml => HotkeyControl.axaml} | 19 +- ...Control.xaml.cs => HotkeyControl.axaml.cs} | 36 ++-- Flow.Launcher/MainWindow.axaml.cs | 14 +- .../Resources/Pages/WelcomePage1.xaml | 189 ------------------ .../Resources/Pages/WelcomePage2.xaml.cs | 52 ----- .../Resources/Pages/WelcomePage3.xaml.cs | 20 -- .../Resources/Pages/WelcomePage4.xaml | 136 ------------- .../Resources/Pages/WelcomePage4.xaml.cs | 20 -- .../Resources/Pages/WelcomePage5.xaml | 122 ----------- Flow.Launcher/SettingWindow.xaml.cs | 2 +- Flow.Launcher/ViewLocator.cs | 36 ++++ Flow.Launcher/ViewModel/ResultViewModel.cs | 4 +- .../WelcomePages/PageViewModelBase.cs | 19 ++ .../WelcomePages/WelcomePage1ViewModel.cs} | 27 ++- .../WelcomePages/WelcomePage2ViewModel.cs | 21 ++ .../WelcomePages/WelcomePage3ViewModel.cs | 18 ++ .../WelcomePages/WelcomePage4ViewModel.cs | 18 ++ .../WelcomePages/WelcomePage5ViewModel.cs | 18 ++ .../ViewModel/WelcomeWindowViewModel.cs | 70 +++++++ Flow.Launcher/WelcomePages/WelcomePage1.axaml | 183 +++++++++++++++++ .../WelcomePages/WelcomePage1.axaml.cs | 14 ++ .../WelcomePage2.axaml} | 82 ++++---- .../WelcomePages/WelcomePage2.axaml.cs | 44 ++++ .../WelcomePage3.axaml} | 152 +++++++------- .../WelcomePages/WelcomePage3.axaml.cs | 19 ++ Flow.Launcher/WelcomePages/WelcomePage4.axaml | 139 +++++++++++++ .../WelcomePages/WelcomePage4.axaml.cs | 20 ++ Flow.Launcher/WelcomePages/WelcomePage5.axaml | 106 ++++++++++ .../WelcomePage5.axaml.cs} | 29 +-- Flow.Launcher/WelcomeWindow.axaml | 125 ++++++++++++ Flow.Launcher/WelcomeWindow.axaml.cs | 34 ++++ Flow.Launcher/WelcomeWindow.xaml | 157 --------------- Flow.Launcher/WelcomeWindow.xaml.cs | 110 ---------- 38 files changed, 1170 insertions(+), 1015 deletions(-) rename Flow.Launcher/{HotkeyControl.xaml => HotkeyControl.axaml} (72%) rename Flow.Launcher/{HotkeyControl.xaml.cs => HotkeyControl.axaml.cs} (82%) delete mode 100644 Flow.Launcher/Resources/Pages/WelcomePage1.xaml delete mode 100644 Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs delete mode 100644 Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs delete mode 100644 Flow.Launcher/Resources/Pages/WelcomePage4.xaml delete mode 100644 Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs delete mode 100644 Flow.Launcher/Resources/Pages/WelcomePage5.xaml create mode 100644 Flow.Launcher/ViewLocator.cs create mode 100644 Flow.Launcher/ViewModel/WelcomePages/PageViewModelBase.cs rename Flow.Launcher/{Resources/Pages/WelcomePage1.xaml.cs => ViewModel/WelcomePages/WelcomePage1ViewModel.cs} (59%) create mode 100644 Flow.Launcher/ViewModel/WelcomePages/WelcomePage2ViewModel.cs create mode 100644 Flow.Launcher/ViewModel/WelcomePages/WelcomePage3ViewModel.cs create mode 100644 Flow.Launcher/ViewModel/WelcomePages/WelcomePage4ViewModel.cs create mode 100644 Flow.Launcher/ViewModel/WelcomePages/WelcomePage5ViewModel.cs create mode 100644 Flow.Launcher/ViewModel/WelcomeWindowViewModel.cs create mode 100644 Flow.Launcher/WelcomePages/WelcomePage1.axaml create mode 100644 Flow.Launcher/WelcomePages/WelcomePage1.axaml.cs rename Flow.Launcher/{Resources/Pages/WelcomePage2.xaml => WelcomePages/WelcomePage2.axaml} (60%) create mode 100644 Flow.Launcher/WelcomePages/WelcomePage2.axaml.cs rename Flow.Launcher/{Resources/Pages/WelcomePage3.xaml => WelcomePages/WelcomePage3.axaml} (68%) create mode 100644 Flow.Launcher/WelcomePages/WelcomePage3.axaml.cs create mode 100644 Flow.Launcher/WelcomePages/WelcomePage4.axaml create mode 100644 Flow.Launcher/WelcomePages/WelcomePage4.axaml.cs create mode 100644 Flow.Launcher/WelcomePages/WelcomePage5.axaml rename Flow.Launcher/{Resources/Pages/WelcomePage5.xaml.cs => WelcomePages/WelcomePage5.axaml.cs} (71%) create mode 100644 Flow.Launcher/WelcomeWindow.axaml create mode 100644 Flow.Launcher/WelcomeWindow.axaml.cs delete mode 100644 Flow.Launcher/WelcomeWindow.xaml delete mode 100644 Flow.Launcher/WelcomeWindow.xaml.cs diff --git a/Flow.Launcher.Infrastructure/Hotkey/HotkeyModel.cs b/Flow.Launcher.Infrastructure/Hotkey/HotkeyModel.cs index 937059436..ab5da3ac6 100644 --- a/Flow.Launcher.Infrastructure/Hotkey/HotkeyModel.cs +++ b/Flow.Launcher.Infrastructure/Hotkey/HotkeyModel.cs @@ -3,6 +3,9 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Windows.Input; +using Avalonia.Input; +using Key = Avalonia.Input.Key; +using KeyGesture = Avalonia.Input.KeyGesture; namespace Flow.Launcher.Infrastructure.Hotkey { @@ -17,8 +20,7 @@ namespace Flow.Launcher.Infrastructure.Hotkey private static readonly Dictionary specialSymbolDictionary = new Dictionary { - {Key.Space, "Space"}, - {Key.Oem3, "~"} + { Key.Space, "Space" }, { Key.Oem3, "~" } }; public ModifierKeys ModifierKeys @@ -30,18 +32,22 @@ namespace Flow.Launcher.Infrastructure.Hotkey { modifierKeys |= ModifierKeys.Alt; } + if (Shift) { modifierKeys |= ModifierKeys.Shift; } + if (Win) { modifierKeys |= ModifierKeys.Windows; } + if (Ctrl) { modifierKeys |= ModifierKeys.Control; } + return modifierKeys; } } @@ -66,31 +72,37 @@ namespace Flow.Launcher.Infrastructure.Hotkey { return; } + List keys = hotkeyString.Replace(" ", "").Split('+').ToList(); if (keys.Contains("Alt")) { Alt = true; keys.Remove("Alt"); } + if (keys.Contains("Shift")) { Shift = true; keys.Remove("Shift"); } + if (keys.Contains("Win")) { Win = true; keys.Remove("Win"); } + if (keys.Contains("Ctrl")) { Ctrl = true; keys.Remove("Ctrl"); } + if (keys.Count == 1) { string charKey = keys[0]; - KeyValuePair? specialSymbolPair = specialSymbolDictionary.FirstOrDefault(pair => pair.Value == charKey); + KeyValuePair? specialSymbolPair = + specialSymbolDictionary.FirstOrDefault(pair => pair.Value == charKey); if (specialSymbolPair.Value.Value != null) { CharKey = specialSymbolPair.Value.Key; @@ -103,7 +115,6 @@ namespace Flow.Launcher.Infrastructure.Hotkey } catch (ArgumentException) { - } } } @@ -116,14 +127,17 @@ namespace Flow.Launcher.Infrastructure.Hotkey { keys.Add("Ctrl"); } + if (Alt) { keys.Add("Alt"); } + if (Shift) { keys.Add("Shift"); } + if (Win) { keys.Add("Win"); @@ -135,9 +149,10 @@ namespace Flow.Launcher.Infrastructure.Hotkey ? specialSymbolDictionary[CharKey] : CharKey.ToString()); } + return string.Join(" + ", keys); } - + /// /// Validate hotkey /// @@ -162,13 +177,15 @@ namespace Flow.Launcher.Infrastructure.Hotkey { try { - KeyGesture keyGesture = new KeyGesture(CharKey, ModifierKeys); + KeyGesture keyGesture = new KeyGesture(CharKey, ToKeyModifiers(ModifierKeys)); } - catch (System.Exception e) when (e is NotSupportedException || e is InvalidEnumArgumentException) + catch (System.Exception e) when + (e is NotSupportedException || e is InvalidEnumArgumentException) { return false; } } + if (ModifierKeys == ModifierKeys.None) { return !IsPrintableCharacter(CharKey); @@ -180,6 +197,58 @@ namespace Flow.Launcher.Infrastructure.Hotkey } } + public ModifierKeys ToModifierKeys(KeyModifiers keyModifiers) + { + ModifierKeys modifierKeys = ModifierKeys.None; + if (keyModifiers.HasFlag(KeyModifiers.Alt)) + { + modifierKeys |= ModifierKeys.Alt; + } + + if (keyModifiers.HasFlag(KeyModifiers.Shift)) + { + modifierKeys |= ModifierKeys.Shift; + } + + if (keyModifiers.HasFlag(KeyModifiers.Meta)) + { + modifierKeys |= ModifierKeys.Windows; + } + + if (keyModifiers.HasFlag(KeyModifiers.Control)) + { + modifierKeys |= ModifierKeys.Control; + } + + return modifierKeys; + } + + public KeyModifiers ToKeyModifiers(ModifierKeys modifierKeys) + { + KeyModifiers keyModifiers = KeyModifiers.None; + if (modifierKeys.HasFlag(ModifierKeys.Alt)) + { + keyModifiers |= KeyModifiers.Alt; + } + + if (modifierKeys.HasFlag(ModifierKeys.Shift)) + { + keyModifiers |= KeyModifiers.Shift; + } + + if (modifierKeys.HasFlag(ModifierKeys.Windows)) + { + keyModifiers |= KeyModifiers.Meta; + } + + if (modifierKeys.HasFlag(ModifierKeys.Control)) + { + keyModifiers |= KeyModifiers.Control; + } + + return keyModifiers; + } + private static bool IsPrintableCharacter(Key key) { // https://stackoverflow.com/questions/11881199/identify-if-a-event-key-is-text-not-only-alphanumeric diff --git a/Flow.Launcher.Infrastructure/Image/ImageCache.cs b/Flow.Launcher.Infrastructure/Image/ImageCache.cs index 70e4ac681..e4d97bae7 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageCache.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageCache.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading; +using System.Threading.Tasks; using System.Windows.Media; using Avalonia.Media.Imaging; @@ -11,7 +12,6 @@ namespace Flow.Launcher.Infrastructure.Image [Serializable] public class ImageUsage { - public int usage; public Bitmap imageSource; @@ -24,7 +24,7 @@ namespace Flow.Launcher.Infrastructure.Image public class ImageCache { - private const int MaxCached = 50; + private const int MaxCached = 150; public ConcurrentDictionary<(string, bool), ImageUsage> Data { get; } = new(); private const int permissibleFactor = 2; private SemaphoreSlim semaphore = new(1, 1); @@ -45,9 +45,9 @@ namespace Flow.Launcher.Infrastructure.Image { return null; } + value.usage++; return value.imageSource; - } set { @@ -64,7 +64,7 @@ namespace Flow.Launcher.Infrastructure.Image SliceExtra(); - async void SliceExtra() + async Task SliceExtra() { // To prevent the dictionary from drastically increasing in size by caching images, the dictionary size is not allowed to grow more than the permissibleFactor * maxCached size // This is done so that we don't constantly perform this resizing operation and also maintain the image cache size at the same time @@ -74,7 +74,8 @@ namespace Flow.Launcher.Infrastructure.Image // To delete the images from the data dictionary based on the resizing of the Usage Dictionary // Double Check to avoid concurrent remove if (Data.Count > permissibleFactor * MaxCached) - foreach (var key in Data.OrderBy(x => x.Value.usage).Take(Data.Count - MaxCached).Select(x => x.Key)) + foreach (var key in Data.OrderBy(x => x.Value.usage).Take(Data.Count - MaxCached) + .Select(x => x.Key)) Data.TryRemove(key, out _); semaphore.Release(); } @@ -84,7 +85,8 @@ namespace Flow.Launcher.Infrastructure.Image public bool ContainsKey(string key, bool isFullImage) { - return key is not null && Data.ContainsKey((key, isFullImage)) && Data[(key, isFullImage)].imageSource != null; + return key is not null && Data.ContainsKey((key, isFullImage)) && + Data[(key, isFullImage)].imageSource != null; } public bool TryGetValue(string key, bool isFullImage, out Bitmap image) diff --git a/Flow.Launcher/App.axaml b/Flow.Launcher/App.axaml index d54b69230..d77454f8d 100644 --- a/Flow.Launcher/App.axaml +++ b/Flow.Launcher/App.axaml @@ -4,7 +4,10 @@ RequestedThemeVariant="Default"> - + + avares://Flow.Launcher/Resources/#Segoe Fluent Icons + + diff --git a/Flow.Launcher/Flow.Launcher.csproj b/Flow.Launcher/Flow.Launcher.csproj index 055123b1a..8fb95b992 100644 --- a/Flow.Launcher/Flow.Launcher.csproj +++ b/Flow.Launcher/Flow.Launcher.csproj @@ -45,6 +45,21 @@ + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + @@ -77,6 +92,7 @@ PreserveNewest + diff --git a/Flow.Launcher/Helper/HotKeyMapper.cs b/Flow.Launcher/Helper/HotKeyMapper.cs index 3949d2828..4b673e88d 100644 --- a/Flow.Launcher/Helper/HotKeyMapper.cs +++ b/Flow.Launcher/Helper/HotKeyMapper.cs @@ -5,6 +5,7 @@ using NHotkey; using NHotkey.Wpf; using Flow.Launcher.Core.Resource; using System.Windows; +using System.Windows.Input; using Flow.Launcher.ViewModel; namespace Flow.Launcher.Helper @@ -40,13 +41,15 @@ namespace Flow.Launcher.Helper string hotkeyStr = hotkey.ToString(); try { - HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action); + HotkeyManager.Current.AddOrReplace(hotkeyStr, (Key)hotkey.CharKey, hotkey.ModifierKeys, action); } catch (Exception) { - string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr); + string errorMsg = + string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), + hotkeyStr); string errorMsgTitle = InternationalizationManager.Instance.GetTranslation("MessageBoxTitle"); - MessageBox.Show(errorMsg,errorMsgTitle); + MessageBox.Show(errorMsg, errorMsgTitle); } } @@ -85,7 +88,8 @@ namespace Flow.Launcher.Helper { try { - HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", currentHotkey.CharKey, currentHotkey.ModifierKeys, (sender, e) => { }); + HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", (Key)currentHotkey.CharKey, + currentHotkey.ModifierKeys, (sender, e) => { }); return true; } diff --git a/Flow.Launcher/HotkeyControl.xaml b/Flow.Launcher/HotkeyControl.axaml similarity index 72% rename from Flow.Launcher/HotkeyControl.xaml rename to Flow.Launcher/HotkeyControl.axaml index acf4a21ec..5ee83a71c 100644 --- a/Flow.Launcher/HotkeyControl.xaml +++ b/Flow.Launcher/HotkeyControl.axaml @@ -1,27 +1,23 @@  + mc:Ignorable="d" + x:DataType="launcher:HotkeyControl"> + Text="{DynamicResource flowlauncherPressHotkey}"/> @@ -47,10 +42,8 @@ x:Name="tbHotkey" Margin="0,0,18,0" VerticalContentAlignment="Center" - input:InputMethod.IsInputMethodEnabled="False" - GotFocus="tbHotkey_GotFocus" LostFocus="tbHotkey_LostFocus" - PreviewKeyDown="TbHotkey_OnPreviewKeyDown" + KeyDown="TbHotkey_OnPreviewKeyDown" TabIndex="100" /> \ No newline at end of file diff --git a/Flow.Launcher/HotkeyControl.xaml.cs b/Flow.Launcher/HotkeyControl.axaml.cs similarity index 82% rename from Flow.Launcher/HotkeyControl.xaml.cs rename to Flow.Launcher/HotkeyControl.axaml.cs index 3da66caeb..ce0828bb2 100644 --- a/Flow.Launcher/HotkeyControl.xaml.cs +++ b/Flow.Launcher/HotkeyControl.axaml.cs @@ -1,17 +1,22 @@ using System; using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using System.Windows.Media; using Flow.Launcher.Core.Resource; using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Plugin; using System.Threading; +using System.Windows.Input; +using Avalonia.Controls; +using Avalonia.Interactivity; +using Avalonia.Threading; +using PropertyChanged; +using FocusManager = Avalonia.Input.FocusManager; +using Key = Avalonia.Input.Key; +using KeyEventArgs = Avalonia.Input.KeyEventArgs; namespace Flow.Launcher { + [DoNotNotify] public partial class HotkeyControl : UserControl { public HotkeyModel CurrentHotkey { get; private set; } @@ -42,7 +47,7 @@ namespace Flow.Launcher e.Handled = true; //when alt is pressed, the real key should be e.SystemKey - Key key = e.Key == Key.System ? e.SystemKey : e.Key; + Key key = e.Key; SpecialKeyState specialKeyState = GlobalHotkey.CheckModifiers(); @@ -58,7 +63,7 @@ namespace Flow.Launcher return; } - _ = Dispatcher.InvokeAsync(async () => + _ = Dispatcher.UIThread.InvokeAsync(async () => { await Task.Delay(500, token); if (!token.IsCancellationRequested) @@ -69,7 +74,7 @@ namespace Flow.Launcher public async Task SetHotkeyAsync(HotkeyModel keyModel, bool triggerValidate = true) { tbHotkey.Text = keyModel.ToString(); - tbHotkey.Select(tbHotkey.Text.Length, 0); + // tbHotkey.Select(tbHotkey.Text.Length, 0); if (triggerValidate) { @@ -87,7 +92,6 @@ namespace Flow.Launcher { CurrentHotkey = keyModel; // To trigger LostFocus - FocusManager.SetFocusedElement(FocusManager.GetFocusScope(this), null); Keyboard.ClearFocus(); } } @@ -96,20 +100,21 @@ namespace Flow.Launcher CurrentHotkey = keyModel; } } - + public Task SetHotkeyAsync(string keyStr, bool triggerValidate = true) { return SetHotkeyAsync(new HotkeyModel(keyStr), triggerValidate); } - private static bool CheckHotkeyAvailability(HotkeyModel hotkey, bool validateKeyGesture) => hotkey.Validate(validateKeyGesture) && HotKeyMapper.CheckAvailability(hotkey); + private static bool CheckHotkeyAvailability(HotkeyModel hotkey, bool validateKeyGesture) => + hotkey.Validate(validateKeyGesture) && HotKeyMapper.CheckAvailability(hotkey); public new bool IsFocused => tbHotkey.IsFocused; private void tbHotkey_LostFocus(object sender, RoutedEventArgs e) { tbHotkey.Text = CurrentHotkey?.ToString() ?? ""; - tbHotkey.Select(tbHotkey.Text.Length, 0); + // tbHotkey.Select(tbHotkey.Text.Length, 0); } private void tbHotkey_GotFocus(object sender, RoutedEventArgs e) @@ -120,22 +125,23 @@ namespace Flow.Launcher private void ResetMessage() { tbMsg.Text = InternationalizationManager.Instance.GetTranslation("flowlauncherPressHotkey"); - tbMsg.SetResourceReference(TextBox.ForegroundProperty, "Color05B"); + // tbMsg.SetResourceReference(TextBox.ForegroundProperty, "Color05B"); } private void SetMessage(bool hotkeyAvailable) { if (!hotkeyAvailable) { - tbMsg.Foreground = new SolidColorBrush(Colors.Red); + // tbMsg.Foreground = new SolidColorBrush(Colors.Red); tbMsg.Text = InternationalizationManager.Instance.GetTranslation("hotkeyUnavailable"); } else { - tbMsg.Foreground = new SolidColorBrush(Colors.Green); + // tbMsg.Foreground = new SolidColorBrush(Colors.Green); tbMsg.Text = InternationalizationManager.Instance.GetTranslation("success"); } - tbMsg.Visibility = Visibility.Visible; + + // tbMsg.Visibility = Visibility.Visible; } } } diff --git a/Flow.Launcher/MainWindow.axaml.cs b/Flow.Launcher/MainWindow.axaml.cs index de7f2fe6c..70dfb35a0 100644 --- a/Flow.Launcher/MainWindow.axaml.cs +++ b/Flow.Launcher/MainWindow.axaml.cs @@ -336,7 +336,7 @@ namespace Flow.Launcher private void CheckFirstLaunch() { - if (_settings.FirstLaunch) + // if (_settings.FirstLaunch) { _settings.FirstLaunch = false; PluginManager.API.SaveAppAllSettings(); @@ -347,7 +347,7 @@ namespace Flow.Launcher private void OpenWelcomeWindow() { var WelcomeWindow = new WelcomeWindow(_settings); - WelcomeWindow.Show(); + WelcomeWindow.ShowDialog(this); } private async void PositionReset() @@ -539,11 +539,11 @@ namespace Flow.Launcher public void HideStartup() { UpdatePosition(); - if (_settings.HideOnStartup) - { - _viewModel.Hide(); - } - else + // if (_settings.HideOnStartup) + // { + // _viewModel.Hide(); + // } + // else { _viewModel.Show(); } diff --git a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml deleted file mode 100644 index 1728195bd..000000000 --- a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Flow Launcher - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs deleted file mode 100644 index e89a7dd03..000000000 --- a/Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Flow.Launcher.Helper; -using Flow.Launcher.Infrastructure.Hotkey; -using Flow.Launcher.Infrastructure.UserSettings; -using System; -using System.Windows; -using System.Windows.Media; -using System.Windows.Navigation; - -namespace Flow.Launcher.Resources.Pages -{ - public partial class WelcomePage2 - { - private Settings Settings { get; set; } - - private Brush tbMsgForegroundColorOriginal; - - private string tbMsgTextOriginal; - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - if (e.ExtraData is Settings settings) - Settings = settings; - else - throw new ArgumentException("Unexpected Parameter setting."); - - InitializeComponent(); - tbMsgTextOriginal = HotkeyControl.tbMsg.Text; - tbMsgForegroundColorOriginal = HotkeyControl.tbMsg.Foreground; - - HotkeyControl.SetHotkeyAsync(Settings.Hotkey, false); - } - private void HotkeyControl_OnGotFocus(object sender, RoutedEventArgs args) - { - HotKeyMapper.RemoveHotkey(Settings.Hotkey); - } - private void HotkeyControl_OnLostFocus(object sender, RoutedEventArgs args) - { - if (HotkeyControl.CurrentHotkeyAvailable) - { - HotKeyMapper.SetHotkey(HotkeyControl.CurrentHotkey, HotKeyMapper.OnToggleHotkey); - Settings.Hotkey = HotkeyControl.CurrentHotkey.ToString(); - } - else - { - HotKeyMapper.SetHotkey(new HotkeyModel(Settings.Hotkey), HotKeyMapper.OnToggleHotkey); - } - - HotkeyControl.tbMsg.Text = tbMsgTextOriginal; - HotkeyControl.tbMsg.Foreground = tbMsgForegroundColorOriginal; - } - } -} diff --git a/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs deleted file mode 100644 index 9051e7c27..000000000 --- a/Flow.Launcher/Resources/Pages/WelcomePage3.xaml.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Windows.Navigation; -using Flow.Launcher.Infrastructure.UserSettings; - -namespace Flow.Launcher.Resources.Pages -{ - public partial class 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 deleted file mode 100644 index 13f003086..000000000 --- a/Flow.Launcher/Resources/Pages/WelcomePage4.xaml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs deleted file mode 100644 index 11bbcd6ed..000000000 --- a/Flow.Launcher/Resources/Pages/WelcomePage4.xaml.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Flow.Launcher.Infrastructure.UserSettings; -using System; -using System.Windows.Navigation; - -namespace Flow.Launcher.Resources.Pages -{ - public partial class 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 deleted file mode 100644 index c898ac9a0..000000000 --- a/Flow.Launcher/Resources/Pages/WelcomePage5.xaml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - -