示例#1
0
 private void LiveBtn_Click(object sender, EventArgs e)
 {
     if (info != null)
     {
         if (LiveBtn.Text == "Live")
         {
             LiveBtn.Text = "Stop";
             if (!CameraManger.StartLive(info.UserID))
             {
                 MessageHelper.ShowError("打开实时拍照失败,相机出现错误,请关闭连接后重新启动或者检查相机设置!");
             }
         }
         else if (LiveBtn.Text == "Stop")
         {
             LiveBtn.Text = "Live";
             if (!CameraManger.StopLive(info.UserID))
             {
                 MessageHelper.ShowError("打开实时拍照失败,相机出现错误,请关闭连接后重新启动或者检查相机设置!");
             }
         }
     }
     else
     {
         MessageHelper.ShowError("拍照失败,无法获取相机信息!请关闭连接后重新启动或者检查相机设置!");
     }
 }
示例#2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (info != null)
     {
         //相机曝光与增益设置
         int shutterValue = this.trackBarShutter.Value;
         int gainValue    = this.trackBarGain.Value;
         CameraManger.SetShutter(info.UserID, shutterValue.ToString());
         CameraManger.SetGain(info.UserID, gainValue.ToString());
         //相机图像格式与延时设置
         if (ImageFormatCombox.SelectedItem != null)
         {
             ImageFormat format = (ImageFormat)ImageFormatCombox.SelectedItem;
             CameraManger.SetImageFormat(info.UserID, format);
             this.info.Format = format;
         }
         int heartBeatime = this.trackBarHeartBeatTime.Value;
         CameraManger.SetHearBeatTime(info.UserID, heartBeatime.ToString());
         //更新Info数据
         this.info.CurExposureTime = shutterValue.ToString();
         this.info.CurGain         = gainValue.ToString();
         this.info.HeartbeatTime   = heartBeatime.ToString();
     }
     CameraManger.SaveDoc();
 }
示例#3
0
        private void ModifyCamBtn_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count <= 0)
            {
                MessageHelper.ShowWarning("请选择相机列表中的任一相机再修改!");
                return;
            }
            int iRow = dataGridView1.SelectedRows[0].Index;

            if (iRow >= 0)
            {
                string camName = dataGridView1.Rows[iRow].Cells[0].Value.ToString();
                string camType = dataGridView1.Rows[iRow].Cells[2].Value.ToString();
                CameraManger.RemoveCameraInfo(camName);
                if (!string.IsNullOrEmpty(CamNameTxt.Text) && CamTypeComBox.SelectedItem != null)
                {
                    if (CameraManger.AddCameraInfo(CamNameTxt.Text, CamTypeComBox.SelectedItem.ToString()))
                    {
                        dataGridView1.Rows[iRow].Cells[0].Value = CamNameTxt.Text;
                        dataGridView1.Rows[iRow].Cells[1].Value = CamTypeComBox.Text;
                        CamNameTxt.Clear();
                        MessageHelper.ShowTips("修改相机成功!");
                        return;
                    }
                }
                CameraManger.AddCameraInfo(camName, camType);

                MessageHelper.ShowWarning("修改相机失败!");
            }
            CamNameTxt.Clear();
        }
示例#4
0
        private void AddCamBtn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(CamNameTxt.Text))
            {
                MessageHelper.ShowWarning("pls input the valid name of Cam");
                return;
            }
            if (CamTypeComBox.SelectedItem == null)
            {
                MessageHelper.ShowWarning("pls select  a type of this Cam");
                return;
            }

            CameraManger.AddCameraInfo(CamNameTxt.Text.Trim(), CamTypeComBox.SelectedItem.ToString());
            if (CameraManger.GetCameraInfoInstance(CamNameTxt.Text) != null)
            {
                DataGridViewRow         newrow   = new DataGridViewRow();
                DataGridViewTextBoxCell namecell = new DataGridViewTextBoxCell();
                namecell.Value = CamNameTxt.Text.Trim();
                DataGridViewTextBoxCell TypecbCell = new DataGridViewTextBoxCell();
                TypecbCell.Value = CamTypeComBox.SelectedItem.ToString();


                newrow.Cells.Add(namecell);
                newrow.Cells.Add(TypecbCell);

                dataGridView1.Rows.Add(newrow);
                CamNameTxt.Clear();
            }
            else
            {
                MessageHelper.ShowError("添加相机失败");
            }
        }
