Exemple #1
0
            public ClientGUI(TcpEchoClient client)
            {
                this.client = client;
                serverLabel = new Label();
                serverLabel.Size = new Size(495, 20);
                serverLabel.Location = new Point(5, 18);
                serverLabel.Dock = DockStyle.Top;
                serverLabel.Text = "Echo Server : " + client.getServer() + ":" + client.getPort();

                recivedText = new TextBox();
                recivedText.Size = new Size(200, 170);
                recivedText.Location = new Point(0, 0);
                recivedText.Dock = DockStyle.Top;
                recivedText.Multiline = true;
                recivedText.ScrollBars = ScrollBars.Both;
                recivedText.ReadOnly = true;
                recivedText.WordWrap = false;
                recivedText.Text = "";

                sendText = new TextBox();

                sendText.Size = new Size(500, 500);
                sendText.Location = new Point(0, 158);
                sendText.Dock = DockStyle.Fill;
                sendText.Multiline = true;
                sendText.ScrollBars = ScrollBars.None;
                sendText.WordWrap = false;
                sendText.Text = "";
                sendText.TextChanged += new EventHandler(HandleTextChange);
                sendText.Focus();

                //Setup Status Label
                statusLabel = new Label();
                statusLabel.Size = new Size(500, 20);
                statusLabel.Location = new Point(0, 158);
                statusLabel.Dock = DockStyle.Bottom;
                statusLabel.Text = "Disconnected";

                Panel pan = new Panel();
                pan.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
                pan.Size = new Size(500, 218);
                pan.Location = new Point(2, 22);
                pan.Controls.AddRange(new Control[] { sendText, recivedText });
                ClientSize = new Size(504, 266);

                Controls.AddRange(new Control[] { serverLabel, pan, statusLabel });
                Text = "TcpEchoClientGUI";
            }