2020-11-23 16:51:05 +01:00
using Flowframes.IO ;
using Flowframes.Properties ;
using System ;
using System.Collections.Generic ;
using System.IO ;
using System.Linq ;
using System.Windows.Forms ;
using Flowframes.Forms ;
2020-12-10 15:19:44 +01:00
using Flowframes.Main ;
2020-11-23 16:51:05 +01:00
namespace Flowframes
{
class Setup
{
public static void Init ( )
{
Console . WriteLine ( "Setup Init()" ) ;
if ( ! InstallIsValid ( ) )
{
Logger . Log ( "No valid installation detected" ) ;
2020-12-10 15:19:44 +01:00
InterpolateUtils . ShowMessage ( $"Some packages are missing!\n\nCheck the log ({Path.GetFileName(Paths.GetDataPath())}/{Path.GetFileName(Paths.GetLogPath())}/{Logger.defaultLogName})." , "Error" ) ;
Application . Exit ( ) ;
//new InstallerForm().ShowDialog();
2020-11-23 16:51:05 +01:00
}
}
public static bool InstallIsValid ( )
{
if ( ! Directory . Exists ( Paths . GetPkgPath ( ) ) )
{
2020-11-26 20:17:18 +01:00
Logger . Log ( "Install invalid - Reason: " + Paths . GetPkgPath ( ) + " does not exist." , true ) ;
2020-11-23 16:51:05 +01:00
return false ;
}
foreach ( FlowPackage pkg in PkgInstaller . packages )
{
// if pkg is required and not installed, return false
2020-11-25 14:04:31 +01:00
if ( pkg . friendlyName . ToLower ( ) . Contains ( "required" ) & & ! PkgUtils . IsInstalled ( pkg ) )
2020-12-10 15:19:44 +01:00
{
2020-12-10 15:37:42 +01:00
Logger . Log ( $"Required package \" { pkg . friendlyName } \ " was not found!" , true ) ;
2020-11-23 16:51:05 +01:00
return false ;
2020-12-10 15:19:44 +01:00
}
2020-11-23 16:51:05 +01:00
}
return true ;
}
}
}