hMailServer.Administrator.ucStatus.RefreshLiveLog C# (CSharp) Method

RefreshLiveLog() private method

private RefreshLiveLog ( ) : void
return void
        private void RefreshLiveLog()
        {
            string liveLog = _logging.LiveLog;

            if (liveLog.Length == 0)
            {
               if (!_logging.LiveLoggingEnabled)
               {
                  timerLiveLog.Enabled = false;
                  DisplayLiveLogButtonCaption();

                  MessageBox.Show("The live log was automatically disabled due to too high throughput." + Environment.NewLine +
                                  "To retrieve logging information, please read the log files.",
                                  EnumStrings.hMailServerAdministrator, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                  return;
               }

            }

            string[] lines = liveLog.Split(Environment.NewLine.ToCharArray());

            List<ListViewItem> items = new List<ListViewItem>();

            foreach (string s in lines)
            {
                if (s.Length == 0)
                    continue;

                string temp = s.Replace("\"", "");
                string[] columns = temp.Split('\t');

                ListViewItem item = new ListViewItem();

                if (columns.Length == 4)
                {
                    item.SubItems.Add("");
                    item.SubItems.Add(columns[1]);
                    item.SubItems.Add(columns[2]);
                    item.SubItems.Add("");
                    item.SubItems.Add(columns[3]);
                }
                else
                {
                    item.Text = columns[0];
                    item.SubItems.Add(columns[2]);
                    item.SubItems.Add(columns[1]);
                    item.SubItems.Add(columns[3]);
                    item.SubItems.Add(columns[4]);
                    item.SubItems.Add(columns[5]);
                }

                items.Add(item);
            }

            if (listLiveLog.Items.Count > 50000)
            {
               TruncateLiveLog();
            }

            // Check if the last item in the list is visible. If so, we should autoscroll.
            ListViewHitTestInfo info = listLiveLog.HitTest(new Point(1, listLiveLog.Height - 10));

            bool focusLastItem = false;

            if (listLiveLog.Items.Count > 0)
            {
               // Is the last item currently visible?
               ListViewItem lastItem = listLiveLog.Items[listLiveLog.Items.Count-1];
               if (lastItem.Position.Y > 0 && lastItem.Position.Y < listLiveLog.Height)
               {
                  focusLastItem = true;
               }
            }
            else
            {
               focusLastItem = true;
            }

            if (items.Count > 0)
            {
               listLiveLog.Items.AddRange(items.ToArray());

               if (focusLastItem)
               {
                  listLiveLog.EnsureVisible(listLiveLog.Items.Count - 1);
               }
            }
        }