• 大小: 28.84MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-06-22
  • 语言: C#
  • 标签: C#GeckoFx  WinForm  

资源简介

WinForm GeckoFx33 Demo JS与C#互交 窗口浏览器之间的相互调用

资源截图

代码片段和文件信息

using Gecko;
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;

namespace TestGeckoFx
{
    public partial class Form1 : Form
    {
        private GeckoWebBrowser gfxBrowser;

        public Form1()
        {
            InitializeComponent();

            InitBrowser();
        }

        private void InitBrowser()
        {
            Gecko.Xpcom.Initialize(“xulrunner“);
            gfxBrowser = new GeckoWebBrowser() { Dock = Dockstyle.Fill };
            gfxBrowser.Parent = pnlMain;
            gfxBrowser.Navigate(string.Format(@“{0}\www\test.html“ Environment.CurrentDirectory));

            gfxBrowser.AddMessageEventListener(“call“ ((string p) => { call(p); }));
            gfxBrowser.AddMessageEventListener(“callMe“ ((string p) => { callMe(p); }));
        }

        public void call(String sss)
        {
            MessageBox.Show(“call:“ + sss);
        }

        public void callMe(String sss)
        {
            MessageBox.Show(“callMe:“ + sss);

        }

        private void button1_Click(object sender EventArgs e)
        {
            Executescript(“htest1(‘来自C#的调用1‘)“);
        }

        private void button2_Click(object sender EventArgs e)
        {
            Executescript(“htest1(‘来自C#的调用2‘)“);
        }

        private void Executescript(string func)
        {
            if (this.gfxBrowser.Document != null)
            {
                try
                {
                    var context = new AutoJSContext(this.gfxBrowser.Window.JSContext);
                    context.Evaluatescript(func gfxBrowser.Window.DomWindow);
                }
                catch (Exception ex)
                {

                }
            }
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        187  2017-07-22 11:18  TestGeckoFx\TestGeckoFx\App.config

     文件       1966  2017-07-22 11:51  TestGeckoFx\TestGeckoFx\Form1.cs

     文件       3792  2017-07-22 11:47  TestGeckoFx\TestGeckoFx\Form1.Designer.cs

     文件       5817  2017-07-22 11:47  TestGeckoFx\TestGeckoFx\Form1.resx

     文件    1309184  2015-06-24 09:14  TestGeckoFx\TestGeckoFx\lib\Geckofx-Core.dll

     文件     134656  2015-06-24 09:14  TestGeckoFx\TestGeckoFx\lib\Geckofx-Winforms.dll

     文件        523  2017-07-22 11:18  TestGeckoFx\TestGeckoFx\Program.cs

     文件       1346  2017-07-22 11:18  TestGeckoFx\TestGeckoFx\Properties\AssemblyInfo.cs

     文件       2874  2017-07-22 11:18  TestGeckoFx\TestGeckoFx\Properties\Resources.Designer.cs

     文件       5612  2017-07-22 11:18  TestGeckoFx\TestGeckoFx\Properties\Resources.resx

     文件       1098  2017-07-22 11:18  TestGeckoFx\TestGeckoFx\Properties\Settings.Designer.cs

     文件        249  2017-07-22 11:18  TestGeckoFx\TestGeckoFx\Properties\Settings.settings

     文件      10704  2017-07-22 11:52  TestGeckoFx\TestGeckoFx\TestGeckoFx.csproj

     文件        228  2017-07-22 11:40  TestGeckoFx\TestGeckoFx\TestGeckoFx.csproj.user

     文件      93436  2017-07-22 11:39  TestGeckoFx\TestGeckoFx\www\jquery-1.8.2.min.js

     文件       1578  2018-09-21 15:35  TestGeckoFx\TestGeckoFx\www\test.html

     文件      11776  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\AccessibleMarshal.dll

     文件      66560  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\breakpadinjector.dll

     文件     107008  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\crashreporter.exe

     文件       4063  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\crashreporter.ini

     文件    2106216  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\D3DCompiler_43.dll

     文件    3231832  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\d3dcompiler_46.dll

     文件        118  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\dependentlibs.list

     文件       3481  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\dictionaries\en-US.aff

     文件     680203  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\dictionaries\en-US.dic

     文件        899  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\freebl3.chk

     文件     323072  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\freebl3.dll

     文件    5001216  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\gkmedias.dll

     文件     126464  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\gmp-fake\1.0\fake.dll

     文件        102  2017-07-04 17:34  TestGeckoFx\TestGeckoFx\xulrunner\gmp-fake\1.0\fake.info

............此处省略46个文件信息

评论

共有 条评论