Example #1
0
    /// <summary>
    /// Invoked when the application is launched normally by the end user.  Other entry points
    /// will be used such as when the application is launched to open a specific file.
    /// </summary>
    /// <param name="args">Details about the launch request and process.</param>
    protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
    {
        m_window = new MainWindow();

        // Setup dependency injection
        services = ConfigureServices();

        m_window.Setup(services);

        // Setup ViewModel of main window
        ((MainWindow)m_window).ViewModel = Services.GetService <MainViewModel>();

        m_window.Activate();
    }
Example #2
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            Frame rootFrame = Microsoft.UI.Xaml.Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Microsoft.UI.Xaml.Window.Current.Content = rootFrame;
            }

            if (e.UWPLaunchActivatedEventArgs.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Microsoft.UI.Xaml.Window.Current.Activate();
            }
        }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
                // 确保当前窗口处于活动状态
                Window.Current.Activate();
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
                titleBar.ButtonBackgroundColor         = Colors.Transparent;
                titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
            }

            if (e.UWPLaunchActivatedEventArgs.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(WebViewLogin), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
Example #4
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs e)
        {
            Container = RegisterServices();
            var dataService = Container.GetService <IDataService>();
            await dataService.InitializeDataAsync();

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.UWPLaunchActivatedEventArgs.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }

                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
Example #5
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs e)
        {
            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e != null && e.UWPLaunchActivatedEventArgs.PrelaunchActivated == false)
            {
#pragma warning disable CA1806 // Do not ignore method results
                new SamplesConfiguration();
#pragma warning restore CA1806 // Do not ignore method results
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(demoscommon.winui.MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
Example #6
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
        {
            // Window.Current is not-null in UWP
            InAppContainer = Window.Current != null;

            Window currentWindow = InAppContainer ? Window.Current : new Window();
            Frame  rootFrame     = currentWindow.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (InAppContainer && args.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                currentWindow.Content = rootFrame;
            }

            if (!InAppContainer || args.UWPLaunchActivatedEventArgs.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), args.Arguments);
                }
                // Ensure the current window is active
                currentWindow.Activate();
            }
        }
Example #7
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            SharedWindow = Window.Current;

            Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();

            // Ensure the current window is active
            Window.Current.Activate();

            Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments);
        }
Example #8
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = false;
            }
#endif
            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
            ThemeHelper.Initialize();

            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e?.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }


            var document    = XDocument.Load("Products.xml");
            var AllProducts = from AllProduct in document.Descendants("Assemblies") select AllProduct;
            foreach (var assembly in AllProducts)
            {
                var qualifiedInfo = assembly.Attribute("QualifiedInfo").Value;
                var className     = assembly.Attribute("ConfigurationFile").Value;
                var products      = from product in document.Descendants("Assembly") select product;

                foreach (var item in products)
                {
                    var name = item.Attribute("Name").Value;
                    var assemblyQualifiedInfo = $"{name}.{className},{name},{qualifiedInfo}";
                    var type = Type.GetType(assemblyQualifiedInfo);
                    if (type != null)
                    {
                        Activator.CreateInstance(type);
                    }
                }
            }


            if (e?.UWPLaunchActivatedEventArgs.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    rootFrame.Navigate(typeof(syncfusion.demoscommon.winui.MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
Example #9
0
 /// <summary>
 /// Invoked when the application is launched normally by the end user.  Other entry points
 /// will be used such as when the application is launched to open a specific file.
 /// </summary>
 /// <param name="args">Details about the launch request and process.</param>
 protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
 {
     m_window = new MainWindow();
     m_window.Activate();
     m_windowhandle = PInvoke.User32.GetActiveWindow();
 }
Example #10
0
 /// <summary>
 /// Invoked when the application is launched normally by the end user.  Other entry points
 /// will be used such as when the application is launched to open a specific file.
 /// </summary>
 /// <param name="args">Details about the launch request and process.</param>
 protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
 {
     m_window       = new MainWindow();
     m_window.Title = this.Resources["ApplicationTitle"] as string;
     m_window.Activate();
 }
Example #11
0
 /// <summary>
 /// Invoked when the application is launched normally by the end user.  Other entry points
 /// will be used such as when the application is launched to open a specific file.
 /// </summary>
 /// <param name="args">Details about the launch request and process.</param>
 protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
 {
     m_window = new Views.Clipboard();
     m_window.Activate();
 }
Example #12
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = false;
            }
#endif

#if WinUI_Desktop
            m_window = new MainWindow();
            m_window.Activate();
            Frame rootFrame = m_window.Content as Frame;


            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                // rootFrame.NavigationFailed += OnNavigationFailed;

                if (e != null && e.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                m_window.Content = rootFrame;
            }

            var document    = XDocument.Load($"{System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)}/Products.xml");
            var AllProducts = from AllProduct in document.Descendants("Assemblies") select AllProduct;
            foreach (var assembly in AllProducts)
            {
                var qualifiedInfo = assembly.Attribute("QualifiedInfo").Value;
                var className     = assembly.Attribute("ConfigurationFile").Value;
                var products      = from product in document.Descendants("Assembly") select product;

                foreach (var item in products)
                {
                    var name = item.Attribute("Name").Value;
                    var assemblyQualifiedInfo = $"{name}.{className},{name},{qualifiedInfo}";
                    var type = Type.GetType(assemblyQualifiedInfo);
                    if (type != null)
                    {
                        Activator.CreateInstance(type);
                    }
                }
            }


            //  if (e != null && e.UWPLaunchActivatedEventArgs.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(demoscommon.winui.MainPage), e.Arguments);
                }
                // Ensure the current window is active
                m_window.Activate();
            }
            ThemeHelper.CurrentApplicationWindow = m_window;
