Die Gui hat nun ein Chatfenster. Bisher können lediglich nachrichten

versandt, jedoch nicht empfangen werden.
This commit is contained in:
2014-05-01 19:06:58 +02:00
parent 7ffba85903
commit 8cada1d5ce
6 changed files with 167 additions and 21 deletions

46
src/Gui/ChatPanel.cs Normal file
View File

@@ -0,0 +1,46 @@
using System.Drawing;
using System.Windows.Forms;
namespace WorldOfPeacecraft
{
public class ChatPanel : Panel
{
private ChatInputBox ChatInput;
private TextBox ChatOutput;
private IBackend Backend;
public ChatPanel (IBackend backend)
{
Backend = backend;
ChatInput = new ChatInputBox ();
ChatInput.ChatMessageSubmitted += OnChatMessageSent;
ChatOutput = new TextBox ();
ChatOutput.ReadOnly = true;
ChatOutput.Multiline = true;
this.Controls.Add (ChatInput);
this.Controls.Add (ChatOutput);
}
protected override void OnLayout (LayoutEventArgs levent)
{
int outputHeight = this.ClientSize.Height - ChatInput.Height;
ChatOutput.Location = new Point (0, 0);
ChatOutput.Size = new Size (this.ClientSize.Width, outputHeight);
ChatInput.Location = new Point (0, outputHeight);
ChatInput.Size = new Size (this.ClientSize.Width, ChatInput.ClientSize.Width);
base.OnLayout (levent);
}
private void OnChatMessageSent (string message)
{
if (message.StartsWith ("/")) {
string command = message.Substring (1);
Backend.SendCommand(command);
} else {
Backend.SendChatMessage(message);
}
// TODO Move focus to board?
}
}
}