Exemplo n.º 1
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            webView.Navigate(BloggerLogic.GetOAuthUri());

            // LayoutAwarePage needs to do something too.
            base.OnNavigatedTo(e);

            SettingsPane.GetForCurrentView().CommandsRequested += CommandsRequested;
        }
Exemplo n.º 2
0
        private void webView_LoadCompleted(object sender, NavigationEventArgs e)
        {
            WebView webView = sender as WebView;

            // If "eval" is called with "alert('hello');" we get "Exception from
            // HRESULT: 0x80020101".

            // To get the whole HTML document use:
            //string html = webView.InvokeScript("eval", new string[] {"document.documentElement.outerHTML;"});

            string scriptString = "var tags = document.getElementsByTagName('title'); tags[0].innerHTML;";
            string pageTitle    = webView.InvokeScript("eval", new string[] { scriptString });

            if (BloggerLogic.DidUserLogInSuccessfully(pageTitle))
            {
                Frame.Navigate(typeof(PostsListPage));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            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();

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

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

            if (rootFrame.Content == null)
            {
                // Sorry, we will make this method 'async' and may block initialization of app.
                // TODO: I promise I will read guidelines to know if this is a good practice or not.
                await BloggerLogic.LoadSettings();

                Type sourcePageType = typeof(LogInPage);
                if (BloggerLogic.IsLogged)
                {
                    sourcePageType = typeof(PostsListPage);
                }

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(sourcePageType, args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }