Exemple #1
0
 private void LoadHandler_OnLoadStart(object sender, Chromium.Event.CfxOnLoadStartEventArgs e)
 {
     if (ci.debug)
     {
         Chromium.ShowDevTools();
     }
 }
Exemple #2
0
        public Form1()
            : base("http://res.app.local/index.html")
        {
            InitializeComponent();

            //FormBorderStyle = FormBorderStyle.FixedDialog;


            GlobalObject.AddFunction("showDialog").Execute += (_, args) =>
            {
                this.RequireUIThread(() =>
                {
                    var form2 = new Form2();
                    form2.ShowDialog(this);
                });
            };

            GlobalObject.AddFunction("showWindow").Execute += (_, args) =>
            {
                this.RequireUIThread(() =>
                {
                    var form2 = new Form2();
                    form2.Show(this);
                });
            };

            GlobalObject.AddFunction("showDevTools").Execute += (func, args) => Chromium.ShowDevTools();
        }
Exemple #3
0
 private void LoadHandler_OnLoadEnd(object sender, Chromium.Event.CfxOnLoadEndEventArgs e)
 {
     if (e.Frame.IsMain)
     {
         Chromium.ShowDevTools();
     }
 }
Exemple #4
0
        private void LoadHandler_OnLoadStart(object sender, Chromium.Event.CfxOnLoadStartEventArgs e)
        {
#if DEBUG
            Chromium.ShowDevTools();
            nfyMain.Visible = false;
#endif
        }
Exemple #5
0
        private void LoadHandler_OnLoadEnd(object sender, Chromium.Event.CfxOnLoadEndEventArgs e)
        {
#if DEBUG
            Chromium.ShowDevTools();
            #endif
            ExecuteJavascript("initAllFile()");
        }
Exemple #6
0
        public Form1()
            : base("http://res.app.local/index.html")
        {
            InitializeComponent();

            GlobalObject.AddFunction("showDevTools").Execute += (func, args) => Chromium.ShowDevTools();
        }
Exemple #7
0
        public Form1(Package <AppState> store)
            : base(store, Config.BaseUrl + "index.html")//"http://res.app.local/index.html"
        {
            InitializeComponent();

            this.ConfigChartAction();
            this.ConfigCommunityActions();

            GlobalObject.AddFunction("showDialog").Execute += (_, args) =>
            {
                this.RequireUIThread(() =>
                {
                    var form2 = new Form2(store);
                    form2.ShowDialog(this);
                });
            };

            GlobalObject.AddFunction("showDevTools").Execute += (func, args) => Chromium.ShowDevTools();

            LoadHandler.OnLoadEnd += LoadHandler_OnLoadEnd;

            store.Subscribe((subscription, action) =>
            {
                var state  = store.GetState();
                string cmd = string.Format("app.updateData({0})", JsonConvert.SerializeObject(state));
                ExecuteJavascript(cmd);
            });

            Store.Dispatch(new loadCommunityList());
        }
Exemple #8
0
 private void LoadHandler_OnLoadEnd(object sender, Chromium.Event.CfxOnLoadEndEventArgs e)
 {
     // Check if it is the main frame when page has loaded.
     if (e.Frame.IsMain)
     {
         Chromium.ShowDevTools();
     }
 }
Exemple #9
0
        private void LoadHandler_OnLoadStart(object sender, Chromium.Event.CfxOnLoadStartEventArgs e)
        {
            var host = ConfigurationManager.AppSettings["Host"].ToString();
            var url  = $"{host}/Excel/asserts/login.html";

#if DEBUG
            Chromium.ShowDevTools();
#endif
        }
Exemple #10
0
        public MainForm(Package <AppStore> store)
            : base(store, Config.BaseUrl + "index.html")
        {
            InitializeComponent();

            this.JsDispatchMethod = "vm.updateData({0})";

            LoadHandler.OnLoadEnd += (sender, e) => { Chromium.ShowDevTools(); };
        }
Exemple #11
0
 /// <summary>
 /// 获取键盘按下的key值
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void KeyboardHandler_OnKeyEvent(object sender, CfxOnKeyEventEventArgs e)
 {
     {
         if (e.Event.WindowsKeyCode == 123) //F12
         {
             Chromium.ShowDevTools();
         }
         if (e.Event.WindowsKeyCode == 116) //F5
         {
         }
     }
 }
