Esempio n. 1
0
 public PoderosaLogDocument(PoderosaLogViewerSession session) {
     _caption = "Poderosa Event Log";
     _session = session;
     //1行はないとだめな制約があるので
     this.AddLine(GLine.CreateSimpleGLine("", TextDecoration.Default));
     _nextLineIsFirstLine = true;
 }
        public void OnNewItem(IPoderosaLogItem item)
        {
            //カテゴリ分けなどあるかもしれないが...
            String text  = String.Format("[{0}] {1}", item.Category.Name, item.Text);
            int    width = PoderosaLogDocument.DefaultWidth;

            //width文字ごとに切り取り。日本語文字があるケースは未サポート
            int offset = 0;

            while (offset < text.Length)
            {
                int   next = RuntimeUtil.AdjustIntRange(offset + width, 0, text.Length);
                GLine line = GLine.CreateSimpleGLine(text.Substring(offset, next - offset), TextDecoration.Default);
                line.EOLType = next < text.Length ? EOLType.Continue : EOLType.CRLF;
                Append(line);
                offset = next;
            }

            PoderosaLogViewControl vc = _session.CurrentView;

            if (vc != null)
            {
                if (vc.InvokeRequired)
                {
                    vc.Invoke(vc.UpdateDocumentDelegate);
                }
                else
                {
                    vc.UpdateDocument();
                }
            }
        }