예제 #1
0
        private void cmbRoom_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbRoom.SelectedIndex == -1)
            {
                return;
            }

            String configName = cmbRoom.SelectedItem.ToString();

            txtConfigName.Text = configName;

            globalVars = VariableSaver.SafeLoad(globalVars, @"\Settings\Rooms\" + configName + ".cfg");

            sldExposure.Value   = (double)GetVar("Exposure");
            sldBrightness.Value = (double)GetVar("Brightness");
            sldContrast.Value   = (double)GetVar("Contrast");
        }
예제 #2
0
        public MainWindow()
        {
            InitializeComponent();


            _capture = new Capture(0);
            _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_AUTO_EXPOSURE, 0);
            _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_SATURATION, 100);
            _capture.Start();

            DeclareVar("Exposure", typeof(double), -5.0);
            DeclareVar("Brightness", typeof(double), 100.0);
            DeclareVar("Contrast", typeof(double), 0.0);
            DeclareVar("Tolerance", typeof(double), 5.0);
            DeclareVar("LightTolerance", typeof(double), 10.0);
            DeclareVar("IndexR", typeof(int), 255);
            DeclareVar("IndexG", typeof(int), 0);
            DeclareVar("IndexB", typeof(int), 0);
            DeclareVar("SideR", typeof(int), 0);
            DeclareVar("SideG", typeof(int), 0);
            DeclareVar("SideB", typeof(int), 255);

            globalVars      = VariableSaver.SafeLoad(globalVars, @"Settings\Settings.cfg");
            varsInitialized = true;

            sldExposure.Value   = (double)GetVar("Exposure");
            sldBrightness.Value = (double)GetVar("Brightness");
            sldContrast.Value   = (double)GetVar("Contrast");

            sldTolerance.Value      = (double)GetVar("Tolerance");
            sldLightTolerance.Value = (double)GetVar("LightTolerance");
            txtIndexR.Text          = GetVar("IndexR").ToString();
            txtIndexG.Text          = GetVar("IndexG").ToString();
            txtIndexB.Text          = GetVar("IndexB").ToString();
            txtSideR.Text           = GetVar("SideR").ToString();
            txtSideG.Text           = GetVar("SideG").ToString();
            txtSideB.Text           = GetVar("SideB").ToString();

            UpdateReader();

            wPrev = new WindowPreview();
            wPrev.Show();
            System.Drawing.Rectangle screen = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            wPrev.Top  = screen.Height - wPrev.Height - 45;
            wPrev.Left = screen.Width - wPrev.Width;

            startingTime = DateTime.Now;

            clkRef.Interval = new TimeSpan(0, 0, 0, 0, 15);
            clkRef.Tick    += new EventHandler(clkRef_Tick);
            clkRef.Start();

            LoadControllers();

            LoadConfigs();

            for (int k = 0; k < 255; k++)
            {
                keyMap.Add((Keys)k, false);
            }

            InputManager.KeyboardHook.KeyDown += new InputManager.KeyboardHook.KeyDownEventHandler(KeyboardHook_KeyDown);
            InputManager.KeyboardHook.KeyUp   += new InputManager.KeyboardHook.KeyUpEventHandler(KeyboardHook_KeyUp);
            InputManager.KeyboardHook.InstallHook();
        }