当前位置: 首页>>代码示例>>C#>>正文


C# TextDocument类代码示例

本文整理汇总了C#中TextDocument的典型用法代码示例。如果您正苦于以下问题:C# TextDocument类的具体用法?C# TextDocument怎么用?C# TextDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TextDocument类属于命名空间,在下文中一共展示了TextDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AppendHtmlText

		static void AppendHtmlText (StringBuilder htmlText, TextDocument doc, ITextEditorOptions options, int start, int end)
		{
			for (int i = start; i < end; i++) {
				char ch = doc.GetCharAt (i);
				switch (ch) {
				case ' ':
					htmlText.Append ("&nbsp;");
					break;
				case '\t':
					for (int i2 = 0; i2 < options.TabSize; i2++)
						htmlText.Append ("&nbsp;");
					break;
				case '<':
					htmlText.Append ("&lt;");
					break;
				case '>':
					htmlText.Append ("&gt;");
					break;
				case '&':
					htmlText.Append ("&amp;");
					break;
				case '"':
					htmlText.Append ("&quot;");
					break;
				default:
					htmlText.Append (ch);
					break;
				}
			}
		}
开发者ID:kekekeks,项目名称:monodevelop,代码行数:30,代码来源:HtmlWriter.cs

示例2: RawlyIndentLine

        public void RawlyIndentLine(int tabsToInsert, TextDocument document, DocumentLine line)
        {
            if (!_doBeginUpdateManually)
                document.BeginUpdate();
            /*
             * 1) Remove old indentation
             * 2) Insert new one
             */

            // 1)
            int prevInd = 0;
            int curOff = line.Offset;
            if (curOff < document.TextLength)
            {
                char curChar = '\0';
                while (curOff < document.TextLength && ((curChar = document.GetCharAt(curOff)) == ' ' || curChar == '\t'))
                {
                    prevInd++;
                    curOff++;
                }

                document.Remove(line.Offset, prevInd);
            }

            // 2)
            string indentString = "";
            for (int i = 0; i < tabsToInsert; i++)
                indentString += dEditor.Editor.Options.IndentationString;

            document.Insert(line.Offset, indentString);
            if (!_doBeginUpdateManually)
                document.EndUpdate();
        }
开发者ID:rumbu13,项目名称:D-IDE,代码行数:33,代码来源:DIndentationStrategy.cs

示例3: AppendRtfText

		static void AppendRtfText (StringBuilder rtfText, TextDocument doc, int start, int end, ref bool appendSpace)
		{
			for (int i = start; i < end; i++) {
				char ch = doc.GetCharAt (i);
				switch (ch) {
				case '\\':
					rtfText.Append (@"\\");
					break;
				case '{':
					rtfText.Append (@"\{");
					break;
				case '}':
					rtfText.Append (@"\}");
					break;
				case '\t':
					rtfText.Append (@"\tab");
					appendSpace = true;
					break;
				default:
					if (appendSpace) {
						rtfText.Append (' ');
						appendSpace = false;
					}
					rtfText.Append (ch);
					break;
				}
			}
		}
开发者ID:rajeshpillai,项目名称:monodevelop,代码行数:28,代码来源:RtfWriter.cs

示例4: FormatComments

        /// <summary>
        /// Reformat all comments between the specified start and end point. Comments that start
        /// within the range, even if they overlap the end are included.
        /// </summary>
        /// <param name="textDocument">The text document.</param>
        /// <param name="start">The start point.</param>
        /// <param name="end">The end point.</param>
        public bool FormatComments(TextDocument textDocument, EditPoint start, EditPoint end)
        {
            var options = new CodeCommentOptions(Settings.Default, _package, textDocument);

            bool foundComments = false;

            while (start.Line <= end.Line)
            {
                if (CodeCommentHelper.IsCommentLine(start))
                {
                    var comment = new CodeComment(start);
                    if (comment.IsValid)
                    {
                        comment.Format(options);
                        foundComments = true;
                    }

                    if (comment.EndPoint != null)
                    {
                        start = comment.EndPoint.CreateEditPoint();
                    }
                }

                if (start.Line == textDocument.EndPoint.Line)
                {
                    break;
                }

                start.LineDown();
                start.StartOfLine();
            }

            return foundComments;
        }
开发者ID:stevenha,项目名称:codemaid,代码行数:41,代码来源:CommentFormatLogic.cs

示例5: Example6

    void Example6()
    {
        //Create a new text document
        TextDocument document = new TextDocument();
        document.New();
        //Create a table for a text document using the TableBuilder
        Table table = TableBuilder.CreateTextDocumentTable(
            document,
            "table1",
            "table1",
            3,
            3,
            16.99,
            false,
            false);

        //Fill the cells
        foreach (Row row in table.RowCollection)
        {
            foreach (Cell cell in row.CellCollection)
            {
                //Create a standard paragraph
                Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                //Add some simple text
                paragraph.TextContent.Add(new SimpleText(document, "Cell text"));
                cell.Content.Add(paragraph);
            }
        }
        //Merge some cells. Notice this is only available in text documents!
        table.RowCollection[1].MergeCells(document, 1, 2, true);
        //Add table to the document
        document.Content.Add(table);
        //Save the document
        document.SaveTo("example6_simpleTableWithMergedCells.odt");
    }
