Skip to content

Commit 5e0b095

Browse files
committed
Remove tray icon & more WinForms references
1 parent 266897e commit 5e0b095

File tree

9 files changed

+7
-376
lines changed

9 files changed

+7
-376
lines changed

Flow.Launcher.Core/Flow.Launcher.Core.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
55
<UseWpf>true</UseWpf>
6-
<UseWindowsForms>true</UseWindowsForms>
76
<OutputType>Library</OutputType>
87
<AppDesignerFolder>Properties</AppDesignerFolder>
98
<RootNamespace>Flow.Launcher.Core</RootNamespace>

Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Concurrent;
1+
using System;
2+
using System.Collections.Concurrent;
23
using System.Collections.Generic;
34
using System.Text.Json;
45
using System.Threading.Tasks;
@@ -145,7 +146,7 @@ public void Save()
145146
API.LogException(ClassName, $"Failed to save plugin settings to path: {SettingPath}", e);
146147
}
147148
}
148-
149+
149150
public bool NeedCreateSettingPanel()
150151
{
151152
// If there are no settings or the settings configuration is empty, return null
@@ -287,7 +288,9 @@ public Control CreateSettingPanel()
287288

288289
Btn.Click += (_, _) =>
289290
{
290-
using System.Windows.Forms.CommonDialog dialog = type switch
291+
throw new NotImplementedException();
292+
293+
/*using System.Windows.Forms.CommonDialog dialog = type switch
291294
{
292295
"inputWithFolderBtn" => new System.Windows.Forms.FolderBrowserDialog(),
293296
_ => new System.Windows.Forms.OpenFileDialog(),
@@ -306,7 +309,7 @@ public Control CreateSettingPanel()
306309
};
307310
308311
textBox.Text = path;
309-
Settings[attributes.Name] = path;
312+
Settings[attributes.Name] = path;*/
310313
};
311314

312315
var stackPanel = new StackPanel()

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -294,19 +294,6 @@ public bool KeepMaxResults
294294
public bool EnableUpdateLog { get; set; }
295295

296296
public bool HideOnStartup { get; set; } = true;
297-
private bool _hideNotifyIcon;
298-
public bool HideNotifyIcon
299-
{
300-
get => _hideNotifyIcon;
301-
set
302-
{
303-
if (_hideNotifyIcon != value)
304-
{
305-
_hideNotifyIcon = value;
306-
OnPropertyChanged();
307-
}
308-
}
309-
}
310297
public bool LeaveCmdOpen { get; set; }
311298
public bool HideWhenDeactivated { get; set; } = true;
312299

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<OutputType>WinExe</OutputType>
55
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
66
<UseWPF>true</UseWPF>
7-
<UseWindowsForms>false</UseWindowsForms>
87
<StartupObject>Flow.Launcher.App</StartupObject>
98
<ApplicationIcon>Resources\app.ico</ApplicationIcon>
109
<ApplicationManifest>app.manifest</ApplicationManifest>

Flow.Launcher/Languages/en.xaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
<system:String x:Key="cancelTopMostInThisQuery">Cancel topmost in this query</system:String>
2929
<system:String x:Key="executeQuery">Execute query: {0}</system:String>
3030
<system:String x:Key="lastExecuteTime">Last execution time: {0}</system:String>
31-
<system:String x:Key="iconTrayOpen">Open</system:String>
32-
<system:String x:Key="iconTraySettings">Settings</system:String>
33-
<system:String x:Key="iconTrayAbout">About</system:String>
34-
<system:String x:Key="iconTrayExit">Exit</system:String>
3531
<system:String x:Key="closeWindow">Close</system:String>
3632
<system:String x:Key="copy">Copy</system:String>
3733
<system:String x:Key="cut">Cut</system:String>
@@ -94,8 +90,6 @@
9490
<system:String x:Key="select">Select</system:String>
9591
<system:String x:Key="hideOnStartup">Hide Flow Launcher on startup</system:String>
9692
<system:String x:Key="hideOnStartupToolTip">Flow Launcher search window is hidden in the tray after starting up.</system:String>
97-
<system:String x:Key="hideNotifyIcon">Hide tray icon</system:String>
98-
<system:String x:Key="hideNotifyIconToolTip">When the icon is hidden from the tray, the Settings menu can be opened by right-clicking on the search window.</system:String>
9993
<system:String x:Key="querySearchPrecision">Query Search Precision</system:String>
10094
<system:String x:Key="querySearchPrecisionToolTip">Changes minimum match score required for results.</system:String>
10195
<system:String x:Key="SearchPrecisionNone">None</system:String>

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818
using Flow.Launcher.Plugin.SharedCommands;
1919
using Flow.Launcher.Plugin.SharedModels;
2020
using Flow.Launcher.ViewModel;
21-
using ModernWpf.Controls;
2221
using DataObject = System.Windows.DataObject;
2322
using Key = System.Windows.Input.Key;
24-
using MouseButtons = System.Windows.Forms.MouseButtons;
25-
using NotifyIcon = System.Windows.Forms.NotifyIcon;
2623

2724
namespace Flow.Launcher
2825
{
@@ -44,11 +41,6 @@ public partial class MainWindow : IDisposable
4441
private readonly Settings _settings;
4542
private readonly Theme _theme;
4643

47-
// Window Notify Icon
48-
private NotifyIcon _notifyIcon;
49-
50-
// Window Context Menu
51-
private readonly ContextMenu _contextMenu = new();
5244
private readonly MainViewModel _viewModel;
5345

5446
// Window Event: Key Event
@@ -128,10 +120,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
128120
_viewModel.Show();
129121
}
130122

131-
// Initialize context menu & notify icon
132-
InitializeContextMenu();
133-
InitializeNotifyIcon();
134-
135123
// Initialize color scheme
136124
if (_settings.ColorScheme == Constant.Light)
137125
{
@@ -198,11 +186,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
198186
_viewModel.QueryTextCursorMovedToEnd = false;
199187
}
200188
break;
201-
case nameof(MainViewModel.GameModeStatus):
202-
_notifyIcon.Icon = _viewModel.GameModeStatus
203-
? Properties.Resources.gamemode
204-
: Properties.Resources.app;
205-
break;
206189
}
207190
};
208191

