當前位置: 首頁>>代碼示例>>C#>>正文


C# RichTextBox.AppendText方法代碼示例

本文整理匯總了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);
            }
        }
開發者ID:nccgroup,項目名稱:44Con2013Game,代碼行數:35,代碼來源:Question.cs

示例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); }));
     }
 }
開發者ID:Apocalipsyz,項目名稱:Lithium,代碼行數:13,代碼來源:TextManager.cs

示例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());
     }
 }
開發者ID:keyanmca,項目名稱:Live-Streamer-Plus,代碼行數:14,代碼來源:Log.cs

示例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;
        }
開發者ID:WenzCao,項目名稱:automatic-graph-layout,代碼行數:34,代碼來源:App.cs

示例5: logWithoutTime

 public void logWithoutTime(string s, RichTextBox rtb)
 {
     rtb.AppendText(s + "\r\n");
     rtb.ScrollToEnd();
 }
開發者ID:keyanmca,項目名稱:Live-Streamer-Plus,代碼行數:5,代碼來源:Log.cs

示例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(" ");
 }
開發者ID:PaveLiArcH,項目名稱:LR1TableGenerator,代碼行數:42,代碼來源:fwMain.xaml.cs

示例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();
 }
開發者ID:AdrianPawelczyk,項目名稱:projekt_C-_ojp2,代碼行數:7,代碼來源:MainWindow.xaml.cs

示例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;
        }
開發者ID:nccgroup,項目名稱:44Con2013Game,代碼行數:23,代碼來源:QuestionCollection.cs

示例9: asyncOutputBoxAppendNoBreak

 private void asyncOutputBoxAppendNoBreak(RichTextBox targetBox, string text)
 {
     targetBox.Dispatcher.Invoke(new Action(() => targetBox.AppendText(text)));
 }
開發者ID:TheQuack45,項目名稱:HypeBotCSharp-old,代碼行數:4,代碼來源:MainWindow.xaml.cs

示例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);
 }
開發者ID:himanshugpt,項目名稱:TestHarness,代碼行數:42,代碼來源:MainWindow.xaml.cs


注:本文中的System.Windows.Controls.RichTextBox.AppendText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。