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>(); } }
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>(); } }
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>(); } }
// 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); }