mirror of
https://github.com/ckaczor/WorkIndicator.git
synced 2026-02-11 10:38:37 -05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 287c008117 | |||
| 42301d5242 | |||
| 3d10cc9635 |
42
App.xaml.cs
42
App.xaml.cs
@@ -3,6 +3,7 @@ using Common.IO;
|
||||
using Common.Wpf.Extensions;
|
||||
using Squirrel;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
@@ -35,6 +36,26 @@ namespace WorkIndicator
|
||||
|
||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||
|
||||
// Create an isolation handle to see if we are already running
|
||||
_isolationHandle = ApplicationIsolation.GetIsolationHandle();
|
||||
|
||||
// If there is another copy then pass it the command line and exit
|
||||
if (_isolationHandle == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
InterprocessMessageSender.SendMessage(Environment.CommandLine);
|
||||
}
|
||||
catch { }
|
||||
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize the command line listener
|
||||
_commandLineListener = new InterprocessMessageListener(Assembly.GetEntryAssembly().GetName().Name);
|
||||
_commandLineListener.MessageReceived += HandleCommandLine;
|
||||
|
||||
// Initialize the tray icon
|
||||
TrayIcon.Initialize();
|
||||
|
||||
@@ -48,21 +69,6 @@ namespace WorkIndicator
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
// Create an isolation handle to see if we are already running
|
||||
_isolationHandle = ApplicationIsolation.GetIsolationHandle();
|
||||
|
||||
// If there is another copy then pass it the command line and exit
|
||||
if (_isolationHandle == null)
|
||||
{
|
||||
InterprocessMessageSender.SendMessage(Environment.CommandLine);
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize the command line listener
|
||||
_commandLineListener = new InterprocessMessageListener(WorkIndicator.Properties.Resources.ApplicationName);
|
||||
_commandLineListener.MessageReceived += HandleCommandLine;
|
||||
|
||||
// Set automatic start into the registry
|
||||
Current.SetStartWithWindows(Settings.Default.StartWithWindows);
|
||||
|
||||
@@ -83,10 +89,12 @@ namespace WorkIndicator
|
||||
|
||||
private void HandleUpdateStatus(UpdateCheck.UpdateStatus status, string message)
|
||||
{
|
||||
if (status != UpdateCheck.UpdateStatus.Downloading)
|
||||
if (status != UpdateCheck.UpdateStatus.Installing)
|
||||
return;
|
||||
|
||||
_dispatcher.Invoke(() => TrayIcon.ShowUpdateMessage(message));
|
||||
|
||||
TrayIcon.Dispose();
|
||||
}
|
||||
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
@@ -98,7 +106,7 @@ namespace WorkIndicator
|
||||
TrayIcon.Dispose();
|
||||
|
||||
// Get rid of the isolation handle
|
||||
_isolationHandle.Dispose();
|
||||
_isolationHandle?.Dispose();
|
||||
|
||||
base.OnExit(e);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace WorkIndicator
|
||||
|
||||
public static void ShowUpdateMessage(string text)
|
||||
{
|
||||
_trayIcon.ShowBalloonTip(250, Resources.ApplicationName, text, ToolTipIcon.None);
|
||||
_trayIcon.ShowBalloonTip(200, Resources.ApplicationName, text, ToolTipIcon.None);
|
||||
}
|
||||
|
||||
static void HandleContextMenuStripOpening(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user