using POSV.Cef.Client.ClientComm; using POSV.Proxy.Stock; using POSV.Utils; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Reflection; using System.Text; using System.Windows.Forms; namespace POSV.Cef { public partial class CostControlListCef : BusinessForm { //===========================构造方法======================== public CostControlListCef() { InitializeComponent(); } public CostControlListCef(string name = null) : this() { DownloadCefDependentFile file = new DownloadCefDependentFile(); if (!file.Needtodownload()) { file.ShowDialog(); if (!file.IsAccomplish) { MessageBox.Show("运行环境安装时出现了问题,请与管理员联系!"); this.Close(); return; } } else { file.Dispose(); file.Close(); } m_costControlList = new CostControlList(); m_costControlList.m_LoadPageEvent += this.LoadModule; m_costControlList.m_BackFormEvent += this.BackForm; m_costControlList.m_CloseFormEvent += this.CloseForm; m_costControlList.m_ReloadFormEvent += this.Reload; m_costControlList.LoadModule("经营会计报表"); } //===========================全局参数======================== private CefUnifyBrowser m_CefClient = null; private CostControlList m_costControlList = null; //===========================共有参数======================== /// /// 经营成本报表 /// public CostControlList CostControlList { get => m_costControlList; } //===========================共有方法======================== public void Init() { #if DEBUG this.m_CefClient.ShowDevTools(); #endif } /// /// 关闭winfrom /// public void CloseForm() { m_CefClient.CloseBrowser(); } /// /// 后退 /// public void BackForm() { this.m_CefClient.BackForm(); } /// /// 后退 /// public void ForwardForm() { this.m_CefClient.ForwardForm(); } public void Reload() { this.m_CefClient.Reload(); } public void OnControlBoxKeyboardClick() { try { this.Invoke((EventHandler)delegate { KeyboardType keyboardType = KeyboardType.数字; Type type = this.ActiveControl.GetType(); PropertyInfo pinfo = type.GetProperty("Keyboard"); if (pinfo != null) { keyboardType = (KeyboardType)pinfo.GetValue(this.ActiveControl, null); } var keyboard = Application.OpenForms["VirtualKeyboard"]; if (keyboard == null) { keyboard = new VirtualKeyboard(keyboardType); } else { return; } ((VirtualKeyboard)keyboard).ShowVirtualKeyboard(this, keyboardType); }); } catch (Exception ex) { LOGGER.Error(ex, "打开屏幕键盘异常"); } } //===========================私有方法======================== /// /// winfrom 关闭窗口监听 /// private void CostControlListCef_FormClosed(object sender, FormClosedEventArgs e) { this.m_CefClient.CloseBrowser(); } /// /// 跳转界面 /// /// private void LoadModule(string url) { if (string.IsNullOrEmpty(url)) { return; } if (this.m_CefClient == null) { this.m_CefClient = new CefUnifyBrowser(this); this.m_CefClient.LoadingStateEvent += this.LoadingStateEvent; this.WindowState = FormWindowState.Maximized; } this.m_CefClient.LoadCef(url); } Loading loading = null; private void LoadingStateEvent(bool IsLoadStatus, string Message) { this.Invoke((EventHandler)delegate { try { if (loading == null) { loading = new Loading(); } if (IsLoadStatus) { loading.BringToFront(); loading.Show(this); } else { loading.Dispose(); loading.Close(); } } catch { } }); } } }