示例#1
0
        public static void Initialize()
        {
            if (initialized)
            {
                return;
            }

            initialized = true;

            try
            {
                var platform = Platform.Instance;
                if (platform == null)
                {
                    platform = new Eto.Mac.Platform();
                    Platform.Initialize(platform);
                }

                platform.LoadAssembly(typeof(EtoInitializer).Assembly);

                if (Application.Instance == null)
                {
                    new Eto.Forms.Application().Attach();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex}");
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            Toolkit opentk = Core.InitOpenTK();

            Platform platform = new Eto.Mac.Platform();

            platform.Add <GLSurface.IHandler>(() => new MacGLSurfaceHandler());

            Style.Add <View>(
                "hidecursor",
                view =>
            {
                CG.DisplayHideCursor((CGDirectDisplayID)0);
                CG.AssociateMouseAndMouseCursorPosition(false);
            });

            Style.Add <View>(
                "showcursor",
                view =>
            {
                CG.AssociateMouseAndMouseCursorPosition(true);
                CG.DisplayShowCursor((CGDirectDisplayID)0);
            });

            var application = new Application(platform);

            application.UnhandledException += Core.UnhandledExceptionHandler;

            using (opentk)
            {
                application.Run(new MainForm());
            }
        }
示例#3
0
        public static void Main(string[] args)
        {
            var platform = new Eto.Mac.Platform();

            //platform.Add<GLSurface.IHandler>(() => new MacGLSurfaceHandler());
            new Application(platform).Run(new MainForm());
        }
示例#4
0
        static void Main(string[] args)
        {
            var platform = new Eto.Mac.Platform();

            var app = new MainApplication(platform);

            app.Run(args);
        }
示例#5
0
        public static void Main(string[] args)
        {
            var platform = new Eto.Mac.Platform();

            platform.Add <CustomEtoButton.IHandler>(() => new CustomEtoButtonHandler());

            new Application(platform).Run(new Main());
        }
示例#6
0
        public static void Main(string[] args)
        {
            var gen = new Eto.Mac.Platform();

            gen.Add <GLSurface.IHandler> (() => new MacGLSurfaceHandler());

            // run application with our main form
            new Application(gen).Run(new MainForm());
        }
示例#7
0
        static void Main()
        {
            // set renderers

            string WinR, LinuxR, MacR;

            WinR   = "WinForms"; // WPF, WinForms, GTK
            LinuxR = "GTK";      // GTK, WinForms
            MacR   = "XamMac2";  // XamMac, WinForms, GTK

            Eto.Platform platform = null;

            if (RunningPlatform() == Platform.Windows)
            {
                switch (WinR)
                {
                case "WinForms":
                    platform = new Eto.WinForms.Platform();
                    platform.Add <ScintillaControl.IScintillaControl>(() => new WinForms.ScintillaControlHandler());
                    break;
                }
            }
            else if (RunningPlatform() == Platform.Linux)
            {
                switch (LinuxR)
                {
                case "WinForms":
                    platform = new Eto.WinForms.Platform();
                    platform.Add <ScintillaControl.IScintillaControl>(() => new WinForms.ScintillaControlHandler());
                    break;

                case "GTK":
                    platform = new Eto.GtkSharp.Platform();
                    platform.Add <ScintillaControl.IScintillaControl>(() => new GTK.ScintillaControlHandler());
                    break;
                }
            }
            else if (RunningPlatform() == Platform.Mac)
            {
                switch (MacR)
                {
                case "XamMac2":
                    platform = new Eto.Mac.Platform();
                    platform.Add <ScintillaControl.IScintillaControl>(() => new Mac.ScintillaControlHandler());
                    break;
                }
            }

            // test control

            new Application(platform).Run(new TestForm());
        }
示例#8
0
        public static void Main(string[] args)
        {
            //VeldridSurface.InitializeOpenTK();

            var platform = new Eto.Mac.Platform();

            // FIXME: This seems to be necessary in order for Mac Release builds
            // to run when double-clicked from Finder. Running the executable
            // from a Terminal works without this. I suspect it has something to
            // do with the use of mkbundle, and whatever effect that has on
            // loading handlers exported from assemblies with Eto.ExportHandler.
            platform.Add <VeldridSurface.IHandler>(() => new Eto.Veldrid.Mac.MacVeldridSurfaceHandler());

            new Application(platform).Run(new MainForm());
        }
示例#9
0
        static void Main(string[] args)
        {
            var mac   = new Eto.Mac.Platform();
            var forms = new EtoFormsPlatform(mac);

            Forms.Init(forms, TargetIdiom.Desktop);
            var window = new Form {
                Size = new Eto.Drawing.Size(800, 600)
            };

            window.Menu = new MenuBar();
            forms.Run(
                window,
                new App()
                );
        }
示例#10
0
文件: Program.cs 项目: junian/termqtt
        static void Main(string[] args)
        {
            var platform = new Eto.Mac.Platform();

            // Register custom UI handlers
            RegisterUIHandlers(platform);

            // Configure custom platform-specific styles
            ConfigureStyles();

            var app = new MainApplication(platform);

            // Register services after MainApplication
            RegisterServices();

            app.Run(args);
        }
示例#11
0
        static void Main(string[] args)
        {
            var platform = new Eto.Mac.Platform();             // mac platform

            // Allow user customization on macOS toolbars
            Eto.Style.Add <ToolBarHandler>("NativeToolbar", handler => {
                var toolbar = handler.Control;
                toolbar.AllowsUserCustomization = true;
                toolbar.AutosavesConfiguration  = true;
            });

            // Allow app to become fullscreen
            Eto.Style.Add <ApplicationHandler>("Application", handler => {
                handler.EnableFullScreen();
            });

            new Application(platform).Run(new MainForm());
        }
示例#12
0
        public static void Main(string[] args)
        {
            VeldridSurface.InitializeOpenTK();

            var platform = new Eto.Mac.Platform();

            // FIXME: This seems to be necessary in order for Mac Release builds
            // to run when double-clicked from Finder. Running the executable
            // from a Terminal works without this. I suspect it has something to
            // do with the use of mkbundle, and whatever effect that has on
            // loading handlers exported from assemblies with Eto.ExportHandler.
            platform.Add <VeldridSurface.IHandler>(() => new Eto.Veldrid.Mac.MacVeldridSurfaceHandler());

            // AppContext.BaseDirectory is too simple for the case of the Mac
            // projects. When building an app bundle that depends on the Mono
            // framework being installed, it properly returns the path of the
            // executable in Eto.Veldrid.app/Contents/MacOS. When building an
            // app bundle that instead bundles Mono by way of mkbundle, on the
            // other hand, it returns the directory containing the .app..
            new Application(platform).Run(new MainForm(
                                              Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName),
                                              Path.Combine("..", "Resources", "shaders")));
        }