#else
            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
            ThemeHelper.Initialize();
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e?.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }


            var document    = XDocument.Load("Products.xml");
            var AllProducts = from AllProduct in document.Descendants("Assemblies") select AllProduct;
            foreach (var assembly in AllProducts)
            {
                var qualifiedInfo = assembly.Attribute("QualifiedInfo").Value;
                var className     = assembly.Attribute("ConfigurationFile").Value;
                var products      = from product in document.Descendants("Assembly") select product;

                foreach (var item in products)
                {
                    var name = item.Attribute("Name").Value;
                    var assemblyQualifiedInfo = $"{name}.{className},{name},{qualifiedInfo}";
                    var type = Type.GetType(assemblyQualifiedInfo);
                    if (type != null)
                    {
                        Activator.CreateInstance(type);
                    }
                }
            }


            if (e?.UWPLaunchActivatedEventArgs.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    rootFrame.Navigate(typeof(syncfusion.demoscommon.winui.MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
#endif
        }
Example #13
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
        {
            var m_window = Services.GetRequiredService <MainWindow>();

            m_window.Activate();
        }
Example #14
0
 protected override async void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
 {
     var activationService = Ioc.Default.GetService <IActivationService>();
     await activationService.ActivateAsync(args);
 }
 /// <summary>
 /// Invoked when the application is launched normally by the end user.  Other entry points
 /// will be used such as when the application is launched to open a specific file.
 /// </summary>
 /// <param name="args">Details about the launch request and process.</param>
 protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
 {
     m_window       = new MainWindow();
     m_window.Title = "WinUI 3, Reunion 0.5 Issues";
     m_window.Activate();
 }
 /// <summary>
 /// Invoked when the application is launched normally by the end user.  Other entry points
 /// will be used such as when the application is launched to open a specific file.
 /// </summary>
 /// <param name="args">Details about the launch request and process.</param>
 protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
 {
     m_window = new Window();
     EnsureWindow();
 }
Example #17
0
 protected override async void OnLaunched(LaunchActivatedEventArgs args)
 {
     base.OnLaunched(args);
     var activationService = Ioc.Default.GetService <IActivationService>();
     await activationService?.ActivateAsync(args);
 }
Example #18
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
        {
            var cmdArgs = Environment.GetCommandLineArgs();

            if (cmdArgs != null && cmdArgs.Length >= RequiredArgumentsQty)
            {
                // Skip the first argument which is prepended when launched by explorer
                if (cmdArgs[0].EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) && cmdArgs[1].EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase) && (cmdArgs.Length >= RequiredArgumentsQty + 1))
                {
                    cmdArgs = cmdArgs.Skip(1).ToArray();
                }

                _            = int.TryParse(cmdArgs[(int)Arguments.PTPid], out int powerToysPID);
                PowerToysPID = powerToysPID;

                IsElevated    = cmdArgs[(int)Arguments.ElevatedStatus] == "true";
                IsUserAnAdmin = cmdArgs[(int)Arguments.IsUserAdmin] == "true";
                ShowOobe      = cmdArgs[(int)Arguments.ShowOobeWindow] == "true";
                ShowScoobe    = cmdArgs[(int)Arguments.ShowScoobeWindow] == "true";

                if (cmdArgs.Length == RequiredAndOptionalArgumentsQty)
                {
                    // open specific window
                    switch (cmdArgs[(int)Arguments.SettingsWindow])
                    {
                    case "Overview": StartupPage = typeof(Views.GeneralPage); break;

                    case "AlwaysOnTop": StartupPage = typeof(Views.AlwaysOnTopPage); break;

                    case "Awake": StartupPage = typeof(Views.AwakePage); break;

                    case "ColorPicker": StartupPage = typeof(Views.ColorPickerPage); break;

                    case "FancyZones": StartupPage = typeof(Views.FancyZonesPage); break;

                    case "Run": StartupPage = typeof(Views.PowerLauncherPage); break;

                    case "ImageResizer": StartupPage = typeof(Views.ImageResizerPage); break;

                    case "KBM": StartupPage = typeof(Views.KeyboardManagerPage); break;

                    case "MouseUtils": StartupPage = typeof(Views.MouseUtilsPage); break;

                    case "PowerRename": StartupPage = typeof(Views.PowerRenamePage); break;

                    case "FileExplorer": StartupPage = typeof(Views.PowerPreviewPage); break;

                    case "ShortcutGuide": StartupPage = typeof(Views.ShortcutGuidePage); break;

                    case "VideoConference": StartupPage = typeof(Views.VideoConferencePage); break;

                    default: Debug.Assert(false, "Unexpected SettingsWindow argument value"); break;
                    }
                }

                RunnerHelper.WaitForPowerToysRunner(PowerToysPID, () =>
                {
                    Environment.Exit(0);
                });

                ipcmanager = new TwoWayPipeMessageIPCManaged(cmdArgs[(int)Arguments.SettingsPipeName], cmdArgs[(int)Arguments.PTPipeName], (string message) =>
                {
                    if (IPCMessageReceivedCallback != null && message.Length > 0)
                    {
                        IPCMessageReceivedCallback(message);
                    }
                });
                ipcmanager.Start();

                settingsWindow = new MainWindow();
                if (!ShowOobe && !ShowScoobe)
                {
                    settingsWindow.Activate();
                    settingsWindow.NavigateToSection(StartupPage);
                }
                else
                {
                    // Create the Settings window so that it's fully initialized and
                    // it will be ready to receive the notification if the user opens
                    // the Settings from the tray icon.
                    if (ShowOobe)
                    {
                        PowerToysTelemetry.Log.WriteEvent(new OobeStartedEvent());
                        OobeWindow oobeWindow = new OobeWindow(OOBE.Enums.PowerToysModules.Overview);
                        oobeWindow.Activate();
                        SetOobeWindow(oobeWindow);
                    }
                    else if (ShowScoobe)
                    {
                        PowerToysTelemetry.Log.WriteEvent(new ScoobeStartedEvent());
                        OobeWindow scoobeWindow = new OobeWindow(OOBE.Enums.PowerToysModules.WhatsNew);
                        scoobeWindow.Activate();
                        SetOobeWindow(scoobeWindow);
                    }
                }
            }
            else
            {
                // For debugging purposes
                // Window is also needed to show MessageDialog
                settingsWindow = new MainWindow();
                settingsWindow.Activate();
                ShowMessageDialog("The application cannot be run as a standalone process. Please start the application through the runner.", "Forbidden");
            }
        }
