Example #1
0
        private void BaslerCameraProperty_Load(object sender, EventArgs e)
        {
            Cursor.Current       = Cursors.WaitCursor;
            base.Visible         = false;
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.StartPosition   = FormStartPosition.CenterParent;
            string path = this.stCurrentDir + @"\conf\camprt.xml";

            this.cameraSetting = new CameraSetting();
            if (!File.Exists(path))
            {
                this.cameraSetting.exposureMode   = 0;
                this.cameraSetting.exposureTime   = 0x1388;
                this.cameraSetting.gainMode       = 0;
                this.cameraSetting.gain           = 0.0;
                this.cameraSetting.whiteLevelMode = 0;
                this.cameraSetting.whiteLevel     = 127.0;
                this.cameraSetting.gamma          = 1.0;
                this.cameraSetting.packetSize     = 0x5dc;
                this.cameraSetting.mode           = 9;
                CameraSetting.WriteCameraProterty <CameraSetting>(this.cameraSetting, path);
            }
            CameraSetting.ReadCameraProperty <CameraSetting>(out this.cameraSetting, path);
            if (this.cameraSetting.packetSize < 0x5dc)
            {
                this.cameraSetting.packetSize = 0x5dc;
                CameraSetting.WriteCameraProterty <CameraSetting>(this.cameraSetting, path);
                CameraSetting.ReadCameraProperty <CameraSetting>(out this.cameraSetting, path);
            }
            this.checkBox1.Checked    = this.cameraSetting.gainMode != 0;
            this.checkBox2.Checked    = this.cameraSetting.whiteLevelMode != 0;
            this.numericUpDown7.Value = this.cameraSetting.exposureTime;
            this.numericUpDown1.Value = (decimal)this.cameraSetting.gain;
            this.numericUpDown2.Value = (decimal)this.cameraSetting.whiteLevel;
            this.numericUpDown3.Value = (decimal)this.cameraSetting.blackLevel;
            this.numericUpDown5.Value = (decimal)this.cameraSetting.gamma;
            this.numericUpDown4.Value = this.cameraSetting.packetSize;
            this.label11.Text         = this.cameraSetting.deviceName;
            this.SetCaptureSize();
            this.SelectResize();
            if ((this.cameraSetting.deviceName.IndexOf("uc") >= 0) || (this.cameraSetting.deviceName.IndexOf("gc") >= 0))
            {
                this.radioButton11.Enabled = true;
                this.radioButton10.Enabled = true;
                if (this.cameraSetting.color == 1)
                {
                    this.radioButton11.Checked = true;
                }
                else
                {
                    this.radioButton10.Checked = true;
                }
            }
            else
            {
                this.radioButton11.Enabled = true;
                this.radioButton11.Checked = true;
                this.radioButton10.Enabled = false;
            }
            base.MaximizeBox   = false;
            base.MinimizeBox   = false;
            base.ActiveControl = this.button2;
            base.Visible       = true;
            Cursor.Current     = Cursors.Default;
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string pPath = this.stCurrentDir + @"\conf\camprt.xml";

            this.cameraSetting.exposureTime = (int)this.numericUpDown7.Value;
            int num = this.checkBox1.Checked ? 2 : 0;

            this.cameraSetting.gainMode = num;
            this.cameraSetting.gain     = (double)this.numericUpDown1.Value;
            num = this.checkBox2.Checked ? 1 : 0;
            this.cameraSetting.whiteLevelMode = num;
            this.cameraSetting.whiteLevel     = (double)this.numericUpDown2.Value;
            this.cameraSetting.blackLevel     = (double)this.numericUpDown3.Value;
            this.cameraSetting.gamma          = (double)this.numericUpDown5.Value;
            this.cameraSetting.packetSize     = (int)this.numericUpDown4.Value;
            if ((((int)this.numericUpDown6.Value) % 2) == 1)
            {
                this.cameraSetting.capWidth = ((int)this.numericUpDown6.Value) - 1;
            }
            else
            {
                this.cameraSetting.capWidth = (int)this.numericUpDown6.Value;
            }
            if ((((int)this.numericUpDown8.Value) % 2) == 1)
            {
                this.cameraSetting.capHeight = ((int)this.numericUpDown8.Value) - 1;
            }
            else
            {
                this.cameraSetting.capHeight = (int)this.numericUpDown8.Value;
            }
            if ((((int)this.numericUpDown9.Value) % 2) == 1)
            {
                this.cameraSetting.capX = ((int)this.numericUpDown9.Value) - 1;
            }
            else
            {
                this.cameraSetting.capX = (int)this.numericUpDown9.Value;
            }
            if ((((int)this.numericUpDown10.Value) % 2) == 1)
            {
                this.cameraSetting.capY = ((int)this.numericUpDown10.Value) - 1;
            }
            else
            {
                this.cameraSetting.capY = (int)this.numericUpDown10.Value;
            }
            this.cameraSetting.deviceName = this.label11.Text;
            this.cameraSetting.fullsize   = this.checkBox5.Checked;
            if (this.radioButton1.Checked)
            {
                this.cameraSetting.capSize = 0;
            }
            else if (this.radioButton2.Checked)
            {
                this.cameraSetting.capSize = 1;
            }
            else if (this.radioButton3.Checked)
            {
                this.cameraSetting.capSize = 2;
            }
            else if (this.radioButton4.Checked)
            {
                this.cameraSetting.capSize = 3;
            }
            if (this.radioButton12.Checked)
            {
                this.cameraSetting.reSize = 0;
            }
            else if (this.radioButton13.Checked)
            {
                this.cameraSetting.reSize = 1;
            }
            else if (this.radioButton14.Checked)
            {
                this.cameraSetting.reSize = 2;
            }
            else if (this.radioButton15.Checked)
            {
                this.cameraSetting.reSize = 3;
            }
            else
            {
                this.cameraSetting.reSize = -1;
            }
            if (this.radioButton11.Checked)
            {
                this.cameraSetting.color = 1;
            }
            else
            {
                this.cameraSetting.color = 0;
            }
            CameraSetting.WriteCameraProterty <CameraSetting>(this.cameraSetting, pPath);
            base.Close();
        }