protected override void AppendNodeToControl(TracePart part)
 {
     if (Ctrl == null)
     {
         return;
     }
     if (Ctrl.Dispatcher.CheckAccess())
     {
         try {
             //ObservableCollection<TracePart> lvList =new ObservableCollection<TracePart> () ;
             //Ctrl.ItemsSource =lvList ;
             int pos = Ctrl.Items.Add(part);
         } catch /*( Exception ex )*/ {
         } finally {
         }
     }
     else
     {
         Ctrl.Dispatcher.Invoke(
             System.Windows.Threading.DispatcherPriority.Normal,
             new AddNodeDelegate(this.AppendNodeToControl),
             /*new object [] { part, }*/ part
             );
     }
 }
        protected override void AppendNodeToControl(TracePart part)
        {
            if (Ctrl == null)
            {
                return;
            }
            if (Ctrl.Dispatcher.CheckAccess())
            {
                try {
                    // Move to the correct node collection given the current node and the depth
                    ItemCollection coll = MoveToDepth(part.IndentLevel);

                    // Add the new message
                    TreeViewItem child = new TreeViewItem();
                    child.Header = part.ToString();
                    if (part.Category.ToLowerInvariant() == "error" || part.Category.ToLowerInvariant() == "exception")
                    {
                        //child.Background =_redBrush ;
                        //child.Foreground =Brushes.White ;
                        child.Foreground = _redBrush;
                    }
                    else if (part.Category.ToLowerInvariant() == "warning")
                    {
                        //child.Background =_yellowBrush ;
                        //child.Foreground =_brownBrush ;
                        child.Foreground = _yellowBrush;
                    }
                    coll.Add(child);

                    TreeViewItem parent = child.Parent as TreeViewItem;
                    while (parent != null)
                    {
                        parent.IsExpanded = true;
                        parent            = parent.Parent as TreeViewItem;
                    }
                    child.BringIntoView();
                } finally {
                }
            }
            else
            {
                Ctrl.Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new AddNodeDelegate(this.AppendNodeToControl),
                    /*new object [] { part, }*/ part
                    );
            }
        }
Esempio n. 3
0
 protected override void AppendNodeToControl(TracePart part)
 {
     if (Ctrl == null)
     {
         return;
     }
     if (Ctrl.Dispatcher.CheckAccess())
     {
         string      st       = "[" + part.Timestamp.ToString("T") + "] " + part.Category + (part.Category != "" ? ": " : "") + IndentString(part.IndentLevel) + part.Info;
         RichTextBox richCtrl = Ctrl as RichTextBox;
         if (richCtrl != null)
         {
             //Paragraph pr =new Paragraph (new Run (part.ToString ())) ;
             //pr.TextIndent =part.IndentLevel * Trace.IndentSize * 5 ;
             Paragraph pr = new Paragraph(new Run(st));
             if (part.Category.ToLowerInvariant() == "error")
             {
                 pr.Background = _redBrush;
                 pr.Foreground = Brushes.White;
             }
             else if (part.Category.ToLowerInvariant() == "warning")
             {
                 pr.Background = _yellowBrush;
                 pr.Foreground = _brownBrush;
             }
             richCtrl.Document.Blocks.Add(pr);
             richCtrl.ScrollToEnd();
         }
         else
         {
             //Ctrl.AppendText (part.ToString () + "\r\n") ;
             Ctrl.AppendText(st + "\r\n");
             Ctrl.ScrollToEnd();
         }
     }
     else
     {
         Ctrl.Dispatcher.Invoke(
             System.Windows.Threading.DispatcherPriority.Normal,
             new AddNodeDelegate(this.AppendNodeToControl),
             /*new object [] { part, }*/ part
             );
     }
 }
 protected abstract void AppendNodeToControl(TracePart part);