parent
6f386111e8
commit
212dd5958e
2 changed files with 28 additions and 21 deletions
|
@ -11,8 +11,8 @@ Global
|
|||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1BF2468D-9579-462D-9153-4836E9C8721F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1BF2468D-9579-462D-9153-4836E9C8721F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
|
|
|
@ -20,7 +20,8 @@ namespace EnvyUpdate
|
|||
readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
|
||||
string gpuURL = null;
|
||||
readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location;
|
||||
bool isAtStartup = false;
|
||||
readonly string exepath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\";
|
||||
readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
|
@ -30,14 +31,6 @@ namespace EnvyUpdate
|
|||
Directory.CreateDirectory(appdata);
|
||||
}
|
||||
|
||||
// A bit of a hacky way to know if running the autostarted version or the regular one.
|
||||
if (System.AppDomain.CurrentDomain.FriendlyName == "EnvyUpdateInstalled.exe")
|
||||
{
|
||||
WindowState = WindowState.Minimized;
|
||||
Hide();
|
||||
isAtStartup = true;
|
||||
}
|
||||
|
||||
if (Util.GetLocDriv() != null)
|
||||
{
|
||||
localDriv = Util.GetLocDriv();
|
||||
|
@ -112,10 +105,11 @@ namespace EnvyUpdate
|
|||
WebClient c = new WebClient();
|
||||
gpuURL = c.DownloadString(gpuURL);
|
||||
string pContent = c.DownloadString(gpuURL);
|
||||
var pattern = @"\d{3}\.\d{2}";
|
||||
var pattern = @"\d{3}\.\d{2} ";
|
||||
Regex rgx = new Regex(pattern);
|
||||
var matches = rgx.Matches(pContent);
|
||||
onlineDriv = Convert.ToString(matches[0]);
|
||||
onlineDriv = onlineDriv.Remove(onlineDriv.Length - 5);
|
||||
textblockOnline.Text = onlineDriv;
|
||||
c.Dispose();
|
||||
|
||||
|
@ -123,14 +117,17 @@ namespace EnvyUpdate
|
|||
{
|
||||
textblockOnline.Foreground = Brushes.Red;
|
||||
buttonDL.Visibility = Visibility.Visible;
|
||||
if (isAtStartup)
|
||||
{
|
||||
Show();
|
||||
WindowState = WindowState.Normal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
textblockOnline.Foreground = Brushes.Green;
|
||||
//if (System.Reflection.Assembly.GetExecutingAssembly().CodeBase == appdata)
|
||||
//{
|
||||
//WindowState = WindowState.Minimized;
|
||||
//System.Threading.Thread.Sleep(100);
|
||||
//Hide();
|
||||
//}
|
||||
}
|
||||
}
|
||||
private void Load(string[] files)
|
||||
{
|
||||
|
@ -157,10 +154,11 @@ namespace EnvyUpdate
|
|||
WebClient c = new WebClient();
|
||||
gpuURL = c.DownloadString(gpuURL);
|
||||
string pContent = c.DownloadString(gpuURL);
|
||||
var pattern = @"\d{3}\.\d{2}";
|
||||
var pattern = @"\d{3}\.\d{2} ";
|
||||
Regex rgx = new Regex(pattern);
|
||||
var matches = rgx.Matches(pContent);
|
||||
onlineDriv = Convert.ToString(matches[0]);
|
||||
onlineDriv = onlineDriv.Remove(onlineDriv.Length - 5);
|
||||
textblockOnline.Text = onlineDriv;
|
||||
c.Dispose();
|
||||
|
||||
|
@ -210,14 +208,23 @@ namespace EnvyUpdate
|
|||
|
||||
private void chkAutostart_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
File.Copy(exeloc, appdata + "EnvyUpdateInstalled.exe", true);
|
||||
Util.CreateShortcut("EnvyUpdate", startup, appdata + "EnvyUpdateInstalled.exe", "Nvidia Updater Application.");
|
||||
if (exepath != appdata)
|
||||
{
|
||||
File.Copy(exeloc, appdata + "EnvyUpdate.exe", true);
|
||||
Util.CreateShortcut("EnvyUpdate", startup, appdata + "EnvyUpdate.exe", "Nvidia Updater Application.");
|
||||
Util.CreateShortcut("EnvyUpdate", startmenu, appdata + "EnvyUpdate.exe", "Nvidia Updater Application.");
|
||||
}
|
||||
else
|
||||
{
|
||||
chkAutostart.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void chkAutostart_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
File.Delete(appdata + "EnvyUpdateInstalled.exe");
|
||||
File.Delete(appdata + "EnvyUpdate.exe");
|
||||
File.Delete(startup + "\\EnvyUpdate.lnk");
|
||||
File.Delete(startmenu + "\\EnvyUpdate.lnk");
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
|
|
Reference in a new issue