private fm_FullScreen m_fmFullScreen;             //全屏显示窗口号

        //构造函数
        public ucVideoGroup()
        {
            InitializeComponent();
            m_arrVideos = new ucSingleVideo[m_iMaxScreen];
            for (int i = 0; i < m_iMaxScreen; i++)
            {
                m_arrVideos[i]                           = new ucSingleVideo();
                m_arrVideos[i].Parent                    = this;
                m_arrVideos[i].Visible                   = false;
                m_arrVideos[i].Tag                       = i;
                m_arrVideos[i].pnlShowVideo.Tag          = i;
                m_arrVideos[i].pnlShowVideo.DoubleClick += new EventHandler(ucSingleVideo_DbClick);
                m_arrVideos[i].pnlShowVideo.MouseDown   += new MouseEventHandler(pnlShowVideo_MouseDown);

                m_arrVideos[i].ContextMenuStrip = cmsVideo;
            }
            ChangeScreens(16);
            m_lstScreenMenu = new List <ToolStripMenuItem>();
            m_lstScreenMenu.Add(tmsiSingleScreen);
            m_lstScreenMenu.Add(tmsiFourScreen);
            m_lstScreenMenu.Add(tmsiNineScreen);
            m_lstScreenMenu.Add(tmsiSixtheenScreen);
            m_fmFullScreen         = new fm_FullScreen();
            m_fmFullScreen.Visible = false;
            Init();
        }
        /// <summary>
        /// 连接视频
        /// </summary>
        /// <param name="strId">连接视频的id</param>
        /// <param name="strIp">连接视频的ip</param>
        /// <param name="strName">摄像机名称</param>
        /// <param name="itype">api类型 1.自己api 2.海康api</param>
        /// <param name="iLoginHandle">海康摄像机的登录句柄</param>
        /// <param name="iChannel">播放通道(海康摄像机)</param>
        public void ConnectVideo(string strId, string strIp, string strName, int iType,
                                 int iChannel, int iLoginHandle = -1)
        {
            //ucSingleVideo sOldVideo = GetSingleFormByCamId(strId);
            ////说明没有找到id对应的窗口
            //if (sOldVideo == null)
            //{
            //返回窗口的信息(空白的窗口)
            ucSingleVideo svideo = GetNextNullWin();

            if (svideo != null)
            {
                switch (iType)
                {
                case 1:    //自己api
                    svideo.ConnectVideo(strId, strIp, strName);
                    svideo.SetCamType(iType, iChannel);
                    svideo.ShowVideoCaption(true);
                    break;

                case 2:    //海康api
                    svideo.ConnectVideoHik(iLoginHandle, iChannel, strName);
                    svideo.SetCamType(iType, iChannel);
                    svideo.ShowVideoCaption(true);
                    break;
                }
            }
            //}
            //else
            //{
            //    setActiveWin(Convert.ToInt32(sOldVideo.Tag));
            //}
        }
        /// <summary>
        /// 根据编号获得窗口对象
        /// </summary>
        public ucSingleVideo GetSingleFormByNo(Int32 _iWinNo)
        {
            ucSingleVideo svideo = null;

            if (_iWinNo >= 0 && _iWinNo < m_iMaxScreen)
            {
                svideo = m_arrVideos[_iWinNo];
            }
            return(svideo);
        }
        /// <summary>
        /// 根据摄像机ID查找窗口
        /// </summary>
        /// <returns>成功返回摄像机对应的控件,否则返回null</returns>
        public ucSingleVideo GetSingleFormByCamId(string strId)
        {
            ucSingleVideo svideo = null;

            for (int i = 0; i < m_iMaxScreen; i++)
            {
                if (m_arrVideos[i].GetLinkCamId() == strId)
                {
                    svideo = m_arrVideos[i];
                    break;
                }
            }
            return(svideo);
        }
        /// <summary>
        /// 根据连接句柄查找窗口对象
        /// </summary>
        public ucSingleVideo GetSingleFormByHandle(Int32 _lHandle)
        {
            ucSingleVideo svideo = null;

            for (int i = 0; i < m_iMaxScreen; i++)
            {
                if (m_arrVideos[i].GetLinkHandle() == _lHandle)
                {
                    svideo = m_arrVideos[i];
                    break;
                }
            }
            return(svideo);
        }
Beispiel #6
0
        /// <summary>
        /// 根据摄像机ip寻找窗口对象
        /// </summary>
        /// <param name="_strCamIp"></param>
        /// <returns></returns>
        public ucSingleVideo GetSingleByHikCamIp(string _strCamIp)
        {
            ucSingleVideo oVideo = null;

            for (int i = 0; i < m_iMaxScreen; i++)
            {
                if (m_arrVideos[i].m_strHikCamIp == _strCamIp)
                {
                    oVideo = m_arrVideos[i];
                    break;
                }
            }
            return(oVideo);
        }
