You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.8 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _09_ClientePPTSondeo
{
public partial class Form1 : Form
{
TcpClient client;
NetworkStream ns;
StreamReader sr;
StreamWriter sw;
String dato;
string ultimaJugada; //para que el timer tick pregunte automaticamente
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
client = new TcpClient(this.textBox1.Text, 2000);
ns = client.GetStream();
sr = new StreamReader(ns);
sw = new StreamWriter(ns);
dato = sr.ReadLine() + System.Environment.NewLine +
sr.ReadLine() + System.Environment.NewLine +
sr.ReadLine() + System.Environment.NewLine +
sr.ReadLine();
this.label1.Text = dato;
}
catch (Exception error)
{
Debug.WriteLine("Eroor: " + error.ToString());
}
}
private void button2_Click(object sender, EventArgs e)
{
sw.WriteLine("#INSCRIBIR#" + this.textBox2.Text + "#");
sw.Flush();
dato = sr.ReadLine();
this.label1.Text = dato;
}
private void button4_Click(object sender, EventArgs e)
{
sw.WriteLine("#PUNTUACION#");
sw.Flush();
dato = sr.ReadLine();
this.label1.Text = dato;
}
private void button3_Click(object sender, EventArgs e)
{
sw.WriteLine("#JUGADA#" + this.comboBox1.Text + "#");
sw.Flush();
dato = sr.ReadLine();
this.label1.Text = dato;
//guradamos la última jugada hecha
string[] subdatos = dato.Split('#');
ultimaJugada = subdatos[2];
}
private void button5_Click(object sender, EventArgs e)
{
sw.WriteLine("#RESULTADOJUGADA#" + this.textBox3.Text + "#");
sw.Flush();
dato = sr.ReadLine();
this.label1.Text = dato;
}
private void button6_Click(object sender, EventArgs e)
{
this.timer1.Enabled = !this.timer1.Enabled;
}
private void timer1_Tick(object sender, EventArgs e)
{
sw.WriteLine("#RESULTADOJUGADA#" + ultimaJugada + "#");
sw.Flush();
dato = sr.ReadLine();
this.label2.Text = dato;
}
}
}

Powered by Informatica FP.