Beispiel #1
0
 public static T UseGtk3 <T>(this AppBuilderBase <T> builder, Gtk3PlatformOptions options = null)
     where T : AppBuilderBase <T>, new()
 {
     return(builder.UseWindowingSubsystem(() => Gtk3Platform.Initialize(options ?? new Gtk3PlatformOptions()),
                                          "GTK3"));
 }
Beispiel #2
0
        private static void Main(string[] args)
        {
#if !_CORERT
            bool useGpu            = true;
            bool deferredRendering = true;
            bool useDirect2D1      = false;
            bool useSkia           = false;
            bool useWin32          = false;
            bool useGtk3           = false;
            bool useNative         = false;

            foreach (var arg in args)
            {
                switch (arg)
                {
                case "--software":
                    useGpu = false;
                    break;

                case "--immediate":
                    deferredRendering = false;
                    break;

                case "--deferred":
                    deferredRendering = true;
                    break;

                case "--d2d":
                    useDirect2D1 = true;
                    break;

                case "--skia":
                    useSkia = true;
                    break;

                case "--win32":
                    useWin32 = true;
                    break;

                case "--gtk3":
                    useGtk3 = true;
                    break;

                case "--native":
                    useNative = true;
                    break;
                }
            }
#endif
            try
            {
                var builder = new ContainerBuilder();
                builder.RegisterModule <LocatorModule>();
                builder.RegisterModule <CoreModule>();
                builder.RegisterModule <DependenciesModule>();
                builder.RegisterModule <AppModule>();
                builder.RegisterModule <ViewModule>();
                using (var container = builder.Build())
                {
                    using (var log = container.Resolve <ILog>())
                    {
                        var appBuilder = BuildAvaloniaApp();
#if !_CORERT
                        if (useDirect2D1 == true)
                        {
                            appBuilder.UseDirect2D1();
                        }
                        if (useSkia == true)
                        {
                            appBuilder.UseSkia();
                        }
                        if (useWin32 == true)
                        {
                            appBuilder.UseWin32(deferredRendering);
                        }
                        if (useGtk3 == true)
                        {
                            var options = new Gtk3PlatformOptions
                            {
                                UseDeferredRendering = deferredRendering,
                                UseGpuAcceleration   = useGpu
                            };
                            appBuilder.UseGtk3(options);
                        }
                        if (useNative == true)
                        {
                            appBuilder.UseAvaloniaNative(null, (opts) =>
                            {
                                opts.UseGpu = useGpu;
                                opts.UseDeferredRendering = deferredRendering;
                            });
                        }
#endif
                        appBuilder.SetupWithoutStarting();
                        var app       = appBuilder.Instance as App;
                        var aboutInfo = app.CreateAboutInfo(
                            appBuilder.RuntimePlatform.GetRuntimeInfo(),
                            appBuilder.WindowingSubsystemName,
                            appBuilder.RenderingSubsystemName);
                        app.Start(container.Resolve <IServiceProvider>(), aboutInfo);
                    }
                }
            }
            catch (Exception ex)
            {
                Print(ex);
            }
        }