コード例 #1
0
        public static void Initialize(Win32PlatformOptions options)
        {
            Options = options;
            AvaloniaLocator.CurrentMutable
            .Bind <IClipboard>().ToSingleton <ClipboardImpl>()
            .Bind <ICursorFactory>().ToConstant(CursorFactory.Instance)
            .Bind <IKeyboardDevice>().ToConstant(WindowsKeyboardDevice.Instance)
            .Bind <IPlatformSettings>().ToConstant(s_instance)
            .Bind <IPlatformThreadingInterface>().ToConstant(s_instance)
            .Bind <IRenderLoop>().ToConstant(new RenderLoop())
            .Bind <IRenderTimer>().ToConstant(new DefaultRenderTimer(60))
            .Bind <ISystemDialogImpl>().ToSingleton <SystemDialogImpl>()
            .Bind <IWindowingPlatform>().ToConstant(s_instance)
            .Bind <PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Control)
            {
                OpenContextMenu =
                {
                    // Add Shift+F10
                    new KeyGesture(Key.F10, KeyModifiers.Shift)
                }
            })
            .Bind <IPlatformIconLoader>().ToConstant(s_instance)
            .Bind <NonPumpingLockHelper.IHelperImpl>().ToConstant(new NonPumpingSyncContext.HelperImpl())
            .Bind <IMountedVolumeInfoProvider>().ToConstant(new WindowsMountedVolumeInfoProvider());

            Win32GlManager.Initialize();

            _uiThread = Thread.CurrentThread;

            if (OleContext.Current != null)
            {
                AvaloniaLocator.CurrentMutable.Bind <IPlatformDragSource>().ToSingleton <DragSource>();
            }
        }
コード例 #2
0
ファイル: Win32Platform.cs プロジェクト: yuyu2you/Avalonia
        public static void Initialize(Win32PlatformOptions options)
        {
            Options = options;
            AvaloniaLocator.CurrentMutable
            .Bind <IClipboard>().ToSingleton <ClipboardImpl>()
            .Bind <IStandardCursorFactory>().ToConstant(CursorFactory.Instance)
            .Bind <IKeyboardDevice>().ToConstant(WindowsKeyboardDevice.Instance)
            .Bind <IPlatformSettings>().ToConstant(s_instance)
            .Bind <IPlatformThreadingInterface>().ToConstant(s_instance)
            .Bind <IRenderLoop>().ToConstant(new RenderLoop())
            .Bind <IRenderTimer>().ToConstant(new RenderTimer(60))
            .Bind <ISystemDialogImpl>().ToSingleton <SystemDialogImpl>()
            .Bind <IWindowingPlatform>().ToConstant(s_instance)
            .Bind <PlatformHotkeyConfiguration>().ToSingleton <PlatformHotkeyConfiguration>()
            .Bind <IPlatformIconLoader>().ToConstant(s_instance);
            if (options.AllowEglInitialization)
            {
                Win32GlManager.Initialize();
            }

            _uiThread = Thread.CurrentThread;

            if (OleContext.Current != null)
            {
                AvaloniaLocator.CurrentMutable.Bind <IPlatformDragSource>().ToSingleton <DragSource>();
            }
        }
コード例 #3
0
ファイル: Win32Platform.cs プロジェクト: xstos/Avalonia
        public static void Initialize(Win32PlatformOptions options)
        {
            Options = options;
            AvaloniaLocator.CurrentMutable
            .Bind <IClipboard>().ToSingleton <ClipboardImpl>()
            .Bind <IStandardCursorFactory>().ToConstant(CursorFactory.Instance)
            .Bind <IKeyboardDevice>().ToConstant(WindowsKeyboardDevice.Instance)
            .Bind <IPlatformSettings>().ToConstant(s_instance)
            .Bind <IPlatformThreadingInterface>().ToConstant(s_instance)
            .Bind <IRenderLoop>().ToConstant(new RenderLoop())
            .Bind <IRenderTimer>().ToConstant(new DefaultRenderTimer(60))
            .Bind <ISystemDialogImpl>().ToSingleton <SystemDialogImpl>()
            .Bind <IWindowingPlatform>().ToConstant(s_instance)
            .Bind <PlatformHotkeyConfiguration>().ToSingleton <PlatformHotkeyConfiguration>()
            .Bind <IPlatformIconLoader>().ToConstant(s_instance)
            .Bind <AvaloniaSynchronizationContext.INonPumpingPlatformWaitProvider>().ToConstant(new NonPumpingWaitProvider())
            .Bind <IMountedVolumeInfoProvider>().ToConstant(new WindowsMountedVolumeInfoProvider());

            Win32GlManager.Initialize();

            _uiThread = Thread.CurrentThread;

            if (OleContext.Current != null)
            {
                AvaloniaLocator.CurrentMutable.Bind <IPlatformDragSource>().ToSingleton <DragSource>();
            }
        }
コード例 #4
0
        // Avalonia configuration, don't remove; also used by visual designer.
        static AppBuilder BuildAvaloniaApp()
        {
#if DEBUG
            // 设计器模式不会执行 Main 函数所以以此区分来初始化文件系统
            if (Assembly.GetCallingAssembly() != Assembly.GetExecutingAssembly())
            {
                FileSystem2.InitFileSystem();
            }
#endif
            SettingsHost.Load();
            var builder = AppBuilder.Configure <App>()
                          .UsePlatformDetect()
                          .LogToTrace()
                          .UseReactiveUI();

            var useGpu = !IApplication.DisableGPU && GeneralSettings.UseGPURendering.Value;

#if MAC
            builder.With(new AvaloniaNativePlatformOptions
            {
                UseGpu = useGpu
            });
#elif LINUX
            builder.With(new X11PlatformOptions
            {
                UseGpu = useGpu
            });
#elif WINDOWS
            var useWgl  = IApplication.UseWgl || GeneralSettings.UseWgl.Value;
            var options = new Win32PlatformOptions
            {
                UseWgl = useWgl,
                AllowEglInitialization = useGpu,
            };
            builder.With(options);
#else
            throw new PlatformNotSupportedException();
#endif

            RenderingSubsystemName = builder.RenderingSubsystemName;
            return(builder);
        }