From a7b4fc7be6dac8c4ff9ae7924eb499d7e2ac1453 Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Tue, 10 Oct 2017 11:21:01 +0200 Subject: Removed packages, added Client project properly. --- Client/MainWindow.cs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Client/MainWindow.cs (limited to 'Client/MainWindow.cs') diff --git a/Client/MainWindow.cs b/Client/MainWindow.cs new file mode 100644 index 0000000..22564ac --- /dev/null +++ b/Client/MainWindow.cs @@ -0,0 +1,35 @@ +using System; +using Gtk; +using Client; + +public partial class MainWindow : Gtk.Window +{ + TcpChatClient tcpChat; + + public MainWindow() : base(Gtk.WindowType.Toplevel) + { + Build(); + tcpChat = new TcpChatClient(); + tcpChat.PropertyChanged += (sender, args) => + outputTv.Buffer.Text = tcpChat.Log; + } + + protected void OnDeleteEvent(object sender, DeleteEventArgs a) + { + Application.Quit(); + a.RetVal = true; + } + + protected async void Connect(object sender, EventArgs e) + { + await tcpChat.Connect(ipEntry.Text, Int32.Parse(portEntry.Text)); + tcpChat.SendMessage($"{usernameEntry.Text} connected."); + } + + protected void SendMessage(object sender, EventArgs e) + { + string message = $"{usernameEntry.Text}: {messageEntry.Text}"; + tcpChat.SendMessage(message); + messageEntry.Text = ""; + } +} -- cgit v1.2.3