示例#1
1
        public void ReConnect(object source, System.Timers.ElapsedEventArgs e)
        {
            foreach (DEV_INFO devinfo in dictDiscontDev.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);

                ClientDemo clientForm = new ClientDemo();

                foreach (Form form in Application.OpenForms)
                {
                    if (form.Name == "ClientDemo")
                    {
                        clientForm = (ClientDemo)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)
                        {
                            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)
                                {
                                    clientForm.m_videoform[chInfo.nWndIndex].ConnectRealPlay(ref devAdd, chInfo.nChannelNo);
                                    Thread.Sleep(10);
                                }
                            }
                            break;
                        }
                    }
                }

                dictDevInfo.Add(lLogin, devAdd);
                XMSDK.H264_DVR_SetupAlarmChan(lLogin);
            }
            if (0 == dictDiscontDev.Count)
            {
                timerDisconnect.Enabled = false;
                timerDisconnect.Stop();
            }
        }
        private void button_login_Click(object sender, EventArgs e)
        {
            H264_DVR_DEVICEINFO OutDev = new H264_DVR_DEVICEINFO();
            short nError = 0;
            StringBuilder strIP = new StringBuilder(this.textBox_ip.Text.ToString().Trim());
            ushort usPort = Convert.ToUInt16(this.textBox_port.Text.ToString().Trim());
            StringBuilder strUserName = new StringBuilder(this.textBox_username.Text.ToString());
            StringBuilder strPassword = new StringBuilder(this.textBox_password.Text.ToString());

            lLoginID = XMSDK.H264_DVR_Login(strIP, usPort, strUserName, strPassword, out OutDev, out nError, SocketStyle.TCPSOCKET);
            if (lLoginID <= 0)
            {
                MessageBox.Show(@"login wrong");
            }
            else
            {
                MessageBox.Show(@"login ok");
            }
        }
        private void button_login_Click(object sender, EventArgs e)
        {
            H264_DVR_DEVICEINFO OutDev = new H264_DVR_DEVICEINFO();
            short         nError       = 0;
            StringBuilder strIP        = new StringBuilder(this.textBox_ip.Text.ToString().Trim());
            ushort        usPort       = Convert.ToUInt16(this.textBox_port.Text.ToString().Trim());
            StringBuilder strUserName  = new StringBuilder(this.textBox_username.Text.ToString());
            StringBuilder strPassword  = new StringBuilder(this.textBox_password.Text.ToString());

            lLoginID = XMSDK.H264_DVR_Login(strIP, usPort, strUserName, strPassword, out OutDev, out nError, SocketStyle.TCPSOCKET);
            if (lLoginID <= 0)
            {
                MessageBox.Show(@"login wrong");
            }
            else
            {
                MessageBox.Show(@"login ok");
            }
        }
        public void ReConnect(object source, System.Timers.ElapsedEventArgs e)
        {
            foreach( DEV_INFO devinfo in dictDiscontDev.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);

                ClientDemo clientForm = new ClientDemo();

                foreach (Form form in Application.OpenForms)
                {
                    if (form.Name == "ClientDemo")
                    {
                        clientForm = (ClientDemo)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)
                        {
                            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  )
                                {
                                    clientForm.m_videoform[chInfo.nWndIndex].ConnectRealPlay(ref devAdd, chInfo.nChannelNo);
                                    Thread.Sleep(10);
                                }

                            }
                            break;
                        }

                    }

                }

                dictDevInfo.Add(lLogin, devAdd);
                XMSDK.H264_DVR_SetupAlarmChan(lLogin);
            }
            if (0 == dictDiscontDev.Count)
            {
                timerDisconnect.Enabled = false;
                timerDisconnect.Stop();
            }
        }
示例#5
0
 public static extern Int32 H264_DVR_Login(StringBuilder sDVRIP, ushort wDVRPort, StringBuilder sUserName, StringBuilder sPassword,
                                           out H264_DVR_DEVICEINFO lpDeviceInfo, out short error, SocketStyle socketstyle);
示例#6
0
 public static extern Int32 H264_DVR_Login(string sDVRIP, ushort wDVRPort, string sUserName, string sPassword,
                                           out H264_DVR_DEVICEINFO lpDeviceInfo, out int error, SocketStyle socketstyle);
示例#7
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)
                {
                    ClientDemo clientForm = new ClientDemo();

                    foreach (Form form in  Application.OpenForms)
                    {
                        if (form.Name == "ClientDemo")
                        {
                            clientForm = (ClientDemo)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 = nLoginID;
                    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);
                    ClientDemo.dictDevInfo.Add(devInfo.lLoginID, devInfo);
                }
                else
                {
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("Please input all data!");
            }
        }
 public static extern Int32 H264_DVR_Login(StringBuilder sDVRIP, ushort wDVRPort, StringBuilder sUserName, StringBuilder sPassword,
     out H264_DVR_DEVICEINFO lpDeviceInfo, out short error, SocketStyle socketstyle);
 public static extern Int32 H264_DVR_Login(string sDVRIP, ushort wDVRPort, string sUserName, string sPassword,
     out H264_DVR_DEVICEINFO lpDeviceInfo, out int error, SocketStyle socketstyle);
