Exemplo n.º 1
0
 /// <summary>
 /// 刷新指令操作TextBox
 /// </summary>
 /// <param name="arrayList"></param>
 public void RefrashTxtResponse(TelnetClient clientObjId, ArrayList contents)
 {
     if (currentTelnet == clientObjId)
     {
         this.txtResponse.Invoke(new DelRefrashTextBox(refrashTextBox), new object[] { contents });
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 创建telnet连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string remoteIp   = this.txtFtpAddr.Text.Trim();
            string remotePort = this.txtFtpPort.Text.Trim();


            if (!Util.IsIP(remoteIp))
            {
                MessageBox.Show("pls input a valid ip address!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int port = 0;

            try
            {
                port = int.Parse(remotePort);
            }
            catch
            {
                MessageBox.Show("pls input a valid port!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TelnetClient telnetClient = new TelnetClient(this.mainFrame, remoteIp, int.Parse(remotePort));

            if (telnetClient.connect())
            {
                mainFrame.AddNewTelnet(telnetClient);
                this.Close();
            }
            else
            {
                MessageBox.Show("connection fail!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 切换telnet树
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeTelnet_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TelnetClient client = (TelnetClient)this.telnetClientTable[e.Node.Tag.ToString()];

            this.currentTelnet = client;

            this.RefrashTxtResponse(client, client.getOperInfoList());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 新增telnet连接
        /// </summary>
        /// <param name="telnetClient"></param>
        internal void AddNewTelnet(TelnetClient client)
        {
            TreeNode clientNode = new TreeNode();

            clientNode.Text = client.RemoteIp + "-" + client.RemotePort + "[已连接]";
            clientNode.Tag  = client.Id;
            telnetClientTable.Add(clientNode.Tag, client);
            treeTelnet.Nodes.Add(clientNode);
            this.currentTelnet = client;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 关闭telnet连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnTelClose_Click(object sender, EventArgs e)
        {
            TreeNode selClientNode = this.treeTelnet.SelectedNode;

            if (selClientNode == null)
            {
                MessageBox.Show("请先选中对应节点!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string       key    = selClientNode.Tag.ToString();
            TelnetClient client = (TelnetClient)this.telnetClientTable[key];

            this.telnetClientTable.Remove(key);
            if (client != null)
            {
                client.Close();
            }
            this.txtRequest.Text  = "";
            this.txtResponse.Text = "";
            this.treeTelnet.Nodes.Remove(selClientNode);
            this.currentTelnet = null;
        }