示例#1
0
 private void TreeView_Config_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
 {
     node_cur_select = TreeView_Config.SelectedItem as ConfigTreeItem;
     if (node_cur_select != null && !node_cur_select.IsRootNode)
     {
         switch (node_cur_select.NType)
         {
         case ConfigTreeItem.NodeType.TcpClient:
         {
             Label_TYPE.Content = node_cur_select.NType.ToString();
             TcpClient client = m_TcpClientList.Find(it => it.Id == node_cur_select.Id);
             if (client != null)
             {
                 Label_IP.Content   = client.GetIPEndPoint().Address.ToString();
                 Label_PORT.Content = client.GetIPEndPoint().Port.ToString();
                 GVL.Context.CheckBox_Use_Receive_Filter_IsChecked = client.IsUseReceiveFilter();
                 GVL.Context.Label_Receive_Filter   = client.ReceiveFilterPath;
                 GVL.Context.IsTcpClientSendingData = client.IsSending();
                 if (client.IsConnect())
                 {
                     GVL.Context.Button_Connect_Enable = false;
                     GVL.Context.Button_Close_Enable   = true;
                 }
                 else
                 {
                     GVL.Context.Button_Connect_Enable = true;
                     GVL.Context.Button_Close_Enable   = false;
                 }
             }
             break;
         }
         }
     }
 }
示例#2
0
 private void UpdateConfigNodes()
 {
     node_cur_select = null;
     TreeView_Config.Items.Clear();
     TreeView_Config.Items.Add(node_TcpServer);
     TreeView_Config.Items.Add(node_TcpClient);
     TreeView_Config.Items.Add(node_UdpServer);
     TreeView_Config.Items.Add(node_UdpClient);
 }
示例#3
0
        private void AddConfigNodeHandle(ConfigTreeItem.NodeType type, string ip, int port)
        {
            ConfigTreeItem newItem = new ConfigTreeItem();

            switch (type)
            {
            case ConfigTreeItem.NodeType.TcpServer:
            {
                newItem.Tag   = ip + "[" + port.ToString() + "]";
                newItem.NType = type;
                node_TcpServer.Children.Add(newItem);
                break;
            }

            case ConfigTreeItem.NodeType.TcpClient:
            {
                newItem.Tag   = ip + "[" + port.ToString() + "]";
                newItem.NType = type;
                node_TcpClient.Children.Add(newItem);
                TcpClient client = new TcpClient(newItem.Id, ip, port);
                m_TcpClientList.Add(client);
                break;
            }

            case ConfigTreeItem.NodeType.UdpServer:
            {
                newItem.Tag   = ip + "[" + port.ToString() + "]";
                newItem.NType = type;
                node_UdpServer.Children.Add(newItem);
                break;
            }

            case ConfigTreeItem.NodeType.UdpClient:
            {
                newItem.Tag   = ip + "[" + port.ToString() + "]";
                newItem.NType = type;
                node_UdpClient.Children.Add(newItem);
                break;
            }
            }
            UpdateConfigNodes();
        }