private void InvalidateAll(bool styleChanged) { var formatter = new ChatFormatter(this.Typeface, this.FontSize, this.Foreground, this.Palette); _lineHeight = Math.Ceiling(this.FontSize * this.Typeface.FontFamily.LineSpacing); if (styleChanged) { var offset = 0; foreach (var b in _blocks) { b.CharStart = offset; b.TimeString = this.FormatTime(b.Source.Time); b.NickString = this.FormatNick(b.Source.Nick); offset += b.TimeString.Length + b.NickString.Length + b.Source.Text.Length; b.CharEnd = offset; } } this.StartProcessingText(); }
private void FormatOne(Block b, bool autoSize) { b.Foreground = this.Palette[b.Source.ColorKey]; var formatter = new ChatFormatter(this.Typeface, this.FontSize, this.Foreground, this.Palette); b.Time = formatter.Format(b.TimeString, null, this.ViewportWidth, b.Foreground, this.Background, TextWrapping.NoWrap).FirstOrDefault(); b.NickX = b.Time != null ? b.Time.WidthIncludingTrailingWhitespace : 0.0; var nickBrush = b.Foreground; if (this.ColorizeNicknames && b.Source.NickHashCode != 0) { nickBrush = this.GetNickColor(b.Source.NickHashCode); } b.Nick = formatter.Format(b.NickString, null, this.ViewportWidth - b.NickX, nickBrush, this.Background, TextWrapping.NoWrap).First(); b.TextX = b.NickX + b.Nick.WidthIncludingTrailingWhitespace; if (autoSize && b.TextX > this.ColumnWidth) { this.ColumnWidth = b.TextX; this.InvalidateAll(false); } if (this.UseTabularView) { b.TextX = this.ColumnWidth + SeparatorPadding * 2.0 + 1.0; b.NickX = this.ColumnWidth - b.Nick.WidthIncludingTrailingWhitespace; } b.Text = formatter.Format(b.Source.Text, b.Source, this.ViewportWidth - b.TextX, b.Foreground, this.Background, TextWrapping.Wrap).ToArray(); b.Height = b.Text.Sum((t) => t.Height); }
private void FormatSingle(ChatLine source) { if (string.IsNullOrEmpty(source.Text)) { return; } var b = new Block(); b.Source = source; b.Foreground = this.Palette[b.Source.ColorKey]; b.TimeString = this.FormatTime(b.Source.Time); b.NickString = this.FormatNick(b.Source.Nick); var formatter = new ChatFormatter(this.Typeface, this.FontSize, this.Foreground, this.Palette); b.Time = formatter.Format(b.TimeString, null, this.ViewportWidth, b.Foreground, this.Background, TextWrapping.NoWrap).FirstOrDefault(); b.NickX = b.Time != null ? b.Time.WidthIncludingTrailingWhitespace : 0.0; var nickBrush = b.Foreground; if (this.ColorizeNicknames && b.Source.NickHashCode != 0) { nickBrush = this.GetNickColor(b.Source.NickHashCode); } b.Nick = formatter.Format(b.NickString, null, this.ViewportWidth - b.NickX, nickBrush, this.Background, TextWrapping.NoWrap).First(); b.TextX = b.NickX + b.Nick.WidthIncludingTrailingWhitespace; if (this.UseTabularView) { if (b.TextX > this.ColumnWidth) { if (this.AutoSizeColumn) { this.ColumnWidth = b.TextX; _blocks.AddLast(b); this.FormatAll(); return; } else { b.Nick = formatter.Format(b.NickString, null, this.ColumnWidth - (b.Time != null ? b.Time.Width : 0.0), nickBrush, this.Background, TextWrapping.NoWrap).First(); } } b.TextX = this.ColumnWidth + SeparatorPadding * 2.0 + 1.0; b.NickX = this.ColumnWidth - b.Nick.WidthIncludingTrailingWhitespace; } var offset = _blocks.Last != null ? _blocks.Last.Value.CharEnd : 0; b.Text = formatter.Format(b.Source.Text, b.Source, this.ViewportWidth - b.TextX, b.Foreground, this.Background, TextWrapping.Wrap).ToArray(); b.Height = b.Text.Sum((t) => t.Height); _lineHeight = b.Text[0].Height; _extentHeight = Math.Max(_extentHeight, _lineHeight); _extentHeight += b.Height; b.CharStart = offset; offset += b.TimeString.Length + b.NickString.Length + b.Source.Text.Length; b.CharEnd = offset; _blocks.AddLast(b); this.InvalidateVisual(); if (_viewer != null) { _viewer.InvalidateScrollInfo(); if (_isAutoScrolling) { this.ScrollToEnd(); } } }
private void FormatAll() { _extentHeight = 0.0; this.InvalidateVisual(); if (_blocks.Count < 1 || this.ViewportWidth < 1.0) { return; } var formatter = new ChatFormatter(this.Typeface, this.FontSize, this.Foreground, this.Palette); _blocks.ForEach((b) => { b.Foreground = this.Palette[b.Source.ColorKey]; b.TimeString = this.FormatTime(b.Source.Time); b.NickString = this.FormatNick(b.Source.Nick); b.NickX = b.TextX = 0.0; b.Time = formatter.Format(b.TimeString, null, this.ViewportWidth, b.Foreground, this.Background, TextWrapping.NoWrap).FirstOrDefault(); b.NickX = b.Time != null ? b.Time.WidthIncludingTrailingWhitespace : 0.0; this.ColumnWidth = Math.Max(this.ColumnWidth, b.NickX); }); double nickX = _blocks.Max((b) => b.NickX); _blocks.ForEach((b) => { var nickBrush = b.Foreground; if (this.ColorizeNicknames && b.Source.NickHashCode != 0) { nickBrush = this.GetNickColor(b.Source.NickHashCode); } b.Nick = formatter.Format(b.NickString, null, this.UseTabularView ? this.ColumnWidth - (b.Time != null ? b.Time.Width : 0.0) : this.ViewportWidth, nickBrush, this.Background, TextWrapping.NoWrap).First(); if (this.UseTabularView) { b.NickX = nickX; } b.TextX = b.NickX + b.Nick.WidthIncludingTrailingWhitespace; }); double textX = this.ColumnWidth + SeparatorPadding * 2.0 + 1.0; var offset = 0; _blocks.ForEach((b) => { if (this.UseTabularView) { b.TextX = textX; b.NickX = Math.Max(b.Time != null ? b.Time.Width : 0.0, this.ColumnWidth - b.Nick.Width); } b.Text = formatter.Format(b.Source.Text, b.Source, this.ViewportWidth - b.TextX, b.Foreground, this.Background, TextWrapping.Wrap).ToArray(); b.Height = b.Text.Sum((t) => t.Height); _extentHeight += b.Height; _lineHeight = b.Text[0].Height; b.CharStart = offset; offset += b.TimeString.Length + b.NickString.Length + b.Source.Text.Length; b.CharEnd = offset; }); _extentHeight += _lineHeight; if (_viewer != null) { _viewer.InvalidateScrollInfo(); if (_isAutoScrolling) { this.ScrollToEnd(); } } }