working towards 2.0

there is a bug in my gpu detection code somewhere but i don't have an nvidia gpu right now to debug it.
hmm.
This commit is contained in:
fyr77 2020-08-03 19:54:08 +02:00
parent ae4a661959
commit 5f56d07f19
13 changed files with 620 additions and 107 deletions

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Resource.Embedder.2.1.1\build\Resource.Embedder.props" Condition="Exists('..\packages\Resource.Embedder.2.1.1\build\Resource.Embedder.props')" />
<Import Project="..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" /> <Import Project="..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
@ -64,6 +65,8 @@
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll</HintPath> <HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
@ -97,6 +100,11 @@
<DependentUpon>InfoWindow.xaml</DependentUpon> <DependentUpon>InfoWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Notify.cs" /> <Compile Include="Notify.cs" />
<Compile Include="Properties\Resources.de.Designer.cs">
<DependentUpon>Resources.de.resx</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="StringExt.cs" /> <Compile Include="StringExt.cs" />
<Compile Include="Util.cs" /> <Compile Include="Util.cs" />
<Page Include="InfoWindow.xaml"> <Page Include="InfoWindow.xaml">
@ -130,8 +138,12 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<EmbeddedResource Include="Properties\Resources.de.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.de.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<None Include="app.manifest" /> <None Include="app.manifest" />
@ -161,16 +173,15 @@
<EmbedInteropTypes>True</EmbedInteropTypes> <EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference> </COMReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="lang\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<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> <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> </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\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.2.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.2.0\build\Fody.targets'))" /> <Error Condition="!Exists('..\packages\Fody.6.2.4\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.2.4\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Resource.Embedder.2.1.1\build\Resource.Embedder.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Resource.Embedder.2.1.1\build\Resource.Embedder.props'))" />
</Target> </Target>
<Import Project="..\packages\Fody.6.2.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.2.0\build\Fody.targets')" /> <Import Project="..\packages\Fody.6.2.4\build\Fody.targets" Condition="Exists('..\packages\Fody.6.2.4\build\Fody.targets')" />
</Project> </Project>

View file

@ -1,14 +1,18 @@
using System; using System;
using System.Collections.Generic; using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EnvyUpdate namespace EnvyUpdate
{ {
class GlobalVars class GlobalVars
{ {
public static string gpuName = null; public static bool isMobile = false;
public static bool mobile = false; public static readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location;
public static readonly string exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\";
public static readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
public static readonly string version = "2.0";
public static readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\";
public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
public static readonly string desktopOverride = exepath + "desktop.envy";
public static readonly string mobileOverride = exepath + "mobile.envy";
} }
} }

View file

@ -4,10 +4,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:EnvyUpdate" xmlns:local="clr-namespace:EnvyUpdate"
xmlns:p="clr-namespace:EnvyUpdate.Properties"
mc:Ignorable="d" mc:Ignorable="d"
Title="InfoWindow" Height="255" Width="286"> Title="" Height="255" Width="286" ResizeMode="NoResize" WindowStyle="ToolWindow" SizeToContent="WidthAndHeight">
<Grid> <Grid>
<Button Content="How to use this application?" Margin="10,10,10,0" VerticalAlignment="Top" Height="45" Click="Button_Click"/> <Button Content="{x:Static p:Resources.ui_info_website}" Margin="10,10,10,0" VerticalAlignment="Top" Height="20" Click="ButtonWeb_Click"/>
<Label Content="Licenses:" HorizontalAlignment="Left" Margin="10,60,0,0" VerticalAlignment="Top" FontWeight="Bold"/> <Label Content="Licenses:" HorizontalAlignment="Left" Margin="10,60,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
<TextBlock x:Name="textEnvyUpdate" Margin="10,91,10,0" TextWrapping="Wrap" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textEnvyUpdate_MouseDown"><Run Text="EnvyUpdate"/><Run Text=": MIT"/></TextBlock> <TextBlock x:Name="textEnvyUpdate" Margin="10,91,10,0" TextWrapping="Wrap" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textEnvyUpdate_MouseDown"><Run Text="EnvyUpdate"/><Run Text=": MIT"/></TextBlock>
<TextBlock x:Name="textFody" Margin="10,109,10,0" TextWrapping="Wrap" Text="Fody: MIT" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textFody_MouseDown"/> <TextBlock x:Name="textFody" Margin="10,109,10,0" TextWrapping="Wrap" Text="Fody: MIT" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textFody_MouseDown"/>
@ -16,6 +17,7 @@
<TextBlock Margin="10,199,10,0" TextWrapping="Wrap" Text="Icon made by Freepik from www.flaticon.com" Height="18" VerticalAlignment="Top"/> <TextBlock Margin="10,199,10,0" TextWrapping="Wrap" Text="Icon made by Freepik from www.flaticon.com" Height="18" VerticalAlignment="Top"/>
<TextBlock x:Name="textNewtonsoft" Margin="10,181,10,0" TextWrapping="Wrap" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textNewtonsoft_MouseDown"><Run Text="Newtonsoft.Json"/><Run Text=": MIT"/></TextBlock> <TextBlock x:Name="textNewtonsoft" Margin="10,181,10,0" TextWrapping="Wrap" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textNewtonsoft_MouseDown"><Run Text="Newtonsoft.Json"/><Run Text=": MIT"/></TextBlock>
<TextBlock x:Name="textCostura" Margin="10,127,10,0" TextWrapping="Wrap" Text="Costura.Fody: MIT" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textCostura_MouseDown"/> <TextBlock x:Name="textCostura" Margin="10,127,10,0" TextWrapping="Wrap" Text="Costura.Fody: MIT" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textCostura_MouseDown"/>
<CheckBox x:Name="chkMobile" Content="{x:Static p:Resources.ui_info_mobile}" Margin="10,40,10,0" VerticalAlignment="Top" Checked="chkMobile_Checked" Unchecked="chkMobile_Unchecked"/>
</Grid> </Grid>
</Window> </Window>

