示例#1
0
文件: Form1.cs 项目: koushurin/Test
 //int _logCount = 0;
 void SendComment(string text, CommentType type, bool sentBySelf)
 {
     var info = new CommentInfo
     {
         Left = pnLeft.Width,
         Text = text,
         Color = GetColor(type),
         SentBySelf = sentBySelf
     };
     lock (_commentsSyncRoot)
     {
         for (int i = 0; i < _comments.Length; i++)
         {
             if (_comments[i] == null)
             {
                 _comments[i] = info;
                 info.Up = i * (TextSize + 5);
                 break;
             }
         }
         var logInfo = new CommentLogInfo
             {
                 Text = text,
                 Time = DateTime.Now,
                 Type = type
             };
         _commentLog.Add(logInfo);
         try
         {
             //string logText = string.Format("{0} [{1}] 「{2}」\n", logInfo.Time, GetSymbol(logInfo.Type), logInfo.Text);
             //_logBuilder.Insert(0, logText);
             //_logBuilder.
             _logBuilder.Clear();
             for (int i = _commentLog.Count - 1; i >= Math.Max(0, _commentLog.Count - 20); i--)
             {
                 _logBuilder.Append(_commentLog[i].Time.ToString()).Append(" ");
                 _logBuilder.Append("[").Append(_commentLog[i].Type.ToString()).Append("] ");
                 _logBuilder.Append("「").Append(_commentLog[i].Text.ToString()).Append("」\n");
             }
             string logText = _logBuilder.ToString();
                 //lblLog.Text += string.Format("{0} [{1}] 「{2}」\n", _commentLog[i].Time, GetSymbol(_commentLog[i].Type), _commentLog[i].Text);
             lblLog.Invoke(new EventHandler((sender, args) =>
                 {
                     lblLog.Text = logText;
                 }));
         }
         catch { }
     }
 }
示例#2
0
文件: Form1.cs 项目: koushurin/Test
 int GetTextWidth(CommentInfo info)
 {
     return -info.Length;
 }