Example #19
0
 /// <summary>
 /// Invoked when the application is launched normally by the end user. Other entry points
 /// will be used such as when the application is launched to open a specific file.
 /// </summary>
 /// <param name="args">Details about the launch request and process.</param>
 protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
 {
     _singleInstanceApp.Launch(args.Arguments);
 }
Example #20
0
        public static void Init(
            Microsoft.UI.Xaml.LaunchActivatedEventArgs launchActivatedEventArgs,
            WindowsBasePage mainWindow,
            IEnumerable <Assembly> rendererAssemblies = null)
        {
            if (IsInitialized)
            {
                return;
            }

            var accent = (WSolidColorBrush)Microsoft.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"];

            Color.SetAccent(accent.ToFormsColor());

#if !UWP_16299
            Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m)));
#else
            Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c)));
#endif
            if (!Microsoft.UI.Xaml.Application.Current.Resources.ContainsKey("RootContainerStyle"))
            {
                Microsoft.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetTabletResources());
            }

            try
            {
                Microsoft.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(new Microsoft.UI.Xaml.Controls.XamlControlsResources());
            }
            catch
            {
                Log.Warning("Resources", "Unable to load WinUI resources. Try adding Microsoft.Maui.Controls.Compatibility nuget to UWP project");
            }

            Device.SetIdiom(TargetIdiom.Tablet);
            Device.SetFlowDirection(GetFlowDirection());

            Device.SetFlags(s_flags);
            Device.Info = new WindowsDeviceInfo();

            switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily)
            {
            case "Windows.Desktop":
                if (Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView().UserInteractionMode ==
                    Windows.UI.ViewManagement.UserInteractionMode.Touch)
                {
                    Device.SetIdiom(TargetIdiom.Tablet);
                }
                else
                {
                    Device.SetIdiom(TargetIdiom.Desktop);
                }
                break;

            case "Windows.Mobile":
                Device.SetIdiom(TargetIdiom.Phone);
                break;

            case "Windows.Xbox":
                Device.SetIdiom(TargetIdiom.TV);
                break;

            default:
                Device.SetIdiom(TargetIdiom.Unsupported);
                break;
            }

            ExpressionSearch.Default = new WindowsExpressionSearch();

            Registrar.ExtraAssemblies = rendererAssemblies?.ToArray();
            s_state = launchActivatedEventArgs.UWPLaunchActivatedEventArgs.PreviousExecutionState;


            MainWindow = mainWindow;
            Microsoft.Maui.Controls.Compatibility.Forms.InitDispatcher(mainWindow.DispatcherQueue);
            mainWindow.LoadApplication(mainWindow.CreateApplication());
            mainWindow.Activate();
        }
        protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs e)
