Exemplo n.º 1
0
        public void AppendLine(ChatLine line)
        {
            this.FormatSingle(line);

            while (_blocks.Count > this.BufferLines)
            {
                _blocks.RemoveFirst();
            }
        }
Exemplo n.º 2
0
        private void Write(string styleKey, int nickHashCode, string nick, string text, bool attn)
        {
            var cl = new ChatLine(styleKey, nickHashCode, nick, text, ChatMarker.None);

            if (_hasDeactivated)
            {
                _hasDeactivated = false;
                if (_markerLine != null)
                {
                    _markerLine.Marker &= ~ChatMarker.NewMarker;
                }
                _markerLine = cl;
                cl.Marker   = ChatMarker.NewMarker;
            }

            if (attn)
            {
                cl.Marker |= ChatMarker.Attention;
            }

            if (this.VisualParent == null)
            {
                if (this.IsNickname || this.Type == ChatPageType.DccChat)
                {
                    // Activity in PM window
                    this.NotifyState = NotifyState.Alert;
                }
                else if (!string.IsNullOrEmpty(nick) && this.NotifyState != NotifyState.Alert)
                {
                    // Chat activity in channel
                    this.NotifyState = NotifyState.ChatActivity;
                }
                else if (this.NotifyState == NotifyState.None)
                {
                    // Other activity in channel / server
                    this.NotifyState = NotifyState.NoiseActivity;
                }
            }

            boxOutput.AppendLine(cl);
            if (_logFile != null)
            {
                _logFile.WriteLine(cl);
            }
        }
Exemplo n.º 3
0
        public void AppendLine(ChatLine line)
        {
            var b = new Block();

            b.Source = line;

            b.TimeString = this.FormatTime(b.Source.Time);
            b.NickString = this.FormatNick(b.Source.Nick);

            var offset = _blocks.Last != null ? _blocks.Last.Value.CharEnd : 0;

            b.CharStart = offset;
            offset     += b.TimeString.Length + b.NickString.Length + b.Source.Text.Length;
            b.CharEnd   = offset;

            _blocks.AddLast(b);
            this.FormatOne(b, this.AutoSizeColumn);
            _bufferLines += b.Text.Length;

            while (_blocks.Count > this.BufferLines)
            {
                if (_blocks.First.Value.Text != null)
                {
                    _bufferLines -= _blocks.First.Value.Text.Length;
                }
                if (_blocks.First == _curSearchBlock)
                {
                    this.ClearSearch();
                }
                _blocks.RemoveFirst();
            }

            this.InvalidateScrollInfo();
            if (!_isAutoScrolling || _isSelecting)
            {
                _scrollPos += b.Text.Length;
            }
            this.InvalidateVisual();
        }
Exemplo n.º 4
0
 public void WriteLine(ChatLine line)
 {
     if (_logFile != null)
     {
         var s = string.Format("{0}\t{1}\t{2}\t{3}\t{4}{5}",
                               line.ColorKey, line.Time.ToBinary(), line.NickHashCode, line.Nick ?? "*", line.RawText, Environment.NewLine);
         if (s.Length > 512)
         {
             s = s.Substring(0, 512);
         }
         byte[] buf = Encoding.UTF8.GetBytes(s);
         try
         {
             _logFile.Write(buf, 0, buf.Length);
             _logFile.Flush();
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine("Error writing to log file: " + ex.Message);
             _logFile = null;
         }
     }
 }
Exemplo n.º 5
0
        private void Write(string styleKey, int nickHashCode, string nick, string text, bool attn)
        {
            var cl = new ChatLine(styleKey, nickHashCode, nick, text, ChatMarker.None);

            if (_hasDeactivated)
            {
                _hasDeactivated = false;
                if (_markerLine != null)
                {
                    _markerLine.Marker &= ~ChatMarker.NewMarker;
                }
                _markerLine = cl;
                cl.Marker = ChatMarker.NewMarker;
            }

            if (attn)
            {
                cl.Marker |= ChatMarker.Attention;
            }

            if (this.VisualParent == null)
            {
                if (!string.IsNullOrEmpty(nick))
                {
                    this.NotifyState = NotifyState.NewMessage;
                }
                else if (this.NotifyState == NotifyState.None)
                {
                    this.NotifyState = NotifyState.NewActivity;
                }
            }

            boxOutput.AppendLine(cl);
            if (_logFile != null)
            {
                _logFile.WriteLine(cl);
            }
        }