@@ -211,19 +194,12 @@ private void OnLoaded(object sender, RoutedEventArgs _)
211194
{
212195
switch (e.PropertyName)
213196
{
214-
case nameof(Settings.HideNotifyIcon):
215-
_notifyIcon.Visible = !_settings.HideNotifyIcon;
216-
break;
217197
case nameof(Settings.Language):
218-
UpdateNotifyIconText();
219198
if (_settings.ShowHomePage && _viewModel.QueryResultsSelected() && string.IsNullOrEmpty(_viewModel.QueryText))
220199
{
221200
_viewModel.QueryResults();
222201
}
223202
break;
224-
case nameof(Settings.Hotkey):
225-
UpdateNotifyIconText();
226-
break;
227203
case nameof(Settings.WindowLeft):
228204
Left = _settings.WindowLeft;
229205
break;
@@ -257,7 +233,6 @@ private async void OnClosing(object sender, CancelEventArgs e)
257233
if (!CanClose)
258234
{
259235
CanClose = true;
260-
_notifyIcon.Visible = false;
261236
App.API.SaveAppAllSettings();
262237
e.Cancel = true;
263238
await PluginManager.DisposePluginsAsync();
@@ -535,103 +510,6 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
535510

536511
#endregion
537512

538-
#region Window Notify Icon
539-
540-
private void InitializeNotifyIcon()
541-
{
542-
_notifyIcon = new NotifyIcon
543-
{
544-
Text = Constant.FlowLauncherFullName,
545-
Icon = Constant.Version == "1.0.0" ? Properties.Resources.dev : Properties.Resources.app,
546-
Visible = !_settings.HideNotifyIcon
547-
};
548-
549-
_notifyIcon.MouseClick += (o, e) =>
550-
{
551-
switch (e.Button)
552-
{
553-
case MouseButtons.Left:
554-
_viewModel.ToggleFlowLauncher();
555-
break;
556-
case MouseButtons.Right:
557-
558-
_contextMenu.IsOpen = true;
559-
// Get context menu handle and bring it to the foreground
560-
if (PresentationSource.FromVisual(_contextMenu) is HwndSource hwndSource)
561-
{
562-
Win32Helper.SetForegroundWindow(hwndSource.Handle);
563-
}
564-
565-
_contextMenu.Focus();
566-
break;
567-
}
568-
};
569-
}
570-
571-
private void UpdateNotifyIconText()
572-
{
573-
var menu = _contextMenu;
574-
((MenuItem)menu.Items[0]).Header = App.API.GetTranslation("iconTrayOpen") +
575-
" (" + _settings.Hotkey + ")";
576-
((MenuItem)menu.Items[1]).Header = App.API.GetTranslation("GameMode");
577-
((MenuItem)menu.Items[2]).Header = App.API.GetTranslation("PositionReset");
578-
((MenuItem)menu.Items[3]).Header = App.API.GetTranslation("iconTraySettings");
579-
((MenuItem)menu.Items[4]).Header = App.API.GetTranslation("iconTrayExit");
580-
}
581-
582-
private void InitializeContextMenu()
583-
{
584-
var menu = _contextMenu;
585-
menu.Items.Clear();
586-
var openIcon = new FontIcon { Glyph = "\ue71e" };
587-
var open = new MenuItem
588-
{
589-
Header = App.API.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")",
590-
Icon = openIcon
591-
};
592-
var gamemodeIcon = new FontIcon { Glyph = "\ue7fc" };
593-
var gamemode = new MenuItem
594-
{
595-
Header = App.API.GetTranslation("GameMode"),
596-
Icon = gamemodeIcon
597-
};
598-
var positionresetIcon = new FontIcon { Glyph = "\ue73f" };
599-
var positionreset = new MenuItem
600-
{
601-
Header = App.API.GetTranslation("PositionReset"),
602-
Icon = positionresetIcon
603-
};
604-
var settingsIcon = new FontIcon { Glyph = "\ue713" };
605-
var settings = new MenuItem
606-
{
607-
Header = App.API.GetTranslation("iconTraySettings"),
608-
Icon = settingsIcon
609-
};
610-
var exitIcon = new FontIcon { Glyph = "\ue7e8" };
611-
var exit = new MenuItem
612-
{
613-
Header = App.API.GetTranslation("iconTrayExit"),
614-
Icon = exitIcon
615-
};
616-
617-
open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
618-
gamemode.Click += (o, e) => _viewModel.ToggleGameMode();
619-
positionreset.Click += (o, e) => _ = PositionResetAsync();
620-
settings.Click += (o, e) => App.API.OpenSettingDialog();
621-
exit.Click += (o, e) => Close();
622-
623-
gamemode.ToolTip = App.API.GetTranslation("GameModeToolTip");
624-
positionreset.ToolTip = App.API.GetTranslation("PositionResetToolTip");
625-
626-
_contextMenu.Items.Add(open);
627-
_contextMenu.Items.Add(gamemode);
628-
_contextMenu.Items.Add(positionreset);
629-
_contextMenu.Items.Add(settings);
630-
_contextMenu.Items.Add(exit);
631-
}
632-
633-
#endregion
634-
635513
#region Window Position
636514

637515
private void UpdatePosition()
@@ -914,7 +792,6 @@ protected virtual void Dispose(bool disposing)
914792
if (disposing)
915793
{
916794
_hwndSource?.Dispose();
917-
_notifyIcon?.Dispose();
918795
_viewModel.ActualApplicationThemeChanged -= ViewModel_ActualApplicationThemeChanged;
919796
}
920797

Flow.Launcher/Properties/Resources.Designer.cs

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)