Пример #1
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            if (args.Kind == ActivationKind.Protocol)
            {
                Frame rootFrame = Window.Current.Content as Frame;

                if (rootFrame == null)
                {
                    rootFrame = new Frame();

                    rootFrame.NavigationFailed += OnNavigationFailed;

                    Window.Current.Content = rootFrame;
                }

                if (rootFrame.Content == null)
                {
                    if (!CredentialsService.IsCredentialsSaved())
                    {
                        rootFrame.Navigate(typeof(LoginPage));
                    }
                    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
                        rootFrame.Navigate(typeof(MainPage));
                    }
                }
                // Ensure the current window is active
                Window.Current.Activate();

                ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
                // TODO: Handle URI activation
                // The received URI is eventArgs.Uri.AbsoluteUri

                if (eventArgs.Uri.Scheme == "mina-laromedel" && CredentialsService.IsCredentialsSaved())
                {
                    var    decoder = new WwwFormUrlDecoder(eventArgs.Uri.Query);
                    string isbn    = eventArgs.Uri.AbsolutePath;
                    int    page    = int.Parse(decoder.GetFirstValueByName("page"));
                    _showReadingWindow(isbn, page);
                }
            }
        }
Пример #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(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    if (!CredentialsService.IsCredentialsSaved())
                    {
                        rootFrame.Navigate(typeof(LoginPage), 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
                        rootFrame.Navigate(typeof(MainPage), e.Arguments);
                    }
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }

            if (e.TileId != null && e.TileId.StartsWith("isbn-") && CredentialsService.IsCredentialsSaved())
            {
                string isbn;
                {
                    var decoder = new WwwFormUrlDecoder(e.Arguments);
                    isbn = decoder.GetFirstValueByName("isbn");
                }

                _showReadingWindow(isbn);
            }
        }