You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-16 07:06:30 +09:00
major update; gen 3.5
This commit is contained in:
70
Samples/Chat/ChatClient/Form1.cs
Normal file
70
Samples/Chat/ChatClient/Form1.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ChatClient
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
textBox1.KeyDown += new KeyEventHandler(textBox1_KeyDown);
|
||||
}
|
||||
|
||||
public void EnableInput()
|
||||
{
|
||||
textBox1.Enabled = true;
|
||||
button1.Enabled = true;
|
||||
}
|
||||
|
||||
public void DisableInput()
|
||||
{
|
||||
textBox1.Enabled = false;
|
||||
button1.Enabled = false;
|
||||
}
|
||||
|
||||
void textBox1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter)
|
||||
{
|
||||
// return is equivalent to clicking "send"
|
||||
button1_Click(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
Program.DisplaySettings();
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (button2.Text == "Connect")
|
||||
{
|
||||
int port;
|
||||
Int32.TryParse(textBox3.Text, out port);
|
||||
Program.Connect(textBox2.Text, port);
|
||||
button2.Text = "Shut down";
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.Shutdown();
|
||||
button2.Text = "Connect";
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Send
|
||||
if (!string.IsNullOrEmpty(textBox1.Text))
|
||||
Program.Send(textBox1.Text);
|
||||
textBox1.Text = "";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user