[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/fdorg/flashdevelop/development/FlashDevelop/Program.cs [Back]  [Original]

using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using PluginCore;
using PluginCore.Helpers;
using PluginCore.Utilities;

namespace FlashDevelop
{
    static class Program
    {
        [STAThread]
        static void Main(string[] arguments)
        {
            if (Win32.ShouldUseWin32()) 
            {
                if (SingleInstanceApp.AlreadyExists)
                {
                    if (!MultiInstanceMode || arguments.Contains("-reuse")) SingleInstanceApp.NotifyExistingInstance(arguments);
                    else RunFlashDevelopWithErrorHandling(arguments, false);
                }
                else RunFlashDevelopWithErrorHandling(arguments, true);
            }
            else // For other platforms
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                MainForm.IsFirst = true;
                MainForm.Arguments = arguments;
                Application.Run(new MainForm());
            }
        }

        /// 
        /// Run FlashDevelop and catch any unhandled exceptions.
        /// 
        static void RunFlashDevelopWithErrorHandling(string[] arguments, bool isFirst)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainForm.IsFirst = isFirst;
            MainForm.Arguments = arguments;
            var mainForm = new MainForm();
            SingleInstanceApp.NewInstanceMessage += (_, message) =>
            {
                MainForm.Arguments = message as string[];
                mainForm.ProcessParameters(message as string[]);
            };
            try
            {
                SingleInstanceApp.Initialize();
                Application.Run(mainForm);
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an unexpected problem while running FlashDevelop: " + ex.Message, "Error");
            }
            finally
            {
                SingleInstanceApp.Close();
            }
        }

        /// 
        /// Checks if we should run in multi instance mode.
        /// 
        public static bool MultiInstanceMode => File.Exists(Path.Combine(PathHelper.AppDir, ".multi"));
    }
}

Web Proxy Viewer  |  New URL  |  Original Page