using System.Drawing; using System.Windows.Forms; namespace WorldOfPeacecraft { public class ChatPanel : Panel { private ChatInputBox ChatInput; private ChatOutputBox ChatOutput; private IBackend Backend; public ChatPanel (IBackend backend) { Backend = backend; ChatInput = new ChatInputBox (); ChatInput.ChatMessageSubmitted += OnChatMessageSent; ChatOutput = new ChatOutputBox (backend); 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? } public void UpdateData() { ChatOutput.UpdateData (); } } }