Esempio n. 1
0
        public ChromeController()
        {
            this.Tesseract             = new TesseractEngine("./tessdata", "chi_sim", EngineMode.Default);
            this.ControllerCancelToken = new CancellationTokenSource();
            this.StartCallerAsync      = WaitNewGambling;
            this._newTabOpenListener   = new Task(() =>
            {
                var wait = new WebDriverWait(this.Instance, new TimeSpan(0, 10, 0));
                try
                {
                    wait.Until((IWebDriver driver) =>
                    {
                        if (driver.WindowHandles.Count == 2)
                        {
                            // Close First tab and select the active tab.
                            driver.SwitchTo().Window(driver.WindowHandles.First()).Close();
                            driver.SwitchTo().Window(driver.WindowHandles.First());

                            // Set bound.
                            driver.Manage().Window.Size = Global.__BROWSER_WINDOWSIZE;
                            AutomateController.Instance().SetDriverPostion(driver);

                            Status = DriverState.Open;
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    });
                }
                catch (WebDriverTimeoutException timeOutException)
                {
                    LogHelper.Error(timeOutException);
                    Status = DriverState.Close;
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                    Status = DriverState.Close;
                }
            });
        }
Esempio n. 2
0
        public FormController InitNotify(bool visible)
        {
            if (!visible)
            {
                if (this._notifyIcon == null)
                {
                    this._notifyIcon             = new NotifyIcon();
                    this._notifyIcon.ContextMenu = new ContextMenu(new MenuItem[]
                    {
                        new MenuItem("退出", new EventHandler((object sender, EventArgs args) =>
                        {
                            this._notifyIcon.Visible = false;
                            AutomateController.Instance().CloseAll(() =>
                            {
                                FormManager.Instance().Close();
                                Application.Exit();
                            });
                        }))
                    });
                }
                this._notifyIcon.Visible     = visible;
                this._notifyIcon.Text        = "Smart Tool ✔";
                this._notifyIcon.Icon        = Icon.FromHandle(Resources.Sleep.GetHicon());
                this._notifyIcon.MouseClick -= this._notifyIcon_MouseClick;
                this._notifyIcon.MouseClick += this._notifyIcon_MouseClick;
            }
            else
            {
                this._notifyIcon.Visible         = visible;
                this._notifyIcon.BalloonTipTitle = "Smart Tool ✔";
                this._notifyIcon.BalloonTipText  = "程序正在后台运行";
                this._notifyIcon.ShowBalloonTip(1);
            }

            return(this);
        }