You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.5 KiB
67 lines
2.5 KiB
using System ;
|
|
using System.Windows.Forms ;
|
|
using System.IO ;
|
|
using System.Diagnostics ;
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
public static class Program
|
|
{
|
|
public const string APP_NAME = "ASL Charts" ;
|
|
|
|
private static string mBaseDir ;
|
|
private static string mDataDir ;
|
|
private static JsonConfig mAppConfig = null ;
|
|
private static JsonConfig mDebugConfig = null ;
|
|
private static MainForm mMainForm = null ;
|
|
|
|
[STAThread]
|
|
static void Main( string[] args )
|
|
{
|
|
// initialize
|
|
mBaseDir = Application.StartupPath ;
|
|
|
|
// locate the data directory
|
|
mDataDir = System.IO.Path.Combine( mBaseDir , "data" ) ;
|
|
if ( ! Directory.Exists( mDataDir ) ) {
|
|
mDataDir = System.IO.Path.Combine( mBaseDir , "../data" ) ;
|
|
if ( ! Directory.Exists( mDataDir ) )
|
|
mDataDir = mBaseDir ;
|
|
}
|
|
|
|
try {
|
|
|
|
// load the app config
|
|
// NOTE: It would be nice to be able to load the app config from another location, but it seems
|
|
// we need to create a new AppDomain to do this, and it doesn't work with Mono :-/
|
|
mAppConfig = new JsonConfig( "app config", Path.Combine( mDataDir, "config.json" ) ) ;
|
|
|
|
// load the debug config
|
|
mDebugConfig = new JsonConfig( "debug config", Path.Combine( mBaseDir, "debug.json" ) ) ;
|
|
|
|
} catch( Exception ex ) {
|
|
showErrorMsg( "Initialization failed:\n\n" + ex.Message ) ;
|
|
return ;
|
|
}
|
|
|
|
// run the application
|
|
Application.EnableVisualStyles() ;
|
|
Application.SetCompatibleTextRenderingDefault( false ) ;
|
|
mMainForm = new MainForm() ;
|
|
Application.Run( mMainForm ) ;
|
|
}
|
|
|
|
public static void showInfoMsg( string msg ) { MessageBox.Show(msg,APP_NAME,MessageBoxButtons.OK,MessageBoxIcon.Information) ; }
|
|
public static void showWarningMsg( string msg ) { MessageBox.Show(msg,APP_NAME,MessageBoxButtons.OK,MessageBoxIcon.Warning) ; }
|
|
public static void showErrorMsg( string msg ) { MessageBox.Show(msg,APP_NAME,MessageBoxButtons.OK,MessageBoxIcon.Error) ; }
|
|
|
|
public static void logTraceMsg( string msg )
|
|
{
|
|
// log a trace message
|
|
Trace.WriteLine( DateTime.Now.ToString("HH:mm:ss") + " | " + msg ) ;
|
|
}
|
|
|
|
public static JsonConfig appConfig { get { return mAppConfig ; } }
|
|
public static JsonConfig debugConfig { get { return mDebugConfig ; } }
|
|
public static string dataDir { get { return mDataDir ; } }
|
|
}
|
|
|