//SOLVE private void button3_Click(object sender, EventArgs e) { Solver solver = new Solver(gameField); if (solver.Solve()) { pictureBox5.Visible = true; } //turn on the lights if (!FlashLighter.IsBusy) { FlashLighter.RunWorkerAsync(); } button4.Enabled = true; }
private void Form1_Load(object sender, EventArgs e) { //turn on the lights FlashLighter.RunWorkerAsync(); //select camera to get real-time image from phone display CameraSelection cselect = new CameraSelection(); DialogResult dresult = cselect.ShowDialog(); if (dresult == DialogResult.OK) { try { imageReceiver = new ImageReceiver(cselect.camNumber); } catch (NullReferenceException exception) { MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } getStreamVideoFromWebCam(); } else { this.Close(); } //select COM-port for phone manipulation COMSelection cmselect = new COMSelection(); dresult = cmselect.ShowDialog(); if (dresult == DialogResult.OK) { manipulator = new Manipulator(cmselect.portName); } else { this.Close(); } }
//RECOGNIZE private void button2_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; Recognizer recognizer = new Recognizer(); ImageProcessor imageProcessor = new ImageProcessor(boardSize); List <Bitmap> digits = imageProcessor.Process(bmpPicture, Config.MinGray); for (int i = 0; i < boardSize; i++) { for (int j = 0; j < boardSize; j++) { if (tempMatrix[i, j] == 0) { tempMatrix[i, j] = recognizer.Recognize(digits[i * boardSize + j]); } } } this.Cursor = Cursors.Arrow; //after successful recognition turn on LED light on phone if (!FlashLighter.IsBusy) { FlashLighter.RunWorkerAsync(); } //check and correct recognized digits RecognitionAccepter ra = new RecognitionAccepter(boardSize); ra.ShowDialog(); //creates game field from recognized digits gameField = new Matrix(boardSize, ra.field); pictureBox6.Visible = true; button3.Enabled = true; //RecognitionWorker.RunWorkerAsync(); }
//UPLOAD private void button4_Click(object sender, EventArgs e) { FlashLighter.CancelAsync(); Uploader.RunWorkerAsync(); pictureBox1.Visible = true; }