开发者ID:hebory,项目名称:aodl-examples-for-unity,代码行数:35,代码来源:Example6.cs

示例6: Howto_special_charInch

 public void Howto_special_charInch()
 {
     TextDocument document		= new TextDocument();
     document.Load(@"F:\odtFiles\Howto_special_char.odt");
     document.SaveTo(@"F:\odtFiles\Howto_special_char.html");
     document.Dispose();
 }
开发者ID:stuzzicadenti,项目名称:aodl,代码行数:7,代码来源:ImportTest.cs

示例7: Example3

 void Example3()
 {
     string imagePath = @"Assets\ODFSample\Examples\example3.png";
     TextDocument document = new TextDocument();
     document.New();
     //Create standard paragraph
     Paragraph paragraphOuter = ParagraphBuilder.CreateStandardTextParagraph(document);
     //Create the frame with graphic
     Frame frame = new Frame(document, "frame1", "graphic1", imagePath);
     //Create a Draw Area Rectangle
     DrawAreaRectangle drawAreaRec = new DrawAreaRectangle(
         document, "0cm", "0cm", "1.5cm", "2.5cm", null);
     drawAreaRec.Href = "http://OpenDocument4all.com";
     //Create a Draw Area Circle
     DrawAreaCircle drawAreaCircle = new DrawAreaCircle(
         document, "4cm", "4cm", "1.5cm", null);
     drawAreaCircle.Href = "http://AODL.OpenDocument4all.com";
     DrawArea[] drawArea = new DrawArea[2] { drawAreaRec, drawAreaCircle };
     //Create a Image Map
     ImageMap imageMap = new ImageMap(document, drawArea);
     //Add Image Map to the frame
     frame.Content.Add(imageMap);
     //Add frame to paragraph
     paragraphOuter.Content.Add(frame);
     //Add paragraph to document
     document.Content.Add(paragraphOuter);
     //Save the document
     document.SaveTo(@"example3_simpleImageMap.odt");
 }
开发者ID:hebory,项目名称:aodl-examples-for-unity,代码行数:29,代码来源:Example3.cs

示例8: ParagraphAddRemoveTest

		public void ParagraphAddRemoveTest()
		{
			TextDocument td = new TextDocument();
			td.New();
			Paragraph p = new Paragraph(td, "P1");
			Assert.IsNotNull(p.Style, "Style object must exist!");
			Assert.AreEqual(p.Style.GetType().Name, "ParagraphStyle", "IStyle object must be type of ParagraphStyle");
			Assert.IsNotNull(((ParagraphStyle)p.Style).Properties, "Properties object must exist!");
			//add text
			p.TextContent.Add(new SimpleText(p, "Hello"));
			IText itext		= p.TextContent[0];
			p.TextContent.Remove(itext);
			//Console.Write(p.Node.Value);
			Assert.IsTrue(p.Node.InnerXml.IndexOf("Hello") == -1, "Must be removed!");
			//Add the Paragraph
			td.Content.Add((IContent)p);
			//Blank para
			td.Content.Add(new Paragraph(td, ParentStyles.Standard.ToString()));
			// new para
			p = new Paragraph(td, "P2");
			p.TextContent.Add(new SimpleText(p, "Hello i'm still here"));
			td.Content.Add(p);
			td.SaveTo("pararemoved.odt");
			//Console.WriteLine("Document: {0}", td.XmlDoc.OuterXml);
		}
开发者ID:rabidbob,项目名称:aodl-reloaded,代码行数:25,代码来源:TestClass.cs

示例9: Howto_special_char

 public void Howto_special_char()
 {
     TextDocument document		= new TextDocument();
     document.Load("Howto_special_char.odt");
     document.SaveTo("Howto_special_char.html");
     document.Dispose();
 }
开发者ID:stuzzicadenti,项目名称:aodl,代码行数:7,代码来源:ImportTest.cs

示例10: NewTextDocument

		public void NewTextDocument()
		{
			TextDocument td = new TextDocument();
			td.New();
			Assert.IsNotNull(td.XmlDoc, "Must exist!");
			//Console.WriteLine("Doc: {0}", td.XmlDoc.OuterXml);
		}
开发者ID:rabidbob,项目名称:aodl-reloaded,代码行数:7,代码来源:TestClass.cs

