本文整理汇总了C#中Windows.UI.Xaml.Controls.WebView.Navigate方法的典型用法代码示例。如果您正苦于以下问题:C# WebView.Navigate方法的具体用法?C# WebView.Navigate怎么用?C# WebView.Navigate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Controls.WebView
的用法示例。
在下文中一共展示了WebView.Navigate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createWebView
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);
}
示例2: MainPage
public MainPage()
{
WebView Navegador = new WebView();
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
Navegador.Navigate(new Uri("http://www.bing.com", UriKind.Absolute));
}
示例3: OnNavigatedTo
/// <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");
}
示例4: GetHtmlPage
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;
}
示例5: Go
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);
}
}
示例6: MainPage_Loaded
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);
}
示例7: AuthorizeAsync
/// <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;
}
示例8: AuthorizeAsync
/// <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;
}
示例9: ContentRoot_Tapped
/// <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;
}
}
示例10: LoadWebContent
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);
}
示例11: OnPrepareContent
/// <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);
}
});
}
示例12: AddWebView
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;
}
示例13: NavigateToWebView
public static void NavigateToWebView(WebView wv, Uri uri)
{
wv.Navigate(uri);
}
示例14: onBrowserNavigationStarting
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);
}
);
}
}
示例15: OnPrepareContent
/// <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);
}
});
}