View file

@ -1,5 +1,7 @@
using System.Windows; using System;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.IO;
namespace EnvyUpdate namespace EnvyUpdate
{ {
@ -8,12 +10,23 @@ namespace EnvyUpdate
/// </summary> /// </summary>
public partial class InfoWindow : Window public partial class InfoWindow : Window
{ {
bool defaultIsMobile = false;
bool isOverride = false;
public InfoWindow() public InfoWindow()
{ {
InitializeComponent(); InitializeComponent();
if (GlobalVars.isMobile)
chkMobile.IsChecked = true;
if (Util.IsMobile())
defaultIsMobile = true;
if (defaultIsMobile != GlobalVars.isMobile)
isOverride = true;
} }
private void Button_Click(object sender, RoutedEventArgs e) private void ButtonWeb_Click(object sender, RoutedEventArgs e)
{ {
System.Diagnostics.Process.Start("https://github.com/fyr77/EnvyUpdate/"); System.Diagnostics.Process.Start("https://github.com/fyr77/EnvyUpdate/");
} }
@ -56,5 +69,62 @@ namespace EnvyUpdate
{ {
System.Diagnostics.Process.Start("https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md"); System.Diagnostics.Process.Start("https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md");
} }
private void chkMobile_Checked(object sender, RoutedEventArgs e)
{
if (isOverride)
{
// If an override was present, delete it.
bool deleteSuccess = false;
while (!deleteSuccess)
{
try
{
File.Delete(GlobalVars.desktopOverride);
deleteSuccess = true;
}
catch (IOException)
{
// This is necessary in case someone ticks and unticks the option quickly, as the File.Create Method has sometimes yet to close the file.
}
}
isOverride = false;
}
else
{
File.Create(GlobalVars.mobileOverride).Close();
GlobalVars.isMobile = true;
isOverride = true;
}
}
private void chkMobile_Unchecked(object sender, RoutedEventArgs e)
{
if (isOverride)
{
// If an override was present, delete it.
bool deleteSuccess = false;
while (!deleteSuccess)
{
try
{
File.Delete(GlobalVars.mobileOverride);
deleteSuccess = true;
}
catch (IOException)
{
// This is necessary in case someone ticks and unticks the option quickly, as the File.Create Method has sometimes yet to close the file.
}
}
isOverride = false;
}
else
{
File.Create(GlobalVars.desktopOverride).Close();
GlobalVars.isMobile = false;
isOverride = true;
}
}
} }
} }

View file

