/// <summary> /// Updates the active console channel and the text color when /// the text box control receives focus. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void txtMain_FocusGained(object sender, System.EventArgs e) { // Input textbox has focus, set channel and text color appropriately // based on the channel selected in the combo box control. ConsoleChannel ch = channels[cmbMain.Text]; if (ch != null) { txtMain.TextColor = ch.Color; } }
/// <summary> /// Draws the client area of the console. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ClientArea_Draw(object sender, DrawEventArgs e) { SpriteFont font = null; if (!SmallFont) { font = Skin.Layers[0].Text.Font.Resource; } else { font = Manager.Skin.Fonts["Default6"].Resource; } Rectangle r = new Rectangle(e.Rectangle.Left, e.Rectangle.Top, e.Rectangle.Width, e.Rectangle.Height); int pos = 0; // Are there messages to display? if (buffer.Count > 0) { // Get messages based on channel index filter. EventedList <ConsoleMessage> b = GetFilteredBuffer(filter); int c = b.Count; int s = (sbVert.Value + sbVert.PageSize); int f = s - sbVert.PageSize; // Still messages to display? if (b.Count > 0) { // Display visible messages based on the scroll bar values.for (int i = s - 1; i >= f; i--) for (int i = s - 1; i >= f; i--) { { pos += 1; int x = 4; int y = r.Bottom - (pos) * ((int)font.LineSpacing + 0); string msg = ((ConsoleMessage)b[i]).Text; string pre = ""; ConsoleChannel ch = (channels[((ConsoleMessage)b[i]).Channel] as ConsoleChannel); if (!((ConsoleMessage)b[i]).NoShow) { if (messageFormat != ConsoleMessageFormats.None) { pre += "[color:" + ch.Color.ToColorString() + "]"; // Prefix message with message timestamp? if ((messageFormat & ConsoleMessageFormats.TimeStamp) == ConsoleMessageFormats.TimeStamp) { pre += string.Format("[{0}]", ((ConsoleMessage)b[i]).Time.ToShortTimeString()); } // Prefix message with console channel name? if ((messageFormat & ConsoleMessageFormats.ChannelName) == ConsoleMessageFormats.ChannelName) { pre += string.Format("[{0}]", channels[((ConsoleMessage)b[i]).Channel].Name); } if (pre != "") { msg = pre + ":[/color] " + msg; //Add the pre text } } } string[] msgs = msg.Split(new string[1] { Manager.StringNewline }, StringSplitOptions.RemoveEmptyEntries); if (b[i].Color != Color.Transparent) { for (int st = 0; st < msgs.Length; st++) { int yTemp = st * font.LineSpacing; e.Renderer.DrawString(font, msgs[st], x, y + yTemp, b[i].Color, base.DrawFormattedText); } } else { for (int st = 0; st < msgs.Length; st++) { int yTemp = st * font.LineSpacing; e.Renderer.DrawString(font, msgs[st], x, y + yTemp, ch.Color, base.DrawFormattedText); } } } } } } }