コード例 #1
0
        private void label1_Click(object sender, EventArgs e)
        {
            foreach (Control ctl in CaneraChangeList.GetPanel3.Controls)
            {
                if (ctl.GetType() == typeof(CameraChangeControl))
                {
                    CameraChangeControl ccc = (CameraChangeControl)ctl;
                    ccc.label1.ForeColor = Color.White;
                }
            }
            this.label1.ForeColor = Color.Yellow;
            string[] camera = new string[3];
            DbControl.SwitchCameraDB(this.TabIndex);
            camera = DbControl.SelectCameraById(this.TabIndex);
            string ip   = camera[0];
            string user = camera[1];
            string pwd  = camera[2];

            if (CameraPlay.Stop())
            {
                if (CameraPlay.Login(ip, user, pwd))
                {
                    CameraPlay.Play();
                }
            }
        }
コード例 #2
0
        private void GetCameraList()
        {
            ArrayList clist = new ArrayList();

            clist = DbControl.GetCamerasByDB();
            if (clist.Count == 0)
            {
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\Release\access.log", true, Encoding.UTF8))
                {
                    string strLog = DateTime.Now.ToString().Replace('/', '-') + " - miss -  没有获取到摄像头信息";
                    file.WriteLine(strLog);
                    file.Close();
                }
                return;
            }
            foreach (string[] camera in clist)
            {
                string cNum   = camera[0];
                string cAlias = camera[1];

                System.Windows.Forms.Panel panel = TeacherWorkTable.CaneraChangeList.GetPanel3;
                CameraChangeControl        ccc   = new CameraChangeControl();
                panel.Controls.Add(ccc);
                ccc.Location      = new System.Drawing.Point(15, int.Parse(cNum) * 35);
                ccc.TabIndex      = int.Parse(cNum);
                ccc.GetLabel.Text = cAlias;
            }
        }
コード例 #3
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            //如果该摄像头正在播放则停止
            string[] camera = new string[4];
            camera = DbControl.GetUseCameraDB();
            if (camera != null)
            {
                if (this.TabIndex == int.Parse(camera[0]))
                {
                    CameraPlay.Stop();
                }
            }

            if (!DbControl.DeleteCameraDB(int.Parse(this.cNum)))
            {
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\Release\access.log", true, Encoding.UTF8))
                {
                    string strLog = DateTime.Now.ToString().Replace('/', '-') + " - error - 摄像头删除失败";
                    file.WriteLine(strLog);
                    file.Close();
                }
                return;
            }
            else
            {
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\Release\access.log", true, Encoding.UTF8))
                {
                    string strLog = DateTime.Now.ToString().Replace('/', '-') + " - info - 摄像头删除成功";
                    file.WriteLine(strLog);
                    file.Close();
                }

                System.Windows.Forms.Panel panel = TeacherWorkTable.CaneraChangeList.GetPanel3;
                foreach (Control ctl in panel.Controls)
                {
                    if (ctl.GetType() == typeof(CameraChangeControl))
                    {
                        CameraChangeControl ccc = (CameraChangeControl)ctl;
                        if (ccc.TabIndex == int.Parse(this.cNum))
                        {
                            ccc.Dispose();
                            break;
                        }
                    }
                }

                this.Dispose();
            }
        }
コード例 #4
0
        private void frmShow_Load(object sender, EventArgs e)
        {
            pnlRightBody.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31)))));
            // pnlRightTelescopic.BackColor = Color.Transparent;
            // pnlRightTelescopic.Parent = pbVideoShow;
            classListItemControl1.funClick = classListItemControl2.funClick = classListItemControl3.funClick = classListItemControl1.funClick = classListItemControl4.funClick = new ClassListItemControl.dlgtItemClick(classChanged);
            label1.BackColor       = Color.Transparent;
            pnlClassList.BackColor = Color.Transparent;
            //pnlToolbar.BackColor = Color.Transparent;
            // pnlToolbar.Parent = pbVideoShow;

            SetBtnStyle(btnTelescopic);
            SetBtnStyle(btnSetting);
            SetBtnStyle(btnLive);

            //settingListControl1.Parent = pbVideoShow;

            btnLive.Enabled = false;

            //预览视频
            CameraPlay.Init(this.pbVideoShow);
            string[] camera = new string[4];
            camera = DbControl.GetUseCameraDB();
            if (camera != null)
            {
                int    id   = int.Parse(camera[0]);
                string ip   = camera[1];
                string user = camera[2];
                string pwd  = camera[3];
                foreach (Control ctl in CaneraChangeList.GetPanel3.Controls)
                {
                    if (ctl.GetType() == typeof(CameraChangeControl))
                    {
                        CameraChangeControl ccc = (CameraChangeControl)ctl;
                        if (ccc.TabIndex == id)
                        {
                            ccc.GetLabel.ForeColor = Color.Yellow;
                            break;
                        }
                    }
                }
                if (CameraPlay.Login(ip, user, pwd))
                {
                    CameraPlay.Play();
                }
            }
        }
