prepare for portable-install split
This commit is contained in:
parent
b54de3eb36
commit
af089f732b
5 changed files with 8 additions and 161 deletions
|
@ -9,7 +9,6 @@ namespace EnvyUpdate
|
|||
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 float version = 2.8F;
|
||||
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";
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
<TextBlock Margin="10,230,10,0" TextWrapping="Wrap" Text="Icon made by Freepik from www.flaticon.com" Height="18" VerticalAlignment="Top"/>
|
||||
<TextBlock x:Name="textNewtonsoft" Margin="10,194,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,140,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"/>
|
||||
<TextBlock x:Name="textResourceEmbedder" Margin="10,212,10,0" TextWrapping="Wrap" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textResourceEmbedder_MouseDown"><Run Text="Resource Embedder"/><Run Text=": MIT"/></TextBlock>
|
||||
<CheckBox x:Name="chkDCH" Content="{x:Static p:Resources.ui_info_dch}" Margin="10,60,10,0" VerticalAlignment="Top" IsEnabled="False"/>
|
||||
<Label x:Name="labelVer" Content="EnvyUpdate" HorizontalAlignment="Left" Margin="10,47,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
@ -10,21 +10,15 @@ namespace EnvyUpdate
|
|||
/// </summary>
|
||||
public partial class InfoWindow : Window
|
||||
{
|
||||
bool defaultIsMobile = false;
|
||||
bool isOverride = false;
|
||||
public InfoWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (GlobalVars.isMobile)
|
||||
chkMobile.IsChecked = true;
|
||||
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
string version = fvi.FileVersion;
|
||||
|
||||
defaultIsMobile = Util.IsMobile();
|
||||
|
||||
if (defaultIsMobile != GlobalVars.isMobile)
|
||||
isOverride = true;
|
||||
|
||||
chkDCH.IsChecked = Util.IsDCH();
|
||||
labelVer.Content += " " + version;
|
||||
}
|
||||
|
||||
private void ButtonWeb_Click(object sender, RoutedEventArgs e)
|
||||
|
@ -74,62 +68,5 @@ namespace EnvyUpdate
|
|||
{
|
||||
System.Diagnostics.Process.Start("https://github.com/MarcStan/resource-embedder/blob/master/LICENSE");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace EnvyUpdate
|
|||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Title += " " + GlobalVars.version;
|
||||
|
||||
// Try to get command line arguments
|
||||
try
|
||||
|
@ -41,35 +40,8 @@ namespace EnvyUpdate
|
|||
MessageBox.Show(Properties.Resources.instance_already_running);
|
||||
Environment.Exit(1);
|
||||
}
|
||||
// Set correct ticks
|
||||
/*
|
||||
if (File.Exists(GlobalVars.startup + "\\EnvyUpdate.lnk"))
|
||||
chkAutostart.IsChecked = true;
|
||||
if (File.Exists(GlobalVars.appdata + "EnvyUpdate.exe"))
|
||||
chkInstall.IsChecked = true;*/
|
||||
//ALSO BROKEN
|
||||
|
||||
// Check if application is installed and update
|
||||
/*
|
||||
if (GlobalVars.exepath == GlobalVars.appdata)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Util.GetNewVer() > GlobalVars.version)
|
||||
{
|
||||
Util.UpdateApp();
|
||||
}
|
||||
}
|
||||
catch (WebException)
|
||||
{
|
||||
// Silently fail.
|
||||
}
|
||||
// Also set correct ticks.
|
||||
chkInstall.IsChecked = true;
|
||||
}*/
|
||||
//BROKEN
|
||||
|
||||
// Delete installed versions
|
||||
// Delete installed legacy versions
|
||||
UninstallAll();
|
||||
|
||||
// Check for overrides
|
||||
|
@ -196,66 +168,6 @@ namespace EnvyUpdate
|
|||
}
|
||||
}
|
||||
|
||||
/*private void chkInstall_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (chkAutostart != null)
|
||||
{
|
||||
chkAutostart.IsEnabled = true;
|
||||
}
|
||||
if (GlobalVars.exepath != GlobalVars.appdata)
|
||||
{
|
||||
if (!Directory.Exists(GlobalVars.appdata))
|
||||
{
|
||||
Directory.CreateDirectory(GlobalVars.appdata);
|
||||
}
|
||||
File.Copy(GlobalVars.exeloc, GlobalVars.appdata + "EnvyUpdate.exe", true);
|
||||
|
||||
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)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
if (chkAutostart != null)
|
||||
{
|
||||
chkAutostart.IsEnabled = false;
|
||||
chkAutostart.IsChecked = false;
|
||||
}
|
||||
|
||||
File.Delete(GlobalVars.appdata + "desktop.envy");
|
||||
File.Delete(GlobalVars.appdata + "mobile.envy");
|
||||
|
||||
File.Delete(GlobalVars.startup + "\\EnvyUpdate.lnk");
|
||||
File.Delete(GlobalVars.startmenu + "\\EnvyUpdate.lnk");
|
||||
|
||||
if ((GlobalVars.exepath == GlobalVars.appdata) && File.Exists(GlobalVars.appdata + "EnvyUpdate.exe"))
|
||||
Util.SelfDelete();
|
||||
else if (File.Exists(GlobalVars.appdata + "EnvyUpdate.exe"))
|
||||
File.Delete(GlobalVars.appdata + "EnvyUpdate.exe");
|
||||
}
|
||||
else
|
||||
chkInstall.IsChecked = true;
|
||||
}
|
||||
|
||||
private void chkAutostart_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Util.CreateShortcut("EnvyUpdate", GlobalVars.startup, GlobalVars.appdata + "EnvyUpdate.exe", Properties.Resources.app_description);
|
||||
}
|
||||
|
||||
private void chkAutostart_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
File.Delete(GlobalVars.startup + "\\EnvyUpdate.lnk");
|
||||
}
|
||||
*/
|
||||
|
||||
public void UninstallAll()
|
||||
{
|
||||
if (File.Exists(GlobalVars.startup + "\\EnvyUpdate.lnk"))
|
||||
|
|
|
@ -49,5 +49,5 @@ using System.Windows;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.8")]
|
||||
[assembly: AssemblyFileVersion("2.8")]
|
||||
[assembly: AssemblyVersion("2.9.0")]
|
||||
[assembly: AssemblyFileVersion("2.9.0")]
|
||||
|
|
Reference in a new issue