@ -4,18 +4,24 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:EnvyUpdate" xmlns:local="clr-namespace:EnvyUpdate"
xmlns:p="clr-namespace:EnvyUpdate.Properties"
xmlns:tb="http://www.hardcodet.net/taskbar" xmlns:tb="http://www.hardcodet.net/taskbar"
mc:Ignorable="d" mc:Ignorable="d"
Title="EnvyUpdate" Height="140" Width="463" Icon="icon.ico" ResizeMode="CanMinimize" StateChanged="Window_StateChanged" Closing="Window_Closing"> Title="EnvyUpdate" Height="159" Width="290.5" Icon="icon.ico" StateChanged="Window_StateChanged" Closing="Window_Closing" ResizeMode="CanMinimize">
<Grid Margin="0,0,0,6"> <Grid Margin="0,0,0,0">
<tb:TaskbarIcon IconSource="/icon.ico" ToolTipText="EnvyUpdate" TrayLeftMouseDown="TaskbarIcon_TrayLeftMouseDown" /> <Grid.RowDefinitions>
<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> <RowDefinition Height="17*"/>
<TextBlock x:Name="textblockGPU" HorizontalAlignment="Left" Margin="166,10,0,0" TextWrapping="Wrap" Text="&lt;none&gt;" VerticalAlignment="Top" RenderTransformOrigin="-0.346,0.564"/> <RowDefinition Height="86*"/>
<Button x:Name="buttonHelp" Content="?" HorizontalAlignment="Left" Margin="425,11,0,0" VerticalAlignment="Top" Width="20" Click="buttonHelp_Click"/> </Grid.RowDefinitions>
<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> <tb:TaskbarIcon IconSource="/icon.ico" ToolTipText="EnvyUpdate" TrayLeftMouseDown="TaskbarIcon_TrayLeftMouseDown" Grid.RowSpan="3" />
<TextBlock x:Name="textblockOnline" HorizontalAlignment="Left" Margin="166,31,0,0" TextWrapping="Wrap" Text="&lt;none&gt;" VerticalAlignment="Top" RenderTransformOrigin="-0.346,0.564"/> <TextBlock HorizontalAlignment="Left" Margin="10,19,0,0" TextWrapping="Wrap" FontWeight="Bold" Width="151" Height="16" VerticalAlignment="Top" Grid.Row="1"><Run Text="{x:Static p:Resources.ui_localdriver}"/></TextBlock>
<CheckBox x:Name="chkInstall" Content="Install" HorizontalAlignment="Left" Margin="10,78,0,0" VerticalAlignment="Top" IsChecked="False" Unchecked="chkInstall_Unchecked" Checked="chkInstall_Checked"/> <TextBlock x:Name="textblockGPU" HorizontalAlignment="Right" Margin="0,19,10,0" TextWrapping="Wrap" Text="&lt;none&gt;" Width="106" Height="16" VerticalAlignment="Top" TextAlignment="Right" Grid.Row="1"/>
<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"/> <Button x:Name="buttonHelp" Content="..." Margin="0,12,10,0" Click="buttonHelp_Click" HorizontalAlignment="Right" Width="20" Height="20" VerticalAlignment="Top" Grid.RowSpan="2"/>
<CheckBox x:Name="chkAutostart" Content="Autostart" HorizontalAlignment="Left" Margin="10,58,0,0" VerticalAlignment="Top" IsEnabled="False" Checked="chkAutostart_Checked" Unchecked="chkAutostart_Unchecked"/> <TextBlock Margin="10,40,0,0" TextWrapping="Wrap" FontWeight="Bold" Grid.Row="1" HorizontalAlignment="Left" Width="151" Height="16" VerticalAlignment="Top"><Run Text="{x:Static p:Resources.ui_onlinedriver}"/></TextBlock>
<TextBlock x:Name="textblockOnline" HorizontalAlignment="Right" Margin="0,40,10,0" TextWrapping="Wrap" Text="&lt;none&gt;" Width="106" Grid.Row="1" Height="16" VerticalAlignment="Top" TextAlignment="Right"/>
<CheckBox x:Name="chkInstall" Content="{x:Static p:Resources.ui_install}" HorizontalAlignment="Left" Margin="10,83,0,0" IsChecked="False" Unchecked="chkInstall_Unchecked" Checked="chkInstall_Checked" Width="51" Grid.Row="1" Height="16" VerticalAlignment="Top"/>
<Button x:Name="buttonDL" Content="⟱" Margin="0,0,10,10" FontSize="20" Click="buttonDL_Click" Foreground="White" Background="#FF3CDA00" Visibility="Hidden" Grid.Row="1" HorizontalAlignment="Right" Width="30" Height="30" VerticalAlignment="Bottom"/>
<CheckBox x:Name="chkAutostart" Content="{x:Static p:Resources.ui_autostart}" HorizontalAlignment="Left" Margin="10,62,0,0" IsEnabled="False" Checked="chkAutostart_Checked" Unchecked="chkAutostart_Unchecked" Width="69" Grid.Row="1" Height="16" VerticalAlignment="Top"/>
<TextBlock x:Name="textblockGPUName" Margin="10,14,35,0" TextWrapping="Wrap" Text="GPU..." Height="16" VerticalAlignment="Top" TextAlignment="Center" Grid.RowSpan="2" FontWeight="Bold"/>
</Grid> </Grid>
</Window> </Window>

