本文整理汇总了C#中WebView类的典型用法代码示例。如果您正苦于以下问题:C# WebView类的具体用法?C# WebView怎么用?C# WebView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebView类属于命名空间,在下文中一共展示了WebView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BrowserWindow
public BrowserWindow()
{
rootTree = RootTree.LoadTree(@"/Library/Frameworks/Mono.framework/Versions/Current/lib/monodoc");
MonoDocWebRequest.RegisterWithRootTree(rootTree);
treeView = new DocTreeView(rootTree);
treeView.SelectionChanged += treeView_SelectionChanged;
scrollView = new ScrollView() { Scrollers = Axis.Both };
scrollView.DocumentView = treeView;
webView = new WebView();
// splitView = new SplitView()
// {
// Margin = new Thickness(0, 0, 0, Window.SmallBottomBarHeight),
// Width = double.NaN,
// Height = double.NaN,
// Orientation = Orientation.Horizontal,
// DividerStyle = DividerStyle.Thin,
// };
// splitView.Children.Add(scrollView);
// splitView.Children.Add(webView);
// Content.Children.Add(splitView);
scrollView.HorizontalAlignment = HorizontalAlignment.Left;
scrollView.Width = 250;
scrollView.Margin = new Thickness(4, 4, 4, Window.SmallBottomBarHeight + 4);
webView.HorizontalAlignment = HorizontalAlignment.Right;
webView.Margin = new Thickness(258, 4, 4, Window.SmallBottomBarHeight + 4);
Content.Children.Add(scrollView);
Content.Children.Add(webView);
CreateToolbarTemplate();
Toolbar = new Toolbar() { Customizable = true, TemplateName = "Main" };
BottomBarHeight = Window.SmallBottomBarHeight;
Title = "Mono Documentation Browser";
}
示例2: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.PlayAnimation);
ImageView btns = FindViewById<ImageView> (Resource.Id.imgNewLoginHeader);
TextView header = FindViewById<TextView> (Resource.Id.txtFirstScreenHeader);
RelativeLayout relLayout = FindViewById<RelativeLayout> (Resource.Id.relativeLayout1);
ImageHelper.setupTopPanel (btns, header, relLayout, header.Context);
Header.headertext = Application.Context.Resources.GetString (Resource.String.animationPlaybackTitle);
Header.fontsize = 36f;
ImageHelper.fontSizeInfo (header.Context);
header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize);
header.Text = Header.headertext;
animationView = FindViewById<WebView> (Resource.Id.animationView);
ImageButton btnBack = FindViewById<ImageButton> (Resource.Id.btnBack);
btnBack.Tag = 0;
btnBack.Click += delegate {
Finish ();
};
ImageButton btnPlay = FindViewById<ImageButton> (Resource.Id.btnPlay);
btnPlay.Tag = 1;
LinearLayout bottom = FindViewById<LinearLayout> (Resource.Id.bottomHolder);
ImageButton[] buttons = new ImageButton[2];
buttons [0] = btnBack;
buttons [1] = btnPlay;
ImageHelper.setupButtonsPosition (buttons, bottom, header.Context);
}
示例3: OnViewCreated
public override void OnViewCreated (View view, Bundle savedInstanceState)
{
mWebView = (WebView)view.FindViewById (Resource.Id.web_view);
// Here, we use #mWebChromeClient with implementation for handling PermissionRequests.
mWebView.SetWebChromeClient (mWebChromeClient);
ConfigureWebSettings (mWebView.Settings);
}
示例4: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
fb = new FacebookClient ();
appId = Intent.GetStringExtra ("AppId");
extendedPermissions = Intent.GetStringExtra ("ExtendedPermissions");
url = GetFacebookLoginUrl (appId, extendedPermissions);
WebView webView = new WebView(this);
webView.Settings.JavaScriptEnabled = true;
webView.Settings.SetSupportZoom(true);
webView.Settings.BuiltInZoomControls = true;
webView.Settings.LoadWithOverviewMode = true; //Load 100% zoomed out
webView.ScrollBarStyle = ScrollbarStyles.OutsideOverlay;
webView.ScrollbarFadingEnabled = true;
webView.VerticalScrollBarEnabled = true;
webView.HorizontalScrollBarEnabled = true;
webView.SetWebViewClient(new FBWebClient (this));
webView.SetWebChromeClient(new FBWebChromeClient (this));
AddContentView(webView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
webView.LoadUrl(url);
}
示例5: MainWindow
public MainWindow()
{
CreateToolbarTemplate();
Style |= WindowStyle.UnifiedTitleAndToolbar;
Toolbar = new Toolbar() { TemplateName = "Main", Customizable = true };
button1 = new Button() { Title = "Click me \u263A", Width = 100, Margin = new Thickness(0, 0, 200, 0), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom };
button1.Action += HandleButton1Action;
button2 = new Button() { Title = "\u26A0 Don't click me \u2620", Width = 200, Margin = new Thickness(0, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom };
button2.Action += HandleButton2Action;
checkBox = new Button() { Title = "Closable", ButtonType = ButtonType.Switch, Width = 100, Height = 24, Margin = new Thickness(120, 0, 0, 100), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom };
paintedView = new DrawableView() { Height = 100, Margin = new Thickness(0, 0, 0, 160), VerticalAlignment = VerticalAlignment.Bottom };
paintedView.Draw += HandlePaintedViewDraw;
webView = new WebView() { Margin = new Thickness(0, 0, 0, 260), VerticalAlignment = VerticalAlignment.Top };
#if DOCUMENT
// checkBox.Checked = true;
#endif
Title = "Hello From C#";
Content.Children.AddRange
(
button1,
button2,
checkBox,
new ColorWell() { Width = 100, Height = 100, Margin = new Thickness(10, 0, 0, 32), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom },
new ColorWell() { Width = 100, Height = 100, Margin = new Thickness(0, 0, 10, 32), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom },
new SearchField() { Width = double.NaN, Height = 22, Margin = new Thickness(120, 0, 120, 32), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Bottom },
new TextField() { Height = 22, Margin = new Thickness(120, 0, 120, 64), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Bottom },
new ComboBox() { Height = 22, Margin = new Thickness(10, 0, 10, 132), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Bottom },
paintedView,
webView
);
}
示例6: Init
protected override void Init()
{
var notWorkingHtml = @"<html><body>
<p><img src='test.jpg' /></p>
<p>After starting (not re-entering!) the app in landscape, scroll down to see a black area which is not supposed to be there.</p>
<p>After starting (not re-entering!) the app in portrait, scroll to the right to see a black area which is not supposed to be there.</p>
<p>This only happends when a local image is loaded.</p>
</body></html>";
var workingHtml = @"<html><body>
<p></p>
<p>Without local image, everything works fine.</p>
</body></html>";
// Initialize ui here instead of ctor
WebView webView = new WebView {
//Source = new UrlWebViewSource {
// Url = "https://blog.xamarin.com/",
//},
Source = new HtmlWebViewSource() {
Html = notWorkingHtml
},
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand
};
Content = webView;
}
示例7: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
_messageHub = Mvx.Resolve<IMvxMessenger>();
var url = Intent.GetStringExtra("cheesebaron.mvxplugins.azureaccesscontrol.droid.Url");
Window.RequestFeature(WindowFeatures.Progress);
_webView = new WebView(this)
{
VerticalScrollBarEnabled = true,
HorizontalScrollBarEnabled = true,
ScrollBarStyle = ScrollbarStyles.OutsideOverlay,
ScrollbarFadingEnabled = true
};
_webView.Settings.JavaScriptEnabled = true;
_webView.Settings.SetSupportZoom(true);
_webView.Settings.BuiltInZoomControls = true;
_webView.Settings.LoadWithOverviewMode = true; //Load 100% zoomed out
var notify = new AccessControlJavascriptNotify();
notify.GotSecurityTokenResponse += GotSecurityTokenResponse;
_webView.AddJavascriptInterface(notify, "external");
_webView.SetWebViewClient(new AuthWebViewClient());
_webView.SetWebChromeClient(new AuthWebChromeClient(this));
_webView.LoadUrl(url);
AddContentView(_webView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
}
示例8: OnPageStarted
public override void OnPageStarted(WebView view, string url, Android.Graphics.Bitmap favicon)
{
base.OnPageStarted(view, url, favicon);
_urlText.Text = url;
_urlText.SetSelection(0);
}
示例9: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
//"a16fe3fa136e7b54b24664bb2a3c647e"
ColorDrawable colorDrawable = new ColorDrawable (Color.ParseColor (Helpers.ColorHeader));
ActionBar.SetBackgroundDrawable (colorDrawable);
//fb = new FacebookClient ();
appId = Intent.GetStringExtra ("AppId");
extendedPermissions = Intent.GetStringExtra ("ExtendedPermissions");
url = GetFacebookLoginUrl (appId, extendedPermissions);
WebView webView = new WebView(this);
webView.Settings.JavaScriptEnabled = true;
webView.Settings.SetSupportZoom(true);
webView.Settings.BuiltInZoomControls = true;
webView.Settings.LoadWithOverviewMode = true; //Load 100% zoomed out
webView.ScrollBarStyle = ScrollbarStyles.OutsideOverlay;
webView.ScrollbarFadingEnabled = true;
webView.VerticalScrollBarEnabled = true;
webView.HorizontalScrollBarEnabled = true;
webView.SetWebViewClient(new FBWebClient (this));
webView.SetWebChromeClient(new FBWebChromeClient (this));
AddContentView(webView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
webView.LoadUrl(url);
}
示例10: ShouldInterceptRequest
public override WebResourceResponse ShouldInterceptRequest(WebView view, IWebResourceRequest request)
{
if (request.Url.Scheme == Uri.UriSchemeFile)
return null;
if (SkipLoading(request.Url.LastPathSegment))
return null;
var baseResponse = base.ShouldInterceptRequest(view, request);
try
{
var result = Task.Run(async () =>
{
using (var c = new HttpClient { Timeout = TimeSpan.FromSeconds(TimeOut) })
{
var response = await c.GetAsync(request.Url.ToString());
var content = await response.Content.ReadAsStreamAsync();
return new WebResourceResponse(baseResponse.MimeType, "UTF-8", (int)response.StatusCode, response.ReasonPhrase, null, content);
}
}).Result;
return result;
}
catch (AggregateException e)
{
return baseResponse;
}
}
示例11: OnViewModelSet
protected override void OnViewModelSet()
{
Window.RequestFeature(WindowFeatures.Progress);
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetHomeButtonEnabled(true);
SupportActionBar.SetBackgroundDrawable(Resources.GetDrawable(Resource.Color.s_main_green));
SupportActionBar.SetLogo(Resource.Drawable.logo_white);
base.OnViewModelSet();
SetContentView(Resource.Layout.page_webview);
var set = this.CreateBindingSet<GenericWebViewView, GenericWebViewViewModel>();
set.Bind(SupportActionBar).For(v => v.Title).To(vm => vm.Title).Mode(MvxBindingMode.OneWay);
set.Apply();
_webView = FindViewById<WebView>(Resource.Id.webView);
_webView.Settings.JavaScriptEnabled = true;
_webView.Settings.SetSupportZoom(true);
var progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar);
var webChromeClient = new ProgressUpdatingWebChromeClient(progressBar);
var webViewClient = new ProgressHandlingWebViewClient(progressBar);
_webView.SetWebViewClient(webViewClient);
_webView.SetWebChromeClient(webChromeClient);
_webView.LoadUrl(ViewModel.Uri);
}
示例12: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
var downloadButton = FindViewById<Button>(Resource.Id.downloadButton);
FindViewById<Button>(Resource.Id.backButton).Click += (sender, args) => { if (_webView.CanGoBack()) _webView.GoBack(); };
FindViewById<Button>(Resource.Id.forwardButton).Click += (sender, args) => { if (_webView.CanGoForward()) _webView.GoForward(); };
_webView = FindViewById<WebView>(Resource.Id.webView1);
var progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar1);
var title = FindViewById<TextView>(Resource.Id.textView1);
var frame = FindViewById(Resource.Id.frameDownload);
frame.Visibility = ViewStates.Gone;
var viewControls = new ViewControls {
DownloadButton = downloadButton,
ProgressBar = progressBar,
Title = title,
DownloadFrame = frame,
Activity = this
};
_webView.Settings.JavaScriptEnabled = true;
_webView.SetWebViewClient(new YoutubeWebViewClient(viewControls));
_webView.LoadUrl("http://www.youtube.com/");
}
示例13: collectDevice
public static void collectDevice()
{
string SessionId = Conekta.DeviceFingerPrint ();
string PublicKey = Conekta.PublicKey;
string html = "<!DOCTYPE html><html><head></head><body style=\"background: blue;\">";
html += "<script type=\"text/javascript\" src=\"https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js\" data-conekta-public-key=\"" + PublicKey + "\" data-conekta-session-id=\"" + SessionId + "\"></script>";
html += "</body></html>";
string contentPath = Environment.CurrentDirectory;
#if __IOS__
UIWebView web = new UIWebView(new RectangleF(new PointF(0,0), new SizeF(0, 0)));
web.ScalesPageToFit = true;
web.LoadHtmlString(html, new NSUrl("https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js"));
Conekta._delegate.View.AddSubview(web);
#endif
#if __ANDROID__
WebView web_view = new WebView(Android.App.Application.Context);
web_view.Settings.JavaScriptEnabled = true;
web_view.Settings.AllowContentAccess = true;
web_view.Settings.DomStorageEnabled = true;
web_view.LoadDataWithBaseURL(Conekta.UriConektaJs, html, "text/html", "UTF-8", null);
#endif
}
示例14: ReceivedErrorEventArgs
public ReceivedErrorEventArgs(WebView webView, ClientError errorCode, string description, string failingUrl)
{
this.WebView = webView;
this.ErrorCode = errorCode;
this.Description = description;
this.FailingUrl = failingUrl;
}
示例15: Reload
public override void Reload (WebView _webview)
{
base.Reload(_webview);
// Feature isnt supported
Console.LogError(Constants.kDebugTag, Constants.kFeatureNotSupported);
}