Add GameMode

This commit is contained in:
DB p 2021-11-19 15:43:47 +09:00
parent 8f8636a9e9
commit 476d2058a2
8 changed files with 53 additions and 8 deletions

View file

@ -104,6 +104,9 @@
<ProjectReference Include="..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\gamemode.ico" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" />
</Target>

View file

@ -6,12 +6,13 @@ 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 static class HotKeyMapper
internal class HotKeyMapper
{
private static Settings settings;
private static MainViewModel mainViewModel;
@ -27,7 +28,13 @@ namespace Flow.Launcher.Helper
internal static void OnToggleHotkey(object sender, HotkeyEventArgs args)
{
mainViewModel.ToggleFlowLauncher();
if (mainViewModel.gameModeStatus == true)
{
}
else
{
mainViewModel.ToggleFlowLauncher();
}
}
private static void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
@ -75,7 +82,7 @@ namespace Flow.Launcher.Helper
{
SetHotkey(hotkey.Hotkey, (s, e) =>
{
if (mainViewModel.ShouldIgnoreHotkeys())
if (mainViewModel.ShouldIgnoreHotkeys() || mainViewModel.gameModeStatus == true)
return;
mainViewModel.MainWindowVisibility = Visibility.Visible;

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View file

@ -15,6 +15,7 @@
<system:String x:Key="iconTrayAbout">About</system:String>
<system:String x:Key="iconTrayExit">Exit</system:String>
<system:String x:Key="closeWindow">Close</system:String>
<system:String x:Key="GameMode">Game Mode</system:String>
<!-- Setting General -->
<system:String x:Key="flowlauncher_settings">Flow Launcher Settings</system:String>

View file

@ -164,8 +164,9 @@ namespace Flow.Launcher
{
var menu = contextMenu;
((MenuItem)menu.Items[1]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen");
((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("GameMode");
((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
}
private void InitializeNotifyIcon()
@ -187,6 +188,10 @@ namespace Flow.Launcher
{
Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen")
};
var gamemode = new MenuItem
{
Header = InternationalizationManager.Instance.GetTranslation("GameMode")
};
var settings = new MenuItem
{
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings")
@ -197,10 +202,12 @@ namespace Flow.Launcher
};
open.Click += (o, e) => Visibility = Visibility.Visible;
gamemode.Click += (o, e) => GameMode();
settings.Click += (o, e) => App.API.OpenSettingDialog();
exit.Click += (o, e) => Close();
contextMenu.Items.Add(header);
contextMenu.Items.Add(open);
contextMenu.Items.Add(gamemode);
contextMenu.Items.Add(settings);
contextMenu.Items.Add(exit);
@ -220,6 +227,19 @@ namespace Flow.Launcher
};
}
public void GameMode()
{
if (_viewModel.gameModeStatus)
{
_notifyIcon.Icon = Properties.Resources.app;
_viewModel.gameModeStatus = false;
}
else
{
_notifyIcon.Icon = Properties.Resources.gamemode;
_viewModel.gameModeStatus = true;
}
}
private void InitProgressbarAnimation()
{
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 150,

View file

@ -69,5 +69,13 @@ namespace Flow.Launcher.Properties {
return ((System.Drawing.Icon)(obj));
}
}
internal static System.Drawing.Icon gamemode
{
get
{
object obj = ResourceManager.GetObject("gamemode", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
}
}

View file

@ -112,13 +112,16 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="app" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\app.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="gamemode" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\gamemode.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View file

@ -44,6 +44,7 @@ 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;
@ -304,6 +305,8 @@ namespace Flow.Launcher.ViewModel
public ResultsViewModel ContextMenu { get; private set; }
public ResultsViewModel History { get; private set; }
public bool gameModeStatus = false;
private string _queryText;
public string QueryText