diff --git a/EnvyUpdate/EnvyUpdate.csproj b/EnvyUpdate/EnvyUpdate.csproj
index 4a0ab73..edcf909 100644
--- a/EnvyUpdate/EnvyUpdate.csproj
+++ b/EnvyUpdate/EnvyUpdate.csproj
@@ -50,6 +50,9 @@
..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll
+
+ ..\packages\Notifications.Wpf.0.1.1\lib\net461\Notifications.Wpf.dll
+
@@ -71,6 +74,7 @@
MSBuild:Compile
Designer
+
MSBuild:Compile
@@ -130,12 +134,12 @@
-
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
+
+
\ No newline at end of file
diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs
index f0a9897..4a5026b 100644
--- a/EnvyUpdate/MainWindow.xaml.cs
+++ b/EnvyUpdate/MainWindow.xaml.cs
@@ -25,10 +25,10 @@ namespace EnvyUpdate
public MainWindow()
{
InitializeComponent();
- if (Util.IsProcessOpen("EnvyUpdate"))
+ if (Util.IsInstanceOpen("EnvyUpdate"))
{
MessageBox.Show("Application is already running.");
- System.Environment.Exit(1);
+ Application.Current.Shutdown(1);
}
if (!Directory.Exists(appdata))
{
@@ -43,7 +43,7 @@ namespace EnvyUpdate
else
{
MessageBox.Show("No NVIDIA GPU found. Application will exit.");
- System.Environment.Exit(255);
+ Application.Current.Shutdown(255);
}
if (File.Exists(appdata + "nvidia-update.txt"))
{
@@ -63,11 +63,6 @@ namespace EnvyUpdate
private void Dt_Tick(object sender, EventArgs e)
{
Load();
- if (textblockOnline.Foreground == Brushes.Red)
- {
- Show();
- WindowState = WindowState.Normal;
- }
}
private void buttonHelp_Click(object sender, RoutedEventArgs e)
@@ -121,15 +116,14 @@ namespace EnvyUpdate
{
textblockOnline.Foreground = Brushes.Red;
buttonDL.Visibility = Visibility.Visible;
+ Notify.ShowUpdatePopup();
}
else
- {
textblockOnline.Foreground = Brushes.Green;
- if (exepath == appdata)
- {
- WindowState = WindowState.Minimized;
- Hide();
- }
+ if (exepath == appdata)
+ {
+ WindowState = WindowState.Minimized;
+ Hide();
}
}
private void Load(string[] files)
@@ -180,8 +174,7 @@ namespace EnvyUpdate
private void TaskbarIcon_TrayLeftMouseDown(object sender, RoutedEventArgs e)
{
- Show();
- WindowState = WindowState.Normal;
+ Util.ShowMain();
}
private void Window_StateChanged(object sender, EventArgs e)
@@ -234,6 +227,7 @@ namespace EnvyUpdate
{
var window = MessageBox.Show("Exit EnvyUpdate?", "", MessageBoxButton.YesNo);
e.Cancel = (window == MessageBoxResult.No);
+ Application.Current.Shutdown();
}
}
}
diff --git a/EnvyUpdate/Notify.cs b/EnvyUpdate/Notify.cs
new file mode 100644
index 0000000..88e4643
--- /dev/null
+++ b/EnvyUpdate/Notify.cs
@@ -0,0 +1,19 @@
+using Notifications.Wpf;
+
+namespace EnvyUpdate
+{
+ class Notify
+ {
+ public static void ShowUpdatePopup()
+ {
+ var notificationManager = new NotificationManager();
+
+ notificationManager.Show(new NotificationContent
+ {
+ Title = "EnvyUpdate",
+ Message = "A new driver update is available for your graphics card. Click for more info.",
+ Type = NotificationType.Information
+ }, onClick: Util.ShowMain);
+ }
+ }
+}
diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs
index 0fa59b8..37bc68c 100644
--- a/EnvyUpdate/Util.cs
+++ b/EnvyUpdate/Util.cs
@@ -4,6 +4,7 @@ using System.Management;
using System.IO;
using IWshRuntimeLibrary;
using System.Diagnostics;
+using System.Windows;
namespace EnvyUpdate
{
@@ -83,17 +84,26 @@ namespace EnvyUpdate
shortcut.TargetPath = targetFileLocation;
shortcut.Save();
}
- public static bool IsProcessOpen(string name)
+ public static bool IsInstanceOpen(string name)
{
+ int count = 0;
foreach (Process clsProcess in Process.GetProcesses())
{
if (clsProcess.ProcessName.Contains(name))
{
- return true;
+ count++;
}
}
- return false;
+ if (count > 1)
+ return true;
+ else
+ return false;
+ }
+ public static void ShowMain()
+ {
+ Application.Current.MainWindow.Show();
+ Application.Current.MainWindow.WindowState = WindowState.Normal;
}
}
}
diff --git a/EnvyUpdate/packages.config b/EnvyUpdate/packages.config
index 68a097f..1c2b0dd 100644
--- a/EnvyUpdate/packages.config
+++ b/EnvyUpdate/packages.config
@@ -1,6 +1,7 @@
-
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index c9c3489..f385068 100644
--- a/README.md
+++ b/README.md
@@ -18,15 +18,11 @@ Simply download the latest release from the [releases page](https://github.com/f
## Compatibility
-The application is compatible with all Nvidia GPUs that have their drivers available on the nvidia.com download page.
-
-## Branches
-
-* The main `master` branch requires Windows 10 because of the way it sends notifications.
-* The `compat` branch does not use notifications, opening the main window instead. This is compatible with Windows 7 and up.
+The application is compatible with all Nvidia GPUs that have their drivers available on the nvidia.com download page and runs on Windows 7 and up.
## Licenses
* This project: [MIT](https://github.com/fyr77/EnvyUpdate/blob/master/LICENSE)
* Fody (for embedding DLLs into the main executable): [MIT](https://github.com/Fody/Fody/blob/master/License.txt)
* wpf-notifyicon (for showing an icon in the system tray): [CPOL](https://github.com/hardcodet/wpf-notifyicon/blob/master/LICENSE)
+* Notifications.Wpf [MIT](https://github.com/Federerer/Notifications.Wpf/blob/master/LICENSE)