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()); }
const int ApplicationTimeout = 5 * 1000; //ms /// <summary> /// Initializes the UI application. /// </summary> public static void Initialize() { if (P.Instance != null) { return; //it is already initialized } P platform = null; try { platform = P.Detect; } catch (Exception ex) { throw ex; } P.Initialize(platform); if (platform.Supports <Application>()) { var ev = new ManualResetEvent(false); Exception exception = null; Thread thread = new Thread(() => { try { var app = new Application(platform); app.Initialized += (sender, e) => ev.Set(); app.Run(); } catch (Exception ex) { //Debug.WriteLine("Error running test application: {0}", ex); exception = ex; ev.Set(); } }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); if (!ev.WaitOne(ApplicationTimeout)) { throw new Exception("Could not initialize application"); } if (exception != null) { ExceptionDispatchInfo.Capture(exception).Throw(); } } }
static void Main() { // initialize OpenTK OpenTK.Toolkit.Init(); // set renderers string WinR, LinuxR, MacR; WinR = "WinForms"; // WPF, WinForms, GTK LinuxR = "GTK"; // GTK, WinForms MacR = "MonoMac"; // MonoMac, WinForms, GTK Eto.Platform platform = null; if (RunningPlatform() == 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; } } else if (RunningPlatform() == 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; } } else if (RunningPlatform() == 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; } } // test CPU drawing (SKControl) new Application(platform).Run(new FormCPU()); // test OpenGL drawing (SKGLControl) new Application(platform).Run(new FormGL()); }