【实例简介】使用miniblink 展示html的例子,miniblink基于chromium的浏览器控件
【实例截图】
点击下图中的百度,即可 实现全屏访问 百度网页 ,如下图:
其实是winform嵌入的这个网页,打开即是 全屏效果
【核心代码】
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Kyozy.MiniblinkNet;
namespace ShowPage
{
public partial class Index : Form
{
private WebView m_wke;
private string path = "";
public Index()
{
m_wke = new WebView();
InitializeComponent();
try
{
string config = ReadTxt(System.AppDomain.CurrentDomain.BaseDirectory "html\\config.txt");
this.StartPosition = FormStartPosition.Manual;
this.FormBorderStyle = FormBorderStyle.None;
this.Location = new Point(Convert.ToInt32(config.Split('|')[0]), Convert.ToInt32(config.Split('|')[1]));
this.Size = new System.Drawing.Size(Convert.ToInt32(config.Split('|')[2]), Convert.ToInt32(config.Split('|')[3]));
path = System.AppDomain.CurrentDomain.BaseDirectory "html\\" config.Split('|')[4] "\\" config.Split('|')[5] ".html";
}
catch { }
}
///
/// 读取txt文件
///
///
///
public string ReadTxt(string path)
{
try
{
if (File.Exists(path))
{
StringBuilder sb = new StringBuilder();
StreamReader sr = new StreamReader(path, Encoding.Default);
String line;
while ((line = sr.ReadLine()) != null)
{
sb.Append(line.ToString());
}
sr.Dispose();
return sb.ToString();
}
else { return ""; }
}
catch { return ""; }
}
private void Index_Load(object sender, EventArgs e)
{
if (!m_wke.Bind(this)) { return; }
m_wke.NavigationToNewWindowEnable = false;
m_wke.CookieEnabled = false;
JsValue.BindFunction("FormClose", new wkeJsNativeFunction(formClose), 0);
JsValue.BindFunction("FormReload", new wkeJsNativeFunction(wkeReload), 0);
m_wke.Load(path);
}
long formClose(IntPtr es, IntPtr param)
{
System.Environment.Exit(0);
return JsValue.UndefinedValue();
}
long wkeReload(IntPtr es, IntPtr param)
{
m_wke.Reload();
return JsValue.UndefinedValue();
}
}
}