基本信息
源码名称:winform嵌入谷歌浏览器
源码大小:558.89M
文件格式:.rar
开发语言:C#
更新时间:2020-08-28
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Web;
using CefSharp;
using CefSharp.WinForms;
using YjiaLife.Utils;
using System.Configuration;

namespace YjiaLife
{
    public partial class Form1 : Form
    {
        //BardCodeHooK BarCode = new BardCodeHooK();

        private ScanerHook listener = new ScanerHook();

        //string value = ""; //value为扫码枪获取的内容,以Enter结尾
        //private delegate void ShowInfoDelegate(BardCodeHooK.BarCodes barCode);
        public Form1()
        {
            InitializeComponent();
        }


        public ChromiumWebBrowser browser;

        [Obsolete]
        public void InitBrowser()
        {
            InitializeComponent();
            this.MaximizeBox = false;

            this.MinimizeBox = false;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            string url = ConfigurationSettings.AppSettings["url"].ToString();
            int wide = Convert.ToInt32(ConfigurationSettings.AppSettings["wide"].ToString());
            int high = Convert.ToInt32(ConfigurationSettings.AppSettings["high"].ToString());

            //string url = "https://m.1jingxi.com/surpriseplus/jump";
            ChromiumWebBrowser webview = new ChromiumWebBrowser(url);
            webview.Dock = DockStyle.Fill;
            webview.Width = wide;
            webview.Height = high;
            webview.ConsoleMessage  = OnConsoleMessage;
            webview.StatusMessage  = OnBrowserStatusMessage;
            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            webview.JavascriptObjectRepository.Register("JsObject", new Class1(), false, BindingOptions.DefaultBinder);
            webview.KeyboardHandler = new CEFKeyBoardHander();
            this.Controls.Add(webview);

            //BarCode.BarCodeEvent  = new BardCodeHooK.BardCodeDeletegate(BarCode_BarCodeEvent);
            listener.ScanerEvent  = Listener_ScanerEvent;
        }
        /// <summary>浏览器状态记录</summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnBrowserStatusMessage(object sender, StatusMessageEventArgs args)
        {
            //loggerAlp.Info(args.Value);
        }
        /// <summary>浏览器错误信息记录</summary>
        /// <param name="o"></param>
        /// <param name="args"></param>
        private void OnConsoleMessage(object o, ConsoleMessageEventArgs args)
        {
            //loggerAlp.Info(string.Format("Line: {0}, Source: {1}, Message: {2}", args.Line, args.Source, args.Message));
        }

        [Obsolete]
        private void Form1_Load(object sender, EventArgs e)
        {
            InitBrowser();
        }


        //private void ShowInfo(BardCodeHooK.BarCodes barCode)
        //{
        //    if (this.InvokeRequired)
        //    {
        //        this.BeginInvoke(new ShowInfoDelegate(ShowInfo), new object[] { barCode });
        //    }
        //    else
        //    {
        //        if (barCode.KeyName.Equals("Enter"))
        //        {
        //            //hook_KeyDown(value);
        //            value = "";
        //        }
        //        else
        //        {
        //            value  = barCode.Chr.ToString();6972294972179

        //        }
        //    }
        //    MessageBox.Show(value);
        //}


        //void BarCode_BarCodeEvent(BardCodeHooK.BarCodes barCode)
        //{
        //    ShowInfo(barCode);
        //}
        private void Listener_ScanerEvent(ScanerHook.ScanerCodes codes)
        {
            MessageBox.Show(codes.Result);
        }
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            listener.Stop();
        }



        //使用例1(LPT打印):

        // printLPT.PrintESC(0);  //打印前退纸

        // printLPT.PrintDataSet(dsPrint);

        // printLPT.PrintESC(1);  //打印后进纸
    }
}