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


C# RichTextBox.Substring方法代碼示例

本文整理匯總了C#中System.Windows.Controls.RichTextBox.Substring方法的典型用法代碼示例。如果您正苦於以下問題:C# RichTextBox.Substring方法的具體用法?C# RichTextBox.Substring怎麽用?C# RichTextBox.Substring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Controls.RichTextBox的用法示例。


在下文中一共展示了RichTextBox.Substring方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: InitializeEditor

        private void InitializeEditor()
        {
            // Obtain line counts.
              conflictBlocks = new List<int>();
              lineCount = new int[content[0].Count];
              for (int i = 0; i < content[0].Count; i++) {
            lineCount[i] = Math.Max(content[0][i].lines.Count, content[1][i].lines.Count);
            if (content[0][i].type != BlockType.Normal) {
              conflictBlocks.Add(i);
            }
              }

              int lines = lineCount.Sum();
              for (int i = 0; i < lines; i++) {
            grid.RowDefinitions.Insert(0, new RowDefinition { Height = GridLength.Auto });
            grid.RowDefinitions.Insert(0, new RowDefinition { Height = GridLength.Auto });
            conflictNav.RowDefinitions.Insert(0, new RowDefinition());
              }

              // Only show the scroll helper if it's a long file.
              if (lines > 25) {
            conflictNav.Visibility = Visibility.Visible;
              }

              // Create grid cells for text blocks.
              lineTexts = new List<RichTextBox>[2];
              lineNums = new List<TextBlock>[2];
              lineTextBackgrounds = new List<Border>[2];
              lineNumBackgrounds = new List<Border>[2];
              for (int i = 0; i < 2; i++) {
            lineTexts[i] = new List<RichTextBox>();
            lineNums[i] = new List<TextBlock>();
            for (int j = 0; j < lines; j++) {
              var lineNum = new TextBlock { Style = GetStyle("lineNumber") };
              Panel.SetZIndex(lineNum, 5);
              Grid.SetRow(lineNum, 2 * j);
              Grid.SetColumn(lineNum, 2 * i);
              grid.Children.Add(lineNum);
              lineNums[i].Add(lineNum);

              var text = new RichTextBox {
            Style = GetStyle("lineText"),
            HorizontalAlignment = HorizontalAlignment.Stretch
              };
              Panel.SetZIndex(text, 5);
              Grid.SetRow(text, 2 * j);
              Grid.SetColumn(text, 1 + 2 * i);
              var doc = new FlowDocument();
              var p = new Paragraph();
              doc.Blocks.Add(p);
              text.Document = doc;
              grid.Children.Add(text);
              lineTexts[i].Add(text);
            }
              }

              // Draw the actual text blocks.
              scrollNavBorders = new List<Border>();
              for (int side = 0; side < 2; side++) {
            int prevLine = 0;
            int lineNum = 1;
            lineNumBackgrounds[side] = new List<Border>();
            lineTextBackgrounds[side] = new List<Border>();
            for (int g = 0; g < content[side].Count; g++) {
              LineBlock lblock = content[side][g];
              for (int i = 0; i < lblock.lines.Count; i++) {
            Line line = lblock.lines[i];
            var p = (Paragraph)lineTexts[side][prevLine + i].Document.Blocks.First();
            foreach (Block b in line.blocks) {
              string text = b.text;
              if (text.EndsWith(SentenceFilter.SentenceDelim)) {
                text = text.Substring(0, text.Length - SentenceFilter.SentenceDelim.Length);
              }
              var run = new Run(text);
              if (b.type != BlockType.Normal) {
                if (lblock.type == BlockType.Conflict || lblock.type == BlockType.Edited) {
                  b.type = lblock.type;
                }
                run.Style = GetStyle("text" + b.type);
              }
              p.Inlines.Add(run);
            }
            lineNums[side][prevLine + i].Text = lineNum++.ToString();
              }

              var numBorder = new Border();
              Panel.SetZIndex(numBorder, 3);
              Grid.SetRow(numBorder, 2 * prevLine);
              Grid.SetColumn(numBorder, side * 2);
              Grid.SetRowSpan(numBorder, 2 * lineCount[g]);
              grid.Children.Add(numBorder);
              lineNumBackgrounds[side].Add(numBorder);

              var textBorder = new Border();
              Panel.SetZIndex(textBorder, 2);
              Grid.SetRow(textBorder, 2 * prevLine);
              Grid.SetColumn(textBorder, side * 2 + 1);
              Grid.SetRowSpan(textBorder, 2 * lineCount[g]);
              grid.Children.Add(textBorder);
              lineTextBackgrounds[side].Add(textBorder);
//.........這裏部分代碼省略.........
開發者ID:SciGit,項目名稱:scigit-client,代碼行數:101,代碼來源:TextMergeViewer.cs


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