コード例 #1
0
ファイル: Program.cs プロジェクト: Miepee/AM2RLauncher
    public static void Main()
    {
        string launcherDataPath = GenerateCurrentPath();

        // Make sure first, ~/.local/share/AM2RLauncher exists
        if (!Directory.Exists(launcherDataPath))
        {
            Directory.CreateDirectory(launcherDataPath);
        }

        // Now, see if log4netConfig exists, if not write it again.
        if (!File.Exists(launcherDataPath + "/log4net.config"))
        {
            File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath));
        }

        // Configure logger
        XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));

        // if we're on debug, always set loglevel to debug
        #if DEBUG
        ((Logger)log.Logger).Level = log4net.Core.Level.Debug;
        #endif

        // Log distro and version (if it exists)
        if (File.Exists("/etc/os-release"))
        {
            string osRelease = File.ReadAllText("/etc/os-release");
            Regex  lineRegex = new Regex(".*=.*");
            var    results   = lineRegex.Matches(osRelease).ToList();
            var    version   = results.FirstOrDefault(x => x.Value.Contains("VERSION"));
            log.Info("Current Distro: " + results.FirstOrDefault(x => x.Value.Contains("NAME"))?.Value.Substring(5).Replace("\"", "") +
                     (version == null ? "" : " " + version.Value.Substring(8).Replace("\"", "")));
        }
        else
        {
            log.Error("Couldn't determine the currently running distro!");
        }


        try
        {
            Application gtkLauncher = new Application(Eto.Platforms.Gtk);
            LauncherUpdater.Main();
            gtkLauncher.UnhandledException += GTKLauncher_UnhandledException;
            gtkLauncher.Run(new MainForm());
        }
        catch (Exception e)
        {
            log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace);
            Console.WriteLine(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace);
            Console.WriteLine("Check the logs at " + launcherDataPath + " for more info!");
        }
    }
コード例 #2
0
    public static void Main()
    {
        string launcherDataPath = GenerateCurrentPath();

        // Make sure first, that the path exists
        if (!Directory.Exists(launcherDataPath))
        {
            Directory.CreateDirectory(launcherDataPath);
        }

        // Now, see if log4netConfig exists, if not write it again.
        if (!File.Exists(launcherDataPath + "/log4net.config"))
        {
            File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath));
        }

        // Configure logger
        XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));

        // if we're on debug, always set loglevel to debug
        #if DEBUG
        ((Logger)log.Logger).Level = log4net.Core.Level.Debug;
        #endif

        //Log Wine
        if (Core.Core.IsThisRunningFromWine)
        {
            log.Info("Currently running from WINE!");
        }

        // Try catch in case it ever crashes before actually getting to the Eto application
        try
        {
            Application winLauncher = new Application(Eto.Platforms.WinForms);
            LauncherUpdater.Main();
            winLauncher.UnhandledException += WinLauncher_UnhandledException;
            winLauncher.Run(new MainForm());
        }
        catch (Exception e)
        {
            log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace);
            System.Windows.Forms.MessageBox.Show(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace, "Microsoft .NET Framework",
                                                 System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
        }
    }
コード例 #3
0
    public static void Main()
    {
        string launcherDataPath = GenerateCurrentPath();

        // Make sure first, ~/.local/share/AM2RLauncher exists
        if (!Directory.Exists(launcherDataPath))
        {
            Directory.CreateDirectory(launcherDataPath);
        }

        // Now, see if log4netConfig exists, if not write it again.
        if (!File.Exists(launcherDataPath + "/log4net.config"))
        {
            File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath));
        }

        // Configure logger
        XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));

        // if we're on debug, always set loglevel to debug
        #if DEBUG
        ((Logger)log.Logger).Level = log4net.Core.Level.Debug;
        #endif

        try
        {
            Application macLauncher = new Application(Eto.Platforms.Mac64);
            LauncherUpdater.Main();
            macLauncher.UnhandledException += MacLauncher_UnhandledException;
            macLauncher.Run(new MainForm());
        }
        catch (Exception e)
        {
            log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace);
            Console.WriteLine(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace);
            Console.WriteLine("Check the logs at " + launcherDataPath + " for more info!");
        }
    }