Navigate() public method

public Navigate ( [ source ) : void
source [
return void
Exemplo n.º 1
0
        async private void LoadAndRefresh(Mark selectedMark, Windows.UI.Xaml.Controls.WebView WebViewControl)
        {
            if (selectedMark.type == "undefined") // just to be sure mark got created
            {
                await Task.Delay(TimeSpan.FromSeconds(2));
            }

            while (shouldRefresh)
            {
                if (selectedMark.type == "link")
                {
                    GetRequest(Globals.serverUrl);
                }
                else
                {
                    GetRequest(Globals.serverUrl);
                    var file = selectedMark.type + ".html?id=" + selectedMark.id;
                    WebViewControl.Navigate(new Uri(Globals.serverUrl + "/template/" + file));
                }

                if (shouldRefresh)
                {
                    await Task.Delay(TimeSpan.FromSeconds(10));
                }
            }
        }
Exemplo n.º 2
0
 public MainPage()
 {
     WebView Navegador = new WebView();
     this.InitializeComponent();
     this.NavigationCacheMode = NavigationCacheMode.Required;
     Navegador.Navigate(new Uri("http://www.bing.com", UriKind.Absolute));
 }
        internal async Task createWebView(Dictionary<string, object> options)
        {
            _browserWindow._window = await _browserWindow.createWindow(options);

            string url;
            if (options.ContainsKey(NKEBrowserOptions.kPreloadURL))
                url = (string)options[NKEBrowserOptions.kPreloadURL];
            else
                url = NKEBrowserDefaults.kPreloadURL;

            WebView webView = new WebView(WebViewExecutionMode.SeparateThread);
            this.webView = webView;
            _browserWindow.webView = webView;

            _browserWindow._window.controls.Add(webView);
            webView.Navigate(new Uri(url));
            _browserWindow.context = await NKSMSWebViewContext.getScriptContext(_id, webView, options);

            webView.NavigationStarting += WebView_NavigationStarting;
            webView.NavigationCompleted += this.WebView_NavigationCompleted;

            this.init_IPC();

            this._type = NKEBrowserType.MSWebView.ToString();
            if (options.itemOrDefault<bool>("NKE.InstallElectro", true))
                await Renderer.addElectro(_browserWindow.context, options);
            NKLogging.log(string.Format("+E{0} Renderer Ready", _id));

            _browserWindow.events.emit("NKE.DidFinishLoad", _id);

        }
        /// <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.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            webView = new WebView();
            webView.Navigate(new Uri("http://flagship.secipin.com/"));
            Content = webView;

            Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;

            GoogleAnalytics.EasyTracker.GetTracker().SendView("MainPage");
        }
Exemplo n.º 5
0
 void Reload()
 {
     if (View.Url?.Contains(":") == true)
     {
         Result.Navigate(GetUri());
     }
     else
     {
         Result.NavigateToString(View.GetExecutableHtml().OrEmpty());
     }
 }
Exemplo n.º 6
0
 private async Task<string> GetHtmlPage(string mangaImageUrl)
 {
     wv  = new WebView();
     //wv.NavigationCompleted += Wv_NavigationCompleted;
     wv.Navigate(new Uri(mangaImageUrl));
     var ss = await WaitForMessageSent();
     if (ss.IsSuccess)
     {
         _content = await wv.InvokeScriptAsync("eval",
             new string[] { "document.documentElement.outerHTML;" });
     }
     return _content;
 }
Exemplo n.º 7
0
    public void Go(ref WebView web, string value, KeyRoutedEventArgs args)
    {
        if (args.Key == Windows.System.VirtualKey.Enter)
        {
            try
            {
                web.Navigate(new Uri(value));
            }
            catch
            {

            }
            web.Focus(FocusState.Keyboard);
        }
    }
Exemplo n.º 8
0
 private void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
     infoloader = ResourceLoader.GetForCurrentView(App.RESOURCE_NAME);
     errorloader = ResourceLoader.GetForCurrentView(App.ERROR_RESOURCE_NAME);
     currentDataContext = DataContext as ViewModelBase;
     ((BIRCViewModel)currentDataContext).GetSelectedConnection().OnAddHistory += MainPage_OnAddHistory;
     ((BIRCViewModel)currentDataContext).OnBeforeServerSelectionChanged += CurrentDataContext_OnBeforeServerSelectionChanged;
     ((BIRCViewModel)currentDataContext).OnAfterServerSelectionChanged += CurrentDataContext_OnAfterServerSelectionChanged;
     resetEvent = new ManualResetEvent(false);
     resetEventAddHistory = new ManualResetEvent(false);
     WebView = new WebView();
     WebView.Navigate(new Uri("ms-appx-web:///assets/base.html"));
     WebViewContainer.Children.Add(WebView);
 }
		/// <summary>
		/// Redirects the user to the authorization URI by using a WebView.
		/// </summary>
		/// <param name="serviceUri">The service URI.</param>
		/// <param name="authorizeUri">The authorize URI.</param>
		/// <param name="callbackUri">The callback URI.</param>
		/// <returns>Dictionary of parameters returned by the authorization URI (code, access_token, refresh_token, ...)</returns>
		public async Task<IDictionary<string, string>> AuthorizeAsync(string serviceUri, string authorizeUri, string callbackUri)
		{
			CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
			if (dispatcher == null)
				throw new Exception("No access to UI thread");

			if (_tcs != null || _popup != null)
				throw new Exception(); // only one authorization process at a time

			_callbackUrl = callbackUri;
			_tcs = new TaskCompletionSource<IDictionary<string, string>>();

			// Set an embedded WebView that displays the authorize page
			await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
			{
				var grid = new Grid();
				grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
				grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
				grid.Height = Window.Current.Bounds.Height;
				grid.Width = Window.Current.Bounds.Width;

					var webView = new WebView();
				webView.NavigationStarting += WebViewOnNavigationStarting;
				Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtonsOnBackPressed;

				webView.Navigate(new Uri(authorizeUri));
				grid.Children.Add(webView);

				// Display the webView in a popup (default behavior, may be customized by an application)
				_popup = new Popup
				{
					Child = grid,
					IsOpen = true
				};
				_popup.Closed += OnPopupClosed;

			});

			return await _tcs.Task;
		}
		/// <summary>
		/// Redirects the user to the authorization URI by using a WebBrowser.
		/// </summary>
		/// <param name="serviceUri">The service URI.</param>
		/// <param name="authorizeUri">The authorize URI.</param>
		/// <param name="callbackUri">The callback URI.</param>
		/// <returns>Dictionary of parameters returned by the authorization URI (code, access_token, refresh_token, ...)</returns>
		public async Task<IDictionary<string, string>> AuthorizeAsync(string serviceUri, string authorizeUri, string callbackUri)
		{
			CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
			if (dispatcher == null)
				throw new Exception("No access to UI thread");

			if (_tcs != null || _popup != null)
				throw new Exception(); // only one authorization process at a time

			_callbackUrl = callbackUri;
			_tcs = new TaskCompletionSource<IDictionary<string, string>>();


			await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
			{
				var grid = new Grid();
				grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
				grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
				grid.Height = Window.Current.Bounds.Height;
				grid.Width = Window.Current.Bounds.Width;

				var webView = new WebView();
				webView.NavigationStarting += WebViewOnNavigationStarting;

				webView.Navigate(new Uri(authorizeUri));
				grid.Children.Add(webView);

				_popup = new Popup
				{
					Child = grid,
					IsOpen = true
				};

				_popup.Closed += OnPopupClosed;


			});

			return await _tcs.Task;
		}
