/// <summary> /// 获取窗口参数 /// </summary> /// <param name="info">窗口操作信息</param> /// <param name="struWinParamCfg">输出配置参数</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallGetWinParam(ref WinCtrlInfo info, ref NET_DVR_WALLWINPARAM struWinParamCfg) { uint m_dwWallNo = info.WallNo; uint m_dwRes = 0; uint m_dwWinNo = info.WinNo; //窗口号(组合):1字节电视墙号+1字节保留+2字节窗口号 uint dwWinNum = ((m_dwWallNo & 0xff) << 24) + ((m_dwRes & 0xff) << 16) + (m_dwWinNo & 0xff); //窗口相关参数 struWinParamCfg = new NET_DVR_WALLWINPARAM(); Int32 nSize = Marshal.SizeOf(struWinParamCfg); IntPtr lpOutBuffer = Marshal.AllocHGlobal(nSize); Marshal.StructureToPtr(struWinParamCfg, lpOutBuffer, false); UInt32 dwReturn = 0; bool b = NET_DVR_GetDVRConfig(info.UserId, NET_DVR_WALLWINPARAM_GET, (int)dwWinNum, lpOutBuffer, (UInt32)nSize, ref dwReturn); if (!b) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_WALLWINPARAM_GET failed, error code= " + iLastErr; //获取窗口相关参数失败,输出错误号 Failed to get the window parameters of device and output the error code } else { struWinParamCfg = (NET_DVR_WALLWINPARAM)Marshal.PtrToStructure(lpOutBuffer, typeof(NET_DVR_WALLWINPARAM)); } Marshal.FreeHGlobal(lpOutBuffer); return(b); }
/// <summary> /// 设置窗口分割 /// </summary> /// <param name="info">窗口操作信息</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallSetWinParam(WinCtrlInfo info) { NET_DVR_WALLWINPARAM m_struWinParamCfg = new NET_DVR_WALLWINPARAM(); uint m_dwWallNo = info.WallNo; uint m_dwRes = 0; uint m_dwWinNo = info.WinNo; //窗口号(组合):1字节电视墙号+1字节保留+2字节窗口号 uint dwWinNum = ((m_dwWallNo & 0xff) << 24) + ((m_dwRes & 0xff) << 16) + (m_dwWinNo & 0xff); //窗口相关参数 Int32 nSize = Marshal.SizeOf(m_struWinParamCfg); m_struWinParamCfg.dwSize = (uint)nSize; m_struWinParamCfg.byWinMode = byte.Parse(info.SplitNum.ToString()); IntPtr lpInBuffer = Marshal.AllocHGlobal(nSize); Marshal.StructureToPtr(m_struWinParamCfg, lpInBuffer, false); bool b = NET_DVR_SetDVRConfig(info.UserId, NET_DVR_WALLWINPARAM_SET, (int)dwWinNum, lpInBuffer, (UInt32)nSize); if (!b) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_WALLWINPARAM_SET failed, error code= " + iLastErr; //设置窗口相关参数失败,输出错误号 Failed to set the window parameters of device and output the error code } Marshal.FreeHGlobal(lpInBuffer); return(b); }
/// <summary> /// 获取分屏数量 /// </summary> /// <param name="lUserID">用户id</param> /// <param name="dwWinNo">窗口号</param> /// <returns>返回分屏数量 -1失败</returns> public static int GetSubWinInfo(int lUserID, uint dwWinNo) { NET_DVR_WALLWINPARAM struWinWallParam = new NET_DVR_WALLWINPARAM(); Int32 nSize = Marshal.SizeOf(struWinWallParam); IntPtr lpOutBuffer = Marshal.AllocHGlobal(nSize); Marshal.StructureToPtr(struWinWallParam, lpOutBuffer, false); UInt32 dwReturn = 0; if (!NET_DVR_GetDVRConfig(lUserID, NET_DVR_WALLWINPARAM_GET, (int)dwWinNo, lpOutBuffer, (uint)nSize, ref dwReturn)) { return(-1); } return((struWinWallParam.byWinMode == 0) ? 1 : struWinWallParam.byWinMode); }
/// <summary> /// 获取开窗 /// </summary> /// <param name="info">窗口操作信息</param> /// <param name="struWinCfg">窗口信息</param> /// <param name="struWinParamCfg">窗口其他信息</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallGetWinCfg(ref WinCtrlInfo info, ref NET_DVR_VIDEOWALLWINDOWPOSITION struWinCfg, ref NET_DVR_WALLWINPARAM struWinParamCfg) { uint m_dwWallNo = info.WallNo; uint m_dwRes = 0; uint m_dwWinNo = info.WinNo; //窗口号(组合):1字节电视墙号+1字节保留+2字节窗口号 uint dwWinNum = ((m_dwWallNo & 0xff) << 24) + ((m_dwRes & 0xff) << 16) + (m_dwWinNo & 0xff); IntPtr lpInBuffer = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwWinNum, lpInBuffer, false); //窗口参数 struWinCfg = new NET_DVR_VIDEOWALLWINDOWPOSITION(); Int32 nSize = Marshal.SizeOf(struWinCfg); IntPtr lpOutBuffer = Marshal.AllocHGlobal(nSize); Marshal.StructureToPtr(struWinCfg, lpOutBuffer, false); //状态参数 UInt32 dwStatusList = 0; IntPtr lpStatusList = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwStatusList, lpStatusList, false); bool b = false; if (!NET_DVR_GetDeviceConfig(info.UserId, NET_DVR_GET_VIDEOWALLWINDOWPOSITION, 1, lpInBuffer, 4, lpStatusList, lpOutBuffer, (UInt32)nSize)) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_WALLWIN_GET failed, error code= " + iLastErr; //获取窗口参数失败,输出错误号 Failed to set the window parameters of device and output the error code return(false); } else { struWinCfg = (NET_DVR_VIDEOWALLWINDOWPOSITION)Marshal.PtrToStructure(lpOutBuffer, typeof(NET_DVR_VIDEOWALLWINDOWPOSITION)); //窗口在电视墙上的坐标位置 b = WallGetWinParam(ref info, ref struWinParamCfg); } Marshal.FreeHGlobal(lpInBuffer); Marshal.FreeHGlobal(lpOutBuffer); Marshal.FreeHGlobal(lpStatusList); return(b); }