public void ResizeChat() { if (!IsResizing) { foreach (DXLabel label in History) { if (label.Size.Width == TextPanel.Size.Width) { continue; } Size size = DXLabel.GetHeight(label, TextPanel.Size.Width); label.Size = new Size(size.Width, size.Height); //label.Size = new Size(TextPanel.Size.Width, DXLabel.GetHeight(label, TextPanel.Size.Width).Height); } UpdateItems(); UpdateScrollBar(); } }
public void ReceiveChat(MessageAction action, params object[] args) { DXLabel label; switch (action) { case MessageAction.Revive: label = new DXLabel { AutoSize = false, Text = "You have died, Click here to revive in town.", Outline = false, DrawFormat = TextFormatFlags.WordBreak | TextFormatFlags.WordEllipsis, Parent = TextPanel, }; label.MouseClick += (o, e) => { CEnvir.Enqueue(new C.TownRevive()); label.Dispose(); }; label.MouseWheel += ScrollBar.DoMouseWheel; label.Disposing += (o, e) => { if (IsDisposed) { return; } History.Remove(label); UpdateScrollBar(); ScrollBar.Value = ScrollBar.MaxValue - label.Size.Height; }; label.Tag = MessageType.Announcement; break; default: return; } UpdateColours(label); Size size = DXLabel.GetHeight(label, TextPanel.Size.Width); label.Size = new Size(size.Width, size.Height); History.Add(label); while (History.Count > 250) { DXLabel oldLabel = History[0]; History.Remove(oldLabel); oldLabel.Dispose(); } AlertIcon.Visible = !IsVisible && Panel.AlertCheckBox.Checked; bool update = ScrollBar.Value >= ScrollBar.MaxValue - ScrollBar.VisibleSize; UpdateScrollBar(); if (update) { ScrollBar.Value = ScrollBar.MaxValue - label.Size.Height; } else { UpdateItems(); } }
public void ReceiveChat(string message, MessageType type) { if (Panel == null) { return; } switch (type) { case MessageType.Normal: if (!Panel.LocalCheckBox.Checked) { return; } break; case MessageType.Shout: if (!Panel.ShoutCheckBox.Checked) { return; } break; case MessageType.Global: if (!Panel.GlobalCheckBox.Checked) { return; } break; case MessageType.Group: if (!Panel.GroupCheckBox.Checked) { return; } break; case MessageType.Hint: if (!Panel.HintCheckBox.Checked) { return; } break; case MessageType.System: if (!Panel.SystemCheckBox.Checked) { return; } break; case MessageType.WhisperIn: case MessageType.WhisperOut: if (!Panel.WhisperCheckBox.Checked) { return; } break; case MessageType.Combat: if (!Panel.GainsCheckBox.Checked) { return; } break; case MessageType.ObserverChat: if (!Panel.ObserverCheckBox.Checked) { return; } break; case MessageType.Guild: if (!Panel.GuildCheckBox.Checked) { return; } break; } DXLabel label = new DXLabel { AutoSize = false, Text = message, Outline = false, DrawFormat = TextFormatFlags.WordBreak | TextFormatFlags.WordEllipsis, Parent = TextPanel, }; label.MouseWheel += ScrollBar.DoMouseWheel; label.Tag = type; switch (type) { case MessageType.Normal: case MessageType.Shout: case MessageType.Global: case MessageType.WhisperIn: case MessageType.WhisperOut: case MessageType.Group: case MessageType.ObserverChat: case MessageType.Guild: label.MouseUp += (o, e) => { string[] parts = label.Text.Split(':', ' '); if (parts.Length == 0) { return; } GameScene.Game.ChatTextBox.StartPM(Regex.Replace(parts[0], "[^A-Za-z0-9]", "")); }; break; } UpdateColours(label); Size size = DXLabel.GetHeight(label, TextPanel.Size.Width); label.Size = new Size(size.Width, size.Height); History.Add(label); while (History.Count > 250) { DXLabel oldLabel = History[0]; History.Remove(oldLabel); oldLabel.Dispose(); } AlertIcon.Visible = !IsVisible && Panel.AlertCheckBox.Checked; bool update = ScrollBar.Value >= ScrollBar.MaxValue - ScrollBar.VisibleSize; UpdateScrollBar(); if (update) { ScrollBar.Value = ScrollBar.MaxValue - label.Size.Height; } else { UpdateItems(); } }