View file

@ -1,5 +1,4 @@
using System; using System;
using System.Globalization;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -16,50 +15,43 @@ namespace EnvyUpdate
{ {
private string localDriv = null; private string localDriv = null;
private string onlineDriv = 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 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 = "2.0";
private string argument = null; private string argument = null;
private bool isDebug = false; private bool isDebug = false;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
Title += " " + version; Title += " " + GlobalVars.version;
// Try to get command line arguments // Try to get command line arguments
try try
{ {
argument = Environment.GetCommandLineArgs()[1]; argument = Environment.GetCommandLineArgs()[1];
Console.WriteLine("Starting in debug mode.");
} }
catch (IndexOutOfRangeException) catch (IndexOutOfRangeException)
{ {
// This is necessary, since .NET throws an exception if you check for a non-existant arg. // This is necessary, since .NET throws an exception if you check for a non-existant arg.
Console.WriteLine("Starting in release mode.");
} }
// Check if EnvyUpdate is already running // Check if EnvyUpdate is already running
if (Util.IsInstanceOpen("EnvyUpdate")) if (Util.IsInstanceOpen("EnvyUpdate"))
{ {
MessageBox.Show("Application is already running."); MessageBox.Show(Properties.Resources.instance_already_running);
Environment.Exit(1); Environment.Exit(1);
} }
// Set correct ticks // Set correct ticks
if (File.Exists(startup + "\\EnvyUpdate.lnk")) if (File.Exists(GlobalVars.startup + "\\EnvyUpdate.lnk"))
chkAutostart.IsChecked = true; chkAutostart.IsChecked = true;
if (File.Exists(appdata + "EnvyUpdate.exe")) if (File.Exists(GlobalVars.appdata + "EnvyUpdate.exe"))
chkInstall.IsChecked = true; chkInstall.IsChecked = true;
// Check if application is installed and update // Check if application is installed and update
if (exepath == appdata) if (GlobalVars.exepath == GlobalVars.appdata)
{ {
try try
{ {
if (Util.GetNewVer() != version) if ((Util.GetNewVer() != GlobalVars.version) && (isDebug = false))
{ {
Util.UpdateApp(); Util.UpdateApp();
} }
@ -71,10 +63,25 @@ namespace EnvyUpdate
// Also set correct ticks. // Also set correct ticks.
chkInstall.IsChecked = true; chkInstall.IsChecked = true;
} }
if (Util.GetLocDriv() != null)
// Check for overrides
if (File.Exists(GlobalVars.desktopOverride))
GlobalVars.isMobile = false;
else if (File.Exists(GlobalVars.mobileOverride))
GlobalVars.isMobile = true;
// Check if mobile, if no override is present
else
GlobalVars.isMobile = Util.IsMobile();
string locDriv = Util.GetLocDriv();
if (locDriv != null)
{ {
localDriv = Util.GetLocDriv(); localDriv = locDriv;
textblockGPU.Text = localDriv; textblockGPU.Text = locDriv;
if (GlobalVars.isMobile)
textblockGPUName.Text = Util.GetGPUName(false) + " (mobile)";
else
textblockGPUName.Text = Util.GetGPUName(false);
} }
else else
{ {
@ -85,7 +92,7 @@ namespace EnvyUpdate
isDebug = true; isDebug = true;
break; break;
default: default:
MessageBox.Show("No NVIDIA GPU found. Application will exit."); MessageBox.Show(Properties.Resources.no_compatible_gpu);
Environment.Exit(255); Environment.Exit(255);
break; break;
} }
@ -93,6 +100,7 @@ namespace EnvyUpdate
DispatcherTimer Dt = new DispatcherTimer(); DispatcherTimer Dt = new DispatcherTimer();
Dt.Tick += new EventHandler(Dt_Tick); Dt.Tick += new EventHandler(Dt_Tick);
// Check for new updates every 5 hours.
Dt.Interval = new TimeSpan(5, 0, 0); Dt.Interval = new TimeSpan(5, 0, 0);
Dt.Start(); Dt.Start();
Load(); Load();
@ -107,7 +115,6 @@ namespace EnvyUpdate
{ {
InfoWindow infoWin = new InfoWindow(); InfoWindow infoWin = new InfoWindow();
infoWin.ShowDialog(); infoWin.ShowDialog();
//System.Diagnostics.Process.Start("https://github.com/fyr77/EnvyUpdate/");
} }
private void Load() private void Load()
@ -145,7 +152,7 @@ namespace EnvyUpdate
textblockOnline.Foreground = Brushes.Green; textblockOnline.Foreground = Brushes.Green;
} }
if (exepath == appdata) if (GlobalVars.exepath == GlobalVars.appdata)
{ {
WindowState = WindowState.Minimized; WindowState = WindowState.Minimized;
Hide(); Hide();
@ -176,47 +183,64 @@ namespace EnvyUpdate
{ {
chkAutostart.IsEnabled = true; chkAutostart.IsEnabled = true;
} }
if (exepath != appdata) if (GlobalVars.exepath != GlobalVars.appdata)
{ {
if (!Directory.Exists(appdata)) if (!Directory.Exists(GlobalVars.appdata))
{ {
Directory.CreateDirectory(appdata); Directory.CreateDirectory(GlobalVars.appdata);
} }
File.Copy(exeloc, appdata + "EnvyUpdate.exe", true); File.Copy(GlobalVars.exeloc, GlobalVars.appdata + "EnvyUpdate.exe", true);
Util.CreateShortcut("EnvyUpdate", startmenu, appdata + "EnvyUpdate.exe", "Nvidia Updater Application.");
if (File.Exists(GlobalVars.mobileOverride))
File.Copy(GlobalVars.mobileOverride, GlobalVars.appdata + "mobile.envy", true);
if (File.Exists(GlobalVars.desktopOverride))
File.Copy(GlobalVars.desktopOverride, GlobalVars.appdata + "desktop.envy", true);
Util.CreateShortcut("EnvyUpdate", GlobalVars.startmenu, GlobalVars.appdata + "EnvyUpdate.exe", Properties.Resources.app_description);
} }
} }
private void chkInstall_Unchecked(object sender, RoutedEventArgs e) private void chkInstall_Unchecked(object sender, RoutedEventArgs e)
{ {
if (chkAutostart != null) // Only uninstall if user confirms. Prevents accidental uninstalls.
if (MessageBox.Show(Properties.Resources.uninstall_confirm, Properties.Resources.uninstall_heading, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
{ {
chkAutostart.IsEnabled = false; if (chkAutostart != null)
chkAutostart.IsChecked = false; {
} chkAutostart.IsEnabled = false;
if (Directory.Exists(appdata)) chkAutostart.IsChecked = false;
{ }
File.Delete(appdata + "EnvyUpdate.exe"); if ((GlobalVars.exepath == GlobalVars.appdata) && File.Exists(GlobalVars.appdata + "EnvyUpdate.exe"))
File.Delete(startup + "\\EnvyUpdate.lnk"); Util.SelfDelete();
File.Delete(startmenu + "\\EnvyUpdate.lnk"); else if (File.Exists(GlobalVars.appdata + "EnvyUpdate.exe"))
File.Delete(GlobalVars.appdata + "EnvyUpdate.exe");
File.Delete(GlobalVars.appdata + "desktop.envy");
File.Delete(GlobalVars.appdata + "mobile.envy");
File.Delete(GlobalVars.startup + "\\EnvyUpdate.lnk");
File.Delete(GlobalVars.startmenu + "\\EnvyUpdate.lnk");
} }
else
chkInstall.IsChecked = true;
} }
private void chkAutostart_Checked(object sender, RoutedEventArgs e) private void chkAutostart_Checked(object sender, RoutedEventArgs e)
{ {
Util.CreateShortcut("EnvyUpdate", startup, appdata + "EnvyUpdate.exe", "Nvidia Updater Application."); Util.CreateShortcut("EnvyUpdate", GlobalVars.startup, GlobalVars.appdata + "EnvyUpdate.exe", Properties.Resources.app_description);
} }
private void chkAutostart_Unchecked(object sender, RoutedEventArgs e) private void chkAutostart_Unchecked(object sender, RoutedEventArgs e)
{ {
File.Delete(startup + "\\EnvyUpdate.lnk"); File.Delete(GlobalVars.startup + "\\EnvyUpdate.lnk");
} }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ {
var window = MessageBox.Show("Exit EnvyUpdate?", "", MessageBoxButton.YesNo); if (MessageBox.Show(Properties.Resources.exit_confirm, "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
e.Cancel = (window == MessageBoxResult.No); Application.Current.Shutdown();
Application.Current.Shutdown(); else
e.Cancel = true;
} }
} }
} }

View file

@ -11,7 +11,7 @@ namespace EnvyUpdate
notificationManager.Show(new NotificationContent notificationManager.Show(new NotificationContent
{ {
Title = "EnvyUpdate", Title = "EnvyUpdate",
Message = "A new driver update is available for your graphics card. Click for more info.", Message = Properties.Resources.update_popup_message,
Type = NotificationType.Information Type = NotificationType.Information
}, onClick: Util.ShowMain); }, onClick: Util.ShowMain);
} }

