Пример #1
0
        private void btn_SearchCards_Click(object sender, EventArgs e)
        {
            Variable.BroadCastlist.Clear();
            cmb_barcode.Items.Clear();
            txt_IP.Text = "";
            IntPtr UDPSearchSecondData = Marshal.AllocHGlobal(1024 * 38);
            int    data_count          = 0;

            int err = LedYNetSdk.search_card(UDPSearchSecondData, ref data_count);

            byte[] datas = new byte[1024 * 38];
            Marshal.Copy(UDPSearchSecondData, datas, 0, 1024 * 38);
            for (int i = 0; i < data_count; i++)
            {
                IntPtr dec = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LedYNetSdk.BroadCast2)));
                Marshal.Copy(datas, Marshal.SizeOf(typeof(LedYNetSdk.BroadCast2)) * i, dec, Marshal.SizeOf(typeof(LedYNetSdk.BroadCast2)));
                LedYNetSdk.BroadCast2 bc = (LedYNetSdk.BroadCast2)Marshal.PtrToStructure(dec, typeof(LedYNetSdk.BroadCast2));
                Variable.BroadCastlist.Add(bc);
                Marshal.FreeHGlobal(dec);
                string pid     = System.Text.Encoding.Unicode.GetString(bc.pid).Split('\0')[0].Replace("&#x0;", "").Replace("쳌", "");
                string barcode = System.Text.Encoding.Unicode.GetString(bc.barcode).Split('\0')[0].Replace("&#x0;", "").Replace("쳌", "");
                cmb_barcode.Items.Add(barcode);
                if (string.IsNullOrEmpty(pid) || bc.port < 0 || bc.port > 65535 || bc.screen_type < 0 || bc.screen_type > 65535 || pid.Length != 32)
                {
                    continue;
                }
            }
            if (cmb_barcode.Items.Count > 0)
            {
                cmb_barcode.SelectedIndex = 0;
                btn_onoff.Enabled         = true;
                btn_firmware.Enabled      = true;
                btn_checktime.Enabled     = true;
                btn_volumn.Enabled        = true;
                btn_bright.Enabled        = true;
                btn_DArea.Enabled         = true;
                btn_program.Enabled       = true;
                btn_Screen.Enabled        = true;
                btn_capture.Enabled       = true;
            }
            else
            {
                btn_onoff.Enabled     = false;
                btn_firmware.Enabled  = false;
                btn_checktime.Enabled = false;
                btn_volumn.Enabled    = false;
                btn_bright.Enabled    = false;
                btn_DArea.Enabled     = false;
                btn_program.Enabled   = false;
                btn_Screen.Enabled    = false;
                btn_capture.Enabled   = false;
            }
        }
Пример #2
0
        private void btn_search_Click(object sender, EventArgs e)
        {
            Variable.BroadCastlist.Clear();
            cmb_barcode.Items.Clear();
            byte[] datas      = new byte[1024 * 64];
            int    data_count = 0;

            LedYNetSdk.Get_CardList(datas, ref data_count);
            for (int i = 0; i < data_count; i++)
            {
                IntPtr dec = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LedYNetSdk.BroadCast2)));
                Marshal.Copy(datas, Marshal.SizeOf(typeof(LedYNetSdk.BroadCast2)) * i, dec, Marshal.SizeOf(typeof(LedYNetSdk.BroadCast2)));
                LedYNetSdk.BroadCast2 bc = (LedYNetSdk.BroadCast2)Marshal.PtrToStructure(dec, typeof(LedYNetSdk.BroadCast2));
                Variable.BroadCastlist.Add(bc);
                Marshal.FreeHGlobal(dec);
                string barcode = System.Text.Encoding.Unicode.GetString(bc.barcode).Split('\0')[0].Replace("&#x0;", "").Replace("쳌", "");
                cmb_barcode.Items.Add(barcode);
            }
            if (cmb_barcode.Items.Count > 0)
            {
                cmb_barcode.SelectedIndex = 0;
                btn_onoff.Enabled         = true;
                btn_firmware.Enabled      = true;
                btn_checktime.Enabled     = true;
                btn_volumn.Enabled        = true;
                btn_bright.Enabled        = true;
                btn_DArea.Enabled         = true;
                btn_program.Enabled       = true;
            }
            else
            {
                btn_onoff.Enabled     = false;
                btn_firmware.Enabled  = false;
                btn_checktime.Enabled = false;
                btn_volumn.Enabled    = false;
                btn_bright.Enabled    = false;
                btn_DArea.Enabled     = false;
                btn_program.Enabled   = false;
            }
        }