Exemplo n.º 11
0
        /// <summary>
        /// Call the global content viewer to show the content.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContentRoot_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (!String.IsNullOrWhiteSpace(m_appUrl))
            {
                // Show our loading overlay
                ui_loadingOverlay.Show(true);

                // If we have a link open it in our hidden webview, this will cause the store
                // to redirect us.
                m_hiddenWebView = new WebView(WebViewExecutionMode.SeparateThread);
                m_hiddenWebView.Navigate(new Uri(m_appUrl, UriKind.Absolute));
                m_hiddenWebView.NavigationCompleted += HiddenWebView_NavigationCompleted;
            }
        }
        /// <summary>
        /// Called by the host when we should show content.
        /// </summary>
        /// <param name="post"></param>
        public async void OnPrepareContent(Post post)
        {
            // So the loading UI
            m_host.ShowLoading();
            m_loadingHidden = false;

            // Since some of this can be costly, delay the work load until we aren't animating.
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                lock (this)
                {
                    if (m_isDestroyed)
                    {
                        return;
                    }

                    // Get the post url
                    m_postUrl = post.Url;

                    // Make the webview
                    m_webView = new WebView(WebViewExecutionMode.SeparateThread);

                    // Setup the listeners, we need all of these because some web pages don't trigger
                    // some of them.
                    m_webView.FrameNavigationCompleted += NavigationCompleted;
                    m_webView.NavigationFailed += NavigationFailed;
                    m_webView.DOMContentLoaded += DOMContentLoaded;
                    m_webView.ContentLoading += ContentLoading;
                    m_webView.ContainsFullScreenElementChanged += WebView_ContainsFullScreenElementChanged;

                    // Navigate
                    try
                    {
                        m_webView.Navigate(new Uri(post.Url, UriKind.Absolute));
                    }
                    catch (Exception e)
                    {
                        App.BaconMan.TelemetryMan.ReportUnExpectedEvent(this, "FailedToMakeUriInWebControl", e);
                        m_host.ShowError();
                    }

                    // Now add an event for navigating.
                    m_webView.NavigationStarting += NavigationStarting;

                    // Insert this before the full screen button.
                    ui_contentRoot.Children.Insert(0, m_webView);
                }
            });
        }
        private void LoadWebContent(WebView browser, Item selectedItem)
        {
            #if WINDOWS_APP
            if (AppSettings.MaximizeYoutubeVideos)
            {
                var youtubeLink = Regex.Match(selectedItem.Description, @"(https?:)?//w*\.?youtube.com/watch[^'\""<>]+").Value;

                if (youtubeLink.Length > 0)
                {
                    //Youtube videos get full screen
                    browser.Navigate(new Uri(youtubeLink));
                    return;
                }
            }
            #endif

            var bc = AppSettings.BackgroundColorOfDescription[0] == '#' ? AppSettings.BackgroundColorOfDescription : FetchBackgroundColor();

            var fc = AppSettings.FontColorOfDescription[0] == '#' ? AppSettings.FontColorOfDescription : FetchFontColor();

            string scriptOptions = string.Empty;
            string disableHyperLinksJS = "<script type='text/javascript'>window.onload = function() {   var anchors = document.getElementsByTagName(\"a\"); for (var i = 0; i < anchors.length; i++) { anchors[i].onclick = function() {return(false);}; }};</script>";
            string disableOpeningHyperLinksInNewTabJS = "<script type='text/javascript'>window.onload = function() {   var anchors = document.getElementsByTagName(\"a\"); for (var i = 0; i < anchors.length; i++) { anchors[i].target = \"_self\"; }};</script>";
            string launchPhoneCallJS = @"<script type='text/javascript'>  function callOutToCSharp(stringParameter){window.external.notify(stringParameter.toLocaleString());} window.onload = function() {   var regex = /((\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4})/, replacement = '<input type=""button"" value=""$1"" onclick=""callOutToCSharp(\'launchPhoneCall:$1\');"" />'; function replaceText(el) { if (el.nodeType === 3) { if (regex.test(el.data)) { var temp_div = document.createElement('div'); temp_div.innerHTML = el.data.replace(regex, replacement); var nodes = temp_div.childNodes; while (nodes[0]) { el.parentNode.insertBefore(nodes[0],el); } el.parentNode.removeChild(el); } } else if (el.nodeType === 1) { for (var i = 0; i < el.childNodes.length; i++) { replaceText(el.childNodes[i]);  }  }} replaceText(document.body); } </script>";

            if (AppSettings.DisableHyperLinksInItemDescriptionView)
                scriptOptions = scriptOptions + disableHyperLinksJS;
            if (AppSettings.DisableOpeningHyperLinksInNewTab)
                scriptOptions = scriptOptions + disableOpeningHyperLinksInNewTabJS;
            #if WINDOWS_PHONE_APP
            if (AppSettings.EnableParsingPhoneNumbersPhone8X)
                scriptOptions = scriptOptions + launchPhoneCallJS;
            #endif

            var webcontent = "<!doctype html><HTML>" +
            "<HEAD>" +
            "<meta name=\"viewport\" content=\"width=320, user-scrollable=no\" />"
            +
                scriptOptions
            +
            "<style type='text/css'>a img {border: 0;}</style>" +
            "</HEAD>" +
            "<BODY style=\"background-color:" + bc + ";color:" + fc + ";-ms-touch-action: pan-y;" + "\">" +
            selectedItem.Description +
            "</BODY>" +
            "</HTML>";

            browser.NavigateToString(webcontent);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Called by the host when we should show content.
        /// </summary>
        /// <param name="post"></param>
        public async void OnPrepareContent(Post post)
        {
            // So the loading UI
            m_host.ShowLoading();
            m_loadingHidden = false;

            // Since some of this can be costly, delay the work load until we aren't animating.
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                lock(this)
                {
                    if(m_isDestroyed)
                    {
                        return;
                    }

                    // Make the webview
                    m_webView = new WebView(WebViewExecutionMode.SeparateThread);

                    // Setup the listeners, we need all of these because some web pages don't trigger
                    // some of them.
                    m_webView.FrameNavigationCompleted += NavigationCompleted;
                    m_webView.NavigationFailed += NavigationFailed;
                    m_webView.DOMContentLoaded += DOMContentLoaded;
                    m_webView.ContentLoading += ContentLoading;

                    // Navigate
                    m_webView.Navigate(new Uri(post.Url, UriKind.Absolute));
                    ui_contentRoot.Children.Add(m_webView);
                }
            });
        }