コード例 #5
0
        private void btnFinished_Click(object sender, EventArgs e)
        {
            if (!(CheckNameFlag && CheckIpFlag && CheckUserFlag && CheckPwdFlag))
            {
                return;
            }
            if (setCtls.GetType() == typeof(SettingListControl))
            {
                SettingListControl setCtl = (SettingListControl)setCtls;
                setCtl.Visible = true;
                this.Visible   = false;
                ArrayList clist = new ArrayList();
                clist = DbControl.GetCamerasByDB();
                int count = DbControl.GetCameraNumByDB();
                int cNum  = -1;
                for (int i = 0; i <= count; i++)
                {
                    bool flag = true;
                    foreach (string[] camera in clist)
                    {
                        if (int.Parse(camera[0]) == i)
                        {
                            flag = false;
                            break;
                        }
                    }
                    if (flag)
                    {
                        cNum = i;
                        break;
                    }
                }
                if (!DbControl.SetCameraToDB(cNum, this.tbName.Text, this.tbIP.Text, this.tbUser.Text, this.tbPassword.Text))
                {
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\Release\access.log", true, Encoding.UTF8))
                    {
                        string strLog = DateTime.Now.ToString().Replace('/', '-') + " - error - 摄像头添加失败";
                        file.WriteLine(strLog);
                        file.Close();
                    }
                }
                else
                {
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\Release\access.log", true, Encoding.UTF8))
                    {
                        string strLog = DateTime.Now.ToString().Replace('/', '-') + " - info - 摄像头添加成功";
                        file.WriteLine(strLog);
                        file.Close();
                    }
                    if (cNum != -1)
                    {
                        //将摄像头添加到摄像头列表
                        SettingCameraListItem cameraItem = new SettingCameraListItem();
                        setCtl.GetPnlCameraList.Controls.Add(cameraItem);
                        cameraItem.Dock     = System.Windows.Forms.DockStyle.Top;
                        cameraItem.Name     = "cameraItem" + cNum;
                        cameraItem.Size     = new System.Drawing.Size(298, 35);
                        cameraItem.TabIndex = cNum;
                        cameraItem.cNum     = cNum.ToString();
                        cameraItem.cAlias   = this.tbName.Text;
                        cameraItem.cIp      = this.tbIP.Text;
                        //将摄像头添加到切换列表
                        System.Windows.Forms.Panel panel = TeacherWorkTable.CaneraChangeList.GetPanel3;
                        CameraChangeControl        ccc   = new CameraChangeControl();
                        panel.Controls.Add(ccc);
                        ccc.GetLabel.Text = this.tbName.Text;
                        ccc.TabIndex      = cNum;
                        //清空表单
                        this.tbName.Text         = "";
                        this.tbIP.Text           = "";
                        this.tbUser.Text         = "";
                        this.tbPassword.Text     = "";
                        this.pictureBox1.Visible = false;
                        this.pictureBox2.Visible = false;
                        this.pictureBox3.Visible = false;
                        this.pictureBox4.Visible = false;
                    }
                }
            }
            else if (setCtls.GetType() == typeof(SettingCameraListItem))
            {
                SettingCameraListItem setCli = (SettingCameraListItem)setCtls;
                setCli.Parent.Visible = true;
                this.Visible          = false;
                if (!DbControl.UpdateCameraDB(int.Parse(setCli.cNum), this.tbName.Text, this.tbIP.Text, this.tbUser.Text, this.tbPassword.Text))
                {
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\Release\access.log", true, Encoding.UTF8))
                    {
                        string strLog = DateTime.Now.ToString().Replace('/', '-') + " - error - 摄像头信息变更失败";
                        file.WriteLine(strLog);
                        file.Close();
                    }
                }
                else
                {
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"..\Release\access.log", true, Encoding.UTF8))
                    {
                        string strLog = DateTime.Now.ToString().Replace('/', '-') + " - info - 摄像头信息变更成功";
                        file.WriteLine(strLog);
                        file.Close();
                    }
                    setCli.cAlias = this.tbName.Text;
                    setCli.cIp    = this.tbIP.Text;

                    System.Windows.Forms.Panel panel = TeacherWorkTable.CaneraChangeList.GetPanel3;
                    foreach (Control ctl in panel.Controls)
                    {
                        if (ctl.GetType() == typeof(CameraChangeControl))
                        {
                            CameraChangeControl ccc = (CameraChangeControl)ctl;
                            if (ccc.TabIndex == int.Parse(setCli.cNum))
                            {
                                ccc.GetLabel.Text = this.tbName.Text;
                            }
                        }
                    }
                    //清空表单
                    this.tbUser.Text         = "";
                    this.tbPassword.Text     = "";
                    this.pictureBox3.Visible = false;
                    this.pictureBox4.Visible = false;
                }
            }
        }