示例#5
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int iRow = e.RowIndex;

            if (iRow >= 0)
            {
                if (dataGridView1.Rows[iRow].Cells[0].Value != null && dataGridView1.Rows[iRow].Cells[1].Value != null)
                {
                    string camName = dataGridView1.Rows[iRow].Cells[0].Value.ToString();
                    formSetting = CreatingHelper <CameraSetting> .GetSingleObject();

                    IVisionCameraInfo info = CameraManger.GetCameraInfoInstance(camName);
                    if (info != null)
                    {
                        formSetting.Info          = info;
                        formSetting.StartPosition = FormStartPosition.CenterScreen;
                        if (formSetting.IsShowing)
                        {
                            formSetting.IsShowing = false;
                            formSetting.Close();
                            System.Threading.Thread.Sleep(10);
                            formSetting.Show();
                            formSetting.IsShowing = true;
                        }
                        else
                        {
                            formSetting.Show();
                            formSetting.IsShowing = true;
                        }
                    }
                }
            }
        }
示例#6
0
 private void CameraSetting_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (info != null)
     {
         CameraManger.StopLive(info.UserID);
     }
     e.Cancel = true;
     this.Hide();
 }
示例#7
0
 private void AdjustExposureTimeValue(int value)
 {
     if (info != null)
     {
         this.UpDownShutter.Value   = Convert.ToDecimal(value);
         this.trackBarShutter.Value = value;
         info.CurExposureTime       = value.ToString();
         CameraManger.SetShutter(info.UserID, info.CurExposureTime);
     }
 }
示例#8
0
 private void AdjustGainValue(int value)
 {
     if (info != null)
     {
         this.UpDownGain.Value   = Convert.ToDecimal(value);
         this.trackBarGain.Value = value;
         info.CurGain            = value.ToString();
         CameraManger.SetGain(info.UserID, info.CurGain);
     }
 }
示例#9
0
 private void AdjustHeartBeatTimeValue(int value)
 {
     if (info != null)
     {
         this.UpDownShutter.Value   = Convert.ToDecimal(value);
         this.trackBarShutter.Value = value;
         info.HeartbeatTime         = value.ToString();
         CameraManger.SetHearBeatTime(info.UserID, info.HeartbeatTime);
     }
 }
示例#10
0
        private void CameraManagerForm_Load(object sender, EventArgs e)
        {
            foreach (IVisionCameraInfo info in CameraManger.GetCameraInfoList())
            {
                DataGridViewRow         gridrow  = new DataGridViewRow();
                DataGridViewTextBoxCell namecell = new DataGridViewTextBoxCell();
                namecell.Value = info.UserID;
                DataGridViewTextBoxCell typecell = new DataGridViewTextBoxCell();
                typecell.Value = info._CameraType.ToString();

                gridrow.Cells.Add(namecell);
                gridrow.Cells.Add(typecell);
                dataGridView1.Rows.Add(gridrow);
            }
            dataGridView1.Invalidate();
        }
示例#11
0
 private void GrabBtn_Click(object sender, EventArgs e)
 {
     if (info != null)
     {
         Image = CameraManger.GetImage(info.UserID);
         if (Image != null)
         {
             this.window.DisplayImage(Image.CopyImage());
         }
         else
         {
             MessageHelper.ShowError("拍照失败,获取图像超时");
         }
     }
     else
     {
         MessageHelper.ShowError("拍照失败,无法获取相机信息!");
     }
 }
示例#12
0
        private void DeleteCamBtn_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count <= 0)
            {
                MessageHelper.ShowWarning("请选择相机列表中的任一相机再修改类型或者名称!");
                return;
            }
            int iRow = dataGridView1.SelectedRows[0].Index;

            if (iRow >= 0)
            {
                string camName = dataGridView1.Rows[iRow].Cells[0].Value.ToString();
                string camType = dataGridView1.Rows[iRow].Cells[2].Value.ToString();
                if (CameraManger.RemoveCameraInfo(camName))
                {
                    MessageHelper.ShowWarning("删除相机成功!");
                }
                else
                {
                    MessageHelper.ShowWarning("删除相机失败!");
                }
            }
            CamNameTxt.Clear();
        }