Exemplo n.º 15
0
 public static void NavigateToWebView(WebView wv, Uri uri)
 {
     wv.Navigate(uri);
 }
 /// <summary>
 /// Logs in a <see cref="ParseUser" /> using Facebook for authentication. If a user for the
 /// given Facebook credentials does not already exist, a new user will be created.
 /// 
 /// The user will be logged in through Facebook's OAuth web flow, so you must supply a
 /// <paramref name="webView"/> that will be navigated to Facebook's authentication pages.
 /// </summary>
 /// <param name="webView">A web view that will be used to present the authorization pages
 /// to the user.</param>
 /// <param name="permissions">A list of Facebook permissions to request.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The user that was either logged in or created.</returns>
 public static async Task<ParseUser> LogInAsync(WebView webView,
     IEnumerable<string> permissions,
     CancellationToken cancellationToken) {
   authProvider.Permissions = permissions;
   LoadCompletedEventHandler loadCompleted = (_, e) => authProvider.HandleNavigation(e.Uri);
   webView.LoadCompleted += loadCompleted;
   Action<Uri> navigate = uri => webView.Navigate(uri);
   authProvider.Navigate += navigate;
   var result = await ParseUser.LogInWithAsync("facebook", cancellationToken);
   authProvider.Navigate -= navigate;
   webView.LoadCompleted -= loadCompleted;
   return result;
 }