示例#13
0
        public static void Main(string[] args)
        {
            //initialize OpenTK

            OpenTK.Toolkit.Init();

            // set global settings

            Settings.CultureInfo         = "en";
            Settings.EnableGPUProcessing = false;
            Settings.OldUI = false;

            Exception loadsetex = null;

            try
            {
                Settings.LoadSettings("dwsim_newui.ini");
            }
            catch (Exception ex)
            {
                loadsetex = ex;
            }

            if (GlobalSettings.Settings.EnableGPUProcessing)
            {
                // initialize gpu if enabled
                try
                {
                    //set CUDA params
                    CudafyModes.Compiler = eGPUCompiler.All;
                    CudafyModes.Target   = (eGPUType)Settings.CudafyTarget;
                    Cudafy.Translator.CudafyTranslator.GenerateDebug = false;
                    DWSIM.Thermodynamics.Calculator.InitComputeDevice();
                    Console.WriteLine("GPU initialized successfully: " + Settings.SelectedGPU + "(" + CudafyModes.Target.ToString() + ")");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("GPU initialization failed: " + ex.ToString());
                    var ex1 = ex;
                    while (ex1.InnerException != null)
                    {
                        Console.WriteLine("GPU initialization failed (IEX): " + ex1.InnerException.ToString());
                        if (ex1.InnerException is ReflectionTypeLoadException)
                        {
                            foreach (var tlex in ((ReflectionTypeLoadException)(ex1.InnerException)).LoaderExceptions)
                            {
                                Console.WriteLine("GPU initialization failed (TLEX): " + tlex.Message);
                            }
                        }
                        ex1 = ex1.InnerException;
                    }
                }
            }

            Eto.Platform platform = null;

            try
            {
                if (Settings.RunningPlatform() == Settings.Platform.Windows)
                {
                    switch (GlobalSettings.Settings.WindowsRenderer)
                    {
                    case Settings.WindowsPlatformRenderer.WinForms:
                        DWSIM.UI.Desktop.WinForms.StyleSetter.SetStyles();
                        platform = new Eto.WinForms.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new WinForms.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new WinForms.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.WinForms.PlotHandler());
                        platform.Add <Eto.Forms.Controls.Scintilla.Shared.ScintillaControl.IScintillaControl>(() => new Eto.Forms.Controls.Scintilla.WinForms.ScintillaControlHandler());
                        break;

                    case Settings.WindowsPlatformRenderer.WPF:
                        DWSIM.UI.Desktop.WPF.StyleSetter.SetTheme("aero", "normalcolor");
                        DWSIM.UI.Desktop.WPF.StyleSetter.SetStyles();
                        platform = new Eto.Wpf.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new WPF.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new WPF.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.WPF.PlotHandler());
                        platform.Add <Eto.Forms.Controls.Scintilla.Shared.ScintillaControl.IScintillaControl>(() => new Eto.Forms.Controls.Scintilla.WPF.ScintillaControlHandler());
                        break;

                    case Settings.WindowsPlatformRenderer.Gtk2:
                        DWSIM.UI.Desktop.GTK.StyleSetter.SetStyles();
                        platform = new Eto.GtkSharp.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new GTK.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new GTK.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.Gtk.PlotHandler());
                        platform.Add <Eto.Forms.Controls.Scintilla.Shared.ScintillaControl.IScintillaControl>(() => new Eto.Forms.Controls.Scintilla.GTK.ScintillaControlHandler());
                        break;
                    }
                    new Application(platform).Run(new MainForm());
                }
                else if (Settings.RunningPlatform() == Settings.Platform.Linux)
                {
                    switch (GlobalSettings.Settings.LinuxRenderer)
                    {
                    case Settings.LinuxPlatformRenderer.Gtk2:
                        DWSIM.UI.Desktop.GTK.StyleSetter.SetStyles();
                        platform = new Eto.GtkSharp.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new GTK.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new GTK.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.Gtk.PlotHandler());
                        platform.Add <Eto.Forms.Controls.Scintilla.Shared.ScintillaControl.IScintillaControl>(() => new Eto.Forms.Controls.Scintilla.GTK.ScintillaControlHandler());
                        break;

                    case Settings.LinuxPlatformRenderer.WinForms:
                        DWSIM.UI.Desktop.WinForms.StyleSetter.SetStyles();
                        platform = new Eto.WinForms.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new WinForms.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new WinForms.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.WinForms.PlotHandler());
                        platform.Add <Eto.Forms.Controls.Scintilla.Shared.ScintillaControl.IScintillaControl>(() => new Eto.Forms.Controls.Scintilla.WinForms.ScintillaControlHandler());
                        break;
                    }
                    new Application(platform).Run(new MainForm());
                }
                else if (Settings.RunningPlatform() == Settings.Platform.Mac)
                {
                    switch (GlobalSettings.Settings.MacOSRenderer)
                    {
                    case Settings.MacOSPlatformRenderer.MonoMac:
                        DWSIM.UI.Desktop.Mac.StyleSetter.SetStyles();
                        platform = new Eto.Mac.Platform();
                        DWSIM.UI.Desktop.Mac.StyleSetter.BeginLaunching();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new Mac.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new Mac.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Mac.PlotHandler());
                        platform.Add <Eto.Forms.Controls.Scintilla.Shared.ScintillaControl.IScintillaControl>(() => new Eto.Forms.Controls.Scintilla.Mac.ScintillaControlHandler());
                        break;

                    case Settings.MacOSPlatformRenderer.Gtk2:
                        DWSIM.UI.Desktop.GTK.StyleSetter.SetStyles();
                        platform = new Eto.GtkSharp.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new GTK.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new GTK.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.Gtk.PlotHandler());
                        platform.Add <Eto.Forms.Controls.Scintilla.Shared.ScintillaControl.IScintillaControl>(() => new Eto.Forms.Controls.Scintilla.GTK.ScintillaControlHandler());
                        break;

                    case Settings.MacOSPlatformRenderer.WinForms:
                        DWSIM.UI.Desktop.WinForms.StyleSetter.SetStyles();
                        platform = new Eto.WinForms.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new WinForms.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new WinForms.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.WinForms.PlotHandler());
                        platform.Add <Eto.Forms.Controls.Scintilla.Shared.ScintillaControl.IScintillaControl>(() => new Eto.Forms.Controls.Scintilla.WinForms.ScintillaControlHandler());
                        break;
                    }
                    var app = new Application(platform);
                    app.Initialized += (sender, e) =>
                    {
                        if (GlobalSettings.Settings.RunningPlatform() == Settings.Platform.Mac)
                        {
                            if (GlobalSettings.Settings.MacOSRenderer == Settings.MacOSPlatformRenderer.MonoMac)
                            {
                                DWSIM.UI.Desktop.Mac.StyleSetter.FinishedLaunching();
                            }
                        }
                        if (loadsetex != null)
                        {
                            MessageBox.Show("Error loading settings from file: " + loadsetex.Message + "\nPlease fix or remove the 'dwsim_newui.ini' from the 'Documents/DWSIM Application Data' folder and try again.", "Error", MessageBoxType.Error);
                        }
                    };
                    app.Run(new MainForm());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("APP CRASH!!!");
                Console.WriteLine();
                Console.WriteLine(ex.ToString());
                string configfiledir = "";
                if (GlobalSettings.Settings.RunningPlatform() == Settings.Platform.Mac)
                {
                    configfiledir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Documents", "DWSIM Application Data");
                }
                else
                {
                    configfiledir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "DWSIM Application Data");
                }
                if (!Directory.Exists(configfiledir))
                {
                    Directory.CreateDirectory(configfiledir);
                }
                File.WriteAllText(System.IO.Path.Combine(configfiledir, "lasterror.txt"), "Output from last app crash:\n\n" + ex.ToString());
            }
        }
