Die Gui hat nun ein Chatfenster. Bisher können lediglich nachrichten
versandt, jedoch nicht empfangen werden.
This commit is contained in:
46
src/Gui/ChatPanel.cs
Normal file
46
src/Gui/ChatPanel.cs
Normal 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?
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user