Exemplo n.º 17
0
 private void AddWebView()
 {
     WebView = new WebView();
     WebView.LoadCompleted += WebView_LoadCompleted;
     WebView.Navigate(new Uri("ms-appx-web:///assets/base.html"));
     WebViewContainer.Children.Add(WebView);
     WebView.ScriptNotify += WebView_ScriptNotify;
 }
 private void onBrowserNavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
 {
     string startURL = IsLoginRedirect(args.Uri);
     if (startURL != null)
     {
         sender.Stop();
         // Cheap REST call to refresh session
         _client.SendAsync(RestRequest.GetRequestForResources(ApiVersion), response =>
         {
             var frontDoorStartURL =
                 new Uri(OAuth2.ComputeFrontDoorUrl(_client.InstanceUrl, LoginOptions.DefaultDisplayType,
                     _client.AccessToken, startURL));
             _syncContext.Post(state => sender.Navigate(state as Uri), frontDoorStartURL);
         }
             );
     }
 }
 private void onBrowserNavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
 {
     string startURL = IsLoginRedirect(args.Uri);
     if (startURL != null)
     {
         sender.Stop();
         // Cheap REST call to refresh session
         _client.SendAsync(RestRequest.GetRequestForResources(API_VERSION), (response) =>
             {
                 Uri frontDoorStartURL = new Uri(OAuth2.ComputeFrontDoorUrl(_client.InstanceUrl, _client.AccessToken, startURL));
                 _syncContext.Post((state) => { sender.Navigate(state as Uri); }, frontDoorStartURL);
             }
         );
     }
 }
 /// <summary>
 /// Links a <see cref="ParseUser" /> to a Facebook account, allowing you to use Facebook
 /// for authentication, and providing access to Facebook data for the user.
 /// 
 /// The user will be logged in through Facebook's OAuth web flow, so you must supply a
 /// <paramref name="webView"/> that will be navigated to Facebook's authentication pages.
 /// </summary>
 /// <param name="user">The user to link with Facebook.</param>
 /// <param name="webView">A web view that will be used to present the authorization pages
 /// to the user.</param>
 /// <param name="permissions">A list of Facebook permissions to request.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 public static async Task LinkAsync(ParseUser user,
     WebView webView,
     IEnumerable<string> permissions,
     CancellationToken cancellationToken) {
   authProvider.Permissions = permissions;
   LoadCompletedEventHandler loadCompleted = (_, e) => authProvider.HandleNavigation(e.Uri);
   webView.LoadCompleted += loadCompleted;
   Action<Uri> navigate = uri => webView.Navigate(uri);
   authProvider.Navigate += navigate;
   await user.LinkWithAsync("facebook", cancellationToken);
   authProvider.Navigate -= navigate;
   webView.LoadCompleted -= loadCompleted;
 }
        /// <summary>
        /// Call the global content viewer to show the content.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ContentRoot_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (!String.IsNullOrWhiteSpace(m_appUrl))
            {
                // Try to parse out the app id if we can, loading the webpage can take a long
                // time so we want to avoid it if possible
                bool successfullyParsedAppId = false;
                try
                {
                    // We are looking to parse 9nblggh58t2h out of something like this
                    // https://www.microsoft.com/en-us/store/apps/device-diagnostics-hub/9nblggh58t2h?cid=appraisin
                    // or this
                    // https://www.microsoft.com/store/apps/9wzdncrfhw68
                    //
                    // Note the /apps/ changes also

                    // Find the last / this should be just before the app id.
                    int appIdStart = m_appUrl.LastIndexOf('/') + 1;

                    // Make sure we found one.
                    if(appIdStart != 0)
                    {
                        // Find the ending, look for a ? if there is one.
                        int appIdEnd = m_appUrl.IndexOf('?', appIdStart);
                        if (appIdEnd == -1)
                        {
                            appIdEnd = m_appUrl.Length;
                        }

                        // Get the app id
                        string appId = m_appUrl.Substring(appIdStart, appIdEnd - appIdStart);

                        // Do a quick sanity check
                        if (appId.Length > 4)
                        {
                            successfullyParsedAppId = await Windows.System.Launcher.LaunchUriAsync(new Uri($"ms-windows-store://pdp/?ProductId={appId}"));
                        }
                    }                
                }
                catch(Exception ex)
                {
                    App.BaconMan.MessageMan.DebugDia("failed to parse app id", ex);
                    App.BaconMan.TelemetryMan.ReportEvent(this, "FailedToParseAppId");
                }

                // If we failed use the web browser
                if(!successfullyParsedAppId)
                {                
                    // Show our loading overlay
                    ui_loadingOverlay.Show(true);

                    // If we have a link open it in our hidden webview, this will cause the store
                    // to redirect us.
                    m_hiddenWebView = new WebView(WebViewExecutionMode.SeparateThread);
                    m_hiddenWebView.Navigate(new Uri(m_appUrl, UriKind.Absolute));
                    m_hiddenWebView.NavigationCompleted += HiddenWebView_NavigationCompleted;
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Creates a new webview, this should be called under lock!
        /// </summary>
        private void MakeWebView()
        {
            if (m_webView != null)
            {
                return;
            }

            // Make the webview
            m_webView = new WebView(WebViewExecutionMode.SeparateThread);

            // Setup the listeners, we need all of these because some web pages don't trigger
            // some of them.
            m_webView.FrameNavigationCompleted += NavigationCompleted;
            m_webView.NavigationFailed += NavigationFailed;
            m_webView.DOMContentLoaded += DOMContentLoaded;
            m_webView.ContentLoading += ContentLoading;
            m_webView.ContainsFullScreenElementChanged += ContainsFullScreenElementChanged;

            // Navigate
            try
            {
                m_webView.Navigate(new Uri(m_base.Source.Url, UriKind.Absolute));
            }
            catch (Exception e)
            {
                App.BaconMan.TelemetryMan.ReportUnexpectedEvent(this, "FailedToMakeUriInWebControl", e);
                m_base.FireOnError(true, "This web page failed to load");
            }

            // Now add an event for navigating.
            m_webView.NavigationStarting += NavigationStarting;

            // Insert this before the full screen button.
            ui_contentRoot.Children.Insert(0, m_webView);
        }