/// <summary> /// 添加设备1处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddDevice1_Click(object sender, EventArgs e) { frm_AddDevice fAddDev = new frm_AddDevice(); fAddDev.ShowDialog(); try { if (fAddDev.blnOKEnter == true) { //设备用户信息获得 deviceInfo = new NET_DEVICEINFO(); int error = 0; //设备1登录:注意登录ID pLoginID1 = DHClient.DHLogin(fAddDev.cmbDevIP.Text.ToString(), ushort.Parse(fAddDev.txtDevProt.Text.ToString()), fAddDev.txtName.Text.ToString(), fAddDev.txtPassword.Text.ToString(), out deviceInfo, out error); //是否登录成功判断 if (pLoginID1 != 0) { MessageBox.Show("设备1登录成功!", "提示"); } else { MessageBox.Show("设备1登录失败!", "提示"); } } } catch { } }
/// <summary> /// 添加设备2处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddDevice2_Click(object sender, EventArgs e) { frm_AddDevice fAddDev = new frm_AddDevice(); fAddDev.ShowDialog(); try { if (fAddDev.blnOKEnter == true) { //设备用户信息获得 deviceInfo = new NET_DEVICEINFO(); int error = 0; //设备2登录:注意登录ID pLoginID2 = DHClient.DHLogin(fAddDev.cmbDevIP.Text.ToString(), ushort.Parse(fAddDev.txtDevProt.Text.ToString()), fAddDev.txtName.Text.ToString(), fAddDev.txtPassword.Text.ToString(), out deviceInfo, out error); //是否登录成功判断 if (pLoginID2 != 0) { MessageBox.Show("设备2登录成功!", "提示"); } else { MessageBox.Show("设备2登录失败!", "提示"); } } } catch { } }
/// <summary> /// [设备用户登录]按钮按下 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUserLogin_Click(object sender, EventArgs e) { frm_AddDevice fAddDev = new frm_AddDevice(); fAddDev.ShowDialog(); //DHClient.DHSetShowException(true); try { if (fAddDev.blnOKEnter == true) { //设备用户信息获得 deviceInfo = new NET_DEVICEINFO(); int error = 0; pLoginID = DHClient.DHLogin(fAddDev.cmbDevIP.Text.ToString(), ushort.Parse(fAddDev.txtDevProt.Text.ToString()), fAddDev.txtName.Text.ToString(), fAddDev.txtPassword.Text.ToString(), out deviceInfo, out error); if (pLoginID != 0) { pPlayBackHandle = new int[deviceInfo.byChanNum]; //画面按钮有效性控制 pRealPlayHandle = null; btnRealPlay.Text = StringUtil.ConvertString("实时监视开始"); btnUserLogin.Enabled = false; btnRealPlay.Enabled = true; btnPlayBackByTime.Enabled = true; gpbPlayBackControl.Enabled = false; btnUserLogout.Enabled = true; gpbPTZControl.Enabled = false; btnPlayByRecordFile.Enabled = true; cmbChannelSelect.Items.Clear(); for (int i = 0; i < deviceInfo.byChanNum; i++) { cmbChannelSelect.Items.Add(i.ToString()); } } else { MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle); btnUserLogin_Click(null, null); } } } catch { //报最后一次操作的错误信息 MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle); btnUserLogin_Click(null, null); } }
/// <summary> /// 添加设备按钮按下 /// </summary> /// <param name="sender">系统参数</param> /// <param name="e">系统参数</param> private void btnAddDevice_Click(object sender, EventArgs e) { bool intLogin = false; frm_AddDevice fAddDev = new frm_AddDevice(); fAddDev.ShowDialog(); try { if (fAddDev.blnOKEnter == true) { //设备用户信息获得 clientInfo.Name = fAddDev.txtName.Text.ToString(); clientInfo.DeviceIP = fAddDev.cmbDevIP.Text.ToString(); clientInfo.DevicePort = int.Parse(fAddDev.txtDevProt.Text.ToString()); clientInfo.Password = fAddDev.txtPassword.Text.ToString(); clientInfo.DeviceName = fAddDev.txtDevName.Text.ToString(); //将用户信息提交给类对象 clientInstance.ClientInfo = clientInfo; intLogin = clientInstance.Login();//DVR设备用户登陆 if (intLogin == true) { clientInstance.RealPlay(0, this.picRealPlay0.Handle); //实时监视绑定容器0 clientInstance.RealPlay(1, this.picRealPlay1.Handle); //实时监视绑定容器1 clientInstance.RealPlay(2, this.picRealPlay2.Handle); //实时监视绑定容器2 clientInstance.RealPlay(3, this.picRealPlay3.Handle); //实时监视绑定容器3 clientInstance.RealPlay(4, this.picRealPlay4.Handle); //实时监视绑定容器4 clientInstance.RealPlay(5, this.picRealPlay5.Handle); //实时监视绑定容器5 clientInstance.RealPlay(6, this.picRealPlay6.Handle); //实时监视绑定容器6 clientInstance.RealPlay(7, this.picRealPlay7.Handle); //实时监视绑定容器7 //画面按钮有效性控制 btnDelDevice.Enabled = true; btnAddDevice.Enabled = false; btn_PlayBackByTime.Enabled = true; btnExit.Enabled = true; tclControl.Enabled = false; } } } catch { MessageBox.Show("设备信息输入有误!", MsgTitle); btnAddDevice_Click(null, null); } }
/// <summary> /// 添加设备按钮按下 /// </summary> /// <param name="sender">系统参数</param> /// <param name="e">系统参数</param> private void btnAddDevice_Click(object sender, EventArgs e) { bool intLogin = false; frm_AddDevice fAddDev = new frm_AddDevice(); fAddDev.ShowDialog(); try { if (fAddDev.blnOKEnter == true) { //设备用户信息获得 clientInfo.Name = fAddDev.txtName.Text.ToString(); clientInfo.DeviceIP = fAddDev.cmbDevIP.Text.ToString(); clientInfo.DevicePort = int.Parse(fAddDev.txtDevProt.Text.ToString()); clientInfo.Password = fAddDev.txtPassword.Text.ToString(); clientInfo.DeviceName = fAddDev.txtDevName.Text.ToString(); //将用户信息提交给类对象 clientInstance.ClientInfo = clientInfo; intLogin = clientInstance.Login();//DVR设备用户登陆 if (intLogin ==true) { clientInstance.RealPlay(0, this.picRealPlay0.Handle);//实时监视绑定容器0 clientInstance.RealPlay(1, this.picRealPlay1.Handle);//实时监视绑定容器1 clientInstance.RealPlay(2, this.picRealPlay2.Handle);//实时监视绑定容器2 clientInstance.RealPlay(3, this.picRealPlay3.Handle);//实时监视绑定容器3 clientInstance.RealPlay(4, this.picRealPlay4.Handle);//实时监视绑定容器4 clientInstance.RealPlay(5, this.picRealPlay5.Handle);//实时监视绑定容器5 clientInstance.RealPlay(6, this.picRealPlay6.Handle);//实时监视绑定容器6 clientInstance.RealPlay(7, this.picRealPlay7.Handle);//实时监视绑定容器7 //画面按钮有效性控制 btnDelDevice.Enabled = true; btnAddDevice.Enabled = false; btn_PlayBackByTime.Enabled = true; btnExit.Enabled = true; tclControl.Enabled = false; } } } catch { MessageBox.Show("设备信息输入有误!", MsgTitle); btnAddDevice_Click(null, null); } }
/// <summary> /// 设备用户登录/注销处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUserLogin_Click(object sender, EventArgs e) { string strLogin = StringUtil.ConvertString("设备用户登录"); string strLogout = StringUtil.ConvertString("设备用户注销"); if (btnUserLogin.Text.Equals(strLogin)) { frm_AddDevice fLogin = new frm_AddDevice(); fLogin.ShowDialog(); if (fLogin.blnOKEnter == true) { //设备用户信息获得 NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO(); int error = 0; //设备用户登录 pLoginID = DHClient.DHLogin(fLogin.cmbDevIP.Text.ToString(), ushort.Parse(fLogin.txtDevProt.Text.ToString()), fLogin.txtName.Text.ToString(), fLogin.txtPassword.Text.ToString(), out deviceInfo, out error); if (pLoginID != 0) { btnUserLogin.BackColor = Color.Yellow; btnUserLogin.Text = strLogout; grpMain.Enabled = true; //读取用户信息 GetUserInfo(pLoginID, ref userManageInfo, 3000); //设置消息回调函数 DHClient.DHSetDVRMessCallBack(msgCallBack, IntPtr.Zero); IntPtr pVer = new IntPtr(); pVer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int))); int nRet = 0; int nVer = 0; bool bRet = DHClient.DHQueryDevState((int)pLoginID, (int)DHClient.DH_DEVSTATE_PROTOCAL_VER, pVer, 4, ref nRet, 2000); if (bRet) { nVer = (int)Marshal.PtrToStructure((IntPtr)((UInt32)pVer), typeof(int)); //开始侦听 if (nVer >= 5) { if (DHClient.DHStartListenEx(pLoginID) == true) { timeDisplayAlarmInfo.Enabled = true; } else { timeDisplayAlarmInfo.Enabled = false; } } else { if (DHClient.DHStartListen(pLoginID) == true) { timeDisplayAlarmInfo.Enabled = true; } else { timeDisplayAlarmInfo.Enabled = false; } } } } } } else { bool result = DHClient.DHLogout(pLoginID); if (result == false) { //报最后一次操作的错误信息 MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle); } //画面初期化 timeDisplayAlarmInfo.Enabled = false; this.Controls.Clear(); InitializeComponent(); StringUtil.InitControlText(this); pLoginID = 0; userManageInfo = new USER_MANAGE_INFO(); clientState = new NET_CLIENT_STATE(); AlarmAudio = new byte[16]; AlarmDiskErr = new byte[32];//DVR最大可挂32块硬盘,每一位表示一个硬盘的状态,0:硬盘状态正常;1:硬盘出错 AlarmDiskFull = false; AlarmShelter = new byte[16]; AlarmExternal = new byte[16]; ActiveUserID = 0; ActiveGroupID = 0; ActiveGroupIndex = 0; ActiveUserIndex = 0; btnUserLogin.BackColor = Color.Transparent; btnUserLogin.Text = strLogin; grpMain.Enabled = false; this.WindowState = FormWindowState.Normal; } }
/// <summary> /// [设备用户登录]按钮按下 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUserLogin_Click(object sender, EventArgs e) { frm_AddDevice fAddDev = new frm_AddDevice(); fAddDev.ShowDialog(); //DHClient.DHSetShowException(true); try { if (fAddDev.blnOKEnter == true) { //设备用户信息获得 deviceInfo = new NET_DEVICEINFO(); int error = 0; pLoginID = DHClient.DHLogin(fAddDev.cmbDevIP.Text.ToString(), ushort.Parse(fAddDev.txtDevProt.Text.ToString()),fAddDev.txtName.Text.ToString(), fAddDev.txtPassword.Text.ToString(), out deviceInfo, out error); if (pLoginID != 0) { pPlayBackHandle = new int[deviceInfo.byChanNum]; //画面按钮有效性控制 pRealPlayHandle = null; btnRealPlay.Text = StringUtil.ConvertString("RealPlay"); btnUserLogin.Enabled = false; btnRealPlay.Enabled = true; btnPlayBackByTime.Enabled = true; gpbPlayBackControl.Enabled = false; btnUserLogout.Enabled = true; gpbPTZControl.Enabled = false; btnPlayByRecordFile.Enabled = true; cmbChannelSelect.Items.Clear(); for (int i = 0; i < deviceInfo.byChanNum; i++) { cmbChannelSelect.Items.Add(i.ToString()); } } else { MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle),pMsgTitle); btnUserLogin_Click(null, null); } } } catch { //报最后一次操作的错误信息 MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle); btnUserLogin_Click(null, null); } }
/// <summary> /// 用户登录按钮按下 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUserLogin_Click(object sender, EventArgs e) { string strLogin = StringUtil.ConvertString("设备用户登录"); string strLogout = StringUtil.ConvertString("设备用户注销"); if (btnUserLogin.Text.Equals(strLogin)) { frm_AddDevice fadFrom = new frm_AddDevice(); fadFrom.ShowDialog(); if (fadFrom.blnOKEnter == true) { //设备用户信息获得 NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO(); int error = 0; pLoginID = DHClient.DHLogin(fadFrom.cmbDevIP.Text.ToString(), ushort.Parse(fadFrom.txtDevProt.Text.ToString()), fadFrom.txtName.Text.ToString(), fadFrom.txtPassword.Text.ToString(), out deviceInfo, out error); if (pLoginID != 0) { btnUserLogin.BackColor = Color.Yellow; btnUserLogin.Text = strLogout; grbMain.Enabled = true; tbcMain.SelectedIndex = 0; } else { //报最后一次操作的错误信息 MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle); btnUserLogin_Click(null, null); } } } else { bool result = DHClient.DHLogout(pLoginID); if (result == false) { //报最后一次操作的错误信息 MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle); } //画面初始化 this.Controls.Clear(); InitializeComponent(); pLoginID = 0; sysAttrConfig = new DHDEV_SYSTEM_ATTR_CFG(); channelConfig = new DHDEV_CHANNEL_CFG[16]; netConfig = new DHDEV_NET_CFG(); recConfig = new DHDEV_RECORD_CFG[16]; commConfig = new DHDEV_COMM_CFG(); alarmAllConfig = new DHDEV_ALARM_SCHEDULE(); btnUserLogin.BackColor = Color.Transparent; btnUserLogin.Text = strLogin; grbMain.Enabled = false; tbcMain.SelectedIndex = 0; } }
/// <summary> /// 设备用户登录/注销处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUserLogin_Click(object sender, EventArgs e) { switch (btnUserLogin.Text) { case "设备用户登录": frm_AddDevice fLogin = new frm_AddDevice(); fLogin.ShowDialog(); if (fLogin.blnOKEnter == true) { //设备用户信息获得 NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO(); int error = 0; //设备用户登录 pLoginID = DHClient.DHLogin(fLogin.cmbDevIP.Text.ToString(), ushort.Parse(fLogin.txtDevProt.Text.ToString()), fLogin.txtName.Text.ToString(), fLogin.txtPassword.Text.ToString(), out deviceInfo, out error); if (pLoginID != 0) { btnUserLogin.BackColor = Color.Yellow; btnUserLogin.Text = "设备用户注销"; grpMain.Enabled = true; //读取用户信息 GetUserInfo(pLoginID, ref userManageInfo, 3000); //设置消息回调函数 DHClient.DHSetDVRMessCallBack(msgCallBack, IntPtr.Zero); //开始侦听 if (DHClient.DHStartListen(pLoginID) == true) { timeDisplayAlarmInfo.Enabled = true; } else { timeDisplayAlarmInfo.Enabled = false; } } } break; case "设备用户注销": bool result = DHClient.DHLogout(pLoginID); if (result == false) { //报最后一次操作的错误信息 MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle); } //画面初期化 timeDisplayAlarmInfo.Enabled = false; this.Controls.Clear(); InitializeComponent(); pLoginID = 0; userManageInfo = new USER_MANAGE_INFO(); clientState = new NET_CLIENT_STATE(); AlarmAudio = new byte[16]; AlarmDiskErr = new byte[32];//DVR最大可挂32块硬盘,每一位表示一个硬盘的状态,0:硬盘状态正常;1:硬盘出错 AlarmDiskFull = false; AlarmShelter = new byte[16]; ActiveUserID = 0; ActiveGroupID = 0; ActiveGroupIndex = 0; ActiveUserIndex = 0; btnUserLogin.BackColor = Color.Transparent; btnUserLogin.Text = "设备用户登录"; grpMain.Enabled = false; this.WindowState = FormWindowState.Normal; break; } }