Beispiel #7
0
        /// <summary>
        /// 连接视频
        /// </summary>
        /// <param name="strId">连接视频的id</param>
        /// <param name="strIp">连接视频的ip</param>
        /// <param name="strName">摄像机名称</param>
        /// <param name="itype">api类型 1.自己api 2.海康api</param>
        /// <param name="iLoginHandle">海康摄像机的登录句柄</param>
        /// <param name="iChannel">播放通道(海康摄像机)</param>
        public void ConnectVideoSwitch(string strId, string strIp, string strName, int iType,
                                       int iChannel, int iLoginHandle = -1)
        {
            ucSingleVideo oSelfCamVideo = GetSingleFormByCamId(strId);
            /*\ 根据海康 /*/
            ucSingleVideo oHikCamVideo = GetSingleByHikCamIp(strIp);

            switch (iType)
            {
            case 1:    //自己api
                if (oSelfCamVideo == null)
                {
                    ucSingleVideo oVideo = GetNextNullWin();
                    if (oVideo != null)
                    {
                        oVideo.ConnectVideo(strId, strIp, strName);
                        oVideo.SetCamType(iType, iChannel);
                        oVideo.ShowVideoCaption(true);
                    }
                }
                else
                {
                    /*\ 判断当先显示的视频是否和要在活动窗口显示的视频id相等 /*/
                    if (m_arrVideos[Convert.ToInt32(oSelfCamVideo.Tag)].m_strCamId == strId)
                    {
                        setActiveWin(Convert.ToInt32(oSelfCamVideo.Tag));
                    }
                    else
                    {
                        /*\ 断开当前连接的视频 /*/
                        m_arrVideos[Convert.ToInt32(oSelfCamVideo.Tag)].DisConnectVideo();
                        /*\ 连接新id的视频 /*/
                        m_arrVideos[Convert.ToInt32(oSelfCamVideo.Tag)].ConnectVideo(strId, strIp, strName);
                        m_arrVideos[Convert.ToInt32(oSelfCamVideo.Tag)].SetCamType(iType, iChannel);
                        m_arrVideos[Convert.ToInt32(oSelfCamVideo.Tag)].ShowVideoCaption(true);
                    }
                }
                break;

            case 2:    //海康api
                       /*\ 判断当前选中窗口是否连接视频,连接视频断开,替换 /*/
                if (oHikCamVideo == null)
                {
                    if (m_iCurScreens == 1)
                    {
                        setActiveWin(0);
                        if (m_arrVideos[m_iActiveWin].m_bConnected)
                        {
                            m_arrVideos[m_iActiveWin].DisConnectVideoHik();
                        }
                    }
                    ucSingleVideo oVideo = GetNextNullWinSwitch();
                    if (oVideo != null)
                    {
                        oVideo.ConnectVideoHik(iLoginHandle, iChannel, strName);
                        oVideo.SetHikCamIp(strIp);
                        oVideo.SetCamType(iType, iChannel);
                        oVideo.ShowVideoCaption(true);
                    }
                }
                else
                {
                    /*\ 判断当先显示的视频是否和要在活动窗口显示的视频Ip相等 /*/
                    int iWinNo = GetWinNoByHikCamIp(strIp);
                    if (iWinNo != -1)
                    {
                        setActiveWin(iWinNo);
                    }
                    else
                    {
                        /*\ 断开当前连接的视频 /*/
                        m_arrVideos[m_iActiveWin].DisConnectVideo();
                        /*\ 连接新id的视频 /*/
                        m_arrVideos[m_iActiveWin].ConnectVideoHik(iLoginHandle, iChannel, strName);
                        m_arrVideos[m_iActiveWin].SetHikCamIp(strIp);
                        m_arrVideos[m_iActiveWin].SetCamType(iType, iChannel);
                        m_arrVideos[m_iActiveWin].ShowVideoCaption(true);
                    }
                    //if (m_arrVideos[m_iActiveWin].m_strHikCamIp == strIp)
                    //{
                    //    setActiveWin(m_iActiveWin);
                    //}
                    //else
                    //{
                    //    /*\ 断开当前连接的视频 /*/
                    //    m_arrVideos[m_iActiveWin].DisConnectVideo();
                    //    /*\ 连接新id的视频 /*/
                    //    m_arrVideos[m_iActiveWin].ConnectVideoHik(iLoginHandle, iChannel, strName);
                    //    m_arrVideos[m_iActiveWin].SetHikCamIp(strIp);
                    //    m_arrVideos[m_iActiveWin].SetCamType(iType, iChannel);
                    //    m_arrVideos[m_iActiveWin].ShowVideoCaption(true);
                    //}
                }
                break;
            }
        }