View file

@ -8,8 +8,8 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace EnvyUpdate.Properties namespace EnvyUpdate.Properties {
{ using System;
/// <summary> /// <summary>
@ -19,31 +19,26 @@ namespace EnvyUpdate.Properties
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources public class Resources {
{
private static global::System.Resources.ResourceManager resourceMan; private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture; private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() internal Resources() {
{
} }
/// <summary> /// <summary>
/// Returns the cached ResourceManager instance used by this class. /// Returns the cached ResourceManager instance used by this class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager public static global::System.Resources.ResourceManager ResourceManager {
{ get {
get if (object.ReferenceEquals(resourceMan, null)) {
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EnvyUpdate.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EnvyUpdate.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
@ -56,16 +51,157 @@ namespace EnvyUpdate.Properties
/// resource lookups using this strongly typed resource class. /// resource lookups using this strongly typed resource class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture public static global::System.Globalization.CultureInfo Culture {
{ get {
get
{
return resourceCulture; return resourceCulture;
} }
set set {
{
resourceCulture = value; resourceCulture = value;
} }
} }
/// <summary>
/// Looks up a localized string similar to NVIDIA Updater Application..
/// </summary>
public static string app_description {
get {
return ResourceManager.GetString("app_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Exit EnvyUpdate?.
/// </summary>
public static string exit_confirm {
get {
return ResourceManager.GetString("exit_confirm", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Preference reset..
/// </summary>
public static string info_reset_caption {
get {
return ResourceManager.GetString("info_reset_caption", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Preference reset.\nEnvyUpdate will ask for computer form factor the next time it is started..
/// </summary>
public static string info_reset_message {
get {
return ResourceManager.GetString("info_reset_message", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Application is already running..
/// </summary>
public static string instance_already_running {
get {
return ResourceManager.GetString("instance_already_running", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to New version of EnvyUpdate found. Application will restart.\nThis will probably take a few seconds..
/// </summary>
public static string message_new_version {
get {
return ResourceManager.GetString("message_new_version", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No NVIDIA GPU found. Application will exit..
/// </summary>
public static string no_compatible_gpu {
get {
return ResourceManager.GetString("no_compatible_gpu", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Autostart.
/// </summary>
public static string ui_autostart {
get {
return ResourceManager.GetString("ui_autostart", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Mobile GPU (Laptop, etc)?.
/// </summary>
public static string ui_info_mobile {
get {
return ResourceManager.GetString("ui_info_mobile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to EnvyUpdate website.
/// </summary>
public static string ui_info_website {
get {
return ResourceManager.GetString("ui_info_website", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Install.
/// </summary>
public static string ui_install {
get {
return ResourceManager.GetString("ui_install", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Local driver version:.
/// </summary>
public static string ui_localdriver {
get {
return ResourceManager.GetString("ui_localdriver", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Online driver version:.
/// </summary>
public static string ui_onlinedriver {
get {
return ResourceManager.GetString("ui_onlinedriver", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Are you sure you want to uninstall EnvyUpdate?.
/// </summary>
public static string uninstall_confirm {
get {
return ResourceManager.GetString("uninstall_confirm", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Uninstall?.
/// </summary>
public static string uninstall_heading {
get {
return ResourceManager.GetString("uninstall_heading", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to A new driver update is available for your graphics card. Click for more info..
/// </summary>
public static string update_popup_message {
get {
return ResourceManager.GetString("update_popup_message", resourceCulture);
}
}
} }
} }

View file

View file

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="app_description" xml:space="preserve">
<value>NVIDIA Aktualisierungsanwendung.</value>
</data>
<data name="exit_confirm" xml:space="preserve">
<value>EnvyUpdate schließen?</value>
</data>
<data name="info_reset_caption" xml:space="preserve">
<value>Einstellung zurückgesetzt.</value>
</data>
<data name="info_reset_message" xml:space="preserve">
<value>Einstellung zurückgesetzt.\nBeim nächsten Start wird EnvyUpdate erneut nach dem Computerformfaktor fragen.</value>
</data>
<data name="instance_already_running" xml:space="preserve">
<value>Anwendung läuft bereits.</value>
</data>
<data name="message_new_version" xml:space="preserve">
<value>Neue Version von EnvyUpdate gefunden. Die Anwendung wird neu starten.\nDies wird wahrscheinlich einige Sekunden dauern.</value>
</data>
<data name="no_compatible_gpu" xml:space="preserve">
<value>Keine NVIDIA GPU gefunden. EnvyUpdate wird sich nun schließen.</value>
</data>
<data name="ui_autostart" xml:space="preserve">
<value>Autostart</value>
</data>
<data name="ui_info_mobile" xml:space="preserve">
<value>Mobile Grafikkarte (Laptop, etc)?</value>
</data>
<data name="ui_info_website" xml:space="preserve">
<value>EnvyUpdate Webseite</value>
</data>
<data name="ui_install" xml:space="preserve">
<value>Installieren</value>
</data>
<data name="ui_localdriver" xml:space="preserve">
<value>Lokale Treiberversion:</value>
</data>
<data name="ui_onlinedriver" xml:space="preserve">
<value>Online Treiberversion:</value>
</data>
<data name="uninstall_confirm" xml:space="preserve">
<value>Sind Sie sich sicher, dass Sie EnvyUpdate deinstallieren wollen?</value>
</data>
<data name="uninstall_heading" xml:space="preserve">
<value>Deinstallieren?</value>
</data>
<data name="update_popup_message" xml:space="preserve">
<value>Eine neue Treiberversion ist verfügbar. Hier klicken für mehr Info.</value>
</data>
</root>

View file

@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
@ -60,6 +60,7 @@
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
@ -68,9 +69,10 @@
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
@ -109,9 +112,57 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="app_description" xml:space="preserve">
<value>NVIDIA Updater Application.</value>
</data>
<data name="exit_confirm" xml:space="preserve">
<value>Exit EnvyUpdate?</value>
</data>
<data name="info_reset_caption" xml:space="preserve">
<value>Preference reset.</value>
</data>
<data name="info_reset_message" xml:space="preserve">
<value>Preference reset.\nEnvyUpdate will ask for computer form factor the next time it is started.</value>
</data>
<data name="instance_already_running" xml:space="preserve">
<value>Application is already running.</value>
</data>
<data name="message_new_version" xml:space="preserve">
<value>New version of EnvyUpdate found. Application will restart.\nThis will probably take a few seconds.</value>
</data>
<data name="no_compatible_gpu" xml:space="preserve">
<value>No NVIDIA GPU found. Application will exit.</value>
</data>
<data name="ui_autostart" xml:space="preserve">
<value>Autostart</value>
</data>
<data name="ui_info_mobile" xml:space="preserve">
<value>Mobile GPU (Laptop, etc)?</value>
</data>
<data name="ui_info_website" xml:space="preserve">
<value>EnvyUpdate website</value>
</data>
<data name="ui_install" xml:space="preserve">
<value>Install</value>
</data>
<data name="ui_localdriver" xml:space="preserve">
<value>Local driver version:</value>
</data>
<data name="ui_onlinedriver" xml:space="preserve">
<value>Online driver version:</value>
</data>
<data name="uninstall_confirm" xml:space="preserve">
<value>Are you sure you want to uninstall EnvyUpdate?</value>
</data>
<data name="uninstall_heading" xml:space="preserve">
<value>Uninstall?</value>
</data>
<data name="update_popup_message" xml:space="preserve">
<value>A new driver update is available for your graphics card. Click for more info.</value>
</data>
</root> </root>

View file

@ -9,6 +9,8 @@ using System.Windows;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Xml; using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
namespace EnvyUpdate namespace EnvyUpdate
{ {
@ -153,11 +155,11 @@ namespace EnvyUpdate
client.DownloadFile("https://github.com/fyr77/EnvyUpdate/releases/latest/download/EnvyUpdate.exe", appdata + "EnvyUpdated.exe"); client.DownloadFile("https://github.com/fyr77/EnvyUpdate/releases/latest/download/EnvyUpdate.exe", appdata + "EnvyUpdated.exe");
} }
MessageBox.Show("New version of EnvyUpdate found. Application will restart.\nThis will probably take a few seconds."); MessageBox.Show(Properties.Resources.message_new_version);
// Replace exe with new one. // Replace exe with new one.
// This starts a seperate cmd process which will wait a bit, then delete EnvyUpdate and rename the previously downloaded EnvyUpdated.exe to EnvyUpdate.exe // This starts a seperate cmd process which will wait a bit, then delete EnvyUpdate and rename the previously downloaded EnvyUpdated.exe to EnvyUpdate.exe
// I know this is a bit dumb, but I honestly couldn't think of a different way to solve this properly, since the Application would need to delete itself. // I know this is a bit dumb, but I honestly couldn't think of a different way to solve this properly, since the Application has to delete itself.
Process process = new Process(); Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo ProcessStartInfo startInfo = new ProcessStartInfo
{ {
@ -171,6 +173,21 @@ namespace EnvyUpdate
Environment.Exit(2); Environment.Exit(2);
} }
public static void SelfDelete()
{
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\";
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
WindowStyle = ProcessWindowStyle.Hidden,
WorkingDirectory = appdata,
FileName = "cmd.exe",
Arguments = "/C timeout 5 && del EnvyUpdate.exe"
};
process.StartInfo = startInfo;
process.Start();
}
public static int GetIDs(string IDtype) public static int GetIDs(string IDtype)
{ {
// TODO: check for 2 occurences of GPU - if yes ask if mobile!!! // TODO: check for 2 occurences of GPU - if yes ask if mobile!!!
@ -196,7 +213,7 @@ namespace EnvyUpdate
} }
} }
XDocument xDoc = XDocument.Parse(xmlcontent); XDocument xDoc = XDocument.Parse(xmlcontent);
string gpuName = GetGPUName(); string gpuName = GetGPUName(true);
switch (IDtype) switch (IDtype)
{ {
@ -266,7 +283,7 @@ namespace EnvyUpdate
value = value1; value = value1;
if (GlobalVars.mobile) if (GlobalVars.isMobile)
{ {
value = value2; value = value2;
} }
@ -317,7 +334,7 @@ namespace EnvyUpdate
/// Returns GPU name in lower case. /// Returns GPU name in lower case.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private static string GetGPUName() public static string GetGPUName(bool lower)
{ {
string GPUName = null; string GPUName = null;
foreach (ManagementObject obj in new ManagementObjectSearcher("SELECT * FROM Win32_VideoController").Get()) foreach (ManagementObject obj in new ManagementObjectSearcher("SELECT * FROM Win32_VideoController").Get())
@ -333,12 +350,35 @@ namespace EnvyUpdate
if (obj["Description"].ToString().ToLower().Contains("nvidia")) if (obj["Description"].ToString().ToLower().Contains("nvidia"))
{ {
// If it's an Nvidia GPU, use VideoProcessor so we don't have to truncate the resulting string. // If it's an Nvidia GPU, use VideoProcessor so we don't have to truncate the resulting string.
GPUName = obj["VideoProcessor"].ToString().ToLower(); if (lower)
{
GPUName = obj["VideoProcessor"].ToString().ToLower();
// Remove any 3GB, 6GB or similar from name. We don't need to know the VRAM to get results.
GPUName = Regex.Replace(GPUName, "\\d+GB", "");
}
else
GPUName = obj["VideoProcessor"].ToString();
break; break;
} }
} }
// This should NEVER return null outside of debugging mode, since EnvyUpdate should refuse to start without and Nvidia GPU. // This should NEVER return null outside of debugging mode, since EnvyUpdate should refuse to start without and Nvidia GPU.
return GPUName; return GPUName;
} }
public static bool IsMobile()
{
bool result = false;
foreach (ManagementObject obj in new ManagementObjectSearcher("SELECT * FROM Win32_Battery").Get())
{
result = true;
}
foreach (ManagementObject obj in new ManagementObjectSearcher("SELECT * FROM Win32_PortableBattery").Get())
{
result = true;
}
return result;
}
} }
} }

View file

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Costura.Fody" version="4.1.0" targetFramework="net472" /> <package id="Costura.Fody" version="4.1.0" targetFramework="net472" />
<package id="Fody" version="6.2.0" targetFramework="net472" developmentDependency="true" /> <package id="Fody" version="6.2.4" targetFramework="net472" developmentDependency="true" />
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.8" targetFramework="net472" /> <package id="Hardcodet.NotifyIcon.Wpf" version="1.0.8" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" /> <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="Notifications.Wpf" version="0.1.1" targetFramework="net472" /> <package id="Notifications.Wpf" version="0.1.1" targetFramework="net472" />
<package id="Resource.Embedder" version="2.1.1" targetFramework="net472" />
</packages> </packages>