Exemple #12
0
        public Form1() : base("about:blank")
        {
            InitializeComponent();

            Text        = "Hotel Management System";
            WindowState = FormWindowState.Maximized;
            GlobalObject.AddFunction("showDevTools").Execute   += (func, args) => Chromium.ShowDevTools();
            GlobalObject.AddFunction("windowMinimize").Execute += (func, args) => WindowState = FormWindowState.Minimized;
            GlobalObject.AddFunction("windowMaximize").Execute += (func, args) => WindowState = (WindowState == FormWindowState.Normal) ? FormWindowState.Maximized : FormWindowState.Normal;
            GlobalObject.AddFunction("windowClose").Execute    += CloseExecute;
            Chromium.BrowserCreated += Chromium_BrowserCreated;
            RegisterObject();
        }
Exemple #13
0
        private void LoadHandler_OnLoadEnd(object sender, Chromium.Event.CfxOnLoadEndEventArgs e)
        {
            // Check if it is the main frame when page has loaded.
            if (e.Frame.IsMain)
            {
                //Open DevTools window to watch js console output messages.
                Chromium.ShowDevTools();

                //call js function without return value
                ExecuteJavascript("sayHello()");

                //call js function with return value
                EvaluateJavascript("sayHelloToSomeone('C#')", (value, exception) =>
                {
                    if (value.IsString)
                    {
                        // Get value from Javascript.
                        var jsValue = value.StringValue;

                        MessageBox.Show(this, jsValue);
                    }
                });
            }
        }
Exemple #14
0
        private void Chromium_BrowserCreated(object sender, Chromium.WebBrowser.Event.BrowserCreatedEventArgs e)
        {
#if DEBUG
            Chromium.ShowDevTools();
#endif
        }
Exemple #15
0
        public Main()
            : base("http://res.app.local/main.html")
        {
            InitializeComponent();
            GetMain = this;

            this.Load += OnLoadForm;

            LoadHandler.OnLoadEnd += (sender, args) =>
            {
                PortMonitor.StartMonitor();
            };

            GlobalObject.AddFunction("ShowDevTools").Execute += (sender, args) =>
            {
                Chromium.ShowDevTools();
            };

            GlobalObject.AddFunction("HostOpenAndCloseSerialDevice").Execute += (sender, args) =>
            {
                try
                {
                    var          callback   = args.Arguments.FirstOrDefault(e => e.IsFunction);
                    string       deviceName = args.Arguments[0].StringValue;
                    SerialPortEx serial     = SelectSerialDevice(deviceName);
                    string       portName   = args.Arguments[1].StringValue;
                    if (!serial.IsOpen)
                    {
                        SerialPortManager.OpenSerialPort(serial, portName);
                    }
                    else
                    {
                        SerialPortManager.CloseSerialPort(serial);
                    }
                    string json = Utility.JsonSerializerBySingleData(serial);
                    callback.ExecuteFunction(null, new Chromium.Remote.CfrV8Value[] { json });
                }
                catch (Exception ex)
                {
                    Log4Helper.ErrorInfo(ex.Message, ex);
                    ViewCallFunction.ViewAlert(ex.Message);
                }
            };

            GlobalObject.AddFunction("HostAutoConnectionDeviced").Execute += (sender, args) =>
            {
                try
                {
                    bool autoConnection = args.Arguments[0].BoolValue;
                    if (autoConnection)
                    {
                        ConnectionSerialDevice.Start();
                    }
                    else
                    {
                        ConnectionSerialDevice.Stop();
                    }
                    ConnectionSerialDevice.AutoConnectioinDevice = autoConnection;
                }
                catch (Exception ex)
                {
                    Log4Helper.ErrorInfo(ex.Message, ex);
                    ViewCallFunction.ViewAlert(ex.Message);
                }
            };

            CardManagerEvh.InitEvent();
            PwdManagerEvh.InitEvent();
            ConfigureManagerEvh.InitEvent();
            WirelessManagerEvh.InitEvent();
            UserManagerEvh.InitEvent();
        }