示例#14
0
        static void Main()
        {
            // initialize OpenTK

            OpenTK.Toolkit.Init();

            // set renderers

            string WinR, LinuxR, MacR;

            WinR   = "WPF";     // WPF, WinForms, GTK
            LinuxR = "GTK";     // GTK, WinForms
            MacR   = "MonoMac"; // MonoMac, WinForms, GTK

            Eto.Platform platform = null;

            switch (RunningPlatform())
            {
            case Platform.Windows:
                switch (WinR)
                {
                case "WPF":
                    platform = new Eto.Wpf.Platform();
                    platform.Add <SKControl.ISKControl>(() => new WPF.SKControlHandler());
                    platform.Add <SKGLControl.ISKGLControl>(() => new WPF.SKGLControlHandler());
                    break;

                case "WinForms":
                    platform = new Eto.WinForms.Platform();
                    platform.Add <SKControl.ISKControl>(() => new WinForms.SKControlHandler());
                    platform.Add <SKGLControl.ISKGLControl>(() => new WinForms.SKGLControlHandler());
                    break;

                case "GTK":
                    platform = new Eto.GtkSharp.Platform();
                    platform.Add <SKControl.ISKControl>(() => new GTK.SKControlHandler());
                    platform.Add <SKGLControl.ISKGLControl>(() => new GTK.SKGLControlHandler());
                    break;
                }
                break;

            case Platform.Linux:
                switch (LinuxR)
                {
                case "WinForms":
                    platform = new Eto.WinForms.Platform();
                    platform.Add <SKControl.ISKControl>(() => new WinForms.SKControlHandler());
                    platform.Add <SKGLControl.ISKGLControl>(() => new WinForms.SKGLControlHandler());
                    break;

                case "GTK":
                    platform = new Eto.GtkSharp.Platform();
                    platform.Add <SKControl.ISKControl>(() => new GTK.SKControlHandler());
                    platform.Add <SKGLControl.ISKGLControl>(() => new GTK.SKGLControlHandler());
                    break;
                }
                break;

            case Platform.Mac:
                switch (MacR)
                {
                case "MonoMac":
                    platform = new Eto.Mac.Platform();
                    platform.Add <SKControl.ISKControl>(() => new Mac.SKControlHandler());
                    platform.Add <SKGLControl.ISKGLControl>(() => new Mac.SKGLControlHandler());
                    break;

                case "WinForms":
                    platform = new Eto.WinForms.Platform();
                    platform.Add <SKControl.ISKControl>(() => new WinForms.SKControlHandler());
                    platform.Add <SKGLControl.ISKGLControl>(() => new WinForms.SKGLControlHandler());
                    break;

                case "GTK":
                    platform = new Eto.GtkSharp.Platform();
                    platform.Add <SKControl.ISKControl>(() => new GTK.SKControlHandler());
                    platform.Add <SKGLControl.ISKGLControl>(() => new GTK.SKGLControlHandler());
                    break;
                }
                break;
            }

            // test CPU drawing (SKControl)

            //new Application(platform).Run(new FormCPU());

            // test OpenGL drawing (SKGLControl)

            new Application(platform).Run(new FormGL());
        }
