Beispiel #1
0
        private void AlarmGet_Click(object sender, EventArgs e)
        {
            if (m_lUserID < 0)
            {
                MessageBox.Show("Please Login!");
                return;
            }
            Int32  iSize       = Marshal.SizeOf(m_strAlarmCfg);
            IntPtr ptrAlarmCfg = Marshal.AllocHGlobal(iSize);

            Marshal.StructureToPtr(m_strAlarmCfg, ptrAlarmCfg, false);
            if (!CHCNetSDK.NET_DVR_GetAlarmDeviceUser(m_lUserID, 1, ref m_strAlarmCfg))
            {
                iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                strErr   = "NET_DVR_GetAlarmDeviceUser failed,error code=" + iLastErr;
                MessageBox.Show(strErr);
            }
            else
            {
                textBoxUserName.Text = System.Text.Encoding.UTF8.GetString(m_strAlarmCfg.sUserName);
                textBoxPassword.Text = System.Text.Encoding.UTF8.GetString(m_strAlarmCfg.sPassword);
                textBoxUserIP.Text   = m_strAlarmCfg.struUserIP.sIpV4;
                if (m_strAlarmCfg.byAMCAddr == null)
                {
                    m_strAlarmCfg.byAMCAddr.CopyTo(System.Text.Encoding.Default.GetBytes("00:00:00:00:00:00"), 0);
                }
                textBoxMac.Text = System.Text.Encoding.UTF8.GetString(m_strAlarmCfg.byAMCAddr);

                if (m_strAlarmCfg.byUserType == 0)
                {
                    comboBoxUserType.SelectedIndex = 0;
                }
                else if (m_strAlarmCfg.byUserType == 1)
                {
                    comboBoxUserType.SelectedIndex = 1;
                }

                if (m_strAlarmCfg.byAlarmOnRight == 1)
                {
                    checkBoxAlarmOn.Checked = true;
                }
                else
                {
                    checkBoxAlarmOn.Checked = false;
                }

                if (m_strAlarmCfg.byAlarmOffRight == 1)
                {
                    checkBoxAlarmOff.Checked = true;
                }
                else
                {
                    checkBoxAlarmOff.Checked = false;
                }

                if (m_strAlarmCfg.byBypassRight == 1)
                {
                    checkBoxByPass.Checked = true;
                }
                else
                {
                    checkBoxByPass.Checked = false;
                }

                for (int i = 0; i < checkBox.Length; i++)
                {
                    if (m_strAlarmCfg.byOtherRight[i] == 1)
                    {
                        checkBox[i].Checked = true;
                    }
                    else
                    {
                        checkBox[i].Checked = false;
                    }
                }
            }
        }