Form1.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using CefSharp;
  2. using CefSharp.WinForms;
  3. using efunbox_xyyf_windows.cusview;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Diagnostics;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace efunbox_xyyf_windows
  15. {
  16. public partial class Form1 : Form
  17. {
  18. public Form1()
  19. {
  20. InitializeComponent();
  21. initWeb();
  22. }
  23. private void Form1_Load(object sender, EventArgs e)
  24. {
  25. }
  26. void initWeb()
  27. {
  28. var setting = new CefSettings();
  29. setting.Locale = "zh-CN";
  30. CefSharp.Cef.Initialize(setting);
  31. webview.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true;
  32. webview.JavascriptObjectRepository.Settings.JavascriptBindingApiEnabled = true;
  33. webview.JavascriptObjectRepository.ResolveObject += (s, eve) =>
  34. {
  35. var repo = eve.ObjectRepository;
  36. //eve.ObjectName对应html里面绑定的bindName
  37. if (eve.ObjectName == "efunboxJS")
  38. {
  39. repo.Register("efunboxJS", new JSInterfaces(), isAsync: true, options: BindingOptions.DefaultBinder);
  40. }
  41. // else if (eve.ObjectName == "videoJS")
  42. // {
  43. // repo.Register("videoJS", new VideoJs(), isAsync: true, options: BindingOptions.DefaultBinder);
  44. // }
  45. };
  46. String url = "http://m-xyyf-web.ai160.com/stage/index/index.html?";
  47. StringBuilder paramss = new StringBuilder();
  48. paramss.Append("uuid=02b5c3ec-4be9-3337-bc0a-f4a172b0f0c8");
  49. paramss.Append("&");
  50. paramss.Append("appCode=2006");
  51. url= url+paramss.ToString();
  52. webview.LoadUrl(url);
  53. webview.MenuHandler = new MenuHandler();
  54. webview.DragHandler=new DragHandler();
  55. }
  56. private void Form1_Resize(object sender, EventArgs e)
  57. {
  58. webview.Dock = DockStyle.Fill;
  59. }
  60. private void button1_Click(object sender, EventArgs e)
  61. {
  62. System.Diagnostics.Debug.WriteLine("xxxxxxx");
  63. }
  64. }
  65. }