示例#15
0
        public static void Main(string[] args)
        {
            //initialize OpenTK

            OpenTK.Toolkit.Init();

            // set global settings

            Settings.CultureInfo         = "en";
            Settings.EnableGPUProcessing = false;
            Settings.OldUI = false;

            Settings.LoadSettings("dwsim_newui.ini");

            Eto.Platform platform = null;

            try
            {
                if (Settings.RunningPlatform() == Settings.Platform.Windows)
                {
                    switch (GlobalSettings.Settings.WindowsRenderer)
                    {
                    case Settings.WindowsPlatformRenderer.WinForms:
                        DWSIM.UI.Desktop.WinForms.StyleSetter.SetStyles();
                        platform = new Eto.Direct2D.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new WinForms.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new WinForms.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.WinForms.PlotHandler());
                        platform.Add <CodeEditorControl.ICodeEditor>(() => new WinForms.CodeEditorControlHandler());
                        break;

                    case Settings.WindowsPlatformRenderer.WinForms_Direct2D:
                        DWSIM.UI.Desktop.WinForms.StyleSetter.SetStyles();
                        platform = new Eto.WinForms.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new WinForms.FlowsheetSurfaceControlHandler());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.WinForms.PlotHandler());
                        platform.Add <CodeEditorControl.ICodeEditor>(() => new WinForms.CodeEditorControlHandler());
                        break;

                    case Settings.WindowsPlatformRenderer.WPF:
                        DWSIM.UI.Desktop.WPF.StyleSetter.SetTheme("aero", "normalcolor");
                        DWSIM.UI.Desktop.WPF.StyleSetter.SetStyles();
                        platform = new Eto.Wpf.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new WPF.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new WPF.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.Wpf.PlotHandler());
                        platform.Add <CodeEditorControl.ICodeEditor>(() => new WPF.CodeEditorControlHandler());
                        break;

                    case Settings.WindowsPlatformRenderer.Gtk2:
                        DWSIM.UI.Desktop.GTK.StyleSetter.SetStyles();
                        platform = new Eto.GtkSharp.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new GTK.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new GTK.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.Gtk.PlotHandler());
                        platform.Add <CodeEditorControl.ICodeEditor>(() => new GTK.CodeEditorControlHandler());
                        break;
                    }
                    new Application(platform).Run(new MainForm());
                }
                else if (Settings.RunningPlatform() == Settings.Platform.Linux)
                {
                    switch (GlobalSettings.Settings.LinuxRenderer)
                    {
                    case Settings.LinuxPlatformRenderer.Gtk2:
                        DWSIM.UI.Desktop.GTK.StyleSetter.SetStyles();
                        platform = new Eto.GtkSharp.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new GTK.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new GTK.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.Gtk.PlotHandler());
                        platform.Add <CodeEditorControl.ICodeEditor>(() => new GTK.CodeEditorControlHandler());
                        break;

                    case Settings.LinuxPlatformRenderer.WinForms:
                        DWSIM.UI.Desktop.WinForms.StyleSetter.SetStyles();
                        platform = new Eto.WinForms.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new WinForms.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new WinForms.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.WinForms.PlotHandler());
                        platform.Add <CodeEditorControl.ICodeEditor>(() => new WinForms.CodeEditorControlHandler());
                        break;
                    }
                    new Application(platform).Run(new MainForm());
                }
                else if (Settings.RunningPlatform() == Settings.Platform.Mac)
                {
                    switch (GlobalSettings.Settings.MacOSRenderer)
                    {
                    case Settings.MacOSPlatformRenderer.MonoMac:
                        DWSIM.UI.Desktop.Mac.StyleSetter.SetStyles();
                        platform = new Eto.Mac.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new Mac.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new Mac.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Mac.PlotHandler());
                        platform.Add <CodeEditorControl.ICodeEditor>(() => new Mac.CodeEditorControlHandler());
                        break;

                    case Settings.MacOSPlatformRenderer.Gtk2:
                        DWSIM.UI.Desktop.GTK.StyleSetter.SetStyles();
                        platform = new Eto.GtkSharp.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new GTK.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new GTK.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.Gtk.PlotHandler());
                        platform.Add <CodeEditorControl.ICodeEditor>(() => new GTK.CodeEditorControlHandler());
                        break;

                    case Settings.MacOSPlatformRenderer.WinForms:
                        DWSIM.UI.Desktop.WinForms.StyleSetter.SetStyles();
                        platform = new Eto.WinForms.Platform();
                        platform.Add <FlowsheetSurfaceControl.IFlowsheetSurface>(() => new WinForms.FlowsheetSurfaceControlHandler());
                        platform.Add <FlowsheetSurfaceControl_OpenGL.IFlowsheetSurface_OpenGL>(() => new WinForms.FlowsheetSurfaceControlHandler_OpenGL());
                        platform.Add <Eto.OxyPlot.Plot.IHandler>(() => new Eto.OxyPlot.WinForms.PlotHandler());
                        platform.Add <CodeEditorControl.ICodeEditor>(() => new WinForms.CodeEditorControlHandler());
                        break;
                    }
                    var app = new Application(platform);
                    app.Initialized += (sender, e) =>
                    {
                        if (GlobalSettings.Settings.RunningPlatform() == Settings.Platform.Mac)
                        {
                            if (GlobalSettings.Settings.MacOSRenderer == Settings.MacOSPlatformRenderer.MonoMac)
                            {
                                DWSIM.UI.Desktop.Mac.StyleSetter.FinishedLaunching();
                                Console.WriteLine("FinishedLaunching");
                            }
                        }
                    };
                    app.Run(new MainForm());
                }
            }
            catch (Exception ex)
            {
                string configfiledir = "";
                if (GlobalSettings.Settings.RunningPlatform() == Settings.Platform.Mac)
                {
                    configfiledir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Documents", "DWSIM Application Data");
                }
                else
                {
                    configfiledir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "DWSIM Application Data");
                }
                if (!Directory.Exists(configfiledir))
                {
                    Directory.CreateDirectory(configfiledir);
                }
                File.WriteAllText(System.IO.Path.Combine(configfiledir, "lasterror.txt"), "Output from last app crash:\n\n" + ex.ToString());
            }
        }