-
-
Notifications
You must be signed in to change notification settings - Fork 447
Display notify icon before loading plugins #3672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
25c56f9
8a96103
c862284
da88fa4
736d96e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.VisualStudio.Threading; | ||
using NotifyIcon = System.Windows.Forms.NotifyIcon; | ||
|
||
namespace Flow.Launcher | ||
{ | ||
|
@@ -32,6 +33,7 @@ | |
#region Public Properties | ||
|
||
public static IPublicAPI API { get; private set; } | ||
public static NotifyIcon NotifyIcon { get; private set; } | ||
public static bool LoadingOrExiting => _mainWindow == null || _mainWindow.CanClose; | ||
|
||
#endregion | ||
|
@@ -103,9 +105,9 @@ | |
// Initialize the public API and Settings first | ||
try | ||
{ | ||
API = Ioc.Default.GetRequiredService<IPublicAPI>(); | ||
_settings.Initialize(); | ||
_mainVM = Ioc.Default.GetRequiredService<MainViewModel>(); | ||
} | ||
catch (Exception e) | ||
{ | ||
|
@@ -154,6 +156,20 @@ | |
|
||
#endregion | ||
|
||
#region Notify Icon | ||
|
||
private static void InitializeNotifyIcon() | ||
{ | ||
NotifyIcon = new NotifyIcon | ||
{ | ||
Text = Constant.FlowLauncherFullName, | ||
Icon = Constant.Version == "1.0.0" ? Launcher.Properties.Resources.dev : Launcher.Properties.Resources.app, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to not have this hardcoded? I am wary when moving to v2.0.0+ we need to bump this dev version too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have not changed the original codes here. And I cannot think a better to do this. Dev branch version should be 1.0.0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah ok. I think it's more consistent if we raise this from 1.0.0 to 2.0.0. we can do this in separate PR. |
||
Visible = !_settings.HideNotifyIcon | ||
}; | ||
} | ||
|
||
#endregion | ||
|
||
#region Fail Fast | ||
|
||
private static void ShowErrorMsgBoxAndFailFast(string message, Exception e) | ||
|
@@ -188,7 +204,7 @@ | |
|
||
Notification.Install(); | ||
|
||
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate(); | ||
|
||
API.LogInfo(ClassName, "Begin Flow Launcher startup ----------------------------------------------------"); | ||
API.LogInfo(ClassName, $"Runtime info:{ErrorReporting.RuntimeInfo()}"); | ||
|
@@ -197,6 +213,9 @@ | |
RegisterDispatcherUnhandledException(); | ||
RegisterTaskSchedulerUnhandledException(); | ||
|
||
// Display notify icon before loading plugins to tell users that Flow is loading | ||
InitializeNotifyIcon(); | ||
|
||
var imageLoadertask = ImageLoader.InitializeAsync(); | ||
|
||
AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings); | ||
|
@@ -204,7 +223,7 @@ | |
PluginManager.LoadPlugins(_settings.PluginSettings); | ||
|
||
// Register ResultsUpdated event after all plugins are loaded | ||
Ioc.Default.GetRequiredService<MainViewModel>().RegisterResultsUpdatedEvent(); | ||
|
||
Http.Proxy = _settings.Proxy; | ||
|
||
|
@@ -213,7 +232,7 @@ | |
// Change language after all plugins are initialized because we need to update plugin title based on their api | ||
await Ioc.Default.GetRequiredService<Internationalization>().InitializeLanguageAsync(); | ||
|
||
await imageLoadertask; | ||
|
||
_mainWindow = new MainWindow(); | ||
|
||
|
@@ -239,7 +258,7 @@ | |
}); | ||
} | ||
|
||
#pragma warning restore VSTHRD100 // Avoid async void methods | ||
|
||
/// <summary> | ||
/// Check startup only for Release | ||
|
@@ -370,6 +389,13 @@ | |
|
||
if (disposing) | ||
{ | ||
// Dispose notify icon first to prevent it from showing balloon tip after main window is closed | ||
if (NotifyIcon != null) | ||
{ | ||
NotifyIcon.Visible = false; | ||
NotifyIcon.Dispose(); | ||
} | ||
|
||
// Dispose needs to be called on the main Windows thread, | ||
// since some resources owned by the thread need to be disposed. | ||
_mainWindow?.Dispatcher.Invoke(_mainWindow.Dispose); | ||
|
Uh oh!
There was an error while loading. Please reload this page.