From 476d2058a26c5eac38bbb7208fec93cfb3650f5b Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 19 Nov 2021 15:43:47 +0900 Subject: [PATCH 1/2] Add GameMode --- Flow.Launcher/Flow.Launcher.csproj | 3 +++ Flow.Launcher/Helper/HotKeyMapper.cs | 13 +++++++--- Flow.Launcher/Images/gamemode.ico | Bin 0 -> 9662 bytes Flow.Launcher/Languages/en.xaml | 1 + Flow.Launcher/MainWindow.xaml.cs | 24 ++++++++++++++++-- .../Properties/Resources.Designer.cs | 8 ++++++ Flow.Launcher/Properties/Resources.resx | 9 ++++--- Flow.Launcher/ViewModel/MainViewModel.cs | 3 +++ 8 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 Flow.Launcher/Images/gamemode.ico diff --git a/Flow.Launcher/Flow.Launcher.csproj b/Flow.Launcher/Flow.Launcher.csproj index fd2f5f1d942..4be5fc2829f 100644 --- a/Flow.Launcher/Flow.Launcher.csproj +++ b/Flow.Launcher/Flow.Launcher.csproj @@ -104,6 +104,9 @@ + + + diff --git a/Flow.Launcher/Helper/HotKeyMapper.cs b/Flow.Launcher/Helper/HotKeyMapper.cs index fe25ecf18ad..01a524160cf 100644 --- a/Flow.Launcher/Helper/HotKeyMapper.cs +++ b/Flow.Launcher/Helper/HotKeyMapper.cs @@ -6,12 +6,13 @@ 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 @@ internal static void Initialize(MainViewModel mainVM) internal static void OnToggleHotkey(object sender, HotkeyEventArgs args) { - mainViewModel.ToggleFlowLauncher(); + if (mainViewModel.gameModeStatus == true) + { + } + else + { + mainViewModel.ToggleFlowLauncher(); + } } private static void SetHotkey(string hotkeyStr, EventHandler action) @@ -75,7 +82,7 @@ internal static void SetCustomQueryHotkey(CustomPluginHotkey hotkey) { SetHotkey(hotkey.Hotkey, (s, e) => { - if (mainViewModel.ShouldIgnoreHotkeys()) + if (mainViewModel.ShouldIgnoreHotkeys() || mainViewModel.gameModeStatus == true) return; mainViewModel.MainWindowVisibility = Visibility.Visible; diff --git a/Flow.Launcher/Images/gamemode.ico b/Flow.Launcher/Images/gamemode.ico new file mode 100644 index 0000000000000000000000000000000000000000..27a46a904d7ccd3d3e90dfc4a09a9a9388ac9ae9 GIT binary patch literal 9662 zcmdU!YfO_@7{{M-DHD3*BA1e=TU?yF4`!@DMeu{kX6BYG*#tzUMFnN3h#;uTqH#oG zHk2t2xhUQ~EY4{3i_&KiNWoQd*3gmtE?0qQKezyqB&hbI{jm`;v!~Hlh6f z=bYy`|MQecg`XKS2)`%Mx33e$6VV$8yhRoSe_wbei-Yg)jmAEYzGmr$or7lmuG?mPy#sN|tlwR2)_*g1roJIQL$`;-XvEk^vk+r> zUJyS6KcZfW-E5}*n>*mYgs2983fRLkbWPA8#w=a)sARlEerRZ5VCQiY{CmM}O4T)B z4Vn>6h?f7<5Fq@}(1>XIHAC0D1^fw|JyW|^h-ZliFn(xgX5c>ue)DKF1SWqAG_<%e z|2di3Cal3eAx2tvdNG%S zj2~-o;0j`bph0txf{>qOX%239j{JG>pC0&6M6Cz@6S2bs|0x9g=RNq(ff4+hum6$# zgM9wV^`F;Ip1VR||MU6h{8oe!p=kcsME)N3cJ#J5cxV$en4rOwYN$nQH>DYNAnHuu zp9TJG@Nb3x{29>?|IGcT68?cK&7s9g`Ikl6!#)pZA?w4Lx+0XR%T$BvQW{XNqDShL zG^pN0EEIPHRhDia&5Jlg(5DA~9{4XSr*cAVC$d9qyRucb{A}t-o)dY5()IO|z<=DwKaX|) zaDF#pniBpG=_kTHtN17Kb=k!?voaNpDfgLF{}eC7}v=bOB(Ve4GRPvf(8Z+59X_^ zmGo8&f!_@N8=?lm|Bp6*`TR5R?@_`}bcApxwiN3e!ku`ShF8ROcv3@72z01y9_V{HV9JB?s>_{o1?0so0) z`cZ{G%fdCW&LL4lkGIF-)xh&w&|vqjgOt~gklXX7jxUP<`+5KP4-bKV$j|=I`Gw)_ zYV?cVL%*mW8oa$CxldGtynaS)8p3{BM6*c+_LF|{Gw|Q{lfQduRA*9EqH7xZUN_3+ zo>z=h=y#PMC*)pNA?mAGo9y1&#Oo{cTj&n)zSVIB{8#hir$vGj{CaG`gtxeETLUR=J7vTT) z`_aD@IIypOfcJ^tGU=KI8n)uIenU>659|{9!2f7?x;Ei&ODIhl{|2LbI{s&$0)Fm& zzC(?i@ETp9&yxGn@p;>zp$!^3P@A04;6#0Ot~B&GQJb8|YbWZf6FHGj2}1o*kiYH- z?A>FE_{DST63*KkoJ-mwO*hp}xz4?99CR4h#rGPa!w4Nl=rAHDjK~RNv92d7Rab|; zv;Xx6?1Zp@e{hWbe|i51UV)!c;C~3ea1s9V3)IJta88+VMy2q8t`vCC6nLK$c%PJy z$%?SWnxeNo5B_BETNU%ecXGcY`RB)|?{{%Vd3fZ8+C0$Ufd=l~5LOQ~I@4o_uALpjXAMeuO{5%?L{PG&WzYyY0@Y`h%zznAd4x^(`&l=>-i`;MhCJp^`I z9o@rw3>o0RAm0mpeQ==ib1mQ&0=|(-^o~UES7ZKf1PedcfO#i)Mb1wvv9sscFN1N|EJ4fTIq9`Lx}?`0X?!S+1JXDojq;ST&Egx(C60dsD$opy literal 0 HcmV?d00001 diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 5ca6bdbfd7a..e5856625c48 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -15,6 +15,7 @@ About Exit Close + Game Mode Flow Launcher Settings diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 16e4be8a030..29cced99728 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -164,8 +164,9 @@ private void UpdateNotifyIconText() { 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 @@ private void InitializeNotifyIcon() { 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 @@ private void InitializeNotifyIcon() }; 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 @@ private void InitializeNotifyIcon() }; } + 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, diff --git a/Flow.Launcher/Properties/Resources.Designer.cs b/Flow.Launcher/Properties/Resources.Designer.cs index a1971607327..43927cb98fd 100644 --- a/Flow.Launcher/Properties/Resources.Designer.cs +++ b/Flow.Launcher/Properties/Resources.Designer.cs @@ -69,5 +69,13 @@ internal static System.Drawing.Icon app { return ((System.Drawing.Icon)(obj)); } } + internal static System.Drawing.Icon gamemode + { + get + { + object obj = ResourceManager.GetObject("gamemode", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } } } diff --git a/Flow.Launcher/Properties/Resources.resx b/Flow.Launcher/Properties/Resources.resx index 3ae43d89b04..2126cb185c7 100644 --- a/Flow.Launcher/Properties/Resources.resx +++ b/Flow.Launcher/Properties/Resources.resx @@ -112,13 +112,16 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + ..\Resources\app.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Images\gamemode.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 547228ee33a..955b3df7ad1 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -44,6 +44,7 @@ public class MainViewModel : BaseModel, ISavable 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 @@ private void InitializeKeyCommands() public ResultsViewModel ContextMenu { get; private set; } public ResultsViewModel History { get; private set; } + public bool gameModeStatus = false; + private string _queryText; public string QueryText From 8102a53d481770cf56f95d46833938251aa1bd1c Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 19 Nov 2021 23:06:02 +1100 Subject: [PATCH 2/2] 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 4be5fc2829f..fd2f5f1d942 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 01a524160cf..eb21c7e757a 100644 --- a/Flow.Launcher/Helper/HotKeyMapper.cs +++ b/Flow.Launcher/Helper/HotKeyMapper.cs @@ -6,13 +6,10 @@ 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 @@ internal static void Initialize(MainViewModel mainVM) 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 @@ internal static void SetCustomQueryHotkey(CustomPluginHotkey hotkey) { 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 29cced99728..e2b91dccda0 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -202,7 +202,7 @@ private void InitializeNotifyIcon() }; 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 @@ private void InitializeNotifyIcon() }; } - 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 955b3df7ad1..d7bbaf1cdcc 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -20,9 +20,6 @@ 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 @@ public class MainViewModel : BaseModel, ISavable 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 @@ private void InitializeKeyCommands() #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;