示例11: Example10

    void Example10()
    {
        //some text e.g read from a TextBox
        string someText = "Max Mustermann\nMustermann Str. 300\n22222 Hamburg\n\n\n\n"
                                + "Heinz Willi\nDorfstr. 1\n22225 Hamburg\n\n\n\n"
                                + "Offer for 200 Intel Pentium 4 CPU's\n\n\n\n"
                                + "Dear Mr. Willi,\n\n\n\n"
                                + "thank you for your request. \tWe can "
                                + "offer you the 200 Intel Pentium IV 3 Ghz CPU's for a price of "
                                + "79,80 € per unit."
                                + "This special offer is valid to 31.10.2005. If you accept, we "
                                + "can deliver within 24 hours.\n\n\n\n"
                                + "Best regards \nMax Mustermann";

        //Create new TextDocument
        TextDocument document = new TextDocument();
        document.New();
        //Use the ParagraphBuilder to split the string into ParagraphCollection
        ParagraphCollection pCollection = ParagraphBuilder.CreateParagraphCollection(
                                             document,
                                             someText,
                                             true,
                                             ParagraphBuilder.ParagraphSeperator);
        //Add the paragraph collection
        foreach (Paragraph paragraph in pCollection)
            document.Content.Add(paragraph);
        //save
        document.SaveTo("example10_Letter.odt");
    }
开发者ID:hebory,项目名称:aodl-examples-for-unity,代码行数:29,代码来源:Example10.cs

示例12: Example4

 void Example4()
 {
     string imagePath = @"Assets\ODFSample\Examples\example3.png";
     TextDocument textdocument = new TextDocument();
     textdocument.New();
     Paragraph pOuter = ParagraphBuilder.CreateStandardTextParagraph(textdocument);
     DrawTextBox drawTextBox = new DrawTextBox(textdocument);
     Frame frameTextBox = new Frame(textdocument, "fr_txt_box");
     frameTextBox.DrawName = "fr_txt_box";
     frameTextBox.ZIndex = "0";
     Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument);
     p.StyleName = "Illustration";
     Frame frame = new Frame(textdocument, "frame1", "graphic1", imagePath);
     frame.ZIndex = "1";
     p.Content.Add(frame);
     p.TextContent.Add(new SimpleText(textdocument, "Illustration"));
     drawTextBox.Content.Add(p);
     frameTextBox.SvgWidth = frame.SvgWidth;
     drawTextBox.MinWidth = frame.SvgWidth;
     drawTextBox.MinHeight = frame.SvgHeight;
     frameTextBox.Content.Add(drawTextBox);
     pOuter.Content.Add(frameTextBox);
     textdocument.Content.Add(pOuter);
     textdocument.SaveTo("example4_drawTextbox.odt");
 }
开发者ID:hebory,项目名称:aodl-examples-for-unity,代码行数:25,代码来源:Example4.cs

示例13: CellParagraphTest

        public void CellParagraphTest()
        {
            TextDocument doc		= new TextDocument();
            doc.New();

            Table table				= new Table(doc, "table1");
            table.Init(5, 3, 16.99);

            foreach(Row r in table.Rows)
                foreach(Cell c in r.Cells)
                    c.InsertText("Hello");

            Paragraph p				= new Paragraph(doc, "P1");

            FormatedText ft			= new FormatedText(p, "T1", "Hello World");

            ((TextStyle)ft.Style).Properties.Italic = "italic";

            p.TextContent.Add(ft);

            table.Rows[0].Cells[0].Content.Add(p);

            doc.Content.Add(table);

            doc.SaveTo("tablewithstyles.odt");
        }
开发者ID:stuzzicadenti,项目名称:aodl,代码行数:26,代码来源:TableTest.cs

示例14: CellSpanTest

        public void CellSpanTest()
        {
            TextDocument doc		= new TextDocument();
            doc.New();

            Table table				= new Table(doc, "table1");
            table.Init(5, 2, 16.99);

            //Create a new row within this table and
            //set the cellspan to 2
            Row row					= new Row(table, "");
            //Create a real cell
            Cell cell				= new Cell(row, "table1.ZZ1");
            //Set cell span
            cell.ColumnRepeating	= "2";
            //Set the border
            ((CellStyle)cell.Style).CellProperties.Border	= Border.NormalSolid;
            //add some content to this cell
            cell.Content.Add(new Paragraph(doc,
                ParentStyles.Standard,
                "Hello I'm merged over two cells!"));
            //add cell to the row
            row.Cells.Add(cell);
            //we have to add one CellSpan object, because the
            //table has original 2 columns
            row.CellSpans.Add(new CellSpan(row));
            //at least at this row the table
            table.Rows.Add(row);
            //add the table to the document
            doc.Content.Add(table);
            //save it to the disk
            doc.SaveTo("tablecellspan.odt");
        }
开发者ID:stuzzicadenti,项目名称:aodl,代码行数:33,代码来源:TableTest.cs

示例15: ExtractRemainingSelection

 private static void ExtractRemainingSelection(TextDocument ActiveDoc, SourceRange SelectRange)
 {
     // Extract Remaining Selection
     CodeRush.Selection.SelectRange(SelectRange);
     ExecuteRefactoring("Extract Method");
     ActiveDoc.ParseIfTextChanged();
 }
开发者ID:modulexcite,项目名称:CR_ExtractMethodAndInlineLiterals,代码行数:7,代码来源:PlugIn1.cs


注:本文中的TextDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。