123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- using CefSharp;
- using CefSharp.WinForms;
- using efunbox_xyyf_windows.baseMvp;
- using efunbox_xyyf_windows.bean;
- using efunbox_xyyf_windows.contract;
- using efunbox_xyyf_windows.cusview;
- using efunbox_xyyf_windows.presenter;
- using efunbox_xyyf_windows.util;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace efunbox_xyyf_windows
- {
- public delegate void ChangeWebUrl(string url);
- public delegate void WebViewReload();
- public delegate string getWebUrl();
- public partial class Main : BaseForm<MainPresenter>, MainContract.IView
- {
-
- /*
- * debug使用到的方法
- * **/
- public static ChangeWebUrl changeWebUrl;
- public static WebViewReload webviewReload;
- public static getWebUrl getWebNowUrl;
- //webview
- ChromiumWebBrowser webview;
- public Main()
- {
- InitializeComponent();
- this.FormClosing += Form1_FormClosing;
- }
- //窗体加载
- private void Form1_Load(object sender, EventArgs e)
- {
- mPresenter = new MainPresenter();
- mPresenter.attachView(this);
- changeWebUrl = ChangeWebUrl;
- webviewReload = WebViewReload;
- getWebNowUrl = getWebUrl;
- }
- //窗体第一次显示
- private void Form1_Shown(object sender, EventArgs e)
- {
- loadingProgress.Value = 20;
- mPresenter.LenvAutoLogin();
- }
- /*
- * 窗体关闭
- * **/
- private void Form1_FormClosing(Object sender, FormClosingEventArgs e)
- {
- //阻止关闭
- //e.Cancel = true;
- //调用js方法通知网页用户想关闭应用
- //webview.GetBrowser().MainFrame.EvaluateScriptAsync("FormClosing()");
- //JS会回调JsInterface里面的exitApp()方法进行退出
- Cef.Shutdown();
- if (webview != null)
- {
- webview.Dispose();
- }
- }
- public string getWebUrl()
- {
- return mPresenter.getWebUrl();
- }
- public ChromiumWebBrowser getWebView()
- {
- try
- {
- return webview;
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- return null;
- }
- }
- public void getLenvIdSuccess()
- {
- loadingProgress.Value = 100;
- loadingProgress.Visible = false;
- //都获取到信息了,初始化webview
- webview = new ChromiumWebBrowser();
- mPresenter.initWebView(webview);
- this.Controls.Add(webview);
- showDialog();
- }
- public ProgressBar getLoadingBar()
- {
- return loadingProgress;
- }
- /*
- *
- * 以下是测试方法,DebugUtilForm窗口调用
- *
- * **/
- public void showDialog()
- {
- //测试用
- DialogResult MsgBoxResult;//设置对话框的返回值
- MsgBoxResult = System.Windows.Forms.MessageBox.Show("打开debug操作窗?", " ", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);//定义对话框的按钮式样
- if (MsgBoxResult.ToString() == "Yes")//如果对话框的返回值是YES(按"Y"按钮)
- {
- DebugUtilForm debugUtilForm = new DebugUtilForm();
- debugUtilForm.Show(this);
- }
- if (MsgBoxResult.ToString() == "No")//如果对话框的返回值是NO(按"N"按钮)
- {
- //选择了No,继续
- }
- }
- public void ChangeWebUrl(string url)
- {
- webview.LoadUrl(url);
- }
- public void WebViewReload()
- {
- webview.Reload();
- }
- }
- }
|