Exemple #1
0
        /// <summary>
        /// ログ表示更新タイマー
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timerLog_Tick(object sender, EventArgs e)
        {
            if (LOG.CheckAndClearRequestFlag())
            {
                var inspos  = listViewLogView.Items.Count;
                var lastseq = inspos == 0 ? -1 : (int)listViewLogView.Items[listViewLogView.Items.Count - 1].Tag;
                LOG.GetCurrent();
                var lu = LOG.GetCurrentLast();

                while (lu != null && lu.Value.Seq > lastseq)
                {
                    string type;
                    switch (lu.Value.Level)
                    {
                    case LLV.WAR: type = "w"; break;

                    case LLV.ERR: type = "e"; break;

                    case LLV.DEV: type = "d"; break;

                    case LLV.INF: type = "i"; break;

                    default: type = "?"; break;
                    }
                    //var type = lu.Value.Level switch
                    //{
                    //    LLV.WAR => "w",
                    //    LLV.ERR => "e",
                    //    LLV.DEV => "d",
                    //    LLV.INF => "i",
                    //    _ => "?",
                    //};
                    var lvi = new ListViewItem(type);
                    lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, DateTime.Now.ToString())).Tag = DateTime.Now;
                    lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, lu.Value.Mes));
                    listViewLogView.Items.Insert(inspos, lvi);
                    lvi.Tag = lu.Value.Seq;
                    if (lu.Value.Level == LLV.ERR)
                    {
                        lvi.BackColor = Color.FromArgb(255, 224, 192);
                    }
                    if (lu.Value.Level == LLV.WAR)
                    {
                        lvi.BackColor = Color.FromArgb(255, 255, 224);
                    }

                    lu = lu.Previous;

                    if (listViewLogView.Items.Count > 10000)    // 多すぎるログは、過去から消して行く
                    {
                        listViewLogView.Items.RemoveAt(0);
                    }
                }
                if (checkBoxAutoScroll.Checked && listViewLogView.Items.Count > 0)
                {
                    listViewLogView.EnsureVisible(listViewLogView.Items.Count - 1);
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// ログの表示更新を試みる
 /// </summary>
 private void refresh()
 {
     if (LOG.CheckAndClearRequestFlag())
     {
         var sr = _tarPane.GetPaneRect();
         sr.LT.Y = sr.RB.Y - _lp.Rect.Height;
         Pane.Invalidate(sr);
     }
     Timer.AddTrigger(500, new GuiTimer.Proc0(refresh));
 }