资源简介
CefSharp是一个针对.NET(WPF和Windows) Chromium 57 内核的应用项目
代码片段和文件信息
// Copyright © 2010-2015 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using CefSharp.OffScreen;
using System.Threading.Tasks;
namespace CefSharp.MinimalExample.OffScreen
{
public class Program
{
private static ChromiumWebBrowser browser;
public static void Main(string[] args)
{
const string testUrl = “https://www.google.com/“;
Console.WriteLine(“This example application will load {0} take a screenshot and save it to your desktop.“ testUrl);
Console.WriteLine(“You may see Chromium debugging output please wait...“);
Console.WriteLine();
var settings = new CefSettings()
{
//By default CefSharp will use an in-memory cache you need to specify a Cache Folder to persist data
CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) “CefSharp\\Cache“)
};
//Perform dependency check to make sure all relevant resources are in our output directory.
Cef.Initialize(settings performDependencyCheck: true browserProcessHandler: null);
// Create the offscreen Chromium browser.
browser = new ChromiumWebBrowser(testUrl);
// An event that is fired when the first page is finished loading.
// This returns to us from another thread.
browser.LoadingStateChanged += BrowserLoadingStateChanged;
// We have to wait for something otherwise the process will exit too soon.
Console.ReadKey();
// Clean up Chromium objects. You need to call this in your application otherwise
// you will get a crash when closing.
Cef.Shutdown();
}
private static void BrowserLoadingStateChanged(object sender LoadingStateChangedEventArgs e)
{
// Check to see if loading is complete - this event is called twice one when loading starts
// second time when it‘s finished
// (rather than an iframe within the main frame).
if (!e.IsLoading)
{
// Remove the load event handler because we only want one snapshot of the initial page.
browser.LoadingStateChanged -= BrowserLoadingStateChanged;
var scriptTask = browser.EvaluatescriptAsync(“document.getElementById(‘lst-ib‘).value = ‘CefSharp Was Here!‘“);
scriptTask.ContinueWith(t =>
{
//Give the browser a little time to render
Thread.Sleep(500);
// Wait for the screenshot to be taken.
var task = browser.ScreenshotAsync();
task.ContinueWith(x =>
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-04-21 22:55 CefSharp.MinimalExample-master\
文件 2518 2017-04-21 22:55 CefSharp.MinimalExample-master\.gitattributes
文件 1522 2017-04-21 22:55 CefSharp.MinimalExample-master\.gitignore
目录 0 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.OffScreen\
文件 4648 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.OffScreen\CefSharp.MinimalExample.OffScreen.csproj
文件 4235 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.OffScreen\Program.cs
目录 0 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.OffScreen\Properties\
文件 1259 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.OffScreen\Properties\AssemblyInfo.cs
文件 143 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.OffScreen\app.config
文件 2596 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.OffScreen\app.manifest
文件 383 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.OffScreen\packages.config
目录 0 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\
文件 10257 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\BrowserForm.Designer.cs
文件 4806 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\BrowserForm.cs
文件 43377 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\BrowserForm.resx
文件 5326 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\CefSharp.MinimalExample.WinForms.csproj
目录 0 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Controls\
文件 821 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Controls\ControlExtensions.cs
文件 1142 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Program.cs
目录 0 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Properties\
文件 1257 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Properties\AssemblyInfo.cs
文件 4697 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Properties\Resources.Designer.cs
文件 7109 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Properties\Resources.resx
目录 0 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Resources\
文件 47032 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Resources\chromium-256.png
文件 948 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Resources\nav_left_green.png
文件 864 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Resources\nav_plain_green.png
文件 864 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Resources\nav_plain_red.png
文件 960 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\Resources\nav_right_green.png
文件 143 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\app.config
文件 2513 2017-04-21 22:55 CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\app.manifest
............此处省略26个文件信息
评论
共有 条评论