Exemple #16
0
 public void ShowDevTools()
 {
     Chromium.ShowDevTools();
 }
        public Main()
            : base("http://res.app.local/index.html")
        {
            InitializeComponent();

            MainForm = this;

            LoadHandler.OnLoadEnd += HtmlLoadEnd;

            GlobalObject.AddFunction("ShowDevTools").Execute += (func, args) =>
            {
                this.RequireUIThread(() =>
                {
                    Chromium.ShowDevTools();
                });
            };

            GlobalObject.AddFunction("ChangeSerialConnection").Execute += (func, args) =>
            {
                this.RequireUIThread(() =>
                {
                    string portName = args.Arguments[0].StringValue;
                    if (SerialPortManager.Device.IsOpen)
                    {
                        SerialPortManager.Close();
                    }
                    else
                    {
                        SerialPortManager.Open(portName);
                    }
                    args.SetReturnValue(SerialPortManager.Device.IsOpen);
                });
            };

            GlobalObject.AddFunction("ChangeConnectionState").Execute += (func, args) =>
            {
                this.RequireUIThread(() =>
                {
                    bool state = args.Arguments[0].BoolValue;
                    if (state)
                    {
                        ConnectionManager.Start();
                    }
                    else
                    {
                        ConnectionManager.Stop();
                    }
                });
            };

            GlobalObject.AddFunction("ReconnectDevice").Execute += (func, args) =>
            {
                this.RequireUIThread(() =>
                {
                    ConnectionManager.Start();
                });
            };

            GlobalObject.AddFunction("RefreshClick").Execute += (func, args) =>
            {
                this.RequireUIThread(() =>
                {
                    bool ret = false;
                    try
                    {
                        DataManager.Params.Clear();
                        string deal = PortAgreement.ReadAllCard();
                        SerialPortManager.Write(deal);
                        OverTimer.start();

                        ret = true;
                    }
                    catch (Exception ex)
                    {
                        Log4Helper.ErrorInfo(ex.Message, ex);
                        JavascriptEvent.ErrorMessage(ex.Message);
                    }
                    args.SetReturnValue(ret);
                });
            };


            GlobalObject.AddFunction("DownloadClick").Execute += (func, args) =>
            {
                int count = DataManager.Params.Where(e => e.State != "设置成功" && e.DataType == "正常").Count();
                if (count == 0)
                {
                    args.SetReturnValue(count);
                    return;
                }
                this.RequireUIThread(() =>
                {
                    string strClientNumber = args.Arguments[0].StringValue;

                    Task.Factory.StartNew(() =>
                    {
                        foreach (Param item in DataManager.Params)
                        {
                            if (item.State != "设置成功" && item.DataType == "正常")
                            {
                                string deal = PortAgreement.WriteClientNumber(item.CardNumber, strClientNumber);
                                bool ret    = SerialPortManager.Write(deal);
                                if (ret)
                                {
                                    SerialPortManager.OperationResult = OperationResults.None;
                                    for (int i = 0; i < 500; i++)
                                    {
                                        Thread.Sleep(10);
                                        if (SerialPortManager.OperationResult != OperationResults.None)
                                        {
                                            if (SerialPortManager.OperationResult == OperationResults.Success)
                                            {
                                                item.State = "设置成功";

                                                DataManager.ViewListDisplay();
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        JavascriptEvent.OperationOver();
                    });
                });
                args.SetReturnValue(-1);
            };

            GlobalObject.AddFunction("SetDeviceClient").Execute += (func, args) =>
            {
                this.RequireUIThread(() =>
                {
                    string strClientNumber = args.Arguments[0].StringValue;
                    string deal            = PortAgreement.EncryptionDevice(strClientNumber);
                    bool ret = SerialPortManager.Write(deal);
                    args.SetReturnValue(ret);
                });
            };

            GlobalObject.AddFunction("SetCardNumber").Execute += (func, args) =>
            {
                this.RequireUIThread(() =>
                {
                    string strOldNumber  = args.Arguments[0].StringValue;
                    string strCardNumber = args.Arguments[1].StringValue;
                    string strType       = args.Arguments[2].StringValue;
                    string deal          = PortAgreement.WriteCardNumber(strOldNumber, strCardNumber, strType);
                    bool ret             = SerialPortManager.Write(deal);
                    if (ret)
                    {
                        if (strCardNumber != "797979" || strCardNumber != "123456")
                        {
                            ConfigManager.SetConfig("Number", strCardNumber);
                        }
                    }
                    args.SetReturnValue(ret);
                });
            };
        }
Exemple #18
0
 /// <summary>
 /// cef加载完成 如果是调试打开调试工具
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void LoadHandler_OnLoadStart(object sender, Chromium.Event.CfxOnLoadStartEventArgs e)
 {
     //#if DEBUG
     Chromium.ShowDevTools();
     //#endif
 }