示例#1
0
        public void Close()
        {
            if (-1 != m_nIndex)
            {
                decodeRuning = false;
                XMSDK.H264_DVR_DelRealDataCallBack_V2(m_iPlayhandle, realDataCallBack_V2, Handle.ToInt32());

                XMSDK.H264_DVR_StopRealPlay(m_iPlayhandle, (uint)this.panelVideo.Handle);
                DVR2Mjpeg DVR2Mjpeg = (DVR2Mjpeg)Parent;
                DVR2Mjpeg.DrawActivePage(false);

                foreach (TreeNode node in DVR2Mjpeg.devForm.DevTree.Nodes)
                {
                    if (node.Name == "Device")
                    {
                        foreach (TreeNode channelnode in node.Nodes)
                        {
                            if (channelnode.Name == "Channel")
                            {
                                CHANNEL_INFO chInfo = (CHANNEL_INFO)channelnode.Tag;
                                if (chInfo.nWndIndex == m_nIndex)
                                {
                                    chInfo.nWndIndex = -1;
                                    channelnode.Tag  = chInfo;
                                    break;
                                }
                            }
                        }
                    }
                }

                deleteImageOnServer();
            }
        }
示例#2
0
        private void VideoForm_Click(object sender, EventArgs e)
        {
            DVR2Mjpeg DVR2Mjpeg = (DVR2Mjpeg)this.Parent;

            DVR2Mjpeg.SetActiveWnd(m_nIndex);
            DVR2Mjpeg.comboBoxCamCount.Focus();
        }
示例#3
0
        bool MessCallBack(int lLoginID, string pBuf, uint dwBufLen, IntPtr dwUser)
        {
            Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss - ") + DateTime.Now.ToString("HH:mm:ss - ") + TAG + ".MessCallBack(" + lLoginID.ToString() + "," + pBuf + "," + dwBufLen.ToString() + ",dwUser" + ")", "DVR INFO");

            DVR2Mjpeg form = new DVR2Mjpeg();

            Marshal.PtrToStructure(dwUser, form);
            return(form.DealwithAlarm(lLoginID, pBuf, dwBufLen));
        }