#endif
        {
#if WINDOWS_UWP
            var curWindow = Window.Current;
#else
            m_window         = new Window();
            m_window.Content = new Frame();
            var curWindow = m_window;
            curWindow.Title = "My Test App - hWnd";

            //Intialize interop helper for dialog parenting scenarios
            var windowNative = m_window.As <IWindowNative>();
            m_windowHandle = windowNative.WindowHandle;

            // Initialize the main Page to load into Window
            m_page = new MainPage();

            //Hook up On*Activated events
            //Could be here or Main
            //Most likely at end of the method
            var activationArgs = AppInstance.GetActivatedEventArgs();
            if (activationArgs.Kind == ActivationKind.File)
            {
                OnFileActivated(activationArgs as FileActivatedEventArgs);
            }
#endif

            Frame rootFrame = curWindow.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;
#if WINDOWS_UWP
                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }
#endif
                // Place the frame in the current Window
                curWindow.Content = rootFrame;
            }


#if WINDOWS_UWP
            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                }
                //Q: How does UWP know what the 'first' page is to pass as e.arguments?
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
#else
            rootFrame.Navigate(typeof(MainPage), m_page);
#endif

            // Ensure the current window is active
            curWindow.Activate();
        }
Example #22
0
 /// <summary>
 /// Invoked when the application is launched. Override this method to perform application initialization and to display initial content in the associated Window.
 /// </summary>
 /// <param name="e">Event data for the event.</param>
 protected override void OnLaunched(LaunchActivatedEventArgs e) =>
 OnLaunchApplication(e);
Example #23
0
 /// <summary>
 /// Invoked when the application is launched normally by the end user.  Other entry points
 /// will be used such as when the application is launched to open a specific file.
 /// </summary>
 /// <param name="args">Details about the launch request and process.</param>
 protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
 {
     m_window = new MainWindow();
     m_window.Activate();
 }
Example #24
0
 protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
 {
     Window = new MainWindow();
     Window.Activate();
     WindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(Window);
 }