Exemple #1
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());
            }
        }
Exemple #2
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());
        }
Exemple #3
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());
        }
Exemple #4
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());
        }
Exemple #5
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());
        }
Exemple #6
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")));
        }
Exemple #7
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());
            }
        }
Exemple #8
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());
        }
Exemple #9
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());
            }
        }