using CefSharp;
using CefSharp.WinForms;
using Newtonsoft.Json;
using OTSIncAReportApp.SysMgrTools;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace OTSIncAReportApp.Control_ECharts
{
///
/// 各图char相关模块
///
public partial class EChart_ParticlesComposition : UserControl
{
#region 图表相关变量
//y轴名称
public string m_str_AxisY { get; set; }
//定义图片
JsEvent js;
//定义图片base64
public string pic { get; set; }
//定义图形类型
public string type { get; set; }
//图形数据
public string data { get; set; }
string url = "Resources/HTML/charts.html";
//数据图类型:常用夹杂物分类CommonlyUsedClassify ,颗粒成分PComponent,元素成分EComponent,颗粒尺寸分布PSize
string ComSel { get; set; }
frmReportApp m_ReportApp;
List FLID = new List() { 0, 1, 2, 4, 6, 7, 8, 9 };
List NameList = new List() { "过小颗粒", "过大颗粒", "亮度不在分析范围内的颗粒", "低计数率颗粒", "不含分析元素的颗粒", "非夹杂物颗粒SiC", "非夹杂物颗粒FeO", "未识别颗粒" };
#endregion
#region 窗体加载及构造函数
public EChart_ParticlesComposition(frmReportApp ReportApp, string comsel)
{
ComSel = comsel;
m_ReportApp = ReportApp;
InitializeComponent();
}
private void EChart_ParticlesComposition_Load(object sender, EventArgs e)
{
//国际化
Language lan = new Language();
Hashtable table = lan.GetNameTable("CompositionDistributionGrid");
NameList = new List() { table["partcletype0"].ToString(), table["partcletype1"].ToString(), table["partcletype2"].ToString(), table["partcletype4"].ToString(), table["partcletype6"].ToString(), table["partcletype7"].ToString(), table["partcletype8"].ToString(), table["partcletype9"].ToString() };
int idx = m_ReportApp.m_DataMgrFun.GetSampleIndexByPropItemName(m_ReportApp.SourceGridData.SampleDataList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
string sou = m_ReportApp.SourceGridData.SampleDataList[idx].itemVal.ToString();
if (sou.Contains("+"))
{
if (m_ReportApp.more)
{
m_ReportApp.trans = false;
}
else
{
m_ReportApp.trans = true;
}
m_ReportApp.more = true;
//获取到List,json的字符串
ChartdateMore list_json_str = GetListJsonStr();
url = "Resources/HTML/chartsMore.html";
m_ReportApp.data = JsonConvert.SerializeObject(list_json_str);
}
else
{
if (!m_ReportApp.more)
{
m_ReportApp.trans = false;
}
else
{
m_ReportApp.trans = true;
}
m_ReportApp.more = false;
//获取到List,json的字符串
List list_json_str = GetListJsonStrByChartStruct();
url = "Resources/HTML/charts.html";
m_ReportApp.data = JsonConvert.SerializeObject(list_json_str[0]);
}
InitBrowser();
}
#endregion
#region 获取单数据源
private Chartdate GetCommonlyUsedClassifyData(string path)
{
DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
//创建新的图形数据源
Chartdate chart = new Chartdate();
chart.Title = m_ReportApp.m_reportname;
chart.YName = m_str_AxisY;
int idx = m_ReportApp.m_DataMgrFun.GetSampleIndexByPropItemName(m_ReportApp.SourceGridData.SampleDataList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
int sel = m_ReportApp.SourceGridData.SampleDataList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.SampleDataList[idx].itemVal.ToString());
string filedAndParticl = "";
if (sel == 1)
{
List selectParticles = m_ReportApp.SelectedParticles;
foreach (var item in selectParticles)
{
filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
}
if (filedAndParticl != "")
{
filedAndParticl = filedAndParticl + ",";
}
}
DataTable dt = particledata.GetCommonlyUsedClassifyData();
//设置标签名称
List listName = new List();
listName.Add("尖晶石");
listName.Add("氧化物");
listName.Add("硫氧化物");
listName.Add("氮化物");
listName.Add("硫化物");
chart.ListName = listName;
//设置数据
List- listData = new List
- ();
//ListData
for (int k = 0; k < dt.Rows.Count; k++)
{
try
{
Item item_SPINEL = new Item()
{
value = decimal.Round(decimal.Parse(dt.Rows[k]["SPINEL"].ToString()), 2).ToString(),
name = "尖晶石"
};
listData.Add(item_SPINEL);
Item item_OXIDE = new Item()
{
value = decimal.Round(decimal.Parse(dt.Rows[k]["OXIDE"].ToString()), 2).ToString(),
name = "氧化物"
};
listData.Add(item_OXIDE);
Item item_SULFIDE_OXIDE = new Item()
{
value = decimal.Round(decimal.Parse(dt.Rows[k]["SULFIDE_OXIDE"].ToString()), 2).ToString(),
name = "硫氧化物"
};
listData.Add(item_SULFIDE_OXIDE);
Item item_NITRIDE = new Item()
{
value = decimal.Round(decimal.Parse(dt.Rows[k]["NITRIDE"].ToString()), 2).ToString(),
name = "氮化物"
};
listData.Add(item_NITRIDE);
Item item_SULFIDE = new Item()
{
value = decimal.Round(decimal.Parse(dt.Rows[k]["SULFIDE"].ToString()), 2).ToString(),
name = "硫化物"
};
listData.Add(item_SULFIDE);
}
catch
{
Item item = new Item()
{
value = "",
name = ""
};
listData.Add(item);
}
}
chart.ListData = listData;
return chart;
}
///
/// 获取颗粒成分数据
///
private Chartdate GetPComponentData(string path)
{
DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
//创建新的图形数据源
Chartdate chart = new Chartdate();
chart.Title = m_ReportApp.m_reportname;
chart.YName = m_str_AxisY;
int idx = m_ReportApp.m_DataMgrFun.GetSampleIndexByPropItemName(m_ReportApp.SourceGridData.SampleDataList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
int sel = m_ReportApp.SourceGridData.SampleDataList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.SampleDataList[idx].itemVal.ToString());
string filedAndParticl = "";
if (sel == 1)
{
List selectParticles = m_ReportApp.SelectedParticles;
foreach (var item in selectParticles)
{
filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
}
if (filedAndParticl != "")
{
filedAndParticl = filedAndParticl + ",";
}
}
DataTable dt = particledata.GetParticleListByIncA("area", filedAndParticl);
//设置标签名称
List listName = new List();
//ListName
for (int i = 0; i < dt.Rows.Count; i++)
{
if (Convert.ToInt32(dt.Rows[i]["TypeId"]) < 100)
{
continue;
}
listName.Add(dt.Rows[i]["TypeName"].ToString());
}
for (int i = 0; i < dt.Rows.Count; i++)
{
if (Convert.ToInt32(dt.Rows[i]["TypeId"]) > 100)
{
continue;
}
int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[i]["TypeId"]));
if (index == -1)
{
index = 7;
}
string name = NameList[index];
if (listName.IndexOf(name) == -1)
{
listName.Add(name);
}
}
chart.ListName = listName;
//设置数据
List
- listData = new List
- ();
//ListData
for (int k = 0; k < dt.Rows.Count; k++)
{
string str = dt.Rows[k]["con"].ToString();
string name = dt.Rows[k]["TypeName"].ToString();
if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
{
int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[k]["TypeId"]));
if (index == -1)
{
index = 7;
}
name = NameList[index];
}
Item item = new Item()
{
value = decimal.Round(decimal.Parse(str), 2).ToString(),
name = name
};
listData.Add(item);
}
chart.ListData = listData;
return chart;
}
///
/// 获取元素成分数据
///
private Chartdate GetEComponentData(string path)
{
DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
//创建新的图形数据源
Chartdate chart = new Chartdate();
chart.Title = m_ReportApp.m_reportname;
chart.YName = m_str_AxisY;
int idx = m_ReportApp.m_DataMgrFun.GetSampleIndexByPropItemName(m_ReportApp.SourceGridData.SampleDataList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
int sel = m_ReportApp.SourceGridData.SampleDataList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.SampleDataList[idx].itemVal.ToString());
string filedAndParticl = "";
if (sel == 1)
{
List selectParticles = m_ReportApp.SelectedParticles;
foreach (var item in selectParticles)
{
filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
}
if (filedAndParticl != "")
{
filedAndParticl = filedAndParticl + ",";
}
}
DataTable dt = particledata.GetElementForArea(filedAndParticl);
//设置标签名称
List listName = new List();
//ListName
for (int i = 0; i < dt.Rows.Count; i++)
{
listName.Add(dt.Rows[i]["name"].ToString());
}
chart.ListName = listName;
//设置数据
List
- listData = new List
- ();
//ListData
for (int k = 0; k < dt.Rows.Count; k++)
{
string str = dt.Rows[k]["earea"].ToString();
try
{
Item item = new Item()
{
value = decimal.Round(decimal.Parse(str), 2).ToString(),
name = dt.Rows[k]["name"].ToString()
};
listData.Add(item);
}
catch
{
Item item = new Item()
{
value = str,
name = dt.Rows[k]["name"].ToString()
};
listData.Add(item);
}
}
chart.ListData = listData;
return chart;
}
///
/// 获取此尺寸分布图数据
///
private Chartdate GetPSizeData(string path)
{
DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
//创建新的图形数据源
Chartdate chart = new Chartdate();
chart.Title = m_ReportApp.m_reportname;
chart.YName = m_str_AxisY;
//设置标签名称
List listName = new List();
//获取粒级表
string pathe = m_ReportApp.m_RptConfigFile.FileFolderSize + m_ReportApp.m_RptConfigFile.PartSizeFile;
DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
{
if (sizestr.Split(',')[i].Length > 0)
{
double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
listName.Add(d1.ToString() + "~" + d2.ToString());
}
}
double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
listName.Add(d.ToString() + "~MAX");
chart.ListName = listName;
int idx = m_ReportApp.m_DataMgrFun.GetSampleIndexByPropItemName(m_ReportApp.SourceGridData.SampleDataList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
int sel = m_ReportApp.SourceGridData.SampleDataList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.SampleDataList[idx].itemVal.ToString());
string filedAndParticl = "";
if (sel == 1)
{
List selectParticles = m_ReportApp.SelectedParticles;
foreach (var item in selectParticles)
{
filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
}
if (filedAndParticl != "")
{
filedAndParticl = filedAndParticl + ",";
}
}
idx = m_ReportApp.m_DataMgrFun.GetSampleIndexByPropItemName(m_ReportApp.SourceGridData.SampleDataList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE);
string con = m_ReportApp.SourceGridData.SampleDataList[idx].itemVal.ToString();
string po = "";
switch (con)
{
case "DMAX":
po = "DMAX";
break;
case "DMIN":
po = "DMIN";
break;
case "Area":
po = "Area";
break;
case "FERET":
po = "DFERET";
break;
}
DataTable dtp = particledata.GetParticleAll(filedAndParticl);
//设置数据
List
- listData = new List
- ();
//ListData
for (int k = 0; k < listName.Count; k++)
{
string str = listName[k];
string d1 = str.Split('~')[0];
string d2 = str.Split('~')[1];
if (d2 == "MAX")
{
d2 = "999";
}
DataRow[] datas = dtp.Select(getWhere(d2, d1, po));
Item item = new Item()
{
value = datas.Count().ToString(),
name = str
};
listData.Add(item);
}
chart.ListData = listData;
return chart;
}
private string getWhere(string max, string min, string col)
{
return col + ">=" + min + " and " + col + "<=" + max;
}
#endregion
#region echarts
///
/// 通过m_list_chartstruct,组合json数据格式
///
///
private List GetListJsonStrByChartStruct()
{
List list = new List();
Chartdate chartdate = new Chartdate();
switch (ComSel)
{
case "CommonlyUsedClassify":
chartdate = GetCommonlyUsedClassifyData(m_ReportApp.resultFilesList[m_ReportApp.WorkingResult].FilePath);
break;
case "PComponent":
chartdate = GetPComponentData(m_ReportApp.resultFilesList[m_ReportApp.WorkingResult].FilePath);
break;
case "EComponent":
chartdate = GetEComponentData(m_ReportApp.resultFilesList[m_ReportApp.WorkingResult].FilePath);
break;
case "PSize":
chartdate = GetPSizeData(m_ReportApp.resultFilesList[m_ReportApp.WorkingResult].FilePath);
break;
}
list.Add(chartdate);
return list;
}
///
/// 通过m_list_chartstruct,组合json数据格式
///
///
private ChartdateMore GetListJsonStr()
{
int idx = m_ReportApp.m_DataMgrFun.GetSampleIndexByPropItemName(m_ReportApp.SourceGridData.SampleDataList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
int sel = m_ReportApp.SourceGridData.SampleDataList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.SampleDataList[idx].itemVal.ToString());
string filedAndParticl = "";
if (sel == 1)
{
List selectParticles = m_ReportApp.SelectedParticles;
foreach (var item in selectParticles)
{
filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
}
if (filedAndParticl != "")
{
filedAndParticl = filedAndParticl + ",";
}
}
DataOperation.DataAccess.ParticleData particledata = null;
DataTable dt = new DataTable();
ChartdateMore chart = new ChartdateMore();
chart.Title = m_ReportApp.m_reportname;
chart.YName = m_str_AxisY;
List listName = new List();
List soursName = new List();
List
> listDataMore = new List>();
idx = m_ReportApp.m_DataMgrFun.GetSampleIndexByPropItemName(m_ReportApp.SourceGridData.SampleDataList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
string sou = m_ReportApp.SourceGridData.SampleDataList[idx].itemVal.ToString();
if (sou.Contains("+"))
{
for (int i = 0; i < sou.Split('+').Length; i++)
{
DataOperation.Model.ResultFile resultFile = m_ReportApp.resultFilesList.Find(s => s.FileName == sou.Split('+')[i]);
if (resultFile == null)
{
continue;
}
soursName.Add(resultFile.FileName);
particledata = new DataOperation.DataAccess.ParticleData(resultFile.FilePath);
switch (ComSel)
{
case "CommonlyUsedClassify":
break;
case "PComponent":
//创建新的图形数据源
dt = particledata.GetParticleListByIncA("area", filedAndParticl);
//设置标签名称
for (int j = 0; j < dt.Rows.Count; j++)
{
if (Convert.ToInt32(dt.Rows[j]["TypeId"]) < 100)
{
continue;
}
string name = dt.Rows[j]["TypeName"].ToString();
if (!listName.Contains(name))
{
listName.Add(name);
}
}
for (int j = 0; j < dt.Rows.Count; j++)
{
if (Convert.ToInt32(dt.Rows[j]["TypeId"]) > 100)
{
continue;
}
int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[j]["TypeId"]));
if (index == -1)
{
index = 7;
}
string name = NameList[index];
if (!listName.Contains(name))
{
listName.Add(name);
}
}
//设置数据
List- listData = new List
- ();
//ListData
for (int k = 0; k < dt.Rows.Count; k++)
{
string str = dt.Rows[k]["con"].ToString();
string name = dt.Rows[k]["TypeName"].ToString();
if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
{
int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[k]["TypeId"]));
name = NameList[index];
}
Item item = new Item()
{
value = decimal.Round(decimal.Parse(str), 2).ToString(),
name = name
};
listData.Add(item);
}
listDataMore.Add(listData);
break;
case "EComponent":
//创建新的图形数据源
dt = particledata.GetElementForArea(filedAndParticl);
//ListName
for (int j = 0; j < dt.Rows.Count; j++)
{
string name = dt.Rows[j]["name"].ToString();
if (!listName.Contains(name))
{
listName.Add(name);
}
}
//设置数据
List
- listData1 = new List
- ();
//ListData
for (int k = 0; k < dt.Rows.Count; k++)
{
string str = dt.Rows[k]["earea"].ToString();
try
{
Item item = new Item()
{
value = decimal.Round(decimal.Parse(str), 2).ToString(),
name = dt.Rows[k]["name"].ToString()
};
listData1.Add(item);
}
catch
{
Item item = new Item()
{
value = str,
name = dt.Rows[k]["name"].ToString()
};
listData1.Add(item);
}
}
listDataMore.Add(listData1);
break;
case "PSize":
//获取粒级表
string pathe = m_ReportApp.m_RptConfigFile.FileFolderSize + m_ReportApp.m_RptConfigFile.PartSizeFile;
DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
List temp = new List();
for (int j = 0; j < sizestr.Split(',').Length - 1; j++)
{
if (sizestr.Split(',')[j].Length > 0)
{
double d1 = Convert.ToDouble(sizestr.Split(',')[j]);
double d2 = Convert.ToDouble(sizestr.Split(',')[j + 1]);
string name = d1.ToString() + "~" + d2.ToString();
temp.Add(name);
if (!listName.Contains(name))
{
listName.Add(name);
}
}
}
double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
string name1 = d.ToString() + "~MAX";
temp.Add(name1);
if (!listName.Contains(name1))
{
listName.Add(name1);
}
string con = m_ReportApp.SourceGridData.SampleDataList[m_ReportApp.m_DataMgrFun.GetSampleIndexByPropItemName(m_ReportApp.SourceGridData.SampleDataList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE)].itemVal.ToString();
string po = "";
switch (con)
{
case "DMAX":
po = "DMAX";
break;
case "DMIN":
po = "DMIN";
break;
case "Area":
po = "Area";
break;
case "FERET":
po = "DFERET";
break;
}
DataTable dtp = particledata.GetParticleAll(filedAndParticl);
//设置数据
List
- listData2 = new List
- ();
//ListData
for (int k = 0; k < temp.Count; k++)
{
string str = temp[k];
string d1 = str.Split('~')[0];
string d2 = str.Split('~')[1];
if (d2 == "MAX")
{
d2 = "999";
}
DataRow[] datas = dtp.Select(getWhere(d2, d1, po));
Item item = new Item()
{
value = datas.Count().ToString(),
name = str
};
listData2.Add(item);
}
listDataMore.Add(listData2);
break;
}
}
}
chart.ListName = listName;
chart.SoursName = soursName;
chart.ListData = listDataMore;
return chart;
}
class Chartdate
{
public string Title { get; set; }
public string YName { get; set; }
public List ListName { get; set; }
public List
- ListData { get; set; }
}
class ChartdateMore
{
public string Title { get; set; }
public string YName { get; set; }
public List ListName { get; set; }
public List SoursName { get; set; }
public List
> ListData { get; set; }
}
class Item
{
public string value { get; set; }
public string name { get; set; }
}
//获取图片
private void button1_Click(object sender, EventArgs e)
{
string str = GetPic();
pic = str;
//保存目录
string dir = Path.Combine(Directory.GetCurrentDirectory(), "Resources/HTML/pic");
//文件名称
string fileName = "headdemo" + DateTime.Now.ToString("yyyyMMddHHmmssff");
//保存文件所在站点位置
string filePath = Path.Combine(dir, fileName);
if (!System.IO.Directory.Exists(dir))
System.IO.Directory.CreateDirectory(dir);
//将Base64String转为图片并保存
byte[] arr2 = Convert.FromBase64String(str.Substring(str.IndexOf(',') + 1));
using (MemoryStream ms2 = new MemoryStream(arr2))
{
System.Drawing.Bitmap bmp2 = new System.Drawing.Bitmap(ms2);
bmp2.Save(filePath + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
///
/// 加载浏览器
///
public void InitBrowser()
{
//加载网页
if (m_ReportApp.browser == null || m_ReportApp.trans)
{
// 获取生成路径下网页文件的绝对路径
string fileName = Path.Combine(Directory.GetCurrentDirectory(), url);
//加载网页
m_ReportApp.browser = new ChromiumWebBrowser(fileName);
//禁止网页
m_ReportApp.browser.MenuHandler = new MenuHandler();
m_ReportApp.browser.Dock = DockStyle.Fill;
m_ReportApp.js.MessageText = "";
//添加网页到当前自定义控件
this.Controls.Add(m_ReportApp.browser);
//供页面调用以传递数据
m_ReportApp.browser.RegisterJsObject("jsObj", m_ReportApp.js, false);
//升级cef版本后新方法
//CefSharpSettings.LegacyJavascriptBindingEnabled = true;
//CefSharpSettings.WcfEnabled = true;
//m_ReportApp.browser.JavascriptObjectRepository.Register("jsObj", m_ReportApp.js, isAsync: false, options: BindingOptions.DefaultBinder);
//网页加载结束后调用事件
m_ReportApp.browser.FrameLoadEnd += WebBrowser_FrameLoadEnd;
}
else
{
m_ReportApp.browser.ResetText();
m_ReportApp.browser.Reload();
m_ReportApp.browser.Refresh();
//供页面调用以传递数据
this.Controls.Add(m_ReportApp.browser);
}
if (m_ReportApp.timerKG)
{
timer1.Enabled = true;
}
}
///
/// 页面加载结束后事件
///
///
///
private void WebBrowser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
{
if (e.Frame.IsMain)
{
//为页面图形提供数据参数
string str = m_ReportApp.data;
//执行网页脚本事件
m_ReportApp.browser.ExecuteScriptAsync("showchart('" + str + "','" + m_ReportApp.type + "')");
}
}
public string GetPic()
{
return js.MessageText;
}
//禁止网页操作,右键点击等
class MenuHandler : CefSharp.IContextMenuHandler
{
void CefSharp.IContextMenuHandler.OnBeforeContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model)
{
model.Clear();
}
bool CefSharp.IContextMenuHandler.OnContextMenuCommand(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.CefMenuCommand commandId, CefSharp.CefEventFlags eventFlags)
{
//throw new NotImplementedException();
return false;
}
void CefSharp.IContextMenuHandler.OnContextMenuDismissed(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame)
{
//throw new NotImplementedException();
}
bool CefSharp.IContextMenuHandler.RunContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model, CefSharp.IRunContextMenuCallback callback)
{
return false;
}
}
class JsEvent
{
public string MessageText { set; get; }
public void ShowTest()
{
MessageBox.Show(MessageText);
}
}
#endregion
#region EChart导出图像委托调用部份
public delegate void MyDelgate(string va);
public event MyDelgate butclic;
private void timer1_Tick(object sender, EventArgs e)
{
if (butclic == null)
return;
if (m_ReportApp.js == null)
return;
if (m_ReportApp.js.MessageText == null)
return;
if (m_ReportApp.js.MessageText != "")
{
butclic(m_ReportApp.js.MessageText);
timer1.Enabled = false;
m_ReportApp.timerKG = false;
}
}
#endregion
}
}