本文整理汇总了C#中System.Windows.Controls.RichTextBox.AppendText方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.AppendText方法的具体用法?C# RichTextBox.AppendText怎么用?C# RichTextBox.AppendText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.AppendText方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Question
public Question(string myFilename, RichTextBox richMain)
{
Filename = Path.GetFileName(myFilename);
string xmlText = File.ReadAllText(myFilename);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlText);
try
{
XmlNode xmlQD = xmlDoc.GetElementsByTagName("QuestionDesc")[0];
XmlNode xmlQ = xmlDoc.GetElementsByTagName("QuestionText")[0];
XmlCDataSection xmlCData = xmlQ.FirstChild as XmlCDataSection;
XmlNode xmlAA = xmlDoc.GetElementsByTagName("AnswerA")[0];
XmlNode xmlAB = xmlDoc.GetElementsByTagName("AnswerB")[0];
XmlNode xmlAC = xmlDoc.GetElementsByTagName("AnswerC")[0];
XmlNode xmlAD = xmlDoc.GetElementsByTagName("AnswerD")[0];
XmlNode xmlT = xmlDoc.GetElementsByTagName("Time")[0];
XmlNode xmlL = xmlDoc.GetElementsByTagName("Level")[0];
XmlNode xmlA = xmlDoc.GetElementsByTagName("Correct")[0];
QuestionDescripion = xmlQD.InnerText.ToString();
QuestionText = xmlCData.InnerText;
AnswerA = xmlAA.InnerText;
AnswerB = xmlAB.InnerText;
AnswerC = xmlAC.InnerText;
AnswerD = xmlAD.InnerText;
Correct = xmlA.InnerText;
Time = Convert.ToInt32(xmlT.InnerText);
Level = Convert.ToInt32(xmlL.InnerText);
}
catch (Exception expError)
{
richMain.AppendText("Problem with question file format: " + expError.Message + Environment.NewLine);
}
}
示例2: ChangeTextProperly
//for system messages
private void ChangeTextProperly(RichTextBox rtb, string msg)
{
if (rtb.Dispatcher.CheckAccess())
{
rtb.AppendText(msg + "\n");
return;
}
else
{
rtb.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new TextChanger(delegate() { this.ChangeTextProperly(rtb, msg); }));
}
}
示例3: logWithTime
public void logWithTime(string s, RichTextBox rtb)
{
DateTime DTN = DateTime.Now;
string LogDateTime = DateTime.SpecifyKind(DTN, DateTimeKind.Local).ToString();
try
{
rtb.AppendText(LogDateTime + ": " + s + "\r\n");
rtb.ScrollToEnd();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
示例4: CreateNodeDialog
Window CreateNodeDialog(out RichTextBox richBox) {
var window = new Window {Width = 200, Height = 200};
var mp = Mouse.GetPosition(_dockPanel);
window.Left = mp.X;
window.Top = mp.Y;
var panel = new DockPanel();
window.Content = panel;
var textBox = new TextBox {Text = "Please modify the node label:"};
DockPanel.SetDock(textBox, Dock.Top);
panel.Children.Add(textBox);
richBox = new RichTextBox();
richBox.FontSize *= 1.5;
richBox.AppendText("Label");
richBox.FontFamily = new FontFamily("Consoles");
richBox.Width = window.Width;
DockPanel.SetDock(richBox, Dock.Top);
panel.Children.Add(richBox);
panel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
panel.Width = textBox.Width;
var button = new Button {Content = "OK"};
button.Click += (a, b) => window.Close();
DockPanel.SetDock(button, Dock.Bottom);
button.IsDefault = true;
button.Width = 40;
button.Height = 40;
panel.Children.Add(button);
panel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
window.SizeToContent = SizeToContent.WidthAndHeight;
return window;
}
示例5: logWithoutTime
public void logWithoutTime(string s, RichTextBox rtb)
{
rtb.AppendText(s + "\r\n");
rtb.ScrollToEnd();
}
示例6: cm_addLexemToRichText
//private void cm_showGram(cParserException _ex)
//{
// f_rtbGram.Document.Blocks.Clear();
// foreach (cToken _token in _ex.cf_Tokens)
// {
// switch (_token.cf_Type)
// {
// case eTokenType.перевод_строки:
// f_rtbGram.AppendText(Environment.NewLine);
// break;
// case eTokenType.стрелка:
// f_rtbGram.AppendText(" -> ");
// break;
// case eTokenType.Null:
// f_rtbGram.AppendText(" -> ");
// break;
// default:
// cm_addLexemToRichText(_token.cf_Value as cLexem, f_rtbGram);
// break;
// }
// }
//}
private void cm_addLexemToRichText(cLexem a_lexem, RichTextBox a_rtb)
{
if (a_lexem.cp_Type == eLexType.NonTerminal)
a_rtb.AppendText("<");
else if (a_lexem.cp_Type == eLexType.Action)
a_rtb.AppendText("{");
//a_rtb.SelectionFont = new Font(a_rtb.SelectionFont, FontStyle.Bold);
//a_rtb.AppendText(a_lexem.ToString());
TextRange _tr = new TextRange(a_rtb.Document.ContentEnd,a_rtb.Document.ContentEnd);
_tr.Text = a_lexem.ToString();
_tr.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
_tr = new TextRange(a_rtb.Document.ContentEnd, a_rtb.Document.ContentEnd);
_tr.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Regular);
//a_rtb.SelectionFont = new Font(a_rtb.SelectionFont, FontStyle.Regular);
if (a_lexem.cp_Type == eLexType.NonTerminal)
a_rtb.AppendText(">");
else if (a_lexem.cp_Type == eLexType.Action)
a_rtb.AppendText("}");
a_rtb.AppendText(" ");
}
示例7: show_info
//---------------------------------------------------------------------------------------------------------
//do wyswietlania informacji dla bierzacego uzytkownika o jego stanie
public void show_info(RichTextBox info, string tekst_info)
{
info.AppendText(tekst_info);
log_info.ScrollToEnd();
}
示例8: LoadQuestions
// Loads the XML questions from this directory
public bool LoadQuestions(string strDirectory, RichTextBox richMain)
{
if (Directory.Exists(strDirectory) == false)
{
System.Windows.MessageBox.Show("Couldn't find the directory containing questions: " + strDirectory, "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
return false;
}
int intCount = 0;
foreach(string strFile in Directory.EnumerateFiles(strDirectory,"*.xml")){
XDocument thisXML = XDocument.Load(strFile);
Question thisQuestion = new Question(strFile,richMain);
lstQuestions.Add(thisQuestion);
intCount++;
}
richMain.AppendText("Loaded a total of " + lstQuestions.Count() + " files" + Environment.NewLine);
Count = lstQuestions.Count();
return true;
}
示例9: asyncOutputBoxAppendNoBreak
private void asyncOutputBoxAppendNoBreak(RichTextBox targetBox, string text)
{
targetBox.Dispatcher.Invoke(new Action(() => targetBox.AppendText(text)));
}
示例10: show_results_Click
// displays the results
private void show_results_Click(object sender, RoutedEventArgs e)
{
if (testSuitname.Text == "")
{
MessageBox.Show("Please provide Test Suite Name");
return;
}
logfilespath.Document.Blocks.Clear() ;
String filename = "";
filename = cc.GetLogFile(testSuitname.Text, username.Text, "detailedResults.log");
//MessageBox.Show(filename);
RichTextBox rctxtBx = new RichTextBox();
rctxtBx.Height = 250;
rctxtBx.Width = 400;
rctxtBx.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
Paragraph p = rctxtBx.Document.Blocks.FirstBlock as Paragraph;
p.Margin = new Thickness(0);
p.LineHeight = 10;
fetchResultGrid.Children.Add(rctxtBx);
filename = cc.GetLogFile(testSuitname.Text,username.Text, "results.xml");
//MessageBox.Show(filename);
if (filename == null || !filename.Contains("xml"))
{
MessageBox.Show("File Not Found. Pleasey try after some time or run the tests suite again.");
return;
}
// MessageBox.Show(filename);
TextReader tr = new StreamReader("Test Results\\" +testSuitname.Text + "_" + "results.xml");
StringBuilder sb = new StringBuilder();
sb.Append(tr.ReadToEnd());
string tempStr = sb.ToString();
sb.Replace("><",">\n<");
rctxtBx.AppendText(sb.ToString());
tr.Close();
DirectoryInfo d = Directory.CreateDirectory("Test Results");
String logFilesPath = System.IO.Path.GetFullPath("Test Results\\" +testSuitname.Text + "_" + "results.xml");
logfilespath.AppendText(logFilesPath);
logfilespath.AppendText("\n");
logFilesPath = System.IO.Path.GetFullPath("Test Results\\" + testSuitname.Text + "_" + "detailedResults.log");
logfilespath.AppendText(logFilesPath);
}