Пример #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="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = PreLaunchSetUp();

#pragma warning disable CA1062 // Validate arguments of public methods
            if (e.PrelaunchActivated == false)
#pragma warning restore CA1062 // Validate arguments of public methods
            {
                if (rootFrame.Content == null)
                {
                    Client              = new FactoryOrchestratorUWPClient(IPAddress.Loopback, 45684);
                    Client.OnConnected += OnIpcConnected;

                    if (await Client.TryConnect(IgnoreVersionMismatch))
                    {
                        OnConnectionPage = false;
                        rootFrame.Navigate(typeof(MainPage), e.Arguments);
                    }
                    else
                    {
                        // When the navigation stack isn't restored navigate to the first page,
                        // configuring the new page by passing required information as a navigation
                        // parameter
                        Client = null;
                        rootFrame.Navigate(typeof(ConnectionPage), e.Arguments);
                    }
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
Пример #2
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
#pragma warning disable CA1062 // Validate arguments of public methods
            if (args.Kind == ActivationKind.Protocol)
#pragma warning restore CA1062 // Validate arguments of public methods
            {
                ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
                var   path      = eventArgs.Uri.LocalPath;
                Frame rootFrame = PreLaunchSetUp();
                if (Client != null)
                {
                    if (await Client.TryConnect(IgnoreVersionMismatch))
                    {
                        OnConnectionPage = false;
                        rootFrame.Navigate(typeof(MainPage), path);
                    }
                }
                else
                {
                    if (rootFrame.Content == null)
                    {
                        Client              = new FactoryOrchestratorUWPClient(IPAddress.Loopback, 45684);
                        Client.OnConnected += OnIpcConnected;

                        if (await Client.TryConnect(IgnoreVersionMismatch))
                        {
                            OnConnectionPage = false;
                            rootFrame.Navigate(typeof(MainPage), path);
                        }
                        else
                        {
                            Client = null;
                            rootFrame.Navigate(typeof(ConnectionPage), path);
                        }
                    }
                }
            }
        }