cleanup code and update packages

This commit is contained in:
fyr77 2020-05-29 11:21:03 +02:00
parent b7ae273fa3
commit 2b523fa7d4
6 changed files with 38 additions and 32 deletions

View file

@ -140,7 +140,7 @@
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props'))" />
<Error Condition="!Exists('..\packages\Fody.6.0.5\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.0.5\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Fody.6.1.2\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.1.2\build\Fody.targets'))" />
</Target>
<Import Project="..\packages\Fody.6.0.5\build\Fody.targets" Condition="Exists('..\packages\Fody.6.0.5\build\Fody.targets')" />
<Import Project="..\packages\Fody.6.1.2\build\Fody.targets" Condition="Exists('..\packages\Fody.6.1.2\build\Fody.targets')" />
</Project>

View file

@ -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
/// </summary>
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();
}
}
}
}

View file

@ -2,7 +2,7 @@
namespace EnvyUpdate
{
class Notify
internal class Notify
{
public static void ShowDrivUpdatePopup()
{
@ -16,4 +16,4 @@ namespace EnvyUpdate
}, onClick: Util.ShowMain);
}
}
}
}

View file

@ -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);
}
}
}
}

View file

@ -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
{
/// <summary>
/// Parses GPU info from a cookie file
@ -35,6 +35,7 @@ namespace EnvyUpdate
int lastno = Convert.ToInt32(found.Split().Last());
return lastno;
}
/// <summary>
/// Gets local driver version.
/// </summary>
@ -68,6 +69,7 @@ namespace EnvyUpdate
return null;
}
}
/// <summary>
/// Creates a standard Windows shortcut.
/// </summary>
@ -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;
}
/// <summary>
/// Updates the application by downloading the new version from Github and replacing the old file using a seperate CMD instance.
/// </summary>
@ -144,4 +150,4 @@ namespace EnvyUpdate
Environment.Exit(2);
}
}
}
}

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="4.1.0" targetFramework="net472" />
<package id="Fody" version="6.0.5" targetFramework="net472" developmentDependency="true" />
<package id="Fody" version="6.1.2" targetFramework="net472" developmentDependency="true" />
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.8" targetFramework="net472" />
<package id="Notifications.Wpf" version="0.1.1" targetFramework="net472" />
</packages>