예제 #1
0
        private void Pb_calibratorBox_MouseUp(object sender, MouseEventArgs e)
        {
            if (OcrCalibrator.CalibrationBoxes == null)
            {
                return;
            }

            _isMouseDown = false;

            //Update position
            if (_selCalibrationPoint == null)
            {
                return;
            }

            OcrCalibrator.CalibrationBoxes[_selCalibrationPoint.Id] = _selCalibrationPoint;

            AlignCalibrationBoxesWhereRelevant(OcrCalibrator.CalibrationBoxes);

            FillRawData();

            pb_calibratorBox.Refresh();

            OcrCalibrator.SaveCalibration();
        }
예제 #2
0
        private void btn_calibrate_Click(object sender, EventArgs e)
        {
            _drawPoints = false;
            DoCalibration();

            if (_refbmp != null)
            {
                _refbmp.Dispose();
            }

            _refbmp = getReferenceScreenshot();

            if (_refbmp == null)
            {
                return;
            }

            btn_calibration_reset.Enabled = true;
            pb_calibratorBox.Image        = _refbmp;

            if (OcrCalibrator.CalibrationBoxes == null)
            {
                //Manual calibrate here
                MessageBox.Show("To calibrate, drag the crosshairs to the position shown and described on the right.");
                ManualCalibrate();
            }
            else
            {
                FillRawData();
                _drawPoints = true;
                OcrCalibrator.SaveCalibration();
            }
        }
예제 #3
0
        private void Btn_calibration_reset_Click(object sender, EventArgs e)
        {
            if (Program.GameSettings.Display != null)
            {
                var calibrations = OcrCalibrator.GetCalculatedCalibrationPoints(Program.GameSettings.Display.Resolution);
                DrawCalibrationPoints(calibrations);
                FillRawData();
                pb_calibratorBox.Refresh();
                OcrCalibrator.SaveCalibration();
                return;
            }

            MessageBox.Show("Unable to calibrate automatically, please calibrate manually...");
        }
예제 #4
0
        private void DoCalibration()
        {
            if (Program.GameSettings.Display != null && (OcrCalibrator.CalibrationBoxes == null || OcrCalibrator.CalibrationBoxes.Count < 1))
            {
                var calibrations = OcrCalibrator.GetCalculatedCalibrationPoints(Program.GameSettings.Display.Resolution);
                DrawCalibrationPoints(calibrations);
                return;
            }

            if (OcrCalibrator.CalibrationBoxes != null || OcrCalibrator.CalibrationBoxes.Count >= 1)
            {
                return;
            }

            MessageBox.Show("Unable to calibrate automatically, please calibrate manually...");
        }
예제 #5
0
        private Bitmap getReferenceScreenshot()
        {
            var openFile = new OpenFileDialog
            {
                DefaultExt       = "bmp",
                Multiselect      = true,
                Filter           = "BMP (*.bmp)|*.bmp",
                InitialDirectory =
                    Environment.GetFolderPath((Environment.SpecialFolder.MyPictures)) +
                    @"\Frontier Developments\Elite Dangerous",
                Title = "Open a screenshot for calibration"
            };

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                var bmp = new Bitmap(openFile.FileName);

                if (bmp.Height == Program.GameSettings.Display.Resolution.Y &&
                    bmp.Width == Program.GameSettings.Display.Resolution.X)
                {
                    return(bmp);
                }
                var wrongres = MessageBox.Show("The selected image has a different resolution from your current game settings. Do you want to pick another image?", "Ooops...", MessageBoxButtons.YesNo);
                if (wrongres == DialogResult.Yes)
                {
                    return(getReferenceScreenshot());
                }

                // Force resolution from input bmp
                Program.GameSettings.Display.ScreenHeight = bmp.Height;
                Program.GameSettings.Display.ScreenWidth  = bmp.Width;
                SetResolutionValues();
                var calibrations = OcrCalibrator.GetCalculatedCalibrationPoints(Program.GameSettings.Display.Resolution);
                DrawCalibrationPoints(calibrations);

                return(bmp);
            }
            return(null);
        }