示例#4
0
        private void catchPictureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //return;
            if (m_nIndex > -1 && m_iPlayhandle > 0 && m_bSaveImageStart == false)
            {
                String    strPath;
                DVR2Mjpeg DVR2Mjpeg = (DVR2Mjpeg)Parent;

                foreach (TreeNode node in DVR2Mjpeg.devForm.DevTree.Nodes)
                {
                    if (node.Name == "Device")
                    {
                        foreach (TreeNode channelnode in node.Nodes)
                        {
                            if (channelnode.Name == "Channel")
                            {
                                CHANNEL_INFO chInfo = (CHANNEL_INFO)channelnode.Tag;
                                if (chInfo.nWndIndex == m_nIndex)
                                {
                                    strPath = String.Format(@"Z:\Pictures\bmp\{0}.bmp", m_nIndex + 1);

                                    bool bCatch = false;

                                    m_bSaveImageStart = true;

                                    try
                                    {
                                        if (DVR2Mjpeg.isConnected)
                                        {
                                            bCatch = XMSDK.H264_DVR_LocalCatchPic(m_iPlayhandle, strPath);
                                        }
                                    }
                                    catch (AccessViolationException ex)
                                    {
                                        Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss - ") + TAG + ".catchPictureToolStripMenuItem_Click.AccessViolationException", "DVR ERROR");
                                        Debug.WriteLine(ex.ToString());
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss - ") + TAG + ".catchPictureToolStripMenuItem_Click.Exception", "DVR ERROR");
                                        Debug.WriteLine(ex.ToString());
                                    }

                                    m_bSaveImageStart = false;

                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
示例#5
0
        private void PTZControl(int nCommand, bool bStop, int nSpeed)
        {
            DVR2Mjpeg clientForm    = (DVR2Mjpeg)this.Owner;
            int       nCurVideoform = clientForm.m_nCurIndex;

            if (nCurVideoform >= 0)
            {
                int nPlayHandel = clientForm.m_videoform[nCurVideoform].m_iPlayhandle;
                if (nPlayHandel > 0)
                {
                    int nLoginID = clientForm.m_videoform[nCurVideoform].m_lLogin;
                    int nChannel = clientForm.m_videoform[nCurVideoform].m_iChannel;
                    XMSDK.H264_DVR_PTZControl(nLoginID, nChannel, (int)nCommand, bStop, nSpeed);
                }
            }
        }
示例#6
0
        private void DevConfigForm_Shown(object sender, EventArgs e)
        {
            comboBoxDevice.ResetText();
            DVR2Mjpeg          clientForm     = (DVR2Mjpeg)this.Owner;
            TreeNodeCollection nodeCollection = clientForm.devForm.DevTree.Nodes;

            foreach (TreeNode node in nodeCollection)
            {
                if (node.Name == "Device")
                {
                    comboBoxDevice.Items.Add(node);
                }
            }
            if (comboBoxDevice.Items.Count > 0)
            {
                comboBoxDevice.SelectedIndex = 0;
            }
        }
示例#7
0
        private void DevTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Node.Name == "Channel")
            {
                DVR2Mjpeg DVR2Mjpeg = (DVR2Mjpeg)Parent;

                TreeNode     nodeDev     = e.Node.Parent;
                DEV_INFO     devinfo     = (DEV_INFO)nodeDev.Tag;
                CHANNEL_INFO chanInfo    = (CHANNEL_INFO)e.Node.Tag;
                int          iRealHandle = ((DVR2Mjpeg)Parent).m_videoform[((DVR2Mjpeg)Parent).m_nCurIndex].ConnectRealPlay(ref devinfo, chanInfo.nChannelNo);
                if (iRealHandle > 0)
                {
                    CHANNEL_INFO chInfo = (CHANNEL_INFO)e.Node.Tag;
                    chInfo.nWndIndex      = ((DVR2Mjpeg)this.Parent).m_nCurIndex;
                    e.Node.Tag            = chInfo;
                    DVR2Mjpeg.isConnected = true;
                }
            }
        }
示例#8
0
        void updateImageOnServer(Bitmap bm)
        {
            MemoryStream stream = new MemoryStream();

            bm.Save(stream, ici, ep);
            bm.Dispose();

            DVR2Mjpeg parentForm = (DVR2Mjpeg)Parent;

            if (parentForm.HttpServer.imageData.ContainsKey((m_nIndex + 1).ToString()))
            {
                parentForm.HttpServer.imageData[(m_nIndex + 1).ToString()] = stream.GetBuffer();
            }
            else
            {
                parentForm.HttpServer.imageData.Add((m_nIndex + 1).ToString(), stream.GetBuffer());
            }
            stream.Dispose();
        }
        // 点击网网络的选项卡
        private void tabControlPlayBack_Click(object sender, EventArgs e)
        {
            if (tabControlPlayBack.SelectedTab.Name == "tabPageRemovePlayBack")
            {
                comboDev.Items.Clear();
                DVR2Mjpeg clientForm = new DVR2Mjpeg();

                foreach (Form form in Application.OpenForms)
                {
                    if (form.Name == "DVR2Mjpeg")
                    {
                        clientForm = (DVR2Mjpeg)form;
                        break;
                    }
                }

                foreach (TreeNode node in clientForm.devForm.DevTree.Nodes)
                {
                    ComboxItem item = new ComboxItem(node.Text, node.Tag);
                    comboDev.Items.Add(item);
                }

                comboRecordType.Items.Clear();

                comboRecordType.Items.Add("All video");
                comboRecordType.Items.Add("External alarm video");
                comboRecordType.Items.Add("Video detection video");
                comboRecordType.Items.Add("Ordinary video");
                comboRecordType.Items.Add("Manual recording");
                comboRecordType.Items.Add("All pictures");
                comboRecordType.Items.Add("Alarm to capture");
                comboRecordType.Items.Add("Video capture detection");
                comboRecordType.Items.Add("Capture timing");
                comboRecordType.Items.Add("Manual capture");
                comboRecordType.SelectedIndex = 0;

                checkFile.Checked = true;
            }
            else
            {
            }
        }
示例#10
0
        /*public int Connect(ref DEV_INFO pDev, int nChannel, int nWndIndex)
         * {
         *  Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss - ") + TAG + ".Connect(" + pDev.szDevName + "," + nChannel.ToString() + "," + nWndIndex.ToString() + ")", "DVR INFO");
         *
         *  int nRet = 0;
         *
         *  //if device did not login,login first
         *  if (pDev.lLoginID <= 0)
         *  {
         *      H264_DVR_DEVICEINFO OutDev;
         *      int nError = 0;
         *      int lLogin = XMSDK.H264_DVR_Login(pDev.szIpaddress, (ushort)pDev.nPort, pDev.szUserName, pDev.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET);
         *      if (lLogin <= 0)
         *      {
         *          int nErr = XMSDK.H264_DVR_GetLastError();
         *          if (nErr == (int)SDK_RET_CODE.H264_DVR_PASSWORD_NOT_VALID)
         *          {
         *              MessageBox.Show(("Error.PwdErr"));
         *          }
         *          else
         *          {
         *              MessageBox.Show(("Error.NotFound"));
         *          }
         *
         *          return nRet;
         *      }
         *
         *      pDev.lLoginID = lLogin;
         *      XMSDK.H264_DVR_SetupAlarmChan(lLogin);
         *  }
         *
         *  //isConnected = true;
         *
         *  int nWnd = m_nCurIndex;
         *  if (nWndIndex >= 0)
         *  {
         *      nWnd = nWndIndex;
         *  }
         *
         *  if (nWnd >= m_nTotalWnd)
         *  {
         *      return nRet;
         *  }
         *
         *  return m_videoform[nWnd].ConnectRealPlay(ref pDev, nChannel);
         * }*/

        /*public void SetColor(uint nBright, uint nContrast, uint nSaturation, uint nHue)
         * {
         *  IntPtr lPlayHandle = m_videoform[m_nCurIndex].Handle;
         *  unsafe
         *  {
         *      if (lPlayHandle.ToPointer() == null)
         *      {
         *          return;
         *      }
         *  }
         *
         *  m_videoform[m_nCurIndex].SetColor((int)nBright, (int)nContrast, (int)nSaturation, (int)nHue);
         *  SetDevChnColor(nBright, nContrast, nSaturation, nHue);
         * }*/

        /*public void PtzControl(uint dwBtn, bool dwStop)
         * {
         *  long lPlayHandle = m_videoform[m_nCurIndex].GetHandle();
         *  if (lPlayHandle <= 0)
         *  {
         *      return;
         *  }
         * }*/

        /*public void KeyBoardMsg(uint dwValue, uint dwState)
         * {
         *  IntPtr lPlayHandle = m_videoform[m_nCurIndex].Handle;
         *  unsafe
         *  {
         *      if (lPlayHandle.ToPointer() == null)
         *      {
         *          return;
         *      }
         *  }
         *
         *  SDK_NetKeyBoardData vKeyBoardData;
         *  vKeyBoardData.iValue = (int)dwValue;
         *  vKeyBoardData.iState = (int)dwState;
         *  m_nCurIndex = m_nCurIndex < 0 ? 0 : m_nCurIndex;
         *  if (!XMSDK.H264_DVR_ClickKey(m_videoform[m_nCurIndex].m_lLogin, ref vKeyBoardData))
         *     MessageBox.Show("AccountMSG.Failed");
         * }*/

        /*public void NetAlarmMsg(uint dwValue, uint dwState)
         * {
         *  if (m_devInfo.lLoginID > 0)
         *  {
         *      SDK_NetAlarmInfo vAlarmInfo;
         *      vAlarmInfo.iEvent = 0;
         *      vAlarmInfo.iState = (int)(dwState << (int)dwValue);
         *      m_nCurIndex = m_nCurIndex < 0 ? 0 : m_nCurIndex;
         *      if (!XMSDK.H264_DVR_SendNetAlarmMsg(m_devInfo.lLoginID, ref vAlarmInfo))
         *          MessageBox.Show("AccountMSG.Failed");
         *  }
         * }*/

        /*public void SetDevInfo(ref DEV_INFO pDev)
         * {
         *  m_devInfo = pDev;
         * }*/

        public void ReConnect(object source, ElapsedEventArgs e)
        {
            Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss - ") + TAG + ".ReConnect(source,e)", "DVR INFO");

            Dictionary <int, DEV_INFO> dictDiscontDevCopy = new Dictionary <int, DEV_INFO>(dictDiscontDev);

            foreach (DEV_INFO devinfo in dictDiscontDevCopy.Values)
            {
                H264_DVR_DEVICEINFO OutDev = new H264_DVR_DEVICEINFO();
                int nError = 0;

                int lLogin = XMSDK.H264_DVR_Login(devinfo.szIpaddress, (ushort)devinfo.nPort, devinfo.szUserName, devinfo.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET);
                if (lLogin <= 0)
                {
                    int nErr = XMSDK.H264_DVR_GetLastError();
                    if (nErr == (int)SDK_RET_CODE.H264_DVR_PASSWORD_NOT_VALID)
                    {
                        MessageBox.Show(("Password Error"));
                    }
                    else if (nErr == (int)SDK_RET_CODE.H264_DVR_LOGIN_USER_NOEXIST)
                    {
                        MessageBox.Show(("User Not Exist"));
                    }

                    return;
                }
                dictDiscontDev.Remove(devinfo.lLoginID);

                DVR2Mjpeg clientForm = new DVR2Mjpeg(true);

                foreach (Form form in Application.OpenForms)
                {
                    if (form.Name == "DVR2Mjpeg")
                    {
                        clientForm = (DVR2Mjpeg)form;
                        break;
                    }
                }
                DEV_INFO devAdd = new DEV_INFO();
                devAdd          = devinfo;
                devAdd.lLoginID = lLogin;

                foreach (TreeNode node in clientForm.devForm.DevTree.Nodes)
                {
                    if (node.Name == "Device")
                    {
                        DEV_INFO dev = (DEV_INFO)node.Tag;
                        if (dev.lLoginID == devinfo.lLoginID)
                        {
                            if (this.InvokeRequired)
                            {
                                this.BeginInvoke((MethodInvoker)(() =>
                                {
                                    node.Text = devAdd.szDevName;
                                    node.Tag = devAdd;
                                    node.Name = "Device";
                                }));
                            }
                            else
                            {
                                node.Text = devAdd.szDevName;
                                node.Tag  = devAdd;
                                node.Name = "Device";
                            }
                            foreach (TreeNode channelnode in node.Nodes)
                            {
                                CHANNEL_INFO chInfo = (CHANNEL_INFO)channelnode.Tag;
                                if (chInfo.nWndIndex > -1)
                                {
                                    if (InvokeRequired)
                                    {
                                        BeginInvoke((MethodInvoker)(() =>
                                        {
                                            int iRealHandle = clientForm.m_videoform[chInfo.nWndIndex].ConnectRealPlay(ref devAdd, chInfo.nChannelNo);
                                            if (iRealHandle > 0)
                                            {
                                                isConnected = true;
                                                chanelOpened++;
                                            }
                                        }));
                                    }
                                    else
                                    {
                                        int iRealHandle = clientForm.m_videoform[chInfo.nWndIndex].ConnectRealPlay(ref devAdd, chInfo.nChannelNo);
                                        if (iRealHandle > 0)
                                        {
                                            isConnected = true;
                                            chanelOpened++;
                                        }
                                    }
                                    Thread.Sleep(100);
                                }
                            }
                            break;
                        }
                    }
                }

                dictDevInfo.Add(lLogin, devAdd);
                XMSDK.H264_DVR_SetupAlarmChan(lLogin);
            }

            if (0 == dictDiscontDev.Count)
            {
                timerDisconnect.Enabled = false;
                timerDisconnect.Stop();
            }
        }
示例#11
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (textBoxDevName.Text.Trim() != "" &&
                textBoxIP.Text.Trim() != "" &&
                textBoxport.Text.Trim() != "" &&
                textBoxUsername.Text.Trim() != "")
            {
                H264_DVR_DEVICEINFO dvrdevInfo = new H264_DVR_DEVICEINFO();
                int      nError;
                int      nLoginID = XMSDK.H264_DVR_Login(textBoxIP.Text.Trim(), ushort.Parse(textBoxport.Text.Trim()), textBoxUsername.Text, textBoxPassword.Text, out dvrdevInfo, out nError, SocketStyle.TCPSOCKET);
                DEV_INFO devInfo  = new DEV_INFO();
                if (nLoginID > 0)
                {
                    DVR2Mjpeg clientForm = new DVR2Mjpeg();

                    foreach (Form form in  Application.OpenForms)
                    {
                        if (form.Name == "DVR2Mjpeg")
                        {
                            clientForm = (DVR2Mjpeg)form;
                            break;
                        }
                    }

                    TreeNode nodeDev = new TreeNode();
                    nodeDev.Text          = textBoxDevName.Text;
                    devInfo.szDevName     = textBoxDevName.Text;
                    devInfo.lLoginID      = nLoginID;
                    devInfo.nPort         = Int32.Parse(textBoxport.Text.Trim());
                    devInfo.szIpaddress   = textBoxIP.Text.Trim();
                    devInfo.szUserName    = textBoxUsername.Text;
                    devInfo.szPsw         = textBoxPassword.Text;
                    devInfo.NetDeviceInfo = dvrdevInfo;
                    nodeDev.Tag           = devInfo;
                    nodeDev.Name          = "Device";
                    for (int i = 0; i < devInfo.NetDeviceInfo.byChanNum + devInfo.NetDeviceInfo.iDigChannel; i++)
                    {
                        TreeNode nodeChannel = new TreeNode(string.Format("CAM{0}", i));
                        nodeChannel.Name = "Channel";
                        CHANNEL_INFO ChannelInfo = new CHANNEL_INFO();
                        ChannelInfo.nChannelNo = i;
                        ChannelInfo.nWndIndex  = -1;
                        nodeChannel.Tag        = ChannelInfo;
                        nodeDev.Nodes.Add(nodeChannel);
                    }

                    clientForm.devForm.DevTree.Nodes.Add(nodeDev);
                    DVR2Mjpeg.dictDevInfo.Add(devInfo.lLoginID, devInfo);
                    this.Close();
                }
                else
                {
                    string strErr;
                    switch (nError)
                    {
                    case -11301:
                        strErr = string.Format("Passwd is Error");
                        break;

                    case -11300:
                        strErr = string.Format("The user has no permissions");
                        break;

                    case -11302:
                        strErr = string.Format("The user does not exist");
                        break;

                    case -11303:
                        strErr = string.Format("The user is locked");
                        break;

                    case -11304:
                        strErr = string.Format("The user is in the blacklist");
                        break;

                    case -11305:
                        strErr = string.Format("The user has landed");
                        break;

                    case -11307:
                        strErr = string.Format("There is no equipment");
                        break;

                    default:
                    {
                        strErr = string.Format("Login Error:{0}", nError);
                    }
                    break;
                    }
                    MessageBox.Show(strErr);
                }
            }
            else
            {
                MessageBox.Show("Please input all data!");
            }
        }
示例#12
0
        void deleteImageOnServer()
        {
            DVR2Mjpeg parentForm = (DVR2Mjpeg)Parent;

            parentForm.HttpServer.imageData.Remove((m_nIndex + 1).ToString());
        }