Chatnachrichten werden jetzt angezeigt

This commit is contained in:
2014-05-01 20:30:33 +02:00
parent 8cada1d5ce
commit 30579e1488
9 changed files with 107 additions and 6 deletions

52
src/Gui/ChatOutputBox.cs Normal file
View File

@@ -0,0 +1,52 @@
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace WorldOfPeacecraft
{
public class ChatOutputBox : RichTextBox
{
private IBackend Backend;
private Font MessageFont;
private Font SenderFont;
private Font IregularSenderFont;
public ChatOutputBox (IBackend backend)
{
Backend = backend;
this.ReadOnly = true;
this.Multiline = true;
MessageFont = this.SelectionFont;
SenderFont = new Font (MessageFont, FontStyle.Bold);
IregularSenderFont = new Font (MessageFont, FontStyle.Bold | FontStyle.Italic);
}
public void UpdateData ()
{
this.SuspendLayout ();
this.Clear ();
IEnumerable<IChatMessage> chatMessages = Backend.GetChatMessages ();
bool firstline = true;
lock (Backend) {
foreach (IChatMessage message in chatMessages) {
if (firstline) {
firstline = false;
} else {
this.AppendText ("\n");
}
if (message.IsSenderPlayer ()) {
this.SelectionFont = SenderFont;
} else {
this.SelectionFont = IregularSenderFont;
}
this.AppendText (message.GetSender ());
this.AppendText (": ");
this.SelectionFont = MessageFont;
this.AppendText (message.GetMessage ());
}
}
this.ResumeLayout ();
}
}
}