From 8102a53d481770cf56f95d46833938251aa1bd1c Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 19 Nov 2021 23:06:02 +1100 Subject: [PATCH] updated toggle game mode --- Flow.Launcher/Flow.Launcher.csproj | 3 --- Flow.Launcher/Helper/HotKeyMapper.cs | 14 +++----------- Flow.Launcher/MainWindow.xaml.cs | 10 +++++----- Flow.Launcher/ViewModel/MainViewModel.cs | 8 +++----- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/Flow.Launcher/Flow.Launcher.csproj b/Flow.Launcher/Flow.Launcher.csproj index 4be5fc282..fd2f5f1d9 100644 --- a/Flow.Launcher/Flow.Launcher.csproj +++ b/Flow.Launcher/Flow.Launcher.csproj @@ -104,9 +104,6 @@ - - - diff --git a/Flow.Launcher/Helper/HotKeyMapper.cs b/Flow.Launcher/Helper/HotKeyMapper.cs index 01a524160..eb21c7e75 100644 --- a/Flow.Launcher/Helper/HotKeyMapper.cs +++ b/Flow.Launcher/Helper/HotKeyMapper.cs @@ -6,13 +6,10 @@ using NHotkey.Wpf; using Flow.Launcher.Core.Resource; using System.Windows; using Flow.Launcher.ViewModel; -using Flow.Launcher; -using System.Threading.Tasks; -using System.Threading; namespace Flow.Launcher.Helper { - internal class HotKeyMapper + internal static class HotKeyMapper { private static Settings settings; private static MainViewModel mainViewModel; @@ -28,13 +25,8 @@ namespace Flow.Launcher.Helper internal static void OnToggleHotkey(object sender, HotkeyEventArgs args) { - if (mainViewModel.gameModeStatus == true) - { - } - else - { + if (!mainViewModel.GameModeStatus) mainViewModel.ToggleFlowLauncher(); - } } private static void SetHotkey(string hotkeyStr, EventHandler action) @@ -82,7 +74,7 @@ namespace Flow.Launcher.Helper { SetHotkey(hotkey.Hotkey, (s, e) => { - if (mainViewModel.ShouldIgnoreHotkeys() || mainViewModel.gameModeStatus == true) + if (mainViewModel.ShouldIgnoreHotkeys() || mainViewModel.GameModeStatus) return; mainViewModel.MainWindowVisibility = Visibility.Visible; diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 29cced997..e2b91dccd 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -202,7 +202,7 @@ namespace Flow.Launcher }; open.Click += (o, e) => Visibility = Visibility.Visible; - gamemode.Click += (o, e) => GameMode(); + gamemode.Click += (o, e) => ToggleGameMode(); settings.Click += (o, e) => App.API.OpenSettingDialog(); exit.Click += (o, e) => Close(); contextMenu.Items.Add(header); @@ -227,17 +227,17 @@ namespace Flow.Launcher }; } - public void GameMode() + private void ToggleGameMode() { - if (_viewModel.gameModeStatus) + if (_viewModel.GameModeStatus) { _notifyIcon.Icon = Properties.Resources.app; - _viewModel.gameModeStatus = false; + _viewModel.GameModeStatus = false; } else { _notifyIcon.Icon = Properties.Resources.gamemode; - _viewModel.gameModeStatus = true; + _viewModel.GameModeStatus = true; } } private void InitProgressbarAnimation() diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 955b3df7a..d7bbaf1cd 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -20,9 +20,6 @@ using Flow.Launcher.Infrastructure.Logger; using Microsoft.VisualStudio.Threading; using System.Threading.Channels; using ISavable = Flow.Launcher.Plugin.ISavable; -using System.Windows.Threading; -using NHotkey; -using Windows.Web.Syndication; namespace Flow.Launcher.ViewModel @@ -44,7 +41,6 @@ namespace Flow.Launcher.ViewModel private readonly History _history; private readonly UserSelectedRecord _userSelectedRecord; private readonly TopMostRecord _topMostRecord; - private MainWindow _mainWindow; private CancellationTokenSource _updateSource; private CancellationToken _updateToken; @@ -302,10 +298,12 @@ namespace Flow.Launcher.ViewModel #region ViewModel Properties public ResultsViewModel Results { get; private set; } + public ResultsViewModel ContextMenu { get; private set; } + public ResultsViewModel History { get; private set; } - public bool gameModeStatus = false; + public bool GameModeStatus { get; set; } private string _queryText;