示例#10
0
        private void UpdateConfig(int nLoginID, int nChannel, uint nConfig)
        {
            if (nLoginID > 0)
            {
                IntPtr bufPtr;
                uint   nBufSize = 0;
                uint   nOutSize = 0;
                switch (nConfig)
                {
                case (uint)SDK_CONFIG_TYPE.E_SDK_CONFIG_SYSNORMAL:
                {
                    nBufSize = (uint)Marshal.SizeOf(typeof(SDK_CONFIG_NORMAL));
                    bufPtr   = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SDK_CONFIG_NORMAL)));
                    int nRet = XMSDK.H264_DVR_GetDevConfig(nLoginID, nConfig, nChannel, bufPtr, nBufSize, out nOutSize, 1000);
                    if (nRet < 0)
                    {
                        MessageBox.Show("Get config error!");
                        return;
                    }

                    SDK_CONFIG_NORMAL cfgNormal = new SDK_CONFIG_NORMAL();
                    cfgNormal = (SDK_CONFIG_NORMAL)Marshal.PtrToStructure(bufPtr, typeof(SDK_CONFIG_NORMAL));

                    nBufSize = (uint)Marshal.SizeOf(typeof(H264_DVR_DEVICEINFO));
                    bufPtr   = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(H264_DVR_DEVICEINFO)));
                    nRet     = XMSDK.H264_DVR_GetDevConfig(nLoginID, (uint)SDK_CONFIG_TYPE.E_SDK_CONFIG_SYSINFO, nChannel, bufPtr, nBufSize, out nOutSize, 1000);
                    H264_DVR_DEVICEINFO cfgSysInfo = new H264_DVR_DEVICEINFO();
                    cfgSysInfo = (H264_DVR_DEVICEINFO)Marshal.PtrToStructure(bufPtr, typeof(H264_DVR_DEVICEINFO));

                    textBoxSerial.Text                  = cfgSysInfo.sSerialNumber.ToString();
                    textBoxDeviceNo.Text                = cfgNormal.iLocalNo.ToString();
                    textBoxDeviceName.Text              = cfgNormal.sMachineName.ToString();
                    textBoxVideoOut.Text                = cfgNormal.iVideoStartOutPut.ToString();
                    textBoxAlarmIn.Text                 = cfgSysInfo.byAlarmInPortNum.ToString();
                    textBoxAlarmOut.Text                = cfgSysInfo.byAlarmOutPortNum.ToString();
                    comboBoxDiskFullTo.SelectedIndex    = cfgNormal.iOverWrite;
                    comboBoxVideoStandard.SelectedIndex = cfgNormal.iVideoFormat;
                    comboBoxDateFormat.SelectedIndex    = cfgNormal.iDateFormat;
                    comboBoxDateSeparator.SelectedIndex = cfgNormal.iDateSeparator;
                    textBoxStandbyTime.Text             = cfgNormal.iWorkDay.ToString();
                    comboBoxTimeFormat.SelectedIndex    = cfgNormal.iTimeFormat;

                    textBoxRecordChannel.Text  = (cfgSysInfo.byChanNum + cfgSysInfo.iDigChannel).ToString();
                    textBoxAudioIn.Text        = cfgSysInfo.iAudioInChannel.ToString();
                    textBoxTalkIn.Text         = cfgSysInfo.iTalkInChannel.ToString();
                    textBoxTalkOut.Text        = cfgSysInfo.iTalkOutChannel.ToString();
                    textBoxVideoOut.Text       = cfgSysInfo.iTalkOutChannel.ToString();
                    textBoxExChannel.Text      = cfgSysInfo.iExtraChannel.ToString();
                    textBoxDigitalChannel.Text = cfgSysInfo.iDigChannel.ToString();
                    textBox1SystemVersion.Text = cfgSysInfo.sSoftWareVersion;

                    StringBuilder strTime;
                    strTime = new StringBuilder();
                    strTime.AppendFormat("{0:d}-{1:d}-{2:d} {3:d}:{4:d}:{5:d}", cfgSysInfo.tmBuildTime.year,
                                         cfgSysInfo.tmBuildTime.month, cfgSysInfo.tmBuildTime.day, cfgSysInfo.tmBuildTime.hour,
                                         cfgSysInfo.tmBuildTime.minute, cfgSysInfo.tmBuildTime.second);

                    textBoxReleaseDate.Text = strTime.ToString();
                    break;
                }

                case (uint)SDK_CONFIG_TYPE.E_SDK_CONFIG_NET_WIFI:
                {
                    nBufSize = (uint)Marshal.SizeOf(typeof(SDK_NetWifiConfig));
                    bufPtr   = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SDK_NetWifiConfig)));
                    int nRet = XMSDK.H264_DVR_GetDevConfig(nLoginID, nConfig, nChannel, bufPtr, nBufSize, out nOutSize, 1000);
                    if (nRet < 0)
                    {
                        MessageBox.Show("Get config error!");
                        return;
                    }

                    curcfgWifi = (SDK_NetWifiConfig)Marshal.PtrToStructure(bufPtr, typeof(SDK_NetWifiConfig));

                    checkEnableWifi.Checked = Convert.ToBoolean(curcfgWifi.bEnable);

                    bool bWifiEnable = checkEnableWifi.Checked;
                    comboBoxWifiEntryType.Enabled = bWifiEnable;
                    if (!checkBoxDHCP.Checked)
                    {
                        textBoxWifiIP.Enabled      = bWifiEnable;
                        textBoxWifiSubmask.Enabled = bWifiEnable;
                        textBoxWifiGateway.Enabled = bWifiEnable;
                    }


                    StringBuilder strIP, strSubMask, strGateway;
                    strIP = new StringBuilder();
                    strIP.AppendFormat("{0:d}.{1:d}.{2:d}.{3:d}", (int)curcfgWifi.HostIP.c[0], (int)curcfgWifi.HostIP.c[1], (int)curcfgWifi.HostIP.c[2], (int)curcfgWifi.HostIP.c[3]);
                    strSubMask = new StringBuilder();
                    strSubMask.AppendFormat("{0:d}.{1:d}.{2:d}.{3:d}", (int)curcfgWifi.Submask.c[0], (int)curcfgWifi.Submask.c[1], (int)curcfgWifi.Submask.c[2], (int)curcfgWifi.Submask.c[3]);
                    strGateway = new StringBuilder();
                    strGateway.AppendFormat("{0:d}.{1:d}.{2:d}.{3:d}", (int)curcfgWifi.Gateway.c[0], (int)curcfgWifi.Gateway.c[1], (int)curcfgWifi.Gateway.c[2], (int)curcfgWifi.Gateway.c[3]);

                    textBoxWifiIP.Text       = strIP.ToString();
                    textBoxWifiSubmask.Text  = strSubMask.ToString();
                    textBoxWifiGateway.Text  = strGateway.ToString();
                    textBoxWifiPassword.Text = curcfgWifi.sKeys;
                    textBoxSSID.Text         = curcfgWifi.sSSID;
                    comboBoxWifiEntryType.Items.Clear();
                    comboBoxWifiEntryType.Items.Add(curcfgWifi.sEncrypType);
                    comboBoxWifiEntryType.SelectedIndex = 0;
                    comboBoxWifiKeyType.SelectedIndex   = 1;

                    if (curcfgWifi.sEncrypType == "WEP")
                    {
                        comboBoxWifiKeyType.SelectedIndex = curcfgWifi.nKeyType;
                        comboBoxWifiKeyType.Show();
                        labelKeyType.Show();
                    }
                    else
                    {
                        comboBoxWifiKeyType.Hide();
                        labelKeyType.Hide();
                    }

                    checkBoxDHCP.Checked       = false;
                    textBoxWifiIP.Enabled      = true;
                    textBoxWifiSubmask.Enabled = true;
                    textBoxWifiGateway.Enabled = true;
                    break;
                }

                case (uint)SDK_CONFIG_TYPE.E_SDK_CONFIG_NET_DHCP:
                {
                    nBufSize = (uint)Marshal.SizeOf(typeof(SDK_NetDHCPConfigAll));
                    bufPtr   = Marshal.AllocHGlobal((int)nBufSize);
                    int nRet = XMSDK.H264_DVR_GetDevConfig(nLoginID, (uint)SDK_CONFIG_TYPE.E_SDK_CONFIG_NET_DHCP, -1, bufPtr, nBufSize, out nOutSize, 1000);
                    if (nRet > 0)
                    {
                        SDK_NetDHCPConfigAll dhcpAll = new SDK_NetDHCPConfigAll();
                        dhcpAll       = (SDK_NetDHCPConfigAll)Marshal.PtrToStructure(bufPtr, typeof(SDK_NetDHCPConfigAll));
                        curDHCPcfgAll = dhcpAll;

                        if (Convert.ToBoolean(dhcpAll.vNetDHCPConfig[2].bEnable))
                        {
                            checkBoxDHCP.Checked       = true;
                            textBoxWifiIP.Enabled      = false;
                            textBoxWifiSubmask.Enabled = false;
                            textBoxWifiGateway.Enabled = false;
                        }
                    }
                    break;
                }

                case (uint)SDK_CONFIG_TYPE.E_SDK_CONFIG_NET_WIFI_AP_LIST:
                {
                    nBufSize = (uint)Marshal.SizeOf(typeof(SDK_NetWifiDeviceAll));
                    bufPtr   = Marshal.AllocHGlobal((int)nBufSize);
                    int nRet = XMSDK.H264_DVR_GetDevConfig(nLoginID, (uint)SDK_CONFIG_TYPE.E_SDK_CONFIG_NET_WIFI_AP_LIST, -1, bufPtr, nBufSize, out nOutSize, 5000);


                    if (nRet >= 0)
                    {
                        listViewWifi.Items.Clear();

                        SDK_NetWifiDeviceAll wifiDeviAll = new SDK_NetWifiDeviceAll();
                        wifiDeviAll = (SDK_NetWifiDeviceAll)Marshal.PtrToStructure(bufPtr, typeof(SDK_NetWifiDeviceAll));
                        for (int i = 0; i < wifiDeviAll.nDevNumber; i++)
                        {
                            string strRSSI;
                            switch (wifiDeviAll.vNetWifiDeviceAll[i].nRSSI)
                            {
                            case (int)SDK_RSSI_SINGNAL.SDK_RSSI_NO_SIGNAL:
                                strRSSI = "ConfigNet.NoSignal";
                                break;

                            case (int)SDK_RSSI_SINGNAL.SDK_RSSI_VERY_LOW:
                                strRSSI = "VeryLow";
                                break;

                            case (int)SDK_RSSI_SINGNAL.SDK_RSSI_LOW:
                                strRSSI = "Low";
                                break;

                            case (int)SDK_RSSI_SINGNAL.SDK_RSSI_GOOD:
                                strRSSI = "Good";
                                break;

                            case (int)SDK_RSSI_SINGNAL.SDK_RSSI_VERY_GOOD:
                                strRSSI = "VeryGood";
                                break;

                            case (int)SDK_RSSI_SINGNAL.SDK_RSSI_EXCELLENT:
                                strRSSI = "Excellent";
                                break;

                            default:
                                strRSSI = "NoSignal";
                                break;
                            }

                            SDK_NetWifiDevice wifi = new SDK_NetWifiDevice();
                            wifi = wifiDeviAll.vNetWifiDeviceAll[i];
                            ListViewItem item = new ListViewItem(new string[] { wifi.sSSID, wifi.sAuth, strRSSI });

                            item.Tag = wifi;
                            listViewWifi.Items.Add(item);
                        }
                    }
                    break;
                }

                case (uint)SDK_CONFIG_TYPE.E_SDK_CONFIG_ABILITY_SYSFUNC:
                {
                    nBufSize = (uint)Marshal.SizeOf(typeof(SDK_SystemFunction));
                    bufPtr   = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SDK_SystemFunction)));
                    int nRet = XMSDK.H264_DVR_GetDevConfig(nLoginID, (uint)SDK_CONFIG_TYPE.E_SDK_CONFIG_ABILITY_SYSFUNC, -1, bufPtr, nBufSize, out nOutSize, 2000);

                    if (nRet > 0)
                    {
                        SDK_SystemFunction sysFunction = new SDK_SystemFunction();
                        sysFunction = (SDK_SystemFunction)Marshal.PtrToStructure(bufPtr, typeof(SDK_SystemFunction));
                        if (!Convert.ToBoolean(sysFunction.vNetServerFunction[(int)SDK_NetServerTypes.SDK_NET_SERVER_TYPES_WIFI]))
                        {
                            tabPageWifi.Hide();
                        }
                        else
                        {
                            tabPageWifi.Show();
                        }
                    }
                    break;
                }
                }
            }
        }
示例#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)
                {
                    ClientDemo clientForm = new ClientDemo();

                    foreach (Form form in  Application.OpenForms)
                    {
                        if (form.Name == "ClientDemo")
                        {
                            clientForm = (ClientDemo)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 = nLoginID;
                    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);
                    ClientDemo.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!");
            }
        }
        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 )
                {
                    ClientDemo clientForm = new ClientDemo();

                    foreach( Form form in  Application.OpenForms)
                    {
                        if ( form.Name == "ClientDemo" )
                        {
                            clientForm = (ClientDemo)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 = nLoginID;
                    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);
                    ClientDemo.dictDevInfo.Add(devInfo.lLoginID, devInfo);
                }
                else
                {

                }
                 this.Close();
            }
            else
            {
                MessageBox.Show("Please input all data!");
            }
        }