Skip to content

Commit 8102a53

Browse files
committed
updated toggle game mode
1 parent 476d205 commit 8102a53

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@
104104
<ProjectReference Include="..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
105105
</ItemGroup>
106106

107-
<ItemGroup>
108-
<Resource Include="Images\gamemode.ico" />
109-
</ItemGroup>
110107
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
111108
<Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" />
112109
</Target>

Flow.Launcher/Helper/HotKeyMapper.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
using Flow.Launcher.Core.Resource;
77
using System.Windows;
88
using Flow.Launcher.ViewModel;
9-
using Flow.Launcher;
10-
using System.Threading.Tasks;
11-
using System.Threading;
129

1310
namespace Flow.Launcher.Helper
1411
{
15-
internal class HotKeyMapper
12+
internal static class HotKeyMapper
1613
{
1714
private static Settings settings;
1815
private static MainViewModel mainViewModel;
@@ -28,13 +25,8 @@ internal static void Initialize(MainViewModel mainVM)
2825

2926
internal static void OnToggleHotkey(object sender, HotkeyEventArgs args)
3027
{
31-
if (mainViewModel.gameModeStatus == true)
32-
{
33-
}
34-
else
35-
{
28+
if (!mainViewModel.GameModeStatus)
3629
mainViewModel.ToggleFlowLauncher();
37-
}
3830
}
3931

4032
private static void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
@@ -82,7 +74,7 @@ internal static void SetCustomQueryHotkey(CustomPluginHotkey hotkey)
8274
{
8375
SetHotkey(hotkey.Hotkey, (s, e) =>
8476
{
85-
if (mainViewModel.ShouldIgnoreHotkeys() || mainViewModel.gameModeStatus == true)
77+
if (mainViewModel.ShouldIgnoreHotkeys() || mainViewModel.GameModeStatus)
8678
return;
8779

8880
mainViewModel.MainWindowVisibility = Visibility.Visible;

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private void InitializeNotifyIcon()
202202
};
203203

204204
open.Click += (o, e) => Visibility = Visibility.Visible;
205-
gamemode.Click += (o, e) => GameMode();
205+
gamemode.Click += (o, e) => ToggleGameMode();
206206
settings.Click += (o, e) => App.API.OpenSettingDialog();
207207
exit.Click += (o, e) => Close();
208208
contextMenu.Items.Add(header);
@@ -227,17 +227,17 @@ private void InitializeNotifyIcon()
227227
};
228228
}
229229

230-
public void GameMode()
230+
private void ToggleGameMode()
231231
{
232-
if (_viewModel.gameModeStatus)
232+
if (_viewModel.GameModeStatus)
233233
{
234234
_notifyIcon.Icon = Properties.Resources.app;
235-
_viewModel.gameModeStatus = false;
235+
_viewModel.GameModeStatus = false;
236236
}
237237
else
238238
{
239239
_notifyIcon.Icon = Properties.Resources.gamemode;
240-
_viewModel.gameModeStatus = true;
240+
_viewModel.GameModeStatus = true;
241241
}
242242
}
243243
private void InitProgressbarAnimation()

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
using Microsoft.VisualStudio.Threading;
2121
using System.Threading.Channels;
2222
using ISavable = Flow.Launcher.Plugin.ISavable;
23-
using System.Windows.Threading;
24-
using NHotkey;
25-
using Windows.Web.Syndication;
2623

2724

2825
namespace Flow.Launcher.ViewModel
@@ -44,7 +41,6 @@ public class MainViewModel : BaseModel, ISavable
4441
private readonly History _history;
4542
private readonly UserSelectedRecord _userSelectedRecord;
4643
private readonly TopMostRecord _topMostRecord;
47-
private MainWindow _mainWindow;
4844

4945
private CancellationTokenSource _updateSource;
5046
private CancellationToken _updateToken;
@@ -302,10 +298,12 @@ private void InitializeKeyCommands()
302298
#region ViewModel Properties
303299

304300
public ResultsViewModel Results { get; private set; }
301+
305302
public ResultsViewModel ContextMenu { get; private set; }
303+
306304
public ResultsViewModel History { get; private set; }
307305

308-
public bool gameModeStatus = false;
306+
public bool GameModeStatus { get; set; }
309307

310308
private string _queryText;
311309

0 commit comments

Comments
 (0)