fix new install handling
This commit is contained in:
parent
6bec92eebc
commit
0bcafdf4a0
2 changed files with 35 additions and 25 deletions
|
@ -6,7 +6,7 @@
|
|||
xmlns:local="clr-namespace:EnvyUpdate"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
mc:Ignorable="d"
|
||||
Title="EnvyUpdate" Height="132.5" Width="463" Icon="icon.ico" ResizeMode="CanMinimize" StateChanged="Window_StateChanged" Closing="Window_Closing">
|
||||
Title="EnvyUpdate" Height="140" Width="463" Icon="icon.ico" ResizeMode="CanMinimize" StateChanged="Window_StateChanged" Closing="Window_Closing">
|
||||
<Grid Margin="0,0,0,6">
|
||||
<tb:TaskbarIcon IconSource="/icon.ico" ToolTipText="EnvyUpdate" TrayLeftMouseDown="TaskbarIcon_TrayLeftMouseDown" />
|
||||
<TextBlock HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontWeight="Bold" Width="151"><Run Text="Local d"/><Run Text="river "/><Run Text="v"/><Run Text="ersion:"/></TextBlock>
|
||||
|
@ -14,7 +14,7 @@
|
|||
<Button x:Name="buttonHelp" Content="?" HorizontalAlignment="Left" Margin="425,11,0,0" VerticalAlignment="Top" Width="20" Click="buttonHelp_Click"/>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="10,31,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontWeight="Bold" Width="151"><Run Text="Online "/><Run Text="d"/><Run Text="river "/><Run Text="v"/><Run Text="ersion:"/></TextBlock>
|
||||
<TextBlock x:Name="textblockOnline" HorizontalAlignment="Left" Margin="166,31,0,0" TextWrapping="Wrap" Text="<none>" VerticalAlignment="Top" RenderTransformOrigin="-0.346,0.564"/>
|
||||
<CheckBox x:Name="chkInstall" Content="Install?" HorizontalAlignment="Left" Margin="10,78,0,0" VerticalAlignment="Top" IsChecked="False" Unchecked="chkInstall_Unchecked" Checked="chkInstall_Checked"/>
|
||||
<CheckBox x:Name="chkInstall" Content="Install" HorizontalAlignment="Left" Margin="10,78,0,0" VerticalAlignment="Top" IsChecked="False" Unchecked="chkInstall_Unchecked" Checked="chkInstall_Checked"/>
|
||||
<Button x:Name="buttonDL" Content="⟱" HorizontalAlignment="Left" Margin="250,10,0,0" VerticalAlignment="Top" Width="37" FontSize="20" Height="37" Click="buttonDL_Click" Foreground="White" Background="#FF3CDA00" Visibility="Hidden"/>
|
||||
<CheckBox x:Name="chkAutostart" Content="Autostart" HorizontalAlignment="Left" Margin="10,58,0,0" VerticalAlignment="Top" IsEnabled="False" Checked="chkAutostart_Checked" Unchecked="chkAutostart_Unchecked"/>
|
||||
</Grid>
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace EnvyUpdate
|
|||
private readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
|
||||
private readonly string version = "2.0";
|
||||
private string argument = null;
|
||||
private bool isDebug = false;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
|
@ -48,6 +49,11 @@ namespace EnvyUpdate
|
|||
MessageBox.Show("Application is already running.");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
// Set correct ticks
|
||||
if (File.Exists(startup + "\\EnvyUpdate.lnk"))
|
||||
chkAutostart.IsChecked = true;
|
||||
if (File.Exists(appdata + "EnvyUpdate.exe"))
|
||||
chkInstall.IsChecked = true;
|
||||
// Check if application is installed and update
|
||||
if (exepath == appdata)
|
||||
{
|
||||
|
@ -64,8 +70,6 @@ namespace EnvyUpdate
|
|||
}
|
||||
// Also set correct ticks.
|
||||
chkInstall.IsChecked = true;
|
||||
if (File.Exists(startup + "\\EnvyUpdate.lnk"))
|
||||
chkAutostart.IsChecked = true;
|
||||
}
|
||||
if (Util.GetLocDriv() != null)
|
||||
{
|
||||
|
@ -78,6 +82,7 @@ namespace EnvyUpdate
|
|||
{
|
||||
case "/ignoregpu":
|
||||
MessageBox.Show("Debug: GPU ignored.");
|
||||
isDebug = true;
|
||||
break;
|
||||
default:
|
||||
MessageBox.Show("No NVIDIA GPU found. Application will exit.");
|
||||
|
@ -112,29 +117,34 @@ namespace EnvyUpdate
|
|||
int osid;
|
||||
//int langid;
|
||||
|
||||
psid = Util.GetIDs("psid");
|
||||
pfid = Util.GetIDs("pfid");
|
||||
osid = Util.GetIDs("osid");
|
||||
gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString(); // + "&lid=" + langid.ToString();
|
||||
WebClient c = new WebClient();
|
||||
gpuURL = c.DownloadString(gpuURL);
|
||||
string pContent = c.DownloadString(gpuURL);
|
||||
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();
|
||||
|
||||
if (localDriv != onlineDriv)
|
||||
// This little bool check is necessary for debug mode on systems without an Nvidia GPU.
|
||||
if (!isDebug)
|
||||
{
|
||||
textblockOnline.Foreground = Brushes.Red;
|
||||
buttonDL.Visibility = Visibility.Visible;
|
||||
Notify.ShowDrivUpdatePopup();
|
||||
psid = Util.GetIDs("psid");
|
||||
pfid = Util.GetIDs("pfid");
|
||||
osid = Util.GetIDs("osid");
|
||||
gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString(); // + "&lid=" + langid.ToString();
|
||||
WebClient c = new WebClient();
|
||||
gpuURL = c.DownloadString(gpuURL);
|
||||
string pContent = c.DownloadString(gpuURL);
|
||||
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();
|
||||
|
||||
if (localDriv != onlineDriv)
|
||||
{
|
||||
textblockOnline.Foreground = Brushes.Red;
|
||||
buttonDL.Visibility = Visibility.Visible;
|
||||
Notify.ShowDrivUpdatePopup();
|
||||
}
|
||||
else
|
||||
textblockOnline.Foreground = Brushes.Green;
|
||||
}
|
||||
else
|
||||
textblockOnline.Foreground = Brushes.Green;
|
||||
|
||||
if (exepath == appdata)
|
||||
{
|
||||
WindowState = WindowState.Minimized;
|
||||
|
|
Reference in a new issue