Пример #1
0
        static void OnConfigureLifeCycle(IWindowsLifecycleBuilder windows)
        {
            windows.OnLaunching((app, args) =>
            {
                // This is the initial Init to set up any system services registered by
                // Forms.Init(). This happens before any UI has appeared.
                // This creates a dummy MauiContext.
                // We need to call this so the Window and Root Page can new up successfully
                // The dispatcher that's inside of Forms.Init needs to be setup before the initial
                // window and root page start creating.
                // Inside OnLaunched we grab the MauiContext that's on the window so we can have the correct
                // MauiContext inside Forms

                var services    = MauiWinUIApplication.Current.Services;
                var mauiContext = new MauiContext(services);
                var state       = new ActivationState(mauiContext, args);
                Forms.Init(state, new InitializationOptions {
                    Flags = InitializationFlags.SkipRenderers
                });
            })
            .OnMauiContextCreated((mauiContext) =>
            {
                // This is the final Init that sets up the real context from the application.

                var state = new ActivationState(mauiContext);
                Forms.Init(state);
            });
        }
Пример #2
0
        static void OnConfigureLifeCycle(IWindowsLifecycleBuilder windows)
        {
            windows
            .OnWindowCreated(window =>
            {
                window.GetWindow()?.Created();
            })
            .OnResumed(window =>
            {
                window.GetWindow()?.Resumed();
            })
            .OnActivated((window, args) =>
            {
                switch (args.WindowActivationState)
                {
                case UI.Xaml.WindowActivationState.CodeActivated:
                case UI.Xaml.WindowActivationState.PointerActivated:
                    window.GetWindow()?.Activated();
                    break;

                case UI.Xaml.WindowActivationState.Deactivated:
                    window.GetWindow()?.Deactivated();
                    break;
                }
            })
            .OnVisibilityChanged((window, args) =>
            {
                if (!args.Visible)
                {
                    window.GetWindow()?.Stopped();
                }
            })
            .OnClosed((window, args) =>
            {
                window.GetWindow()?.Destroying();
            });
        }
 public static IWindowsLifecycleBuilder OnVisibilityChanged(this IWindowsLifecycleBuilder lifecycle, WindowsLifecycle.OnVisibilityChanged del) => lifecycle.OnEvent(del);
 public static IWindowsLifecycleBuilder OnLaunched(this IWindowsLifecycleBuilder lifecycle, WindowsLifecycle.OnLaunched del) => lifecycle.OnEvent(del);
Пример #5
0
 internal static IWindowsLifecycleBuilder OnMauiContextCreated(this IWindowsLifecycleBuilder lifecycle, WindowsLifecycle.OnMauiContextCreated del) => lifecycle.OnEvent(del);
Пример #6
0
 public static IWindowsLifecycleBuilder OnPlatformWindowSubclassed(this IWindowsLifecycleBuilder lifecycle, WindowsLifecycle.OnPlatformWindowSubclassed del) => lifecycle.OnPlatformWindowSubclassed(del);
Пример #7
0
 public static IWindowsLifecycleBuilder OnPlatformMessage(this IWindowsLifecycleBuilder lifecycle, WindowsLifecycle.OnPlatformMessage del) => lifecycle.OnEvent(del);