summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <zelent.marcin@protonmail.com>2017-10-09 08:56:25 +0200
committermarcinzelent <zelent.marcin@protonmail.com>2017-10-09 08:56:25 +0200
commit295e3c10bb6d1c83796554edf8369e5aa87a20a8 (patch)
treef6ad54798c039b6db9aceca3099fd409f6ea4ba8 /Server/MainWindow.cs
Initial commit.
Diffstat (limited to 'Server/MainWindow.cs')
-rw-r--r--Server/MainWindow.cs76
1 files changed, 76 insertions, 0 deletions
diff --git a/Server/MainWindow.cs b/Server/MainWindow.cs
new file mode 100644
index 0000000..e8974d2
--- /dev/null
+++ b/Server/MainWindow.cs
@@ -0,0 +1,76 @@
+using System;
+using Xwt;
+using Xwt.Formats;
+
+namespace Server
+{
+ public class MainWindow : Window
+ {
+ TcpChatServer tcpChatServer;
+
+ public MainWindow()
+ {
+ Title = "TCP Chat X Server";
+ Width = 600;
+ Height = 400;
+
+ VBox mainVBox;
+ HBox connectionHBox, messageHBox;
+ TextEntry ipTextEntry = new TextEntry
+ {
+ PlaceholderText = "IP Address",
+ Text = "127.0.0.1",
+ };
+ TextEntry portTextEntry = new TextEntry
+ {
+ WidthRequest = 100,
+ PlaceholderText = "Port",
+ Text = "6789"
+ };
+ Button startButton = new Button
+ {
+ Label = "Start"
+ };
+ startButton.Clicked += (object sender, EventArgs e) =>
+ {
+ tcpChatServer = new TcpChatServer();
+ tcpChatServer.Start(ipTextEntry.Text, int.Parse(portTextEntry.Text));
+ };
+ RichTextView outputTextView = new RichTextView
+ {
+ ExpandHorizontal = true,
+ ExpandVertical = true,
+ MinHeight = 200
+ };
+ LogSingleton.Instance.PropertyChanged += (sender, args) =>
+ outputTextView.LoadText(LogSingleton.Instance.Log, TextFormat.Plain);
+
+ TextEntry messageTextEntry = new TextEntry()
+ {
+ PlaceholderText = "Message"
+ };
+ Button sendButton = new Button
+ {
+ Label = "Send"
+ };
+ sendButton.Clicked += (object sender, EventArgs e) =>
+ {
+ tcpChatServer.SendMessage($"Server: {messageTextEntry.Text}");
+ messageTextEntry.Text = "";
+ };
+
+ Content = mainVBox = new VBox();
+
+ mainVBox.PackStart(connectionHBox = new HBox());
+ connectionHBox.PackStart(ipTextEntry , true);
+ connectionHBox.PackStart(portTextEntry);
+ connectionHBox.PackStart(startButton);
+
+ mainVBox.PackStart(outputTextView, true, true);
+
+ mainVBox.PackStart(messageHBox = new HBox());
+ messageHBox.PackStart(messageTextEntry, true, true);
+ messageHBox.PackStart(sendButton);
+ }
+ }
+}