示例#1
0
        void ShowResult(string strOut, eState eI)
        {
            if (btnResult.InvokeRequired)
            {
                ShowResultDelegate SRD = new ShowResultDelegate(ShowResult);
                this.BeginInvoke(SRD, new object[] { strOut, eI });
            }
            else
            {
                btnResult.Text = strOut;
                switch (eI)
                {
                case eState.eTesting:
                {
                    btnResult.BackColor = Color.PaleGoldenrod;
                    break;
                }

                case eState.ePass:
                {
                    btnResult.BackColor = Color.YellowGreen;
                    break;
                }

                case eState.eFail:
                {
                    btnResult.BackColor = Color.Red;
                    break;
                }

                default:
                    break;
                }
            }
        }
示例#2
0
        public Form1()
        {
            InitializeComponent();
            ShowResultDelegate showResult = new ShowResultDelegate(DisplayText);

            brain = new Brain(showResult);
        }
示例#3
0
 public Brain(ShowResultDelegate resultDelegate)
 {
     this.resultDelegate = resultDelegate;
     tempNumber          = "";
     tempNumber2         = "";
     operation           = "";
     operation2          = "";
     resultDelegate("0");
 }
示例#4
0
        static void Main(string[] args)
        {
            ShowResultDelegate showResultDelegate = new ShowResultDelegate(PrintInfo);
            Brain brain = new Brain(showResultDelegate);

            while (true)
            {
                ConsoleKeyInfo consoleKeyInfo = Console.ReadKey();
                brain.Process(consoleKeyInfo.KeyChar.ToString());
            }
        }
示例#5
0
        private void Browser_DocumentCompletedSingle(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (endOfRender)
            {
                WebBrowserEx wb = sender as WebBrowserEx;
                wb.Document.Window.Error += new HtmlElementErrorEventHandler(Window_Error);

                try
                {
                    string filename = wb.Document.Title;
                    wb.Width  = wb.Document.Body.ScrollRectangle.Width;
                    wb.Height = wb.Document.Body.ScrollRectangle.Height + DEFAULTHEIGHOFFSET;

                    if (wb.Width == 0 | wb.Height == 0)
                    {
                        wb.Height = 1;
                        wb.Width  = 1;
                    }

                    wb.MaximumSize = new Size(SWidth, SHeight);
                    wb.Width       = SWidth;

                    //Crop images to prevent crashes/reduce required disk space
                    if (wb.Height > SHeight)
                    {
                        wb.Height = SHeight;
                    }

                    using (Bitmap bitmap = new Bitmap(wb.Width, wb.Height))
                    {
                        DateTime dt = DateTime.Now;
                        if (argOutputPath != "")
                        {
                            folder = argOutputPath;
                            if (!argOutputPath.EndsWith("\\"))
                            {
                                folder += "\\";
                            }
                        }
                        else
                        {
                            folder = Path.GetTempPath();
                        }
                        string imagePath = folder + tbFileReference.Text + SFileExtension;

                        NativeMethods.GetImage(wb.ActiveXInstance, bitmap, Color.White); //Solution to get google working: http://stackoverflow.com/posts/27590132/revisions

                        byte[] imgBytes;
                        if (argWatermarkUrl == NOWATERMARKSELECTED)
                        {
                            imgBytes = ImageToByte(bitmap);
                        }
                        else
                        {
                            imgBytes = ImageToByte(bitmap, argWatermarkUrl);
                        }
                        File.WriteAllBytes(imagePath, imgBytes);

                        ShowResultDelegate wfd = new ShowResultDelegate(ShowResultOnGui);
                        if (InvokeRequired)
                        {
                            Invoke(wfd, imagePath);
                        }
                        else
                        {
                            ShowResultOnGui(imagePath);
                        }

                        if (autorun)
                        {
                            Close();
                            //Application.Exit();
                        }
                    }
                }
                catch
                {
                    if (error == "")
                    {
                        error = "Something went wrong.\r\n\r\nPlease try lowering the dimension sizes or check if you have a working internet connection. In case that does not help, restart the application and try again.";
                    }
                    MessageBox.Show(error, APPTITLE, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    error = "";
                }
            }
        }