Exemplo n.º 6
0
        private void Write(string styleKey, int nickHashCode, string nick, string text, bool attn)
        {
            var cl = new ChatLine(styleKey, nickHashCode, nick, text, ChatMarker.None);

            if (_hasDeactivated)
            {
                _hasDeactivated = false;
                if (_markerLine != null)
                {
                    _markerLine.Marker &= ~ChatMarker.NewMarker;
                }
                _markerLine = cl;
                cl.Marker = ChatMarker.NewMarker;
            }

            if (attn)
            {
                cl.Marker |= ChatMarker.Attention;
            }

            if (this.VisualParent == null)
            {
                if (this.IsNickname || this.Type == ChatPageType.DccChat)
                {
                    // Activity in PM window
                    this.NotifyState = NotifyState.Alert;
                }
                else if (!string.IsNullOrEmpty(nick) && this.NotifyState != NotifyState.Alert)
                {
                    // Chat activity in channel
                    this.NotifyState = NotifyState.ChatActivity;
                }
                else if (this.NotifyState == NotifyState.None)
                {
                    // Other activity in channel / server
                    this.NotifyState = NotifyState.NoiseActivity;
                }
            }

            boxOutput.AppendLine(cl);
            if (_logFile != null)
            {
                _logFile.WriteLine(cl);
            }
        }
Exemplo n.º 7
0
 public void WriteLine(ChatLine line)
 {
     if (_logFile != null)
     {
         var s = string.Format("{0}\t{1}\t{2}\t{3}\t{4}{5}",
             line.ColorKey, line.Time.ToBinary(), line.NickHashCode, line.Nick ?? "*", line.RawText, Environment.NewLine);
         if (s.Length > 512)
         {
             s = s.Substring(0, 512);
         }
         byte[] buf = Encoding.UTF8.GetBytes(s);
         try
         {
             _logFile.Write(buf, 0, buf.Length);
             _logFile.Flush();
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine("Error writing to log file: " + ex.Message);
             _logFile = null;
         }
     }
 }
Exemplo n.º 8
0
 public void AppendLine(ChatLine line)
 {
     _presenter.AppendLine(line);
 }
		public void AppendLine(ChatLine line)
		{
			var b = new Block();
			b.Source = line;

			b.TimeString = this.FormatTime(b.Source.Time);
			b.NickString = this.FormatNick(b.Source.Nick);

			var offset = _blocks.Last != null ? _blocks.Last.Value.CharEnd : 0;
			b.CharStart = offset;
			offset += b.TimeString.Length + b.NickString.Length + b.Source.Text.Length;
			b.CharEnd = offset;

			_blocks.AddLast(b);
			this.FormatOne(b, this.AutoSizeColumn);
			_bufferLines += b.Text.Length;

			while (_blocks.Count > this.BufferLines)
			{
				if (_blocks.First.Value.Text != null)
				{
					_bufferLines -= _blocks.First.Value.Text.Length;
				}
				if (_blocks.First == _curSearchBlock)
				{
					this.ClearSearch();
				}
				_blocks.RemoveFirst();
			}

			this.InvalidateScrollInfo();
			if (!_isAutoScrolling || _isSelecting)
			{
				_scrollPos += b.Text.Length;
			}
			this.InvalidateVisual();
		}
Exemplo n.º 10
0
 public void AppendLine(ChatLine line)
 {
     _presenter.AppendLine(line);
 }
Exemplo n.º 11
0
        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();
                }
            }
        }