public SourceWindow(QWidget parent, ClassItem klass) : base(parent, "", WidgetFlags.WType_TopLevel) { SetCaption(klass.Model.sourceFile.sourceFile); Resize(640, 480); QBoxLayout layout = new QBoxLayout(this, 0); editor = new QTextEdit(this); editor.SetTextFormat(TextFormat.PlainText); editor.SetReadOnly(true); editor.SetFamily("misc-fixed"); editor.SetPointSize(13); editor.SetWordWrap(QTextEdit.WordWrap.NoWrap); layout.AddWidget(editor); int[] coverage = klass.Model.sourceFile.Coverage; StreamReader infile = new StreamReader(klass.Model.sourceFile.sourceFile); int pos = 1; QColor deadColor = editor.Color(); QColor hitColor = new QColor("blue"); QColor missedColor = new QColor("red"); while (infile.Peek() > -1) { if (pos < coverage.Length) { int count = coverage [pos]; if (count > 0) { editor.SetColor(hitColor); } else if (count == 0) { editor.SetColor(missedColor); } else { editor.SetColor(deadColor); } } else { editor.SetColor(deadColor); } editor.Append(String.Format("{0, 6}", pos) + " " + infile.ReadLine()); pos++; } editor.SetCursorPosition(0, 0); }
public void HandleAccountAdded(Account account) { QApplication.Invoke(delegate { QTextEdit textEdit = new QTextEdit(this); textEdit.FrameShape = QFrame.Shape.NoFrame; textEdit.ReadOnly = true; QWidget widget = new QWidget(); QVBoxLayout layout = new QVBoxLayout(widget); layout.Margin = 0; layout.AddWidget(textEdit); m_XmlToolBox.AddItem(widget, account.Jid); m_AccountXmlWidgets.Add(account, widget); account.Client.OnWriteText += delegate(object sender, string txt) { QApplication.Invoke(delegate { if (enableConsoleCheckBox.Checked) { textEdit.Append("<b>" + Qt.Escape(txt) + "</b><br/>"); } }); }; account.Client.OnReadText += delegate(object sender, string txt) { QApplication.Invoke(delegate { if (enableConsoleCheckBox.Checked) { textEdit.Append(Qt.Escape(txt) + "<br/>"); } }); }; }); }
public SourceWindow(QWidget parent, ClassItem klass) : base(parent, "", WidgetFlags.WType_TopLevel) { SetCaption (klass.Model.sourceFile.sourceFile); Resize (640, 480); QBoxLayout layout = new QBoxLayout (this, 0); editor = new QTextEdit (this); editor.SetTextFormat (TextFormat.PlainText); editor.SetReadOnly (true); editor.SetFamily ("misc-fixed"); editor.SetPointSize (13); editor.SetWordWrap (QTextEdit.WordWrap.NoWrap); layout.AddWidget (editor); int[] coverage = klass.Model.sourceFile.Coverage; StreamReader infile = new StreamReader (klass.Model.sourceFile.sourceFile); int pos = 1; QColor deadColor = editor.Color (); QColor hitColor = new QColor ("blue"); QColor missedColor = new QColor ("red"); while (infile.Peek () > -1) { if (pos < coverage.Length) { int count = coverage [pos]; if (count > 0) editor.SetColor (hitColor); else if (count == 0) editor.SetColor (missedColor); else editor.SetColor (deadColor); } else editor.SetColor (deadColor); editor.Append (String.Format ("{0, 6}", pos) + " " + infile.ReadLine ()); pos ++; } editor.SetCursorPosition (0, 0); }