Ejemplo n.º 1
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("添加相机失败");
            }
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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();
        }