diff --git a/EnvyUpdate/EnvyUpdate.csproj b/EnvyUpdate/EnvyUpdate.csproj index c773f85..d6075f6 100644 --- a/EnvyUpdate/EnvyUpdate.csproj +++ b/EnvyUpdate/EnvyUpdate.csproj @@ -140,7 +140,7 @@ 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 de69848..bdccd02 100644 --- a/EnvyUpdate/MainWindow.xaml.cs +++ b/EnvyUpdate/MainWindow.xaml.cs @@ -1,8 +1,8 @@ using System; -using System.Windows; using System.IO; using System.Net; using System.Text.RegularExpressions; +using System.Windows; using System.Windows.Media; using System.Windows.Threading; @@ -13,20 +13,22 @@ namespace EnvyUpdate /// public partial class MainWindow : Window { - string localDriv = null; - string onlineDriv = null; - readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\"; - readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); - string gpuURL = null; - readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location; - readonly string exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; - readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); - readonly string version = "1.1"; + private string localDriv = null; + private string onlineDriv = null; + private readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\"; + private readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); + private string gpuURL = null; + private readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location; + private readonly string exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; + private readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); + private readonly string version = "1.1"; public MainWindow() { InitializeComponent(); Title += " " + version; + + // Check if EnvyUpdate is already running if (Util.IsInstanceOpen("EnvyUpdate")) { MessageBox.Show("Application is already running."); @@ -37,6 +39,7 @@ namespace EnvyUpdate Directory.CreateDirectory(appdata); } + // Check if application is in Autorun mode and update if (exepath == appdata) { try @@ -102,6 +105,7 @@ namespace EnvyUpdate } } } + private void Load() { FileInfo f = new FileInfo(appdata + "nvidia-update.txt"); @@ -143,6 +147,7 @@ namespace EnvyUpdate Hide(); } } + private void Load(string[] files) { FileInfo f = new FileInfo(files[0]); @@ -184,6 +189,7 @@ namespace EnvyUpdate else textblockOnline.Foreground = Brushes.Green; } + private void buttonDL_Click(object sender, RoutedEventArgs e) { System.Diagnostics.Process.Start(gpuURL); @@ -247,4 +253,4 @@ namespace EnvyUpdate Application.Current.Shutdown(); } } -} +} \ No newline at end of file diff --git a/EnvyUpdate/Notify.cs b/EnvyUpdate/Notify.cs index 4754310..a7c944c 100644 --- a/EnvyUpdate/Notify.cs +++ b/EnvyUpdate/Notify.cs @@ -2,7 +2,7 @@ namespace EnvyUpdate { - class Notify + internal class Notify { public static void ShowDrivUpdatePopup() { @@ -16,4 +16,4 @@ namespace EnvyUpdate }, onClick: Util.ShowMain); } } -} +} \ No newline at end of file diff --git a/EnvyUpdate/StringExt.cs b/EnvyUpdate/StringExt.cs index 7f421b5..fbcd4e0 100644 --- a/EnvyUpdate/StringExt.cs +++ b/EnvyUpdate/StringExt.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace EnvyUpdate +namespace EnvyUpdate { public static class StringExt { @@ -14,4 +8,4 @@ namespace EnvyUpdate return value.Length <= maxLength ? value : value.Substring(0, maxLength); } } -} +} \ No newline at end of file diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index 9a10b15..2edd933 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -1,15 +1,15 @@ -using System; +using IWshRuntimeLibrary; +using System; +using System.Diagnostics; +using System.IO; using System.Linq; using System.Management; -using System.IO; -using IWshRuntimeLibrary; -using System.Diagnostics; -using System.Windows; using System.Net; +using System.Windows; namespace EnvyUpdate { - class Util + internal class Util { /// /// Parses GPU info from a cookie file @@ -35,6 +35,7 @@ namespace EnvyUpdate int lastno = Convert.ToInt32(found.Split().Last()); return lastno; } + /// /// Gets local driver version. /// @@ -68,6 +69,7 @@ namespace EnvyUpdate return null; } } + /// /// Creates a standard Windows shortcut. /// @@ -85,6 +87,7 @@ namespace EnvyUpdate shortcut.TargetPath = targetFileLocation; shortcut.Save(); } + public static bool IsInstanceOpen(string name) { int count = 0; @@ -101,20 +104,23 @@ namespace EnvyUpdate else return false; } + public static void ShowMain() { Application.Current.MainWindow.Show(); Application.Current.MainWindow.WindowState = WindowState.Normal; } + public static string GetNewVer() { string updPath = "https://raw.githubusercontent.com/fyr77/EnvyUpdate/master/res/version.txt"; - System.Net.WebClient wc = new System.Net.WebClient(); + WebClient wc = new WebClient(); string webData = wc.DownloadString(updPath).Truncate(3); return webData; } + /// /// Updates the application by downloading the new version from Github and replacing the old file using a seperate CMD instance. /// @@ -144,4 +150,4 @@ namespace EnvyUpdate Environment.Exit(2); } } -} +} \ No newline at end of file diff --git a/EnvyUpdate/packages.config b/EnvyUpdate/packages.config index 1c2b0dd..9ed1b0a 100644 --- a/EnvyUpdate/packages.config +++ b/EnvyUpdate/packages.config @@ -1,7 +1,7 @@  - + \ No newline at end of file