Exemplo n.º 1
0
        private void frmBoxPower_Load(object sender, EventArgs e)
        {
            xtraTabControl1.SelectedTabPage = xtraTabPage3;
            AddTreeView("0", (TreeNode)null);
            treeView1.ExpandAll();

            TableInit();
            ShowDataTable();

            if (manager == null)
            {
                manager = new UDPClientManager("61003");
                manager.Start(int.Parse("61003"));  //开启端口监听
                manager.UDPMessageReceived += new UDPMessageReceivedEventHandler(manager_UDPMessageReceived);
            }


            //if (UDPClientManager.ClientExist("61003"))
            //{
            //    MessageBox.Show("客户端已存在!");
            //    return;
            //}
            //else
            //{

            //}
        }
Exemplo n.º 2
0
        /// <summary>
        /// 窗体加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmUDPClient_Load(object sender, EventArgs e)
        {
            Text = "UDPClient " + _client_id + ":" + _port;

            //注册事件
            UDPClientManager manager = new UDPClientManager(_client_id);

            manager.UDPMessageReceived += new UDPMessageReceivedEventHandler(manager_UDPMessageReceived);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 创建客户端
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (UDPClientManager.ClientExist(textBox2.Text))
            {
                MessageBox.Show("客户端已存在!");
                return;
            }
            UDPClientManager manager = new UDPClientManager(textBox2.Text);

            manager.Start(int.Parse(textBox1.Text));  //开启端口监听

            frmUDPClient frmudpclient = new frmUDPClient(textBox2.Text, int.Parse(textBox1.Text));

            frmudpclient.Show();
        }
Exemplo n.º 4
0
        /// <summary>
        /// 连接读写器
        /// </summary>
        public void ConnectReader()
        {
            if (UDPClientManager.ClientExist(strReaderToPort))
            {
                //if (frmMain.blDebug)
                //    MessageUtil.ShowTips("半有源读写器,客户端已存在");

                if (manager == null)
                {
                    manager = new UDPClientManager(strReaderToPort);
                }
                manager.Start(int.Parse(strReaderToPort));  //开启端口监听
            }
            else
            {
                if (manager == null)
                {
                    manager = new UDPClientManager(strReaderToPort);
                    manager.Start(int.Parse(strReaderToPort));  //开启端口监听
                    manager.UDPMessageReceived += new UDPMessageReceivedEventHandler(manager_UDPMessageReceived);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 关闭
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            UDPClientManager manager = new UDPClientManager(_client_id);

            manager.Stop();
        }
Exemplo n.º 6
0
        /// <summary>
        /// 发送文本
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            UDPClientManager manager = new UDPClientManager(_client_id);

            manager.SendTo(Msg.Zmsg1, Encoding.Unicode.GetBytes(textBox2.Text), textBox4.Text, int.Parse(textBox5.Text));
        }